function __construct()
 {
     $this->object = 'file';
     $this->subtype = 'all';
     $this->method = 'api';
     if (Factory::getKettenrad()->getTag() == 'restorepoint') {
         $this->enabled = false;
     }
 }
Пример #2
0
 public function onStep($tpl = null)
 {
     $this->setLayout('step');
     $kettenrad = Factory::getKettenrad();
     $array = $kettenrad->getStatusArray();
     $model = $this->getModel();
     $key = $model->getState('key', '');
     $this->array = $array;
     $this->key = $key;
     return true;
 }
Пример #3
0
 function __construct()
 {
     $this->object = 'dbobject';
     $this->subtype = 'all';
     $this->method = 'api';
     $this->filter_name = 'SRPData';
     if (Factory::getKettenrad()->getTag() != 'restorepoint') {
         $this->enabled = false;
     } else {
         $this->init();
     }
 }
Пример #4
0
 function __construct()
 {
     $this->object = 'dir';
     $this->subtype = 'content';
     $this->method = 'direct';
     if (empty($this->filter_name)) {
         $this->filter_name = strtolower(basename(__FILE__, '.php'));
     }
     if (Factory::getKettenrad()->getTag() == 'restorepoint') {
         $this->enabled = false;
     }
     parent::__construct();
 }
Пример #5
0
 function __construct()
 {
     $this->object = 'dir';
     $this->subtype = 'content';
     $this->method = 'api';
     $this->filter_name = 'SRPSkipFiles';
     if (Factory::getKettenrad()->getTag() != 'restorepoint') {
         $this->enabled = false;
     } else {
         $this->filter_data = array();
         $this->init();
     }
 }
Пример #6
0
 function __construct()
 {
     if (!defined('_JEXEC')) {
         $this->enabled = false;
         return;
     }
     $this->object = 'dir';
     $this->subtype = 'all';
     $this->method = 'api';
     $this->filter_name = 'SRPDirectories';
     if (Factory::getKettenrad()->getTag() != 'restorepoint') {
         $this->enabled = false;
     } else {
         $this->init();
     }
 }
Пример #7
0
 public function __construct()
 {
     $this->object = 'dir';
     $this->subtype = 'inclusion';
     $this->method = 'direct';
     $this->filter_name = 'Libraries';
     if (Factory::getKettenrad()->getTag() == 'restorepoint') {
         $this->enabled = false;
     }
     // FIXME This filter doesn't work very well on many live hosts. Disabled for now.
     parent::__construct();
     return;
     if (empty($this->filter_name)) {
         $this->filter_name = strtolower(basename(__FILE__, '.php'));
     }
     // Get the saved library path and compare it to the default
     $jlibdir = Platform::getInstance()->get_platform_configuration_option('jlibrariesdir', '');
     if (empty($jlibdir)) {
         if (defined('JPATH_LIBRARIES')) {
             $jlibdir = JPATH_LIBRARIES;
         } elseif (defined('JPATH_PLATFORM')) {
             $jlibdir = JPATH_PLATFORM;
         } else {
             $jlibdir = false;
         }
     }
     if ($jlibdir !== false) {
         $jlibdir = Factory::getFilesystemTools()->TranslateWinPath($jlibdir);
         $defaultLibraries = Factory::getFilesystemTools()->TranslateWinPath(JPATH_SITE . '/libraries');
         if ($defaultLibraries != $jlibdir) {
             // The path differs, add it here
             $this->filter_data['JPATH_LIBRARIES'] = $jlibdir;
         }
     } else {
         $this->filter_data = array();
     }
     parent::__construct();
 }
