WordPress

Briefly unavailable for scheduled maintenance.
Check back in a some hours.
403WebShell
403Webshell
Server IP : 38.242.244.58  /  Your IP : 216.73.217.126
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/src/Command/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/sura/src/Command/ProcessFtpUploadCommand.php
<?php

namespace App\Command;

use App\Entity\FtpUser;
use App\Entity\Stock;
use App\Entity\User;
use App\Service\ImageHelper;
use FFMpeg\Coordinate\Dimension;
use FFMpeg\Coordinate\TimeCode;
use FFMpeg\FFMpeg;
use Intervention\Image\Exception\NotReadableException;
use Intervention\Image\ImageManager;
use Psr\Container\ContainerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Process\Process;

class ProcessFtpUploadCommand extends Command
{
    protected static $defaultName = 'app:ftp-process-upload';
    private $container;
    private $params;
    public function __construct(ContainerInterface $container, ParameterBagInterface $parameterBag)
    {


        parent::__construct();
        $this->params = $parameterBag;
        $this->container = $container;

        $this->em = $this->container->get('doctrine')->getManager();
    }
    protected function configure()
    {
        $this
            ->setDescription('Add a short description for your command')
            ->addOption('option1', null, InputOption::VALUE_NONE, 'Option description')
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $cmd=  'rsync -a  -e "ssh -i '.getenv('FTP_SERVER_KEY_FILE').'" root@144.91.124.39:/home '.getenv('FTP_ROOT');
        $process= shell_exec($cmd);
        $cmd2 =  "chown -R www-data ".getenv('FTP_ROOT');
        $process= shell_exec($cmd2);

        $ftpRepository=$this->em->getRepository(FtpUser::class);
        $ftpUsers = $ftpRepository->findAll();
        foreach ($ftpUsers as $ftpUser) {
            /** @var FtpUser $ftpUser */
            $photosDirectory = getenv('FTP_ROOT').'/home/'.$ftpUser->getUserid().'/ftp/files';
            if(!is_dir($photosDirectory)){
                $command =  "mkdir ".getenv('FTP_ROOT').'/home/'.$ftpUser->getUserid();
                $command2 =  "mkdir ".getenv('FTP_ROOT').'/home/'.$ftpUser->getUserid().'/ftp';
                $command3 =  "mkdir ".getenv('FTP_ROOT').'/home/'.$ftpUser->getUserid().'/ftp/files';
                shell_exec($command);
                shell_exec($command2);
                shell_exec($command3);
                shell_exec($cmd2);
            }
            $cmd3= 'rsync --remove-source-files -a -e "ssh -i '.getenv('FTP_SERVER_KEY_FILE').'" root@144.91.124.39:/home/'.$ftpUser->getUserid().'/ftp/files/ '.getenv('FTP_ROOT').'/home/'.$ftpUser->getUserid().'/ftp/files/';
            $process= shell_exec($cmd3);
            $user = $ftpUser->getUser();
            $videoMimes = [
                "video/x-flv", "video/mp4", "video/3gpp",
            ];
            $imageMimes = [
                "image/jpeg",
            ];
            if(is_dir($photosDirectory)){
                $finder = new Finder();
                $finder->files()->in($photosDirectory);
                if($finder->hasResults()){
                    foreach ($finder as $file) {
                        if (!is_dir($file)) {
                            $filesystem = new Filesystem();
                            $fileName = $file->getFilename();
                            $file = new File($file->getPathname());
                            $fileMime = $file->getMimeType();
                            $storage_dir = $this->params->get('uploads_directory');
                            $target_file = $storage_dir.$ftpUser->getUserid().DIRECTORY_SEPARATOR.$fileName;
                            if(in_array($fileMime, $imageMimes) || in_array($fileMime, $videoMimes) ){
                                try {
                                    $filesystem->copy($file->getPathname(), $target_file,true);
                                    if (in_array($fileMime, $videoMimes)){
                                        $extension = $file->getExtension();
                                        //dump($extension); die;
                                        $gifName = str_replace($extension,"gif",$fileName);
                                        $ffmpeg = FFMpeg::create();
                                        try{
                                            $video = $ffmpeg->open($target_file);

                                            $clip = $video
                                                ->gif(TimeCode::fromSeconds(3),new Dimension(600, 400), 5);
                                            $clip->save($storage_dir.$ftpUser->getUserid().DIRECTORY_SEPARATOR.$gifName);
                                        }catch (\Exception $e){
                                            dump("exception: ". $e->getMessage());
                                        }
                                    }
                                    else{
                                        //image
                                        if (in_array($fileMime, $imageMimes)){
                                            $thumbLocation = $storage_dir.$ftpUser->getUserid().DIRECTORY_SEPARATOR.Stock::IMAGE_THUMBS_DIR;

                                            if(!is_dir($thumbLocation)){
                                                mkdir($thumbLocation,0777);
                                            }

                                            $manager = new ImageManager();
                                            $thumbImage = $manager->make($target_file);
                                            $thumbImage->resize(null,400, function ($constraint){
                                                $constraint->aspectRatio();
                                            })->save($thumbLocation.DIRECTORY_SEPARATOR.$fileName);
                                        }

                                    }

                                }catch (NotReadableException $exception){
                                    continue;
                                }

                            }

                            $filesystem->remove($file->getPathname());

                        }
                    }
                }
            }




            }
        return 0;
    }
}



Youez - 2016 - github.com/yon3zu
LinuXploit