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


PHP Factory::getStatistics方法代码示例

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


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

示例1: execute

 /**
  * Execute the JSON API task
  *
  * @param   array $parameters The parameters to this task
  *
  * @return  mixed
  *
  * @throws  \RuntimeException  In case of an error
  */
 public function execute(array $parameters = array())
 {
     // Get the passed configuration values
     $defConfig = array('backup_id' => 0);
     $defConfig = array_merge($defConfig, $parameters);
     $backup_id = (int) $defConfig['backup_id'];
     // Get the basic statistics
     $record = Platform::getInstance()->get_statistics($backup_id);
     // Get a list of filenames
     $backup_stats = Platform::getInstance()->get_statistics($backup_id);
     // Backup record doesn't exist
     if (empty($backup_stats)) {
         throw new \RuntimeException('Invalid backup record identifier', 404);
     }
     $filenames = Factory::getStatistics()->get_all_filenames($record);
     if (empty($filenames)) {
         // Archives are not stored on the server or no files produced
         $record['filenames'] = array();
     } else {
         $filedata = array();
         $i = 0;
         // Get file sizes per part
         foreach ($filenames as $file) {
             $i++;
             $size = @filesize($file);
             $size = is_numeric($size) ? $size : 0;
             $filedata[] = array('part' => $i, 'name' => basename($file), 'size' => $size);
         }
         // Add the file info to $record['filenames']
         $record['filenames'] = $filedata;
     }
     return $record;
 }
开发者ID:AlexanderKri,项目名称:joom-upd,代码行数:42,代码来源:GetBackupInfo.php

示例2: execute

 /**
  * Execute the JSON API task
  *
  * @param   array $parameters The parameters to this task
  *
  * @return  mixed
  *
  * @throws  \RuntimeException  In case of an error
  */
 public function execute(array $parameters = array())
 {
     $filter = \JFilterInput::getInstance();
     // Get the passed configuration values
     $defConfig = array('profile' => null, 'tag' => AKEEBA_BACKUP_ORIGIN, 'backupid' => null);
     $defConfig = array_merge($defConfig, $parameters);
     $profile = $filter->clean($defConfig['profile'], 'int');
     $tag = $filter->clean($defConfig['tag'], 'cmd');
     $backupid = $filter->clean($defConfig['backupid'], 'cmd');
     // Set the active profile
     $session = $this->container->session;
     // Try to set the profile from the setup parameters
     if (!empty($profile)) {
         $profile = max(1, $profile);
         // Make sure $profile is a positive integer >= 1
         $session->set('profile', $profile);
         define('AKEEBA_PROFILE', $profile);
     }
     /** @var \Akeeba\Backup\Site\Model\Backup $model */
     $model = $this->container->factory->model('Backup')->tmpInstance();
     $model->setState('tag', $tag);
     $model->setState('backupid', $backupid);
     $array = $model->stepBackup(false);
     if ($array['Error'] != '') {
         throw new \RuntimeException('A backup error has occurred: ' . $array['Error'], 500);
     }
     // BackupID contains the numeric backup record ID. backupid contains the backup id (usually in the form id123)
     $statistics = Factory::getStatistics();
     $array['BackupID'] = $statistics->getId();
     // Remote clients expect a boolean, not an integer.
     $array['HasRun'] = $array['HasRun'] === 0;
     return $array;
 }
开发者ID:AlexanderKri,项目名称:joom-upd,代码行数:42,代码来源:StepBackup.php

示例3: execute

 /**
  * Execute the JSON API task
  *
  * @param   array $parameters The parameters to this task
  *
  * @return  mixed
  *
  * @throws  \RuntimeException  In case of an error
  */
 public function execute(array $parameters = array())
 {
     $filter = \JFilterInput::getInstance();
     // Get the passed configuration values
     $defConfig = array('profile' => 1, 'description' => '', 'comment' => '', 'backupid' => null, 'overrides' => array());
     $defConfig = array_merge($defConfig, $parameters);
     $profile = (int) $defConfig['profile'];
     $profile = max(1, $profile);
     // Make sure $profile is a positive integer >= 1
     $description = $filter->clean($defConfig['description'], 'string');
     $comment = $filter->clean($defConfig['comment'], 'string');
     $backupid = $filter->clean($defConfig['backupid'], 'cmd');
     $backupid = empty($backupid) ? null : $backupid;
     // Otherwise the Engine doesn't set a backup ID
     $overrides = $filter->clean($defConfig['overrides'], 'array');
     $this->container->session->set('profile', $profile);
     define('AKEEBA_PROFILE', $profile);
     /**
      * DO NOT REMOVE!
      *
      * The Model will only try to load the configuration after nuking the factory. This causes Profile 1 to be
      * loaded first. Then it figures out it needs to load a different profile and it does – but the protected keys
      * are NOT replaced, meaning that certain configuration parameters are not replaced. Most notably, the chain.
      * This causes backups to behave weirdly. So, DON'T REMOVE THIS UNLESS WE REFACTOR THE MODEL.
      */
     Platform::getInstance()->load_configuration($profile);
     /** @var \Akeeba\Backup\Site\Model\Backup $model */
     $model = $this->container->factory->model('Backup')->tmpInstance();
     $model->setState('tag', AKEEBA_BACKUP_ORIGIN);
     $model->setState('backupid', $backupid);
     $model->setState('description', $description);
     $model->setState('comment', $comment);
     $array = $model->startBackup($overrides);
     if ($array['Error'] != '') {
         throw new \RuntimeException('A backup error has occurred: ' . $array['Error'], 500);
     }
     // BackupID contains the numeric backup record ID. backupid contains the backup id (usually in the form id123)
     $statistics = Factory::getStatistics();
     $array['BackupID'] = $statistics->getId();
     // Remote clients expect a boolean, not an integer.
     $array['HasRun'] = $array['HasRun'] === 0;
     return $array;
 }
