当前位置: 首页>>代码示例>>PHP>>正文


PHP Factory::getDatabase方法代码示例

本文整理汇总了PHP中Akeeba\Engine\Factory::getDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::getDatabase方法的具体用法?PHP Factory::getDatabase怎么用?PHP Factory::getDatabase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Akeeba\Engine\Factory的用法示例。


在下文中一共展示了Factory::getDatabase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _prepare

 protected function _prepare()
 {
     Factory::getLog()->log(LogLevel::DEBUG, __CLASS__ . " :: Processing parameters");
     // Get the DB connection parameters
     if (is_array($this->_parametersArray)) {
         $driver = array_key_exists('driver', $this->_parametersArray) ? $this->_parametersArray['driver'] : 'mysql';
         $host = array_key_exists('host', $this->_parametersArray) ? $this->_parametersArray['host'] : '';
         $port = array_key_exists('port', $this->_parametersArray) ? $this->_parametersArray['port'] : '';
         $username = array_key_exists('username', $this->_parametersArray) ? $this->_parametersArray['username'] : '';
         $username = array_key_exists('user', $this->_parametersArray) ? $this->_parametersArray['user'] : $username;
         $password = array_key_exists('password', $this->_parametersArray) ? $this->_parametersArray['password'] : '';
         $database = array_key_exists('database', $this->_parametersArray) ? $this->_parametersArray['database'] : '';
         $prefix = array_key_exists('prefix', $this->_parametersArray) ? $this->_parametersArray['prefix'] : '';
     }
     if ($driver == 'mysql' && !function_exists('mysql_connect')) {
         $driver = 'mysqli';
     }
     $options = array('driver' => $driver, 'host' => $host . ($port != '' ? ':' . $port : ''), 'user' => $username, 'password' => $password, 'database' => $database, 'prefix' => is_null($prefix) ? '' : $prefix);
     $db = Factory::getDatabase($options);
     $driverType = $db->getDriverType();
     if ($driverType == 'mssql') {
         $driverType = 'sqlsrv';
     }
     $className = '\\Akeeba\\Engine\\Dump\\Reverse\\' . ucfirst($driverType);
     Factory::getLog()->log(LogLevel::DEBUG, __CLASS__ . " :: Instanciating new reverse engineering database dump engine {$className}");
     if (!class_exists($className, true)) {
         $this->setState('error', 'Akeeba Engine does not have a reverse engineering dump engine for ' . $driverType . ' databases');
     } else {
         $this->_engine = new $className();
         $this->_engine->setup($this->_parametersArray);
         $this->_engine->callStage('_prepare');
         $this->setState($this->_engine->getState(), $this->_engine->getError());
         $this->propagateFromObject($this->_engine);
     }
 }
开发者ID:AlexanderKri,项目名称:joom-upd,代码行数:35,代码来源:Reverse.php

示例2: getLatestBackupInformation

 /**
  * Get the information for the latest backup
  *
  * @return   array|null  An array of backup record information or null if there is no usable backup for site transfer
  */
 public function getLatestBackupInformation()
 {
     // Initialise
     $ret = null;
     $db = Factory::getDatabase();
     /** @var AkeebaModelStatistics $model */
     $model = F0FModel::getTmpInstance('Statistics', 'AkeebaModel');
     $model->savestate(0);
     $model->setState('limitstart', 0);
     $model->setState('limit', 1);
     $backups = $model->getStatisticsListWithMeta(false, null, $db->qn('id') . ' DESC');
     // No valid backups? No joy.
     if (empty($backups)) {
         return $ret;
     }
     // Get the latest backup
     $backup = array_shift($backups);
     // If it's not stored on the server (e.g. remote backup), no joy.
     if ($backup['meta'] != 'ok') {
         return $ret;
     }
     // If it's not a full site backup, no joy.
     if ($backup['type'] != 'full') {
         return $ret;
     }
     return $backup;
 }
开发者ID:brenot,项目名称:forumdesenvolvimento,代码行数:32,代码来源:transfers.php

