示例#1
0
文件: backup.php 项目: 01J/topm
 public function browse()
 {
     // Check permissions
     $this->_checkPermissions();
     // Set the profile
     $this->_setProfile();
     // Start the backup
     JLoader::import('joomla.utilities.date');
     AECoreKettenrad::reset(array('maxrun' => 0));
     AEUtilTempfiles::deleteTempFiles();
     AEUtilTempvars::reset(AKEEBA_BACKUP_ORIGIN);
     $kettenrad = AECoreKettenrad::load(AKEEBA_BACKUP_ORIGIN);
     $dateNow = new JDate();
     $description = JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->format(JText::_('DATE_FORMAT_LC2'), true);
     $options = array('description' => $description, 'comment' => '');
     $kettenrad->setup($options);
     $kettenrad->tick();
     $kettenrad->tick();
     $array = $kettenrad->getStatusArray();
     AECoreKettenrad::save(AKEEBA_BACKUP_ORIGIN);
     if ($array['Error'] != '') {
         // An error occured
         die('500 ERROR -- ' . $array['Error']);
     } else {
         $noredirect = $this->input->get('noredirect', 0, 'int');
         if ($noredirect != 0) {
             @ob_end_clean();
             echo "301 More work required";
             flush();
             JFactory::getApplication()->close();
         } else {
             $this->_customRedirect(JURI::base() . 'index.php?option=com_akeeba&view=backup&task=step&key=' . $this->input->get('key', '', 'none', 2) . '&profile=' . $this->input->get('profile', 1, 'int'));
         }
     }
 }
 public function display()
 {
     // Check permissions
     $this->_checkPermissions();
     // Set the profile
     $this->_setProfile();
     // Start the backup
     jimport('joomla.utilities.date');
     AECoreKettenrad::reset(array('maxrun' => 0));
     AEUtilTempfiles::deleteTempFiles();
     AEUtilTempvars::reset(AKEEBA_BACKUP_ORIGIN);
     $kettenrad = AECoreKettenrad::load(AKEEBA_BACKUP_ORIGIN);
     $user = JFactory::getUser();
     $userTZ = $user->getParam('timezone', 0);
     $dateNow = new JDate();
     $dateNow->setOffset($userTZ);
     if (AKEEBA_JVERSION == '16') {
         $description = JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->format(JText::_('DATE_FORMAT_LC2'), true);
     } else {
         $description = JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->toFormat(JText::_('DATE_FORMAT_LC2'));
     }
     $options = array('description' => $description, 'comment' => '');
     $kettenrad->setup($options);
     $array = $kettenrad->tick();
     $array = $kettenrad->tick();
     AECoreKettenrad::save(AKEEBA_BACKUP_ORIGIN);
     if ($array['Error'] != '') {
         // An error occured
         die('500 ERROR -- ' . $array['Error']);
     } else {
         $noredirect = JRequest::getInt('noredirect', 0);
         if ($noredirect != 0) {
             @ob_end_clean();
             echo "301 More work required";
             flush();
             JFactory::getApplication()->close();
         } else {
             $this->setRedirect(JURI::base() . 'index.php?option=com_akeeba&view=backup&task=step&key=' . JRequest::getVar('key') . '&profile=' . JRequest::getInt('profile', 1));
         }
     }
 }
