public function step() { // Check permissions $this->_checkPermissions(); // Set the profile $this->_setProfile(); $kettenrad =& AECoreKettenrad::load(AKEEBA_BACKUP_ORIGIN); $array = $kettenrad->tick(); AECoreKettenrad::save(AKEEBA_BACKUP_ORIGIN); if ($array['Error'] != '') { @ob_end_clean(); echo '500 ERROR -- ' . $array['Error']; flush(); JFactory::getApplication()->close(); } elseif ($array['HasRun'] == false) { // All done AEFactory::nuke(); AEUtilTempvars::reset(); @ob_end_clean(); echo '200 OK'; flush(); JFactory::getApplication()->close(); } 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)); } } }
public function step() { // Check permissions $this->_checkPermissions(); // Set the profile $this->_setProfile(); $kettenrad = AECoreKettenrad::load(AKEEBA_BACKUP_ORIGIN); $kettenrad->tick(); $array = $kettenrad->getStatusArray(); $kettenrad->resetWarnings(); // So as not to have duplicate warnings reports AECoreKettenrad::save(AKEEBA_BACKUP_ORIGIN); if ($array['Error'] != '') { @ob_end_clean(); echo '500 ERROR -- ' . $array['Error']; flush(); JFactory::getApplication()->close(); } elseif ($array['HasRun'] == 1) { // All done AEFactory::nuke(); AEUtilTempvars::reset(); @ob_end_clean(); echo '200 OK'; flush(); JFactory::getApplication()->close(); } 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->setRedirect(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 step() { // Check permissions $this->_checkPermissions(); // Set the profile $this->_setProfile(); // Get the backup ID $backupId = $this->input->get('backupid', null, 'raw', 2); if (empty($backupId)) { $backupId = null; } $kettenrad = AECoreKettenrad::load(AKEEBA_BACKUP_ORIGIN, $backupId); $kettenrad->setBackupId($backupId); $kettenrad->tick(); $array = $kettenrad->getStatusArray(); $kettenrad->resetWarnings(); // So as not to have duplicate warnings reports AECoreKettenrad::save(AKEEBA_BACKUP_ORIGIN, $backupId); if ($array['Error'] != '') { @ob_end_clean(); echo '500 ERROR -- ' . $array['Error']; flush(); JFactory::getApplication()->close(); } elseif ($array['HasRun'] == 1) { // All done AEFactory::nuke(); AEUtilTempvars::reset(); @ob_end_clean(); echo '200 OK'; flush(); JFactory::getApplication()->close(); } 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); } } }
/** * Loads the factory from the storage (if it exists) and returns a reference to the * Kettenrad object. * * @param $tag string The backup tag to load * * @return AECoreKettenrad A reference to the Kettenrad object */ public static function &load($tag = null) { if (is_null($tag) && defined('AKEEBA_BACKUP_ORIGIN')) { $tag = AKEEBA_BACKUP_ORIGIN; } // In order to load anything, we need to have the correct profile loaded. Let's assume // that the latest backup record in this tag has the correct profile number set. $config = AEFactory::getConfiguration(); if (empty($config->activeProfile)) { // Only bother loading a configuration if none has been already loaded $statList = AEPlatform::getInstance()->get_statistics_list(array('filters' => array(array('field' => 'tag', 'value' => $tag)), 'order' => array('by' => 'id', 'order' => 'DESC'))); if (is_array($statList)) { $stat = array_pop($statList); $profile = $stat['profile_id']; AEPlatform::getInstance()->load_configuration($profile); } } AEUtilLogger::openLog($tag); AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Kettenrad :: Attempting to load from database ({$tag})"); $serialized_factory = AEUtilTempvars::get($tag); if ($serialized_factory !== false) { AEUtilLogger::WriteLog(_AE_LOG_DEBUG, " -- Loaded stored Akeeba Factory ({$tag})"); AEFactory::unserialize($serialized_factory); } else { // There is no serialized factory. Nuke the in-memory factory. AEUtilLogger::WriteLog(_AE_LOG_DEBUG, " -- Stored Akeeba Factory ({$tag}) not found - hard reset"); AEFactory::nuke(); AEPlatform::getInstance()->load_configuration(); } unset($serialized_factory); return AEFactory::getKettenrad(); }
private function _angieUpgrade() { // Get all profiles $model = FOFModel::getTmpInstance('Cpanels', 'AkeebaModel'); $db = JFactory::getDbo(); $query = $db->getQuery(true)->select(array($db->qn('id')))->from($db->qn('#__ak_profiles'))->order($db->qn('id') . " ASC"); $db->setQuery($query); $profiles = $db->loadColumn(); $session = JFactory::getSession(); $oldProfile = $session->get('profile', 1, 'akeeba'); foreach ($profiles as $profile_id) { AEFactory::nuke(); AEPlatform::getInstance()->load_configuration($profile_id); $config = AEFactory::getConfiguration(); $config->set('akeeba.advanced.embedded_installer', 'angie'); AEPlatform::getInstance()->save_configuration($profile_id); } AEFactory::nuke(); AEPlatform::getInstance()->load_configuration($oldProfile); }
public function runBackup() { $ret_array = array(); $ajaxTask = $this->getState('ajax'); switch ($ajaxTask) { case 'start': // Description is passed through a strict filter which removes HTML $description = $this->getState('description'); // The comment is passed through the Safe HTML filter (note: use 2 to force no filtering) $comment = $this->getState('comment'); $jpskey = $this->getState('jpskey'); $tag = $this->getState('tag'); // Try resetting the engine AECoreKettenrad::reset(array('maxrun' => 0)); // Remove any stale memory files left over from the previous step if (empty($tag)) { $tag = AEPlatform::getInstance()->get_backup_origin(); } AEUtilTempvars::reset($tag); $kettenrad = AECoreKettenrad::load($tag); // Take care of System Restore Point setup if ($tag == 'restorepoint') { // Fetch the extension's version information require_once JPATH_COMPONENT_ADMINISTRATOR . '/liveupdate/classes/xmlslurp.php'; $slurp = new LiveUpdateXMLSlurp(); $exttype = $this->getState('type'); switch ($exttype) { case 'component': $extname = 'com_'; break; case 'module': $extname = 'mod_'; break; case 'plugin': $extname = 'plg_'; break; case 'template': $extname = 'tpl_'; break; } $extname .= $this->getState('name'); $info = $slurp->getInfo($extname, ''); // Get the configOverrides for this extension $configOverrides = $this->getConfigOverridesForSRP($extname, $info); // Create an SRP descriptor $srpdescriptor = array('type' => $this->getState('type'), 'name' => $this->getState('name'), 'group' => $this->getState('group'), 'version' => $info['version'], 'date' => $info['date']); // Set the description and comment $description = "System Restore Point - " . JText::_($exttype) . ": {$extname}"; $comment = "---BEGIN SRP---\n" . json_encode($srpdescriptor) . "\n---END SRP---"; $jpskey = ''; // Set a custom finalization action queue $configOverrides['volatile.core.finalization.action_handlers'] = array(new AEFinalizationSrpquotas()); $configOverrides['volatile.core.finalization.action_queue'] = array('remove_temp_files', 'update_statistics', 'update_filesizes', 'apply_srp_quotas'); // Apply the configuration overrides, please $platform = AEPlatform::getInstance(); $platform->configOverrides = $configOverrides; } $options = array('description' => $description, 'comment' => $comment, 'jpskey' => $jpskey); $kettenrad->setup($options); $kettenrad->tick(); if ($kettenrad->getState() != 'running' && $tag == 'restorepoint') { $kettenrad->tick(); } $ret_array = $kettenrad->getStatusArray(); $kettenrad->resetWarnings(); // So as not to have duplicate warnings reports AECoreKettenrad::save($tag); break; case 'step': $tag = $this->getState('tag'); $kettenrad = AECoreKettenrad::load($tag); $kettenrad->tick(); $ret_array = $kettenrad->getStatusArray(); $kettenrad->resetWarnings(); // So as not to have duplicate warnings reports AECoreKettenrad::save($tag); if ($ret_array['HasRun'] == 1) { // Clean up AEFactory::nuke(); AEUtilTempvars::reset($tag); } break; default: break; } return $ret_array; }
private function _apiStepBackup($config) { $defConfig = array('profile' => null, 'tag' => AKEEBA_BACKUP_ORIGIN); $config = array_merge($defConfig, $config); extract($config); // Try to set the profile from the setup parameters if (!empty($profile)) { $registry = AEFactory::getConfiguration(); $session = JFactory::getSession(); $session->set('profile', $profile, 'akeeba'); } $kettenrad = AECoreKettenrad::load($tag); $registry = AEFactory::getConfiguration(); $session = JFactory::getSession(); $session->set('profile', $registry->activeProfile, 'akeeba'); $array = $kettenrad->tick(); $ret_array = $kettenrad->getStatusArray(); $array['Progress'] = $ret_array['Progress']; AECoreKettenrad::save($tag); 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']; } elseif ($array['HasRun'] == false) { AEFactory::nuke(); AEUtilTempvars::reset(); } return $array; }
/** * Returns the backup state ('none','start', or 'step') */ private function getBackupState() { $this->debugInfo = '<h6>Akeeba Backup Lazy Mode</h6><hr/>'; // Make sure we're not locked if($this->isLocked()) { $this->debugInfo .= 'Backup locked'; // If the backup has crashed, clean up if($this->isCrashed) { $this->debugInfo .= 'Crashed backup detected'; AEFactory::nuke(); AEUtilTempvars::reset('lazy'); $this->unsetNonce(); $this->unsetLock(); $this->saveStorage(); } else { return 'none'; } } // Is there a backup running? $this->getNonce(); $action = empty($this->nonce) ? 'start' : 'step'; $this->debugInfo .= '<br/>Action: '.$action; // If there is no running backup, try to figure out if we should start // a new backup. if($action == 'start') { // Get the last backup time $lastBackup = $this->getLastBackupTime(); $this->debugInfo .= '<br/>Last backup: '.$lastBackup.' ('.date('Y/m/d H:i:s',$lastBackup).' GMT)'; // Remove the time part of the backup time (we want the date starting at midnight!) $deconstructedDate = getdate($lastBackup); $lastBackup = mktime( 0,0,0, $deconstructedDate['mon'], $deconstructedDate['mday'], $deconstructedDate['year'] ); $this->debugInfo .= '<br/>Adjusted last backup time: '.$lastBackup.' ('.date('Y/m/d H:i:s',$lastBackup).' GMT)'; // Get the preferences and calculate the next backup time $daysfreq = (int)$this->params->get('daysfreq',1); if($daysfreq <= 0) $daysfreq = 1; $this->debugInfo .= '<br/>Days frequency: '.$daysfreq; $daysfreq *= 86400; $backuptime = $this->params->get('backuptime','00:00'); $this->debugInfo .= '<br/>Backup time: '.$backuptime; $backuptime = trim($backuptime); $parts = explode(':',$backuptime); if(count($parts) != 2) { $backuptime = 0; } else { $hours = (int)$parts[0]; $mins = (int)$parts[1]; $backuptime = $hours * 3600 + $mins * 60; } $this->debugInfo .= ' ('.$backuptime.' seconds)'; $nextBackup = $lastBackup + $daysfreq + $backuptime; $this->debugInfo .= '<br/>Next Backup: '.$nextBackup.' ('.date('Y/m/d H:i:s',$nextBackup).' GMT)'; // The next backup time is in GMT. Convert to local. jimport('joomla.utilities.date'); $date = new JDate($nextBackup, 0); $jreg = JFactory::getConfig(); $offset = $jreg->getValue('config.offset'); $date->setOffset($offset); $nextBackup = $date->toUnix(true); $this->debugInfo .= '<br/>Next Backup: '.$nextBackup.' ('.date('Y/m/d H:i:s',$nextBackup).' LOCAL)'; $this->debugInfo .= '<br/>Time Now: '.time().' ('.date('Y/m/d H:i:s').' LOCAL)'; // Is it time for the next backup to run? if( time() < $nextBackup ) { $this->debugInfo .= '<br/>I will not start a new backup.'; } else { $this->debugInfo .= '<br/><strong>Starting new backup.</strong>'; } if( time() < $nextBackup ) return 'none'; // Create a new nonce $this->setNonce(); $this->saveStorage(); } return $action; }
/** * Apply the ANGIE upgrade */ function com_akeeba_postinstall_angie_action() { // Necessary defines for Akeeba Engine if (!defined('AKEEBAENGINE')) { define('AKEEBAENGINE', 1); // Required for accessing Akeeba Engine's factory class define('AKEEBAROOT', dirname(__FILE__) . '/../akeeba'); define('ALICEROOT', dirname(__FILE__) . '/../alice'); } // Load the factory require_once JPATH_ADMINISTRATOR . '/components/com_akeeba/akeeba/factory.php'; @(include_once JPATH_ADMINISTRATOR . '/components/com_akeeba/alice/factory.php'); // Get all profiles include_once JPATH_SITE . '/libraries/f0f/include.php'; if (!defined('F0F_INCLUDED') || !class_exists('F0FForm', true)) { JError::raiseError('500', 'Your Akeeba Backup installation is broken; please re-install. Alternatively, extract the installation archive and copy the fof directory inside your site\'s libraries directory.'); return; } $model = F0FModel::getTmpInstance('Cpanels', 'AkeebaModel'); $db = JFactory::getDbo(); $query = $db->getQuery(true)->select(array($db->qn('id')))->from($db->qn('#__ak_profiles'))->order($db->qn('id') . " ASC"); $db->setQuery($query); $profiles = $db->loadColumn(); // Save the current profile number $session = JFactory::getSession(); $oldProfile = $session->get('profile', 1, 'akeeba'); // Upgrade all profiles foreach ($profiles as $profile_id) { AEFactory::nuke(); AEPlatform::getInstance()->load_configuration($profile_id); $config = AEFactory::getConfiguration(); $config->set('akeeba.advanced.embedded_installer', 'angie'); AEPlatform::getInstance()->save_configuration($profile_id); } // Restore the old profile AEFactory::nuke(); AEPlatform::getInstance()->load_configuration($oldProfile); com_akeeba_postinstall_common_savesettings(1); }