示例3: _prepare

 protected function _prepare()
 {
     Factory::getLog()->log(LogLevel::DEBUG, __CLASS__ . " :: Processing parameters");
     $options = null;
     // Get the DB connection parameters
     if (is_array($this->_parametersArray)) {
         $driver = array_key_exists('driver', $this->_parametersArray) ? $this->_parametersArray['driver'] : 'mysql';
         $host = array_key_exists('host', $this->_parametersArray) ? $this->_parametersArray['host'] : '';
         $port = array_key_exists('port', $this->_parametersArray) ? $this->_parametersArray['port'] : '';
         $username = array_key_exists('username', $this->_parametersArray) ? $this->_parametersArray['username'] : '';
         $username = array_key_exists('user', $this->_parametersArray) ? $this->_parametersArray['user'] : $username;
         $password = array_key_exists('password', $this->_parametersArray) ? $this->_parametersArray['password'] : '';
         $database = array_key_exists('database', $this->_parametersArray) ? $this->_parametersArray['database'] : '';
         $prefix = array_key_exists('prefix', $this->_parametersArray) ? $this->_parametersArray['prefix'] : '';
         $options = array('driver' => $driver, 'host' => $host . ($port != '' ? ':' . $port : ''), 'user' => $username, 'password' => $password, 'database' => $database, 'prefix' => is_null($prefix) ? '' : $prefix);
     }
     $db = Factory::getDatabase($options);
     $driverType = $db->getDriverType();
     $className = '\\Akeeba\\Engine\\Dump\\Native\\' . ucfirst($driverType);
     // Check if we have a native dump driver
     if (!class_exists($className, true)) {
         Factory::getLog()->log(LogLevel::DEBUG, __CLASS__ . " :: Native database dump engine {$className} not found; trying Reverse Engineering instead");
         // Native driver nor found, I will try falling back to reverse engineering
         $className = '\\Akeeba\\Engine\\Dump\\Reverse\\' . ucfirst($driverType);
     }
     if (!class_exists($className, true)) {
         $this->setState('error', 'Akeeba Engine does not have a native dump engine for ' . $driverType . ' databases');
     } else {
         Factory::getLog()->log(LogLevel::DEBUG, __CLASS__ . " :: Instanciating new native database dump engine {$className}");
         $this->_engine = new $className();
         $this->_engine->setup($this->_parametersArray);
         $this->_engine->callStage('_prepare');
         $this->setState($this->_engine->getState(), $this->_engine->getError());
     }
 }
开发者ID:ForAEdesWeb,项目名称:AEW2,代码行数:35,代码来源:Native.php

示例4: loadConfig

 private static function loadConfig()
 {
     $db = Factory::getDatabase();
     $sql = $db->getQuery(true)->select($db->qn('params'))->from($db->qn('#__extensions'))->where($db->qn('element') . " = " . $db->q('com_akeeba'));
     $db->setQuery($sql);
     $config_ini = $db->loadResult();
     // OK, Joomla! 1.6 stores values JSON-encoded so, what do I do? Right!
     $config_ini = json_decode($config_ini, true);
     if (is_null($config_ini) || empty($config_ini)) {
         $config_ini = array();
     }
     return $config_ini;
 }
开发者ID:esorone,项目名称:efcpw,代码行数:13,代码来源:Comconfig.php