开发者ID:AlexanderKri,项目名称:joom-upd,代码行数:52,代码来源:StartBackup.php

示例4: execute

 /**
  * Execute the JSON API task
  *
  * @param   array $parameters The parameters to this task
  *
  * @return  mixed
  *
  * @throws  \RuntimeException  In case of an error
  */
 public function execute(array $parameters = array())
 {
     // Get the passed configuration values
     $defConfig = array('backup_id' => 0, 'part_id' => 1, 'segment' => 1, 'chunk_size' => 1);
     $defConfig = array_merge($defConfig, $parameters);
     $backup_id = (int) $defConfig['backup_id'];
     $part_id = (int) $defConfig['part_id'];
     $segment = (int) $defConfig['segment'];
     $chunk_size = (int) $defConfig['chunk_size'];
     $backup_stats = Platform::getInstance()->get_statistics($backup_id);
     if (empty($backup_stats)) {
         // Backup record doesn't exist
         throw new \RuntimeException('Invalid backup record identifier', 404);
     }
     $files = Factory::getStatistics()->get_all_filenames($backup_stats);
     if (count($files) < $part_id || $part_id <= 0) {
         // Invalid part
         throw new \RuntimeException('Invalid backup part', 404);
     }
     $file = $files[$part_id - 1];
     $filesize = @filesize($file);
     $seekPos = $chunk_size * 1048576 * ($segment - 1);
     if ($seekPos > $filesize) {
         // Trying to seek past end of file
         throw new \RuntimeException('Invalid segment', 404);
     }
     $fp = fopen($file, 'rb');
     if ($fp === false) {
         // Could not read file
         throw new \RuntimeException('Error reading backup archive', 500);
     }
     rewind($fp);
     if (fseek($fp, $seekPos, SEEK_SET) === -1) {
         // Could not seek to position
         throw new \RuntimeException('Error reading specified segment', 500);
     }
     $buffer = fread($fp, 1048576);
     if ($buffer === false) {
         throw new \RuntimeException('Error reading specified segment', 500);
     }
     fclose($fp);
     return base64_encode($buffer);
 }
开发者ID:AlexanderKri,项目名称:joom-upd,代码行数:52,代码来源:Download.php

示例5: stepDatabaseDump