Пример #8
0
 /**
  * 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
     $profile_id = Platform::getInstance()->get_active_profile();
     Factory::getLog()->log(LogLevel::INFO, "Loaded profile #{$profile_id}");
     // Get archive name
     list($relativeArchiveName, $absoluteArchiveName) = $this->getArchiveName();
     // ==== Stats initialisation ===
     $origin = Platform::getInstance()->get_backup_origin();
     // Get backup origin
     $profile_id = Platform::getInstance()->get_active_profile();
     // Get active profile
     $registry = Factory::getConfiguration();
     $backupType = $registry->get('akeeba.basic.backup_type');
     Factory::getLog()->log(LogLevel::DEBUG, "Backup type is now set to '" . $backupType . "'");
     // Substitute "variables" in the archive name
     $fsUtils = Factory::getFilesystemTools();
     $description = $fsUtils->replace_archive_name_variables($this->description);
     $comment = $fsUtils->replace_archive_name_variables($this->comment);
     if ($registry->get('volatile.writer.store_on_server', true)) {
         // Archive files are stored on our server
         $stat_relativeArchiveName = $relativeArchiveName;
         $stat_absoluteArchiveName = $absoluteArchiveName;
     } else {
         // Archive files are not stored on our server (FTP backup, cloud backup, sent by email, etc)
         $stat_relativeArchiveName = '';
         $stat_absoluteArchiveName = '';
     }
     $kettenrad = Factory::getKettenrad();
     $temp = array('description' => $description, 'comment' => $comment, 'backupstart' => Platform::getInstance()->get_timestamp_database(), 'status' => 'run', 'origin' => $origin, 'type' => $backupType, 'profile_id' => $profile_id, 'archivename' => $stat_relativeArchiveName, 'absolute_path' => $stat_absoluteArchiveName, 'multipart' => 0, 'filesexist' => 1, 'tag' => $kettenrad->getTag(), 'backupid' => $kettenrad->getBackupId());
     // Save the entry
     $statistics = Factory::getStatistics();
     $statistics->setStatistics($temp);
     if ($statistics->getError()) {
         $this->setError($statistics->getError());
         return;
     }
     $statistics->release_multipart_lock();
     // Initialize the archive.
     if (Factory::getEngineParamsProvider()->getScriptingParameter('core.createarchive', true)) {
         Factory::getLog()->log(LogLevel::DEBUG, "Expanded archive file name: " . $absoluteArchiveName);
         Factory::getLog()->log(LogLevel::DEBUG, "Initializing archiver engine");
         $archiver = Factory::getArchiverEngine();
         $archiver->initialize($absoluteArchiveName);
         $archiver->setComment($comment);
         // Add the comment to the archive itself.
         $archiver->propagateToObject($this);
         if ($this->getError()) {
             return;
         }
     }
     $this->setState('postrun');
 }
Пример #9
0
 private function _apiStepBackup($config)
 {
     $defConfig = array('profile' => null, 'tag' => AKEEBA_BACKUP_ORIGIN, 'backupid' => null);
     $config = array_merge($defConfig, $config);
     $profile = $config['profile'];
     $tag = $config['tag'];
     $backupid = $config['backupid'];
     // Try to set the profile from the setup parameters
     if (!empty($profile)) {
         $registry = Factory::getConfiguration();
         $session = JFactory::getSession();
         $session->set('profile', $profile, 'akeeba');
     }
     Factory::loadState($tag, $backupid);
     $kettenrad = Factory::getKettenrad();
     $kettenrad->setBackupId($backupid);
     $registry = Factory::getConfiguration();
     $session = JFactory::getSession();
     $session->set('profile', $registry->activeProfile, 'akeeba');
     $array = $kettenrad->tick();
     $ret_array = $kettenrad->getStatusArray();
     $array['Progress'] = $ret_array['Progress'];
     try {
         Factory::saveState(AKEEBA_BACKUP_ORIGIN, $backupid);
     } catch (\RuntimeException $e) {
         $array['Error'] = $e->getMessage();
     }
     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) {
         Factory::nuke();
         Factory::getFactoryStorage()->reset();
     } else {
         $statistics = Factory::getStatistics();
         $array['BackupID'] = $statistics->getId();
     }
     return $array;
 }
Пример #10
0
 /**
  * Starts or step a backup process
  *
  * @return array An Akeeba Engine return array
  */
 public function runBackup()
 {
     $ret_array = array();
     $ajaxTask = $this->getState('ajax');
     $tag = $this->getState('tag');
     $backupId = $this->getState('backupid');
     switch ($ajaxTask) {
         // Start a new backup
         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');
             $angiekey = $this->getState('angiekey');
             if (is_null($backupId)) {
                 $db = $this->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);
             }
             // Try resetting the engine
             Factory::resetState(array('maxrun' => 0));
             // Remove any stale memory files left over from the previous step
             if (empty($tag)) {
                 $tag = Platform::getInstance()->get_backup_origin();
             }
             $tempVarsTag = $tag;
             $tempVarsTag .= empty($backupId) ? '' : '.' . $backupId;
             Factory::getFactoryStorage()->reset($tempVarsTag);
             Factory::loadState($tag, $backupId);
             $kettenrad = Factory::getKettenrad();
             $kettenrad->setBackupId($backupId);
             $options = array('description' => $description, 'comment' => $comment, 'jpskey' => $jpskey, 'angiekey' => $angiekey);
             $kettenrad->setup($options);
             $kettenrad->tick();
             $ret_array = $kettenrad->getStatusArray();
             $kettenrad->resetWarnings();
             // So as not to have duplicate warnings reports
             try {
                 Factory::saveState($tag, $backupId);
             } catch (\RuntimeException $e) {
                 $ret_array['Error'] = $e->getMessage();
             }
             break;
             // Step through a backup
         // Step through a backup
         case 'step':
             Factory::loadState($tag, $backupId);
             $kettenrad = Factory::getKettenrad();
             $kettenrad->setBackupId($backupId);
             $kettenrad->tick();
             $ret_array = $kettenrad->getStatusArray();
             $kettenrad->resetWarnings();
             // So as not to have duplicate warnings reports
             try {
                 Factory::saveState($tag, $backupId);
             } catch (\RuntimeException $e) {
                 $ret_array['Error'] = $e->getMessage();
             }
             if ($ret_array['HasRun'] == 1) {
                 // Clean up
                 Factory::nuke();
                 $tempVarsTag = $tag;
                 $tempVarsTag .= empty($backupId) ? '' : '.' . $backupId;
                 Factory::getFactoryStorage()->reset($tempVarsTag);
             }
             break;
             // Send a push notification for backup failure
         // Send a push notification for backup failure
         case 'pushFail':
             Factory::loadState($tag, $backupId);
             $errorMessage = $this->getState('errorMessage');
             $platform = Platform::getInstance();
             $pushSubject = sprintf($platform->translate('COM_AKEEBA_PUSH_ENDBACKUP_FAIL_SUBJECT'), $platform->get_site_name(), $platform->get_host());
             $key = empty($errorMessage) ? 'COM_AKEEBA_PUSH_ENDBACKUP_FAIL_BODY' : 'COM_AKEEBA_PUSH_ENDBACKUP_FAIL_BODY_WITH_MESSAGE';
             $pushDetails = sprintf($platform->translate($key), $platform->get_site_name(), $platform->get_host(), $errorMessage);
             Factory::getPush()->message($pushSubject, $pushDetails);
             break;
         default:
             break;
     }
     return $ret_array;
 }