示例5: make_listing

 /**
  * Returns a list of the database tables, views, procedures, functions and triggers,
  * along with their filter status in array format, for use in the GUI
  * @return array
  */
 public function make_listing($root)
 {
     // Get database inclusion filters
     $filters = Factory::getFilters();
     $database_list = $filters->getInclusions('db');
     // Load the database object for the selected database
     $config = $database_list[$root];
     $config['user'] = $config['username'];
     $db = Factory::getDatabase($config);
     // Load the table data
     try {
         $table_data = $db->getTables();
     } catch (Exception $e) {
         $table_data = array();
     }
     // Process filters
     $tables = array();
     if (!empty($table_data)) {
         foreach ($table_data as $table_name => $table_type) {
             $status = array();
             // Add table type
             $status['type'] = $table_type;
             // Check dbobject/all filter (exclude)
             $result = $filters->isFilteredExtended($table_name, $root, 'dbobject', 'all', $byFilter);
             $status['tables'] = !$result ? 0 : ($byFilter == 'tables' ? 1 : 2);
             // Check dbobject/content filter (skip table data)
             $result = $filters->isFilteredExtended($table_name, $root, 'dbobject', 'content', $byFilter);
             $status['tabledata'] = !$result ? 0 : ($byFilter == 'tabledata' ? 1 : 2);
             if ($table_type != 'table') {
                 $status['tabledata'] = 2;
             }
             // We can't filter contents of views, merge tables, black holes, procedures, functions and triggers :)
             $tables[$table_name] = $status;
         }
     }
     return array('tables' => $tables, 'root' => $root);
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:42,代码来源:dbefs.php

示例6: _run

 /**
  * Implements the _run() abstract method
  *
  * @return  void
  */
 protected function _run()
 {
     if ($this->getState() == 'postrun') {
         Factory::getLog()->log(LogLevel::DEBUG, __CLASS__ . " :: Already finished");
         $this->setStep('');
         $this->setSubstep('');
         return;
     } else {
         $this->setState('running');
     }
     // Initialise the extra notes variable, used by platform classes to return warnings and errors
     $extraNotes = null;
     // Load the version defines
     Platform::getInstance()->load_version_defines();
     $registry = Factory::getConfiguration();
     // Write log file's header
     $version = defined('AKEEBABACKUP_VERSION') ? AKEEBABACKUP_VERSION : AKEEBA_VERSION;
     $date = defined('AKEEBABACKUP_DATE') ? AKEEBABACKUP_DATE : AKEEBA_DATE;
     Factory::getLog()->log(LogLevel::INFO, "--------------------------------------------------------------------------------");
     Factory::getLog()->log(LogLevel::INFO, "Akeeba Backup " . $version . ' (' . $date . ')');
     Factory::getLog()->log(LogLevel::INFO, "Got backup?");
     Factory::getLog()->log(LogLevel::INFO, "--------------------------------------------------------------------------------");
     // PHP configuration variables are tried to be logged only for debug and info log levels
     if ($registry->get('akeeba.basic.log_level') >= 2) {
         Factory::getLog()->log(LogLevel::INFO, "--- System Information ---");
         Factory::getLog()->log(LogLevel::INFO, "PHP Version        :" . PHP_VERSION);
         Factory::getLog()->log(LogLevel::INFO, "PHP OS             :" . PHP_OS);
         Factory::getLog()->log(LogLevel::INFO, "PHP SAPI           :" . PHP_SAPI);
         if (function_exists('php_uname')) {
             Factory::getLog()->log(LogLevel::INFO, "OS Version         :" . php_uname('s'));
         }
         $db = Factory::getDatabase();
         Factory::getLog()->log(LogLevel::INFO, "DB Version         :" . $db->getVersion());
         if (isset($_SERVER['SERVER_SOFTWARE'])) {
             $server = $_SERVER['SERVER_SOFTWARE'];
         } elseif ($sf = getenv('SERVER_SOFTWARE')) {
             $server = $sf;
         } else {
             $server = 'n/a';
         }
         Factory::getLog()->log(LogLevel::INFO, "Web Server         :" . $server);
         $platform = 'Unknown platform';
         $version = '(unknown version)';
         $platformData = Platform::getInstance()->getPlatformVersion();
         Factory::getLog()->log(LogLevel::INFO, $platformData['name'] . " version    :" . $platformData['version']);
         if (isset($_SERVER['HTTP_USER_AGENT'])) {
             Factory::getLog()->log(LogLevel::INFO, "User agent         :" . phpversion() <= "4.2.1" ? getenv("HTTP_USER_AGENT") : $_SERVER['HTTP_USER_AGENT']);
         }
         Factory::getLog()->log(LogLevel::INFO, "Safe mode          :" . ini_get("safe_mode"));
         Factory::getLog()->log(LogLevel::INFO, "Display errors     :" . ini_get("display_errors"));
         Factory::getLog()->log(LogLevel::INFO, "Error reporting    :" . self::error2string());
         Factory::getLog()->log(LogLevel::INFO, "Error display      :" . self::errordisplay());
         Factory::getLog()->log(LogLevel::INFO, "Disabled functions :" . ini_get("disable_functions"));
         Factory::getLog()->log(LogLevel::INFO, "open_basedir restr.:" . ini_get('open_basedir'));
         Factory::getLog()->log(LogLevel::INFO, "Max. exec. time    :" . ini_get("max_execution_time"));
         Factory::getLog()->log(LogLevel::INFO, "Memory limit       :" . ini_get("memory_limit"));
         if (function_exists("memory_get_usage")) {
             Factory::getLog()->log(LogLevel::INFO, "Current mem. usage :" . memory_get_usage());
         }
         if (function_exists("gzcompress")) {
             Factory::getLog()->log(LogLevel::INFO, "GZIP Compression   : available (good)");
         } else {
             Factory::getLog()->log(LogLevel::INFO, "GZIP Compression   : n/a (no compression)");
         }
         $extraNotes = Platform::getInstance()->log_platform_special_directories();
         if (!empty($extraNotes) && is_array($extraNotes)) {
             if (isset($extraNotes['warnings']) && is_array($extraNotes['warnings'])) {
                 foreach ($extraNotes['warnings'] as $warning) {
                     $this->setWarning($warning);
                 }
             }
             if (isset($extraNotes['errors']) && is_array($extraNotes['errors'])) {
                 foreach ($extraNotes['errors'] as $error) {
                     $this->setError($error);
                 }
             }
         }
         Factory::getLog()->log(LogLevel::INFO, "Output directory   :" . $registry->get('akeeba.basic.output_directory'));
         Factory::getLog()->log(LogLevel::INFO, "Part size (bytes)  :" . $registry->get('engine.archiver.common.part_size', 0));
         Factory::getLog()->log(LogLevel::INFO, "--------------------------------------------------------------------------------");
     }
     // Quirks reporting
     $quirks = Factory::getConfigurationChecks()->getDetailedStatus(true);
     if (!empty($quirks)) {
         Factory::getLog()->log(LogLevel::INFO, "Akeeba Backup has detected the following potential problems:");
         foreach ($quirks as $q) {
             Factory::getLog()->log(LogLevel::INFO, '- ' . $q['code'] . ' ' . $q['description'] . ' (' . $q['severity'] . ')');
         }
         Factory::getLog()->log(LogLevel::INFO, "You probably do not have to worry about them, but you should be aware of them.");
         Factory::getLog()->log(LogLevel::INFO, "--------------------------------------------------------------------------------");
     }
     if (!version_compare(PHP_VERSION, '5.4.0', 'ge')) {
         Factory::getLog()->log(LogLevel::WARNING, "You are using an outdated version of PHP. Akeeba Engine may not work properly. Please upgrade to PHP 5.4.0 or later.");
     }
     // Report profile ID
//.........这里部分代码省略.........
开发者ID:AlexanderKri,项目名称:joom-upd,代码行数:101,代码来源:Init.php

示例7: save_filters

 /**
  * Saves the nested filter data array $filter_data to the database
  *
  * @param    array $filter_data The filter data to save
  *
  * @return    bool    True on success
  */
 public function save_filters(&$filter_data)
 {
     $profile_id = $this->get_active_profile();
     $db = Factory::getDatabase($this->get_platform_database_options());
     $sql = $db->getQuery(true)->update($db->qn($this->tableNameProfiles))->set($db->qn('filters') . '=' . $db->q(serialize($filter_data)))->where($db->qn('id') . ' = ' . $db->q($profile_id));
     $db->setQuery($sql);
     try {
         $db->query();
     } catch (\Exception $exc) {
         return false;
     }
     return true;
 }
开发者ID:BillVGN,项目名称:PortalPRP,代码行数:20,代码来源:Base.php

示例8: apply_obsolete_quotas

 /**
  * Keeps a maximum number of "obsolete" records
  *
  * @return  void
  */
 protected function apply_obsolete_quotas()
 {
     $this->setStep('Applying quota limit on obsolete backup records');
     $this->setSubstep('');
     $registry = Factory::getConfiguration();
     $limit = $registry->get('akeeba.quota.obsolete_quota', 0);
     $limit = (int) $limit;
     if ($limit <= 0) {
         return;
     }
     $statsTable = Platform::getInstance()->tableNameStats;
     $db = Factory::getDatabase(Platform::getInstance()->get_platform_database_options());
     $query = $db->getQuery(true)->select(array($db->qn('id'), $db->qn('backupid'), $db->qn('absolute_path')))->from($db->qn($statsTable))->where($db->qn('status') . ' = ' . $db->q('complete'))->where($db->qn('filesexist') . '=' . $db->q('0'))->order($db->qn('id') . ' DESC');
     $db->setQuery($query, $limit, 100000);
     $records = $db->loadAssocList();
     if (empty($records)) {
         return;
     }
     $array = array();
     // Delete backup-specific log files if they exist and add the IDs of the records to delete in the $array
     foreach ($records as $stat) {
         $array[] = $stat['id'];
         // We can't delete logs if there is no backup ID in the record
         if (!isset($stat['backupid']) || empty($stat['backupid'])) {
             continue;
         }
         $logFileName = 'akeeba.' . $stat['tag'] . '.' . $stat['backupid'] . '.log';
         $logPath = dirname($stat['absolute_path']) . '/' . $logFileName;
         @unlink($logPath);
     }
     $ids = array();
     foreach ($array as $id) {
         $ids[] = $db->q($id);
     }
     $ids = implode(',', $ids);
     $query = $db->getQuery(true)->delete($db->qn($statsTable))->where($db->qn('id') . " IN ({$ids})");
     $db->setQuery($query);
     $db->query();
 }
开发者ID:ForAEdesWeb,项目名称:AEW2,代码行数:44,代码来源:Finalization.php

示例9: createDatabasesINI

    protected function createDatabasesINI()
    {
        // caching databases.ini contents
        Factory::getLog()->log(LogLevel::DEBUG, __CLASS__ . "AkeebaCUBEDomainDBBackup :: Creating databases.ini data");
        // Create a new string
        $this->databases_ini = '';
        $blankOutPass = Factory::getConfiguration()->get('engine.dump.common.blankoutpass', 0);
        // Loop through databases list
        foreach ($this->dumpedDatabases as $definition) {
            $section = basename($definition['dumpFile']);
            $dboInstance = Factory::getDatabase($definition);
            $type = $dboInstance->name;
            $tech = $dboInstance->getDriverType();
            if ($blankOutPass) {
                $this->databases_ini .= <<<ENDDEF
[{$section}]
dbtype = "{$type}"
dbtech = "{$tech}"
dbname = "{$definition['database']}"
sqlfile = "{$definition['dumpFile']}"
dbhost = "{$definition['host']}"
dbuser = ""
dbpass = ""
prefix = "{$definition['prefix']}"
parts = "{$definition['parts']}"

ENDDEF;
            } else {
                // We have to escape the password
                $escapedPassword = addcslashes($definition['password'], "\"\\\n\r");
                $this->databases_ini .= <<<ENDDEF
[{$section}]
dbtype = "{$type}"
dbtech = "{$tech}"
dbname = "{$definition['database']}"
sqlfile = "{$definition['dumpFile']}"
dbhost = "{$definition['host']}"
dbuser = "{$definition['username']}"
dbpass = "{$escapedPassword}"
prefix = "{$definition['prefix']}"
parts = "{$definition['parts']}"

ENDDEF;
            }
        }
    }
开发者ID:esorone,项目名称:efcpw,代码行数:46,代码来源:Db.php

示例10: switch

 public function &get($tag = null)
 {
     $storage_filename = $this->get_storage_filename($tag);
     $ret = false;
     switch ($this->storageEngine) {
         case 'file':
             $data = @file_get_contents($storage_filename);
             if ($data === false) {
                 return $ret;
             }
             break;
         case 'db':
             $db = Factory::getDatabase();
             $sql = $db->getQuery(true)->select($db->qn('data'))->from($db->qn('#__ak_storage'))->where($db->qn('tag') . ' = ' . $db->q($storage_filename));
             $db->setQuery($sql);
             try {
                 $data = $db->loadResult();
             } catch (\Exception $e) {
                 $data = '';
             }
             break;
     }
     $ret = $this->decode($data);
     unset($data);
     return $ret;
 }
开发者ID:jvhost,项目名称:A-Website,代码行数:26,代码来源:FactoryStorage.php

示例11: get_administrator_emails

 /**
  * Returns a list of emails to the Super Administrators
  *
  * @return  array
  */
 public function get_administrator_emails()
 {
     $options = $this->get_platform_database_options();
     $db = Factory::getDatabase($options);
     // Load the root asset node and read the rules
     $query = $db->getQuery(true)->select($db->qn('rules'))->from('#__assets')->where($db->qn('name') . ' = ' . $db->q('root.1'));
     $db->setQuery($query);
     $jsonRules = $db->loadResult();
     $rules = json_decode($jsonRules, true);
     $adminGroups = array();
     $mails = array();
     if (array_key_exists('core.admin', $rules)) {
         $rawGroups = $rules['core.admin'];
         if (!empty($rawGroups)) {
             foreach ($rawGroups as $group => $allowed) {
                 if ($allowed) {
                     $adminGroups[] = $db->q($group);
                 }
             }
         }
     }
     if (empty($adminGroups)) {
         return $mails;
     }
     $adminGroups = implode(',', $adminGroups);
     $query = $db->getQuery(true)->select(array($db->qn('u') . '.' . $db->qn('name'), $db->qn('u') . '.' . $db->qn('email')))->from($db->qn('#__users') . ' AS ' . $db->qn('u'))->join('INNER', $db->qn('#__user_usergroup_map') . ' AS ' . $db->qn('m') . ' ON (' . $db->qn('m') . '.' . $db->qn('user_id') . ' = ' . $db->qn('u') . '.' . $db->qn('id') . ')')->where($db->qn('m') . '.' . $db->qn('group_id') . ' IN (' . $adminGroups . ')');
     $db->setQuery($query);
     $superAdmins = $db->loadAssocList();
     if (!empty($superAdmins)) {
         foreach ($superAdmins as $admin) {
             $mails[] = $admin['email'];
         }
     }
     return $mails;
 }
开发者ID:BillVGN,项目名称:PortalPRP,代码行数:40,代码来源:Platform.php

示例12: get_profile_name

 /**
  * Returns the selected profile's name. If no ID is specified, the current
  * profile's name is returned.
  *
  * @return string
  */
 public function get_profile_name($id = null)
 {
     if (empty($id)) {
         $id = $this->get_active_profile();
     }
     $id = (int) $id;
     $sql = 'SELECT `description` FROM `#__ak_profiles` WHERE `id` = ' . $id;
     $db = Factory::getDatabase($this->get_platform_database_options());
     $db->setQuery($sql);
     return $db->loadResult();
 }
开发者ID:ForAEdesWeb,项目名称:AEW2,代码行数:17,代码来源:Platform.php

示例13: array

 /**
  * Return an instance of DriverBase
  *
  * @return DriverBase
  */
 protected function &getDB()
 {
     $host = $this->host . ($this->port != '' ? ':' . $this->port : '');
     $user = $this->username;
     $password = $this->password;
     $driver = $this->driver;
     $database = $this->database;
     $prefix = is_null($this->prefix) ? '' : $this->prefix;
     $options = array('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $prefix);
     $db = Factory::getDatabase($options);
     if ($error = $db->getError()) {
         $this->setError(__CLASS__ . ' :: Database Error: ' . $error);
         $false = false;
         return $false;
     }
     if ($db->getErrorNum() > 0) {
         $error = $db->getErrorMsg();
         $this->setError(__CLASS__ . ' :: Database Error: ' . $error);
         $false = false;
         return $false;
     }
     return $db;
 }
开发者ID:AlexanderKri,项目名称:joom-upd,代码行数:28,代码来源:Base.php

示例14: load_configuration

 /**
  * Loads the current configuration off the database table
  *
  * @param    int $profile_id The profile where to read the configuration from, defaults to current profile
  *
  * @return    bool    True if everything was read properly
  */
 public function load_configuration($profile_id = null)
 {
     // Load the database class
     $db = Factory::getDatabase($this->get_platform_database_options());
     // Initialize the registry
     $registry = Factory::getConfiguration();
     $registry->reset();
     // 1) Load the INI format local configuration dump:
     $filename = realpath(dirname(__FILE__) . '/Config/config.ini');
     $ini_data_local = file_get_contents($filename);
     // Configuration found. Convert to array format.
     $ini_data_local = \Akeeba\Engine\Util\ParseIni::parse_ini_file_php($ini_data_local, true, true);
     $ini_data = array();
     foreach ($ini_data_local as $section => $row) {
         if (!empty($row)) {
             foreach ($row as $key => $value) {
                 $ini_data["{$section}.{$key}"] = $value;
             }
         }
     }
     unset($ini_data_local);
     // Import the configuration array
     $protected_keys = $registry->getProtectedKeys();
     $registry->resetProtectedKeys();
     $registry->mergeArray($ini_data, false, false);
     $registry->setProtectedKeys($protected_keys);
     // 2) Load the INI format local configuration dump off the database:
     $db = \Akeeba\Engine\Factory::getDatabase($this->get_platform_database_options());
     $sql = $db->getQuery(true)->select($db->qn('configuration'))->from($db->qn($this->tableNameProfiles))->where($db->qn('id') . ' = ' . $db->q(1));
     $db->setQuery($sql);
     $ini_data_local = $db->loadResult();
     if (empty($ini_data_local) || is_null($ini_data_local)) {
         // No configuration was saved yet - store the defaults
         $this->save_configuration($profile_id);
     } else {
         // Configuration found. Convert to array format.
         if (function_exists('get_magic_quotes_runtime')) {
             if (@get_magic_quotes_runtime()) {
                 $ini_data_local = stripslashes($ini_data_local);
             }
         }
         // Decrypt the data if required
         $ini_data_local = \Akeeba\Engine\Factory::getSecureSettings()->decryptSettings($ini_data_local);
         $ini_data_local = \Akeeba\Engine\Util\ParseIni::parse_ini_file_php($ini_data_local, true, true);
         $ini_data = array();
         foreach ($ini_data_local as $section => $row) {
             if (is_array($row) && !empty($row)) {
                 foreach ($row as $key => $value) {
                     $ini_data["{$section}.{$key}"] = $value;
                 }
             }
         }
         unset($ini_data_local);
         $allowedOverrides = array('akeeba.basic.clientsidewait', 'akeeba.basic.file_extensions', 'akeeba.basic.exclude_folders', 'akeeba.basic.exclude_files', 'akeeba.tuning.min_exec_time', 'akeeba.tuning.max_exec_time', 'akeeba.tuning.run_time_bias');
         foreach ($allowedOverrides as $key) {
             if (isset($ini_data[$key])) {
                 $registry->setKeyProtection($key, false);
                 $registry->set($key, $ini_data[$key]);
                 $registry->setKeyProtection($key, true);
             }
         }
     }
     $registry->activeProfile = 1;
     // Apply config overrides
     if (is_array($this->configOverrides) && !empty($this->configOverrides)) {
         $protected_keys = $registry->getProtectedKeys();
         $registry->resetProtectedKeys();
         $registry->mergeArray($this->configOverrides, false, false);
         $registry->setProtectedKeys($protected_keys);
     }
     $registry->activeProfile = $profile_id;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:79,代码来源:Platform.php

示例15: createDatabasesINI

    protected function createDatabasesINI()
    {
        // caching databases.ini contents
        Factory::getLog()->log(LogLevel::DEBUG, __CLASS__ . "AkeebaCUBEDomainDBBackup :: Creating databases.ini data");
        // Create a new string
        $this->databases_ini = '';
        $blankOutPass = Factory::getConfiguration()->get('engine.dump.common.blankoutpass', 0);
        $siteRoot = Factory::getConfiguration()->get('akeeba.platform.newroot', '');
        // Loop through databases list
        foreach ($this->dumpedDatabases as $definition) {
            $section = basename($definition['dumpFile']);
            $dboInstance = Factory::getDatabase($definition);
            $type = $dboInstance->name;
            $tech = $dboInstance->getDriverType();
            // If the database is a sqlite one, we have to process the database name which contains the path
            // At the moment we only handle the case where the db file is UNDER site root
            if ($tech == 'sqlite') {
                $definition['database'] = str_replace($siteRoot, '#SITEROOT#', $definition['database']);
            }
            if ($blankOutPass) {
                $this->databases_ini .= <<<ENDDEF
[{$section}]
dbtype = "{$type}"
dbtech = "{$tech}"
dbname = "{$definition['database']}"
sqlfile = "{$definition['dumpFile']}"
dbhost = "{$definition['host']}"
dbuser = ""
dbpass = ""
prefix = "{$definition['prefix']}"
parts = "{$definition['parts']}"

ENDDEF;
            } else {
                // We have to escape the password
                $escapedPassword = addcslashes($definition['password'], "\"\\\n\r");
                $this->databases_ini .= <<<ENDDEF
[{$section}]
dbtype = "{$type}"
dbtech = "{$tech}"
dbname = "{$definition['database']}"
sqlfile = "{$definition['dumpFile']}"
dbhost = "{$definition['host']}"
dbuser = "{$definition['username']}"
dbpass = "{$escapedPassword}"
prefix = "{$definition['prefix']}"
parts = "{$definition['parts']}"

ENDDEF;
            }
        }
    }
开发者ID:AlexanderKri,项目名称:joom-upd,代码行数:52,代码来源:Db.php


注:本文中的Akeeba\Engine\Factory::getDatabase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。