//.........这里部分代码省略.........
                         $this->table_autoincrement['value'] = $myRow[$this->table_autoincrement['field']];
                     }
                     continue;
                 }
             }
             if (!$this->extendedInserts || $this->extendedInserts && empty($this->query)) {
                 $newQuery = true;
                 $fieldList = $this->getFieldListSQL(array_keys($myRow), $numOfFields);
                 if ($numOfFields > 0) {
                     $this->query = "INSERT INTO " . $db->nameQuote(!$use_abstract ? $tableName : $tableAbstract) . " {$fieldList} VALUES ";
                 }
             } else {
                 // On other cases, just mark that we should add a comma and start a new VALUES entry
                 $newQuery = false;
             }
             $outData = '(';
             // Step through each of the row's values
             $fieldID = 0;
             // Used in running backup fix
             $isCurrentBackupEntry = false;
             // Fix 1.2a - NULL values were being skipped
             if ($numOfFields > 0) {
                 foreach ($myRow as $value) {
                     // The ID of the field, used to determine placement of commas
                     $fieldID++;
                     if ($fieldID > $numOfFields) {
                         // This is required for SQL Server backups, do NOT remove!
                         continue;
                     }
                     // Fix 2.0: Mark currently running backup as successful in the DB snapshot
                     if ($tableAbstract == '#__ak_stats') {
                         if ($fieldID == 1) {
                             // Compare the ID to the currently running
                             $statistics = Factory::getStatistics();
                             $isCurrentBackupEntry = $value == $statistics->getId();
                         } elseif ($fieldID == 6) {
                             // Treat the status field
                             $value = $isCurrentBackupEntry ? 'complete' : $value;
                         }
                     }
                     // Post-process the value
                     if (is_null($value)) {
                         $outData .= "NULL";
                         // Cope with null values
                     } else {
                         // Accommodate for runtime magic quotes
                         $value = @get_magic_quotes_runtime() ? stripslashes($value) : $value;
                         $value = $db->Quote($value);
                         if ($this->postProcessValues) {
                             $value = $this->postProcessQuotedValue($value);
                         }
                         $outData .= $value;
                     }
                     if ($fieldID < $numOfFields) {
                         $outData .= ', ';
                     }
                 }
             }
             $outData .= ')';
             if ($numOfFields) {
                 // If it's an existing query and we have extended inserts
                 if ($this->extendedInserts && !$newQuery) {
                     // Check the existing query size
                     $query_length = strlen($this->query);
                     $data_length = strlen($outData);
                     if ($query_length + $data_length > $this->packetSize) {
开发者ID:jvhost,项目名称:A-Website,代码行数:67,代码来源:Mysql.php

示例6: createNewPartFile

 /**
  * Creates a new part for the spanned archive
  *
  * @param   bool $finalPart Is this the final archive part?
  *
  * @return  bool  True on success
  */
 protected function createNewPartFile($finalPart = false)
 {
     // Close any open file pointers
     if (is_resource($this->fp)) {
         $this->fclose($this->fp);
     }
     if (is_resource($this->cdfp)) {
         $this->fclose($this->cdfp);
     }
     // Remove the just finished part from the list of resumable offsets
     $this->removeFromOffsetsList($this->_dataFileName);
     // Set the file pointers to null
     $this->fp = null;
     $this->cdfp = null;
     // Push the previous part if we have to post-process it immediately
     $configuration = Factory::getConfiguration();
     if ($configuration->get('engine.postproc.common.after_part', 0)) {
         $this->finishedPart[] = $this->_dataFileName;
     }
     // Add the part's size to our rolling sum
     clearstatcache();
     $this->totalCompressedSize += filesize($this->_dataFileName);
     $this->totalParts++;
     $this->currentPartNumber = $this->totalParts;
     if ($finalPart) {
         $this->_dataFileName = $this->dataFileNameWithoutExtension . '.zip';
     } else {
         $this->_dataFileName = $this->dataFileNameWithoutExtension . '.z' . sprintf('%02d', $this->currentPartNumber);
     }
     Factory::getLog()->log(LogLevel::INFO, 'Creating new ZIP part #' . $this->currentPartNumber . ', file ' . $this->_dataFileName);
     // Inform CUBE that we have changed the multipart number
     $statistics = Factory::getStatistics();
     $statistics->updateMultipart($this->totalParts);
     // Try to remove any existing file
     @unlink($this->_dataFileName);
     // Touch the new file
     $result = @touch($this->_dataFileName);
     if (function_exists('chmod')) {
         chmod($this->_dataFileName, 0666);
     }
     return $result;
 }
开发者ID:AlexanderKri,项目名称:joom-upd,代码行数:49,代码来源:Zip.php

示例7: resetState

 /**
  * Resets the engine state, wiping out any pending backups and/or stale
  * temporary data.
  *
  * @param array $config Configuration parameters for the reset operation
  */
 public static function resetState($config = array())
 {
     $default_config = array('global' => true, 'log' => false, 'maxrun' => 180);
     $config = (object) array_merge($default_config, $config);
     // Pause logging if so desired
     if (!$config->log) {
         Factory::getLog()->pause();
     }
     $originTag = null;
     if (!$config->global) {
         // If we're not resetting globally, get a list of running backups per tag
         $originTag = Platform::getInstance()->get_backup_origin();
     }
     // Cache the factory before proceeding
     $factory = self::serialize();
     $runningList = Platform::getInstance()->get_running_backups($originTag);
     // Origins we have to clean
     $origins = array(Platform::getInstance()->get_backup_origin());
     // 1. Detect failed backups
     if (is_array($runningList) && !empty($runningList)) {
         // The current timestamp
         $now = time();
         // Mark running backups as failed
         foreach ($runningList as $running) {
             if (empty($originTag)) {
                 // Check the timestamp of the log file to decide if it's stuck,
                 // but only if a tag is not set
                 $tstamp = Factory::getLog()->getLastTimestamp($running['origin']);
                 if (!is_null($tstamp)) {
                     // We can only check the timestamp if it's returned. If not, we assume the backup is stale
                     $difference = abs($now - $tstamp);
                     // Backups less than maxrun seconds old are not considered stale (default: 3 minutes)
                     if ($difference < $config->maxrun) {
                         continue;
                     }
                 }
             }
             $filenames = Factory::getStatistics()->get_all_filenames($running, false);
             $totalSize = 0;
             // Process if there are files to delete...
             if (!is_null($filenames)) {
                 // Delete the failed backup's archive, if exists
                 foreach ($filenames as $failedArchive) {
                     if (file_exists($failedArchive)) {
                         $totalSize += (int) @filesize($failedArchive);
                         Platform::getInstance()->unlink($failedArchive);
                     }
                 }
             }
             // Mark the backup failed
             if (!$running['total_size']) {
                 $running['total_size'] = $totalSize;
             }
             $running['status'] = 'fail';
             $running['multipart'] = 0;
             $dummy = null;
             Platform::getInstance()->set_or_update_statistics($running['id'], $running, $dummy);
             $backupId = isset($running['backupid']) ? '.' . $running['backupid'] : '';
             $origins[] = $running['origin'] . $backupId;
         }
     }
     if (!empty($origins)) {
         $origins = array_unique($origins);
         foreach ($origins as $originTag) {
             self::loadState($originTag);
             // Remove temporary files
             Factory::getTempFiles()->deleteTempFiles();
             // Delete any stale temporary data
             self::getFactoryStorage()->reset($originTag);
         }
     }
     // Reload the factory
     self::unserialize($factory);
     unset($factory);
     // Unpause logging if it was previously paused
     if (!$config->log) {
         Factory::getLog()->unpause();
     }
 }
开发者ID:jvhost,项目名称:A-Website,代码行数:85,代码来源:Factory.php

示例8: _logFileChange

 /**
  * Adds a log entry to the #__admintools_scanalerts table, marking a modified, added or suspicious file.
  *
  * @param   \stdClass       $newFileRecord  The record of the current version of the file
  * @param   \stdClass|null  $oldFileRecord  The record of the old version of the file (or null if it's an added file)
  *
  * @return  void
  */
 private function _logFileChange(&$newFileRecord, &$oldFileRecord = null)
 {
     // Initialise the new alert record
     $alertRecord = array('path' => $newFileRecord->path, 'scan_id' => \Akeeba\Engine\Factory::getStatistics()->getId(), 'diff' => '', 'threat_score' => 0, 'acknowledged' => 0);
     // Produce the diff if there is an old file
     if (!is_null($oldFileRecord)) {
         if ($this->generateDiff) {
             // Modified file, generate diff
             $newText = gzinflate($newFileRecord->data);
             $newText = str_replace("\r\n", "\n", $newText);
             $newText = str_replace("\r", "\n", $newText);
             $newLines = explode("\n", $newText);
             unset($newText);
             $oldText = gzinflate($oldFileRecord->data);
             $oldText = str_replace("\r\n", "\n", $oldText);
             $oldText = str_replace("\r", "\n", $oldText);
             $oldLines = explode("\n", $oldText);
             unset($oldText);
             $diffObject = new \Horde_Text_Diff('native', array($newLines, $oldLines));
             $renderer = new \Horde_Text_Diff_Renderer();
             $alertRecord['diff'] = $renderer->render($diffObject);
             unset($renderer);
             unset($diffObject);
             unset($newLines);
             unset($oldLines);
             $alertRecord['threat_score'] = $this->_getThreatScore($alertRecord['diff']);
         } else {
             // Modified file, do not generate diff
             $alertRecord['diff'] = "###MODIFIED FILE###\n";
             $newText = @file_get_contents($newFileRecord->sourcePath);
             $alertRecord['threat_score'] = $this->_getThreatScore($newText);
             unset($newText);
         }
     } else {
         // New file
         $newText = @file_get_contents($newFileRecord->sourcePath);
         $alertRecord['threat_score'] = $this->_getThreatScore($newText);
         unset($newText);
     }
     // Do not create a record for non-threat files
     if ($this->ignoreNonThreats && !$alertRecord['threat_score']) {
         return;
     }
     $alertRecord = (object) $alertRecord;
     $db = \JFactory::getDbo();
     $db->insertObject('#__admintools_scanalerts', $alertRecord);
     unset($alertRecord);
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:56,代码来源:Jfscan.php

示例9: deleteFile

 /**
  * Delete the backup file of the stats record whose ID is set in the model
  *
  * @return  bool  True on success
  */
 public function deleteFile()
 {
     JLoader::import('joomla.filesystem.file');
     $id = $this->getState('id', 0);
     if (!is_numeric($id) || $id <= 0) {
         throw new RecordNotLoaded(JText::_('COM_AKEEBA_BUADMIN_ERROR_INVALIDID'));
     }
     // Get the backup statistics record and the files to delete
     $stat = Platform::getInstance()->get_statistics($id);
     $allFiles = Factory::getStatistics()->get_all_filenames($stat, false);
     // Remove the custom log file if necessary
     $this->deleteLogs($stat);
     // No files? Nothing to do.
     if (empty($allFiles)) {
         return true;
     }
     $status = true;
     foreach ($allFiles as $filename) {
         if (!@file_exists($filename)) {
             continue;
         }
         $new_status = @unlink($filename);
         if (!$new_status) {
             $new_status = JFile::delete($filename);
         }
         $status = $status ? $new_status : false;
     }
     return $status;
 }
开发者ID:AlexanderKri,项目名称:joom-upd,代码行数:34,代码来源:Statistics.php

示例10: _apiDownloadDirect

 private function _apiDownloadDirect($config)
 {
     $defConfig = array('backup_id' => 0, 'part_id' => 1);
     $config = array_merge($defConfig, $config);
     $backup_id = $config['backup_id'];
     $part_id = $config['part_id'];
     $backup_stats = Platform::getInstance()->get_statistics($backup_id);
     if (empty($backup_stats)) {
         // Backup record doesn't exist
         $this->status = self::STATUS_NOT_FOUND;
         $this->encapsulation = self::ENCAPSULATION_RAW;
         @ob_end_clean();
         header('HTTP/1.1 500 Invalid backup record identifier');
         flush();
         JFactory::getApplication()->close();
     }
     $files = Factory::getStatistics()->get_all_filenames($backup_stats);
     if (count($files) < $part_id || $part_id <= 0) {
         // Invalid part
         $this->status = self::STATUS_NOT_FOUND;
         $this->encapsulation = self::ENCAPSULATION_RAW;
         @ob_end_clean();
         header('HTTP/1.1 500 Invalid backup part');
         flush();
         JFactory::getApplication()->close();
     }
     $filename = $files[$part_id - 1];
     @clearstatcache();
     // For a certain unmentionable browser -- Thank you, Nooku, for the tip
     if (function_exists('ini_get') && function_exists('ini_set')) {
         if (ini_get('zlib.output_compression')) {
             ini_set('zlib.output_compression', 'Off');
         }
     }
     // Remove php's time limit -- Thank you, Nooku, for the tip
     if (function_exists('ini_get') && function_exists('set_time_limit')) {
         if (!ini_get('safe_mode')) {
             @set_time_limit(0);
         }
     }
     $basename = @basename($filename);
     $filesize = @filesize($filename);
     $extension = strtolower(str_replace(".", "", strrchr($filename, ".")));
     while (@ob_end_clean()) {
     }
     @clearstatcache();
     // Send MIME headers
     header('MIME-Version: 1.0');
     header('Content-Disposition: attachment; filename="' . $basename . '"');
     header('Content-Transfer-Encoding: binary');
     header('Accept-Ranges: bytes');
     switch ($extension) {
         case 'zip':
             // ZIP MIME type
             header('Content-Type: application/zip');
             break;
         default:
             // Generic binary data MIME type
             header('Content-Type: application/octet-stream');
             break;
     }
     // Notify of filesize, if this info is available
     if ($filesize > 0) {
         header('Content-Length: ' . @filesize($filename));
     }
     // Disable caching
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     header("Expires: 0");
     header('Pragma: no-cache');
     flush();
     if ($filesize > 0) {
         // If the filesize is reported, use 1M chunks for echoing the data to the browser
         $blocksize = 1048756;
         //1M chunks
         $handle = @fopen($filename, "r");
         // Now we need to loop through the file and echo out chunks of file data
         if ($handle !== false) {
             while (!@feof($handle)) {
                 echo @fread($handle, $blocksize);
                 @ob_flush();
                 flush();
             }
         }
         if ($handle !== false) {
             @fclose($handle);
         }
     } else {
         // If the filesize is not reported, hope that readfile works
         @readfile($filename);
     }
     flush();
     JFactory::getApplication()->close();
 }
开发者ID:brenot,项目名称:forumdesenvolvimento,代码行数:93,代码来源:jsons.php

示例11: getBackupFilePaths

 /**
  * Find where to store the backup files
  *
  * @param $partNumber int The SQL part number, default is 0 (.sql)
  */
 protected function getBackupFilePaths($partNumber = 0)
 {
     Factory::getLog()->log(LogLevel::DEBUG, __CLASS__ . " :: Getting temporary file");
     $this->tempFile = Factory::getTempFiles()->registerTempFile(dechex(crc32(microtime())) . '.sql');
     Factory::getLog()->log(LogLevel::DEBUG, __CLASS__ . " :: Temporary file is {$this->tempFile}");
     // Get the base name of the dump file
     $partNumber = intval($partNumber);
     $baseName = $this->dumpFile;
     if ($partNumber > 0) {
         // The file names are in the format dbname.sql, dbname.s01, dbname.s02, etc
         if (strtolower(substr($baseName, -4)) == '.sql') {
             $baseName = substr($baseName, 0, -4) . '.s' . sprintf('%02u', $partNumber);
         } else {
             $baseName = $baseName . '.s' . sprintf('%02u', $partNumber);
         }
     }
     if (empty($this->installerSettings)) {
         // Fetch the installer settings
         $this->installerSettings = (object) array('installerroot' => 'installation', 'sqlroot' => 'installation/sql', 'databasesini' => 1, 'readme' => 1, 'extrainfo' => 1);
         $config = Factory::getConfiguration();
         $installerKey = $config->get('akeeba.advanced.embedded_installer');
         $installerDescriptors = Factory::getEngineParamsProvider()->getInstallerList();
         if (array_key_exists($installerKey, $installerDescriptors)) {
             // The selected installer exists, use it
             $this->installerSettings = (object) $installerDescriptors[$installerKey];
         } elseif (array_key_exists('angie', $installerDescriptors)) {
             // The selected installer doesn't exist, but ANGIE exists; use that instead
             $this->installerSettings = (object) $installerDescriptors['angie'];
         }
     }
     switch (Factory::getEngineParamsProvider()->getScriptingParameter('db.saveasname', 'normal')) {
         case 'output':
             // The SQL file will be stored uncompressed in the output directory
             $statistics = Factory::getStatistics();
             $statRecord = $statistics->getRecord();
             $this->saveAsName = $statRecord['absolute_path'];
             break;
         case 'normal':
             // The SQL file will be stored in the SQL root of the archive, as
             // specified by the particular embedded installer's settings
             $this->saveAsName = $this->installerSettings->sqlroot . '/' . $baseName;
             break;
         case 'short':
             // The SQL file will be stored on archive's root
             $this->saveAsName = $baseName;
             break;
     }
     if ($partNumber > 0) {
         Factory::getLog()->log(LogLevel::DEBUG, "AkeebaDomainDBBackup :: Creating new SQL dump part #{$partNumber}");
     }
     Factory::getLog()->log(LogLevel::DEBUG, "AkeebaDomainDBBackup :: SQL temp file is " . $this->tempFile);
     Factory::getLog()->log(LogLevel::DEBUG, "AkeebaDomainDBBackup :: SQL file location in archive is " . $this->saveAsName);
 }
开发者ID:AlexanderKri,项目名称:joom-upd,代码行数:58,代码来源:Base.php

示例12: enableSplitArchives

 /**
  * Enable split archive creation where possible
  *
  * @return  void
  */
 protected function enableSplitArchives()
 {
     $configuration = Factory::getConfiguration();
     $partSize = $configuration->get('engine.archiver.common.part_size', 0);
     // If the part size is less than 64Kb we won't enable split archives
     if ($partSize < 65536) {
         return;
     }
     $extension = $this->getExtension();
     $altExtension = substr($extension, 0, 2) . '01';
     $archiveTypeUppercase = strtoupper(substr($extension, 1));
     Factory::getLog()->log(LogLevel::INFO, __CLASS__ . " :: Split {$archiveTypeUppercase} creation enabled");
     $this->useSplitArchive = true;
     $this->partSize = $partSize;
     $this->dataFileNameWithoutExtension = dirname($this->_dataFileName) . '/' . basename($this->_dataFileName, $extension);
     $this->_dataFileName = $this->dataFileNameWithoutExtension . $altExtension;
     // Indicate that we have at least 1 part
     $statistics = Factory::getStatistics();
     $statistics->updateMultipart(1);
 }
开发者ID:AlexanderKri,项目名称:joom-upd,代码行数:25,代码来源:BaseArchiver.php

示例13: apply_srp_quotas

 public function apply_srp_quotas($parent)
 {
     $parent->relayStep('Applying quotas');
     $parent->relaySubstep('');
     // If no quota settings are enabled, quit
     $registry = Factory::getConfiguration();
     $srpQuotas = $registry->get('akeeba.quota.srp_size_quota');
     if ($srpQuotas <= 0) {
         Factory::getLog()->log(LogLevel::DEBUG, "No restore point quotas were defined; old restore point files will be kept intact");
         return true;
         // No quota limits were requested
     }
     // Get valid-looking backup ID's
     $validIDs = Platform::getInstance()->get_valid_backup_records(true, array('restorepoint'));
     if (!empty($validIDs)) {
         $validIDs = array_splice($validIDs, 1);
     }
     $statistics = Factory::getStatistics();
     $latestBackupId = $statistics->getId();
     // Create a list of valid files
     $allFiles = array();
     if (count($validIDs)) {
         foreach ($validIDs as $id) {
             $stat = Platform::getInstance()->get_statistics($id);
             // Get the log file name
             $tag = $stat['tag'];
             $backupId = isset($stat['backupid']) ? $stat['backupid'] : '';
             $logName = '';
             if (!empty($backupId)) {
                 $logName = 'akeeba.' . $tag . '.' . $backupId . '.log';
             }
             // Multipart processing
             $filenames = Factory::getStatistics()->get_all_filenames($stat, true);
             if (!is_null($filenames)) {
                 // Only process existing files
                 $filesize = 0;
                 foreach ($filenames as $filename) {
                     $filesize += @filesize($filename);
                 }
                 $allFiles[] = array('id' => $id, 'filenames' => $filenames, 'size' => $filesize, 'logname' => $logName);
             }
         }
     }
     unset($validIDs);
     // If there are no files, exit early
     if (count($allFiles) == 0) {
         Factory::getLog()->log(LogLevel::DEBUG, "There were no old restore points to apply quotas on");
         return true;
     }
     // Init arrays
     $killids = array();
     $killLogs = array();
     $ret = array();
     $leftover = array();
     // Do we need to apply size quotas?
     Factory::getLog()->log(LogLevel::DEBUG, "Processing restore point size quotas");
     // OK, let's start counting bytes!
     $runningSize = 0;
     while (count($allFiles) > 0) {
         // Each time, remove the last element of the backup array and calculate
         // running size. If it's over the limit, add the archive to the return array.
         $def = array_pop($allFiles);
         $runningSize += $def['size'];
         if ($runningSize >= $srpQuotas) {
             if ($latestBackupId == $def['id']) {
                 $runningSize -= $def['size'];
             } else {
                 $ret[] = $def['filenames'];
                 $killids[] = $def['filenames'];
                 if (!empty($def['logname'])) {
                     $filePath = reset($def['filenames']);
                     if (!empty($filePath)) {
                         $killLogs[] = dirname($filePath) . '/' . $def['logname'];
                     }
                 }
             }
         }
     }
     // Convert the $ret 2-dimensional array to single dimensional
     $quotaFiles = array();
     foreach ($ret as $temp) {
         foreach ($temp as $filename) {
             $quotaFiles[] = $filename;
         }
     }
     // Update the statistics record with the removed remote files
     if (!empty($killids)) {
         foreach ($killids as $id) {
             $data = array('filesexist' => '0');
             Platform::getInstance()->set_or_update_statistics($id, $data, $parent);
         }
     }
     // Apply quotas to SRP backup archives
     if (count($quotaFiles) > 0) {
         Factory::getLog()->log(LogLevel::DEBUG, "Applying quotas");
         \JLoader::import('joomla.filesystem.file');
         foreach ($quotaFiles as $file) {
             if (!@Platform::getInstance()->unlink($file)) {
                 $parent->setWarning("Failed to remove old system restore point file " . $file);
             }
//.........这里部分代码省略.........
开发者ID:ppantilla,项目名称:bbninja,代码行数:101,代码来源:Srpquotas.php

示例14: get_remote_quotas

 /**
  * Applies the size and count quotas
  *
  * @return bool True on success
  */
 protected function get_remote_quotas()
 {
     // Get all records with a remote filename
     $allRecords = Platform::getInstance()->get_valid_remote_records();
     // Bail out if no records found
     if (empty($allRecords)) {
         return array();
     }
     // Try to find the files to be deleted due to quota settings
     $statistics = Factory::getStatistics();
     $latestBackupId = $statistics->getId();
     // Filter out the current record
     $temp = array();
     foreach ($allRecords as $item) {
         if ($item['id'] == $latestBackupId) {
             continue;
         }
         $item['files'] = $this->get_remote_files($item['remote_filename'], $item['multipart']);
         $temp[] = $item;
     }
     $allRecords = $temp;
     // Bail out if only the current backup was included in the list
     if (count($allRecords) == 0) {
         return array();
     }
     // Get quota values
     $registry = Factory::getConfiguration();
     $countQuota = $registry->get('akeeba.quota.count_quota');
     $sizeQuota = $registry->get('akeeba.quota.size_quota');
     $useCountQuotas = $registry->get('akeeba.quota.enable_count_quota');
     $useSizeQuotas = $registry->get('akeeba.quota.enable_size_quota');
     $useDayQuotas = $registry->get('akeeba.quota.maxage.enable');
     $daysQuota = $registry->get('akeeba.quota.maxage.maxdays');
     $preserveDay = $registry->get('akeeba.quota.maxage.keepday');
     $leftover = array();
     $ret = array();
     $killids = array();
     if ($useDayQuotas) {
         $killDatetime = new \DateTime();
         $killDatetime->modify('-' . $daysQuota . ($daysQuota == 1 ? ' day' : ' days'));
         $killTS = $killDatetime->format('U');
         foreach ($allRecords as $def) {
             $backupstart = new \DateTime($def['backupstart']);
             $backupTS = $backupstart->format('U');
             $backupDay = $backupstart->format('d');
             // Is this on a preserve day?
             if ($preserveDay > 0) {
                 if ($preserveDay == $backupDay) {
                     $leftover[] = $def;
                     continue;
                 }
             }
             // Otherwise, check the timestamp
             if ($backupTS < $killTS) {
                 $ret[] = $def['files'];
                 $killids[] = $def['id'];
             } else {
                 $leftover[] = $def;
             }
         }
     }
     // Do we need to apply count quotas?
     if ($useCountQuotas && $countQuota >= 1 && !$useDayQuotas) {
         $countQuota--;
         // Are there more files than the quota limit?
         if (!(count($allRecords) > $countQuota)) {
             // No, effectively skip the quota checking
             $leftover = $allRecords;
         } else {
             Factory::getLog()->log(LogLevel::DEBUG, "Processing remote count quotas");
             // Yes, apply the quota setting.
             $totalRecords = count($allRecords);
             for ($count = 0; $count <= $totalRecords; $count++) {
                 $def = array_pop($allRecords);
                 if (count($leftover) >= $countQuota) {
                     $ret[] = $def['files'];
                     $killids[] = $def['id'];
                 } else {
                     $leftover[] = $def;
                 }
             }
             unset($allRecords);
         }
     } else {
         // No count quotas are applied
         $leftover = $allRecords;
     }
     // Do we need to apply size quotas?
     if ($useSizeQuotas && $sizeQuota > 0 && count($leftover) > 0 && !$useDayQuotas) {
         Factory::getLog()->log(LogLevel::DEBUG, "Processing remote size quotas");
         // OK, let's start counting bytes!
         $runningSize = 0;
         while (count($leftover) > 0) {
             // Each time, remove the last element of the backup array and calculate
             // running size. If it's over the limit, add the archive to the $ret array.
//.........这里部分代码省略.........
开发者ID:ForAEdesWeb,项目名称:AEW2,代码行数:101,代码来源:Finalization.php

示例15: is_excluded_by_api

 protected function is_excluded_by_api($test, $root)
 {
     static $filter_switch = null;
     static $last_backup = null;
     if (is_null($filter_switch)) {
         $config = Factory::getConfiguration();
         $filter_switch = Factory::getEngineParamsProvider()->getScriptingParameter('filter.incremental', 0);
         $filter_switch = $filter_switch == 1;
         $last_backup = $config->get('volatile.filter.last_backup', null);
         if (is_null($last_backup) && $filter_switch) {
             // Get a list of backups on this profile
             $backups = Platform::getInstance()->get_statistics_list(array('filters' => array(array('field' => 'profile_id', 'value' => Platform::getInstance()->get_active_profile()))));
             // Find this backup's ID
             $model = Factory::getStatistics();
             $id = $model->getId();
             if (is_null($id)) {
                 $id = -1;
             }
             // Initialise
             $last_backup = time();
             $now = $last_backup;
             // Find the last time a successful backup with this profile was made
             if (count($backups)) {
                 foreach ($backups as $backup) {
                     // Skip the current backup
                     if ($backup['id'] == $id) {
                         continue;
                     }
                     // Skip non-complete backups
                     if ($backup['status'] != 'complete') {
                         continue;
                     }
                     $tzUTC = new \DateTimeZone('UTC');
                     $dateTime = new \DateTime($backup['backupstart'], $tzUTC);
                     $backuptime = $dateTime->getTimestamp();
                     $last_backup = $backuptime;
                     break;
                 }
             }
             if ($last_backup == $now) {
                 // No suitable backup found; disable this filter
                 $config->set('volatile.scripting.incfile.filter.incremental', 0);
                 $filter_switch = false;
             } else {
                 // Cache the last backup timestamp
                 $config->set('volatile.filter.last_backup', $last_backup);
             }
         }
     }
     if (!$filter_switch) {
         return false;
     }
     // Get the filesystem path for $root
     $config = Factory::getConfiguration();
     $fsroot = $config->get('volatile.filesystem.current_root', '');
     $ds = $fsroot == '' || $fsroot == '/' ? '' : DIRECTORY_SEPARATOR;
     $filename = $fsroot . $ds . $test;
     // Get the timestamp of the file
     $timestamp = @filemtime($filename);
     // If we could not get this information, include the file in the archive
     if ($timestamp === false) {
         return false;
     }
     // Compare it with the last backup timestamp and exclude if it's older than the last backup
     if ($timestamp <= $last_backup) {
         //Factory::getLog()->log(LogLevel::DEBUG, "Excluding $filename due to incremental backup restrictions");
         return true;
     }
     // No match? Just include the file!
     return false;
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:71,代码来源:Incremental.php


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