Пример #11
0
 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;
     }
     Factory::loadState(AKEEBA_BACKUP_ORIGIN, $backupId);
     $kettenrad = Factory::getKettenrad();
     $kettenrad->setBackupId($backupId);
     $kettenrad->tick();
     $array = $kettenrad->getStatusArray();
     $kettenrad->resetWarnings();
     // So as not to have duplicate warnings reports
     try {
         Factory::saveState(AKEEBA_BACKUP_ORIGIN, $backupId);
     } catch (\RuntimeException $e) {
         $array['Error'] = $e->getMessage();
     }
     if ($array['Error'] != '') {
         @ob_end_clean();
         echo '500 ERROR -- ' . $array['Error'];
         flush();
         JFactory::getApplication()->close();
     } elseif ($array['HasRun'] == 1) {
         // All done
         Factory::nuke();
         Factory::getFactoryStorage()->reset();
         @ob_end_clean();
         header('Content-type: text/plain');
         header('Connection: close');
         echo '200 OK';
         flush();
         JFactory::getApplication()->close();
     } else {
         $noredirect = $this->input->get('noredirect', 0, 'int');
         if ($noredirect != 0) {
             @ob_end_clean();
             header('Content-type: text/plain');
             header('Connection: close');
             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);
         }
     }
 }