示例#3
0
 public function browse()
 {
     // Check permissions
     $this->_checkPermissions();
     // Set the profile
     $this->_setProfile();
     // Get the backup ID
     $backupId = $this->input->get('backupid', null, 'raw', 2);
     if (strtoupper($backupId) == '[DEFAULT]') {
         $db = JFactory::getDbo();
         $query = $db->getQuery(true)->select('MAX(' . $db->qn('id') . ')')->from($db->qn('#__ak_stats'));
         try {
             $maxId = $db->setQuery($query)->loadResult();
         } catch (Exception $e) {
             $maxId = 0;
         }
         $backupId = 'id' . ($maxId + 1);
     } elseif (empty($backupId)) {
         $backupId = null;
     }
     // Start the backup
     JLoader::import('joomla.utilities.date');
     AECoreKettenrad::reset(array('maxrun' => 0));
     AEUtilTempfiles::deleteTempFiles();
     $tempVarsTag = AKEEBA_BACKUP_ORIGIN;
     $tempVarsTag .= empty($backupId) ? '' : '.' . $backupId;
     AEUtilTempvars::reset($tempVarsTag);
     $kettenrad = AECoreKettenrad::load(AKEEBA_BACKUP_ORIGIN, $backupId);
     $kettenrad->setBackupId($backupId);
     $dateNow = new JDate();
     $description = JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->format(JText::_('DATE_FORMAT_LC2'), true);
     $options = array('description' => $description, 'comment' => '');
     $kettenrad->setup($options);
     $kettenrad->tick();
     $kettenrad->tick();
     $array = $kettenrad->getStatusArray();
     AECoreKettenrad::save(AKEEBA_BACKUP_ORIGIN, $backupId);
     if ($array['Error'] != '') {
         // An error occured
         die('500 ERROR -- ' . $array['Error']);
     } else {
         $noredirect = $this->input->get('noredirect', 0, 'int');
         if ($noredirect != 0) {
             @ob_end_clean();
             echo "301 More work required";
             flush();
             JFactory::getApplication()->close();
         } else {
             $curUri = JUri::getInstance();
             $ssl = $curUri->isSSL() ? 1 : 0;
             $tempURL = JRoute::_('index.php?option=com_akeeba', false, $ssl);
             $uri = new JUri($tempURL);
             $uri->setVar('view', 'backup');
             $uri->setVar('task', 'step');
             $uri->setVar('key', $this->input->get('key', '', 'none', 2));
             $uri->setVar('profile', $this->input->get('profile', 1, 'int'));
             if (!empty($backupId)) {
                 $uri->setVar('backupid', $backupId);
             }
             // Maybe we have a multilingual site?
             $lg = F0FPlatform::getInstance()->getLanguage();
             $languageTag = $lg->getTag();
             $uri->setVar('lang', $languageTag);
             $redirectionUrl = $uri->toString();
             $this->_customRedirect($redirectionUrl);
         }
     }
 }
示例#4
0
 /**
  * Resets the Kettenrad state, wipping out any pending backups and/or stale
  * temporary data.
  *
  * @param array $config Configuration parameters for the reset operation
  */
 public static function reset($config = array())
 {
     $default_config = array('global' => true, 'log' => false, 'maxrun' => 0);
     $config = (object) array_merge($default_config, $config);
     // Pause logging if so desired
     if (!$config->log) {
         AEUtilLogger::WriteLog(false, '');
     }
     $tag = null;
     if (!$config->global) {
         // If we're not resetting globally, get a list of running backups per tag
         $tag = AEPlatform::getInstance()->get_backup_origin();
     }
     // Cache the factory before proceeding
     $factory = AEFactory::serialize();
     $runningList = AEPlatform::getInstance()->get_running_backups($tag);
     // Origins we have to clean
     $origins = array(AEPlatform::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($tag)) {
                 // Check the timestamp of the log file to decide if it's stuck,
                 // but only if a tag is not set
                 $tstamp = @filemtime(AEUtilLogger::logName($running['origin']));
                 if ($tstamp !== false) {
                     // 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 3 minutes old are not considered stale
                     if ($difference < $config->maxrun) {
                         continue;
                     }
                 }
             }
             $filenames = AEUtilStatistics::get_all_filenames($running, false);
             // Process if there are files to delete...
             if (!is_null($filenames)) {
                 // Delete the failed backup's archive, if exists
                 foreach ($filenames as $failedArchive) {
                     AEPlatform::getInstance()->unlink($failedArchive);
                 }
             }
             // Mark the backup failed
             $running['status'] = 'fail';
             $running['multipart'] = 0;
             $dummy = null;
             AEPlatform::getInstance()->set_or_update_statistics($running['id'], $running, $dummy);
             $origins[] = $running['origin'];
         }
     }
     if (!empty($origins)) {
         $origins = array_unique($origins);
         foreach ($origins as $tag) {
             AECoreKettenrad::load($tag);
             // Remove temporary files
             AEUtilTempfiles::deleteTempFiles();
             // Delete any stale temporary data
             AEUtilTempvars::reset($tag);
         }
     }
     // Reload the factory
     AEFactory::unserialize($factory);
     unset($factory);
     // Unpause logging if it was previously paused
     if (!$config->log) {
         AEUtilLogger::WriteLog(true, '');
     }
 }
