403Webshell
Server IP : 46.62.235.243  /  Your IP : 216.73.216.217
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux Linkabili3Dicembre 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.1.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/linkabili/app/Console/Commands/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/linkabili/app/Console/Commands/ImportUsers.php
<?php

namespace App\Console\Commands;

require_once 'app/Helpers/helper.php';

use App\ChMessage;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Mail;
use App\User;
use Illuminate\Support\Str;
use App\Models\State;
use App\Models\MedicalCenter;
use App\Models\Profession;
use App\Models\Pathology;

use App\Http\Controllers\Auth\RegisterController;

class ImportUsers extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'linkabili:ImportUsers';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = "Command import users";

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $first = true;
        $index = 0;

        if (($open = fopen(storage_path() . "/app/import.csv", "r")) !== FALSE) {

            while (($data = fgetcsv($open, 1000, ";")) !== FALSE) {
                if ($first) {
                    $header_row = $data;
                    $first = false;
                }
                else {
                    $row = array_combine($header_row, $data);

                    $user_type = $data[0];
                    $patologie = [];
                    $professioni = [];

                    $state_id = $row["provincia"] ? State::where("provincia", $row["provincia"])->first()->id : null;

                    for ($i = 1; $i <= 99; $i++) {
                        if (isset($row["patologia$i"]) && $row["patologia$i"]) {
                            $patologie[] = Pathology::where('name', $row["patologia$i"])->first()->id;
                        }

                        if (isset($row["professione$i"]) && $row["professione$i"]) {
                            $professioni[] = Profession::where('name', $row["professione$i"])->first()->id;
                        }
                    }

                    $user = [
                        "user_type" => $user_type,
                        "name_" . $user_type => $row["nome"],
                        "surname_" . $user_type => $row["cognome"],
                        "email_" . $user_type => $row["email"],

                        "password_" . $user_type => Str::random(8),

                        "gender" => $row["sesso"],

                        "tel_istitution" => $row["tel"],
                        "tel_professionist" => $row["tel"],
                        "business_name_istitution" => $row["business_name"],
                        "business_name" => $row["business_name"],
                        
                        "city_other_istitute" => $row["citta"],
                        "municipality_professionist" => $row["citta"],

                        "state_istitution" => $state_id,
                        "states" => $state_id,
                        "states_medical_center" => $state_id,

                        "profession_professionist" => Profession::where('name', $row["professione_principale"])->first()->id,

                        "work_with_underage" => $row["lavora_con_minorenni"] === "Si",

                        "medical_center_id" => $row["medical_center"] ? MedicalCenter::where('name', $row["medical_center"])->first()->id : null,

                        "facebook_professionist" => $row["facebook"],
                        "linkedin_professionist" => $row["linkedin"],
                        "instagram_professionist" => $row["instagram"],
                        "twitter_professionist" => $row["twitter"],
                        "imported" => true,

                        "pathology_professionist" => $patologie,
                        "pathology_medical_center" => $patologie,
                        "pathology_istitution" => $patologie,

                        "other_profession_professionist" => $professioni,

                    ];

                    $rc = new RegisterController();
                    $rc->create($user);

                }
            }

            fclose($open);
        }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit