/** * Public constructor */ public function __construct() { // Call AEAbstractObject's contructor parent::__construct(); // Set the filter name if it's missing (filename in lowercase, minus the .php extension) if(empty($this->filter_name)) $this->filter_name = strtolower(basename(__FILE__,'.php')); }
/** * Public constructor, creates the timer object and calculates the execution time limits * @return AECoreTimer */ public function __construct() { parent::__construct(); // Initialize start time $this->start_time = $this->microtime_float(); // Get configured max time per step and bias $configuration =& AEFactory::getConfiguration(); $config_max_exec_time = $configuration->get('akeeba.tuning.max_exec_time', 14); $bias = $configuration->get('akeeba.tuning.run_time_bias', 75)/100; // Get PHP's maximum execution time (our upper limit) /** if(@function_exists('ini_get')) { $php_max_exec_time = @ini_get("maximum_execution_time"); if ( (!is_numeric($php_max_exec_time)) || ($php_max_exec_time == 0) ) { // If we have no time limit, set a hard limit of about 10 seconds // (safe for Apache and IIS timeouts, verbose enough for users) $php_max_exec_time = 14; } } else { // If ini_get is not available, use a rough default $php_max_exec_time = 14; } // Apply an arbitrary correction to counter CMS load time $php_max_exec_time--; // Apply bias $php_max_exec_time = $php_max_exec_time * $bias; $config_max_exec_time = $config_max_exec_time * $bias; // Use the most appropriate time limit value if( $config_max_exec_time > $php_max_exec_time ) { $this->max_exec_time = $php_max_exec_time; } else { $this->max_exec_time = $config_max_exec_time; } /**/ $this->max_exec_time = $config_max_exec_time * $bias; }
/** * Public constructor * @return AECoreDomainInstaller */ public function __construct() { parent::__construct(); // Fetch the installer settings $this->installerSettings = (object) array('installerroot' => 'installation', 'sqlroot' => 'installation/sql', 'databasesini' => 1, 'readme' => 1, 'extrainfo' => 1, 'password' => 0); $config = AEFactory::getConfiguration(); $installerKey = $config->get('akeeba.advanced.embedded_installer'); $installerDescriptors = AEUtilInihelper::getInstallerList(); if (array_key_exists($installerKey, $installerDescriptors)) { // The selected installer exists, use it $this->installerSettings = (object) $installerDescriptors[$installerKey]; } elseif (array_key_exists('abi', $installerDescriptors)) { // The selected installer doesn't exist, but ABI exists; use that instead $this->installerSettings = (object) $installerDescriptors['abi']; } // If no installer was found, we are using "safe defaults", which are // pretty much what ABI is using, and hope for the best! }
/** * Resets the error condition in the driver. Useful to reset the error state after handling a thrown exception. * * @return $this for chaining */ public function resetErrors() { $this->errorNum = 0; $this->errorMsg = ''; parent::resetErrors(); return $this; }
/** * Overrides setWarning() in order to also write the warning message to the log file * * @param string $warning The warning message * * @return void * * @see AEAbstractObject#setWarning($warning) */ public function setWarning($warning) { parent::setWarning($warning); AEUtilLogger::WriteLog(_AE_LOG_WARNING, $warning); }
/** * Public constructor, loads filter data and filter classes */ public final function __construct() { static $initializing = false; parent::__construct(); // Call parent's constructor // Load filter data from platform's database AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Fetching filter data from database'); $this->filter_registry =& AEPlatform::getInstance()->load_filters(); // Load platform, plugin and core filters $this->filters = array(); $locations = array(AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'platform' . DIRECTORY_SEPARATOR . AKEEBAPLATFORM . DIRECTORY_SEPARATOR . 'filters', AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'filters', AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'filters'); AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Loading filters'); foreach ($locations as $folder) { $is_platform = $folder == AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'platform' . DIRECTORY_SEPARATOR . AKEEBAPLATFORM . DIRECTORY_SEPARATOR . 'filters'; $files = AEUtilScanner::getFiles($folder); if ($files === false) { continue; } // Skip inexistent folders if (empty($files)) { continue; } // Skip no-match folders // Loop all files foreach ($files as $file) { if (substr($file, -4) != '.php') { continue; } // Skip non-PHP files if (in_array(substr($file, 0, 1), array('.', '_'))) { continue; } // Skip filter files starting with dot or dash $filter_name = ($is_platform ? 'Platform' : '') . ucfirst(basename($file, '.php')); // Extract filter base name if (array_key_exists($filter_name, $this->filters)) { continue; } // Skip already loaded filters AEUtilLogger::WriteLog(_AE_LOG_DEBUG, '-- Loading filter ' . $filter_name); $this->filters[$filter_name] =& AEFactory::getFilterObject($filter_name); // Add the filter } } // Load platform, plugin and core stacked filters $locations = array(AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'platform' . DIRECTORY_SEPARATOR . AKEEBAPLATFORM . DIRECTORY_SEPARATOR . 'filters' . DIRECTORY_SEPARATOR . 'stack', AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'filters' . DIRECTORY_SEPARATOR . 'stack', AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'filters' . DIRECTORY_SEPARATOR . 'stack'); $config =& AEFactory::getConfiguration(); AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Loading optional filters'); foreach ($locations as $folder) { $is_platform = $folder == AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'platform' . DIRECTORY_SEPARATOR . AKEEBAPLATFORM . DIRECTORY_SEPARATOR . 'filters' . DIRECTORY_SEPARATOR . 'stack'; $files = AEUtilScanner::getFiles($folder); if ($files === false) { continue; } // Skip inexistent folders if (empty($files)) { continue; } // Skip no-match folders // Loop all files foreach ($files as $file) { if (substr($file, -4) != '.php') { continue; } // Skip non-PHP files $bare_name = strtolower(basename($file, '.php')); $filter_name = 'Stack' . ($is_platform ? 'Platform' : '') . ucfirst(basename($file, '.php')); // Extract filter base name if (array_key_exists($filter_name, $this->filters)) { continue; } // Skip already loaded filters if (!file_exists(substr($file, 0, -4) . '.ini')) { continue; } // Make sure the INI file also exists $key = "core.filters.{$bare_name}.enabled"; if ($config->get($key, 0)) { AEUtilLogger::WriteLog(_AE_LOG_DEBUG, '-- Loading optional filter ' . $filter_name); $this->filters[$filter_name] =& AEFactory::getFilterObject($filter_name); // Add the filter } } } }
/** * Creates or updates the statistics record of the current backup attempt * * @param int $id Backup record ID, use null for new record * @param array $data The data to store * @param AEAbstractObject $caller The calling object * * @return int|null|bool The new record id, or null if this doesn't apply, or false if it failed */ public function set_or_update_statistics($id = null, $data = array(), &$caller) { if (!is_array($data)) { return null; } // No valid data? if (empty($data)) { return null; } // No data at all? $db = AEFactory::getDatabase($this->get_platform_database_options()); if (is_null($id)) { // Create a new record $sql_fields = array(); $sql_values = ''; foreach ($data as $key => $value) { $sql_fields[] = $db->qn($key); $sql_values .= (!empty($sql_values) ? ',' : '') . $db->Quote($value); } $sql = $db->getQuery(true)->insert($db->quoteName($this->tableNameStats))->columns($sql_fields)->values($sql_values); $db->setQuery($sql); try { $db->query(); } catch (Exception $exc) { $caller->setError($exc->getMessage()); return false; } return $db->insertid(); } else { $sql_set = array(); foreach ($data as $key => $value) { if ($key == 'id') { continue; } $sql_set[] = $db->qn($key) . '=' . $db->q($value); } $sql = $db->getQuery(true)->update($db->qn($this->tableNameStats))->set($sql_set)->where($db->qn('id') . '=' . $db->q($id)); $db->setQuery($sql); try { $db->query(); } catch (Exception $exc) { $caller->setError($exc->getMessage()); return false; } return null; } }
/** * Public constructor, loads filter data and filter classes */ public final function __construct() { static $initializing = false; parent::__construct(); // Call parent's constructor // Load filter data from platform's database AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Fetching filter data from database'); $this->filter_registry = AEPlatform::getInstance()->load_filters(); // Load platform, plugin and core filters $this->filters = array(); $locations = array(AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'filters', AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'filters'); $platform_paths = AEPlatform::getInstance()->getPlatformDirectories(); foreach ($platform_paths as $p) { $locations[] = $p . '/filters'; } AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Loading filters'); foreach ($locations as $folder) { $is_platform = $this->isPlatformDirectory($folder); $files = AEUtilScanner::getFiles($folder); if ($files === false) { continue; } // Skip inexistent folders if (empty($files)) { continue; } // Skip no-match folders // Loop all files foreach ($files as $file) { if (substr($file, -4) != '.php') { continue; // Skip non-PHP files } if (in_array(substr($file, 0, 1), array('.', '_'))) { continue; // Skip filter files starting with dot or dash } // Some hosts copy .ini and .php files, renaming them (ie foobar.1.php) // We need to exclude them, otherwise we'll get a fatal error for declaring the same class twice $bare_name = strtolower(basename($file, '.php')); if (preg_match('/[^a-z0-9]/', $bare_name)) { continue; } $filter_name = ($is_platform ? 'Platform' : '') . ucfirst(basename($file, '.php')); // Extract filter base name if (array_key_exists($filter_name, $this->filters)) { continue; // Skip already loaded filters } AEUtilLogger::WriteLog(_AE_LOG_DEBUG, '-- Loading filter ' . $filter_name); $this->filters[$filter_name] = AEFactory::getFilterObject($filter_name); // Add the filter } } // Load platform, plugin and core stacked filters $locations = array(AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'filters' . DIRECTORY_SEPARATOR . 'stack', AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'filters' . DIRECTORY_SEPARATOR . 'stack'); $platform_paths = AEPlatform::getInstance()->getPlatformDirectories(); $platform_stack_paths = array(); foreach ($platform_paths as $p) { $locations[] = $p . '/filters'; $locations[] = $p . '/filters/stack'; $platform_stack_paths[] = $p . '/filters/stack'; } $config = AEFactory::getConfiguration(); AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Loading optional filters'); foreach ($locations as $folder) { $is_platform = $this->isPlatformDirectory($folder); $files = AEUtilScanner::getFiles($folder); if ($files === false) { continue; } // Skip inexistent folders if (empty($files)) { continue; } // Skip no-match folders // Loop all files foreach ($files as $file) { if (substr($file, -4) != '.php') { continue; } // Skip non-PHP files // Some hosts copy .ini and .php files, renaming them (ie foobar.1.php) // We need to exclude them, otherwise we'll get a fatal error for declaring the same class twice $bare_name = strtolower(basename($file, '.php')); if (preg_match('/[^a-z0-9]/', $bare_name)) { continue; } $filter_name = 'Stack' . ($is_platform ? 'Platform' : '') . ucfirst(basename($file, '.php')); // Extract filter base name if (array_key_exists($filter_name, $this->filters)) { continue; } // Skip already loaded filters if (!file_exists($folder . '/' . substr($file, 0, -4) . '.ini')) { continue; } // Make sure the INI file also exists $key = "core.filters.{$bare_name}.enabled"; if ($config->get($key, 0)) { AEUtilLogger::WriteLog(_AE_LOG_DEBUG, '-- Loading optional filter ' . $filter_name); $this->filters[$filter_name] = AEFactory::getFilterObject($filter_name); // Add the filter } } } }