Пример #12
0
 /**
  * Starts or step a backup process
  *
  * @return array An Akeeba Engine return array
  */
 public function runBackup()
 {
     $ret_array = array();
     $ajaxTask = $this->getState('ajax');
     $tag = $this->getState('tag');
     $backupId = $this->getState('backupid');
     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');
             $angiekey = $this->getState('angiekey');
             if (is_null($backupId)) {
                 $db = $this->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);
             }
             // Try resetting the engine
             Factory::resetState(array('maxrun' => 0));
             // Remove any stale memory files left over from the previous step
             if (empty($tag)) {
                 $tag = Platform::getInstance()->get_backup_origin();
             }
             $tempVarsTag = $tag;
             $tempVarsTag .= empty($backupId) ? '' : '.' . $backupId;
             Factory::getFactoryStorage()->reset($tempVarsTag);
             Factory::loadState($tag, $backupId);
             $kettenrad = Factory::getKettenrad();
             $kettenrad->setBackupId($backupId);
             // Take care of System Restore Point setup
             if ($tag == 'restorepoint') {
                 // Fetch the extension's version information
                 require_once JPATH_COMPONENT_ADMINISTRATOR . '/assets/xmlslurp/xmlslurp.php';
                 $slurp = new LiveUpdateXMLSlurp();
                 $exttype = $this->getState('type');
                 switch ($exttype) {
                     case 'component':
                         $extname = 'com_';
                         break;
                     case 'file':
                         $extname = 'file';
                         break;
                     case 'library':
                         $extname = 'lib_';
                         break;
                     case 'module':
                         $extname = 'mod_';
                         break;
                     case 'package':
                         $extname = 'pkg_';
                         break;
                     case 'plugin':
                         $extname = 'plg_';
                         break;
                     case 'template':
                         $extname = 'tpl_';
                         break;
                     default:
                         $extname = '';
                         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 = '';
                 $angiekey = '';
                 // Set a custom finalization action queue
                 $configOverrides['volatile.core.finalization.action_handlers'] = array(new Akeeba\Engine\Finalization\Srpquotas());
                 $configOverrides['volatile.core.finalization.action_queue'] = array('remove_temp_files', 'update_statistics', 'update_filesizes', 'apply_srp_quotas');
                 // Apply the configuration overrides, please
                 $platform = Platform::getInstance();
                 $platform->configOverrides = $configOverrides;
             }
             $options = array('description' => $description, 'comment' => $comment, 'jpskey' => $jpskey, 'angiekey' => $angiekey);
             $kettenrad->setup($options);
             $kettenrad->tick();
             if ($kettenrad->getState() != 'running' && $tag == 'restorepoint') {
                 Factory::saveState($tag, $backupId);
                 Factory::loadState($tag, $backupId);
                 $kettenrad = Factory::getKettenrad();
                 $kettenrad->setBackupId($backupId);
                 $kettenrad->tick();
             }
             $ret_array = $kettenrad->getStatusArray();
             $kettenrad->resetWarnings();
             // So as not to have duplicate warnings reports
             Factory::saveState($tag, $backupId);
             break;
         case 'step':
             Factory::loadState($tag, $backupId);
             $kettenrad = Factory::getKettenrad();
             $kettenrad->setBackupId($backupId);
             $kettenrad->tick();
             $ret_array = $kettenrad->getStatusArray();
             $kettenrad->resetWarnings();
             // So as not to have duplicate warnings reports
             Factory::saveState($tag, $backupId);
             if ($ret_array['HasRun'] == 1) {
                 // Clean up
                 Factory::nuke();
                 $tempVarsTag = $tag;
                 $tempVarsTag .= empty($backupId) ? '' : '.' . $backupId;
                 Factory::getFactoryStorage()->reset($tempVarsTag);
             }
             break;
         default:
             break;
     }
     return $ret_array;
 }
Пример #13
0
 /**
  * Starts or step a backup process
  *
  * @return array An Akeeba Engine return array
  */
 public function runBackup()
 {
     $ret_array = array();
     $ajaxTask = $this->getState('ajax');
     $tag = $this->getState('tag');
     $backupId = $this->getState('backupid');
     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');
             $angiekey = $this->getState('angiekey');
             if (is_null($backupId)) {
                 $db = $this->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);
             }
             // Try resetting the engine
             Factory::resetState(array('maxrun' => 0));
             // Remove any stale memory files left over from the previous step
             if (empty($tag)) {
                 $tag = Platform::getInstance()->get_backup_origin();
             }
             $tempVarsTag = $tag;
             $tempVarsTag .= empty($backupId) ? '' : '.' . $backupId;
             Factory::getFactoryStorage()->reset($tempVarsTag);
             Factory::loadState($tag, $backupId);
             $kettenrad = Factory::getKettenrad();
             $kettenrad->setBackupId($backupId);
             $options = array('description' => $description, 'comment' => $comment, 'jpskey' => $jpskey, 'angiekey' => $angiekey);
             $kettenrad->setup($options);
             $kettenrad->tick();
             $ret_array = $kettenrad->getStatusArray();
             $kettenrad->resetWarnings();
             // So as not to have duplicate warnings reports
             Factory::saveState($tag, $backupId);
             break;
         case 'step':
             Factory::loadState($tag, $backupId);
             $kettenrad = Factory::getKettenrad();
             $kettenrad->setBackupId($backupId);
             $kettenrad->tick();
             $ret_array = $kettenrad->getStatusArray();
             $kettenrad->resetWarnings();
             // So as not to have duplicate warnings reports
             Factory::saveState($tag, $backupId);
             if ($ret_array['HasRun'] == 1) {
                 // Clean up
                 Factory::nuke();
                 $tempVarsTag = $tag;
                 $tempVarsTag .= empty($backupId) ? '' : '.' . $backupId;
                 Factory::getFactoryStorage()->reset($tempVarsTag);
             }
             break;
         default:
             break;
     }
     return $ret_array;
 }