示例#5
0
文件: finalization.php 项目: 01J/topm
 /**
  * Removes temporary files
  *
  * @return bool
  */
 private function remove_temp_files()
 {
     $this->setStep('Removing temporary files');
     $this->setSubstep('');
     AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Removing temporary files");
     AEUtilTempfiles::deleteTempFiles();
     return true;
 }
示例#6
0
 private function _apiStartBackup($config)
 {
     // Get the passed configuration values
     $defConfig = array('profile' => 1, 'description' => '', 'comment' => '', 'backupid' => null);
     $config = array_merge($defConfig, $config);
     foreach ($config as $key => $value) {
         if (!array_key_exists($key, $defConfig)) {
             unset($config[$key]);
         }
     }
     extract($config);
     // Nuke the factory
     AEFactory::nuke();
     // Set the profile
     $profile = (int) $profile;
     if (!is_numeric($profile)) {
         $profile = 1;
     }
     if (strtoupper($backupid) == '[DEFAULT]') {
         $db = JFactory::getDbo();
         $query = $db->getQuery(true)->select('MAX(' . $db->qn('id') . ')')->from($db->qn('#__ak_stats'));
         try {
             $maxId = $db->setQuery($query)->loadResult();
         } catch (Exception $e) {
             $maxId = 0;
         }
         $backupid = 'id' . ($maxId + 1);
     } elseif (empty($backupid)) {
         $backupid = null;
     }
     $session = JFactory::getSession();
     $session->set('profile', $profile, 'akeeba');
     AEPlatform::getInstance()->load_configuration($profile);
     // Use the default description if none specified
     if (empty($description)) {
         JLoader::import('joomla.utilities.date');
         $dateNow = new JDate();
         /*
         $user = JFactory::getUser();
         $userTZ = $user->getParam('timezone',0);
         $dateNow->setOffset($userTZ);
         */
         $description = JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->format(JText::_('DATE_FORMAT_LC2'), true);
     }
     // Start the backup
     AECoreKettenrad::reset(array('maxrun' => 0));
     AEUtilTempfiles::deleteTempFiles();
     $tempVarsTag = AKEEBA_BACKUP_ORIGIN;
     $tempVarsTag .= empty(${$backupid}) ? '' : '.' . ${$backupid};
     AEUtilTempvars::reset($tempVarsTag);
     $kettenrad = AECoreKettenrad::load(AKEEBA_BACKUP_ORIGIN, $backupid);
     $kettenrad->setBackupId($backupid);
     $options = array('description' => $description, 'comment' => $comment, 'tag' => AKEEBA_BACKUP_ORIGIN);
     $kettenrad->setup($options);
     // Setting up the engine
     $array = $kettenrad->tick();
     // Initializes the init domain
     AECoreKettenrad::save(AKEEBA_BACKUP_ORIGIN, $backupid);
     $array = $kettenrad->getStatusArray();
     if ($array['Error'] != '') {
         // A backup error had occurred. Why are we here?!
         $this->status = self::STATUS_ERROR;
         $this->encapsulation = self::ENCAPSULATION_RAW;
         return 'A backup error had occurred: ' . $array['Error'];
     } else {
         $statistics = AEFactory::getStatistics();
         $array['BackupID'] = $statistics->getId();
         $array['HasRun'] = 1;
         // Force the backup to go on.
         return $array;
     }
 }