Пример #14
0
 private function parseScanArray($array)
 {
     $kettenrad = \Akeeba\Engine\Factory::getKettenrad();
     $kettenrad->resetWarnings();
     if ($array['HasRun'] != 1 && empty($array['Error'])) {
         // Still have work to do
         return array('status' => true, 'done' => false, 'error' => '');
     } elseif (!empty($array['Error'])) {
         // Error!
         return array('status' => false, 'done' => true, 'error' => $array['Error']);
     } else {
         // All done
         \Akeeba\Engine\Factory::getFactoryStorage()->reset(AKEEBA_BACKUP_ORIGIN);
         return array('status' => true, 'done' => true, 'error' => '');
     }
 }
Пример #15
0
 /**
  * Steps through a backup.
  *
  * State variables expected (MUST be set):
  * backupid		The ID of the backup.
  * tag			The backup tag, e.g. "frontend".
  * profile      (optional) The profile ID of the backup.
  *
  * @param   bool  $requireBackupId  Should the backup ID be required?
  *
  * @return  array  An Akeeba Engine return array
  */
 public function stepBackup($requireBackupId = true)
 {
     // Get the tag. If not specified use the AKEEBA_BACKUP_ORIGIN constant.
     $tag = $this->getState('tag', null, 'string');
     if (is_null($tag) && defined('AKEEBA_BACKUP_ORIGIN')) {
         $tag = AKEEBA_BACKUP_ORIGIN;
     }
     // Get the Backup ID. If not specified use the AKEEBA_BACKUP_ID constant.
     $backupId = $this->getState('backupid', null, 'string');
     if (is_null($backupId) && defined('AKEEBA_BACKUP_ID')) {
         $backupId = AKEEBA_BACKUP_ID;
     }
     // Get the profile from the session, the AKEEBA_PROFILE constant or the model state – in this order
     $session = $this->container->session;
     $profile = $session->get('profile', null);
     $profile = defined('AKEEBA_PROFILE') ? AKEEBA_PROFILE : $profile;
     $profile = $this->getState('profile', $profile, 'int');
     $profile = max(0, (int) $profile);
     if (empty($profile)) {
         $profile = $this->getLastBackupProfile($tag, $backupId);
     }
     // Set the active profile
     $session->set('profile', $profile);
     if (!defined('AKEEBA_PROFILE')) {
         define('AKEEBA_PROFILE', $profile);
     }
     // Run a backup step
     $ret_array = array('Error' => '');
     try {
         // Reload the configuration
         Platform::getInstance()->load_configuration($profile);
         // Load the engine from storage
         Factory::loadState($tag, $backupId, $requireBackupId);
         // Set the backup ID and run a backup step
         $kettenrad = Factory::getKettenrad();
         $kettenrad->setBackupId($backupId);
         $kettenrad->tick();
         $ret_array = $kettenrad->getStatusArray();
         // Prevent duplicate reporting of warnings
         $kettenrad->resetWarnings();
     } catch (\Exception $e) {
         $ret_array['Error'] = $e->getMessage();
     }
     try {
         if (empty($ret_array['Error']) && $ret_array['HasRun'] != 1) {
             Factory::saveState($tag, $backupId);
         }
     } catch (\RuntimeException $e) {
         $ret_array['Error'] = $e->getMessage();
     }
     if (!empty($ret_array['Error']) || $ret_array['HasRun'] == 1) {
         // Clean up
         Factory::nuke();
         $tempVarsTag = $tag;
         $tempVarsTag .= empty($backupId) ? '' : '.' . $backupId;
         Factory::getFactoryStorage()->reset($tempVarsTag);
     }
     return $ret_array;
 }