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 _apiStartSRPBackup($config) { // Get the passed configuration values $defConfig = array('tag' => 'restorepoint', 'type' => 'component', 'name' => 'akeeba', 'group' => '', 'customdirs' => array(), 'extraprefixes' => array(), 'customtables' => array(), 'skiptables' => array(), 'xmlname' => ''); $config = array_merge($defConfig, $config); foreach ($config as $key => $value) { if (!array_key_exists($key, $defConfig)) { unset($config[$key]); } } // Fetch the extension's version information require_once JPATH_ADMINISTRATOR . '/components/com_akeeba/assets/xmlslurp/xmlslurp.php'; $slurp = new LiveUpdateXMLSlurp(); $exttype = $config['type']; switch ($exttype) { case 'component': $extname = 'com_'; break; case 'module': $extname = 'mod_'; break; case 'plugin': $extname = 'plg_'; break; case 'template': $extname = 'tpl_'; break; } $extname .= $config['name']; $info = $slurp->getInfo($extname, ''); $configOverrides = array('akeeba.basic.archive_name' => 'restore-point-[DATE]-[TIME]', 'akeeba.basic.backup_type' => 'full', 'akeeba.basic.backup_type' => 'full', 'akeeba.advanced.archiver_engine' => 'jpa', 'akeeba.advanced.postproc_engine' => 'none', 'akeeba.advanced.embedded_installer' => 'none', 'engine.archiver.common.dereference_symlinks' => true, 'core.filters.srp.type' => $config['type'], 'core.filters.srp.group' => $config['group'], 'core.filters.srp.name' => $config['name'], 'core.filters.srp.customdirs' => $config['customdirs'], 'core.filters.srp.customfiles' => $config['customfiles'], 'core.filters.srp.extraprefixes' => $config['extraprefixes'], 'core.filters.srp.customtables' => $config['customtables'], 'core.filters.srp.skiptables' => $config['skiptables'], 'core.filters.srp.langfiles' => $config['langfiles']); // Parse a local file stored in (backend)/assets/srpdefs/$extname.xml JLoader::import('joomla.filesystem.file'); $filename = JPATH_COMPONENT_ADMINISTRATOR . '/assets/srpdefs/' . $extname . '.xml'; if (JFile::exists($filename)) { $xml = JFactory::getXMLParser('simple'); if ($xml->loadFile($filename)) { $extraConfig = $this->parseRestorePointXML($xml->document); if ($extraConfig !== false) { $this->mergeSRPConfig($configOverrides, $extraConfig); } } unset($xml); } // Parse the extension's manifest file and look for a <restorepoint> tag if (!empty($info['xmlfile'])) { $xml = JFactory::getXMLParser('simple'); if ($xml->loadFile($info['xmlfile'])) { $restorepoint = $xml->document->getElementByPath('restorepoint'); if ($restorepoint) { $extraConfig = $this->parseRestorePointXML($restorepoint); if ($extraConfig !== false) { $this->mergeSRPConfig($configOverrides, $extraConfig); } } } unset($restorepoint); unset($xml); } // Create an SRP descriptor $srpdescriptor = array('type' => $config['type'], 'name' => $config['name'], 'group' => $config['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; // Nuke the factory Factory::nuke(); $profile = 1; $session = JFactory::getSession(); $session->set('profile', $profile, 'akeeba'); Platform::getInstance()->load_configuration($profile); Factory::getFactoryStorage()->reset('restorepoint'); Factory::loadState('restorepoint'); $kettenrad = Factory::getKettenrad(); $options = array('description' => $description, 'comment' => $comment, 'tag' => 'restorepoint'); $kettenrad->setup($options); // Setting up the engine $kettenrad->tick(); if ($kettenrad->getState() != 'running' && $tag == 'restorepoint') { $kettenrad->tick(); } $kettenrad->resetWarnings(); // So as not to have duplicate warnings reports Factory::saveState($tag); $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 = Factory::getStatistics(); $array['BackupID'] = $statistics->getId(); $array['HasRun'] = 1; // Force the backup to go on. return $array; } }
private function parsePackageXML(SimpleXMLElement $xml) { $return = array(); $files = (array) $xml->xpath('//file'); $slurp = new LiveUpdateXMLSlurp(); foreach ($files as $file) { $group = ''; $type = (string) $file->attributes()->type; $extension = (string) $file->attributes()->id; $info = $slurp->getInfo($extension, ''); if ($type == 'plugin') { $group = (string) $file->attributes()->group; } if ($type == 'module') { $group = (string) $file->attributes()->client; } $return['core.filters.srp.name'][] = $extension; $return['core.filters.srp.type'][] = $type; $return['core.filters.srp.group'][] = $group; $return = $this->getConfigOverridesForSRP($extension, $info, $return); } if (!$return) { $return = false; } return $return; }
/** * Get the current version from the XML manifest of the extension and * populate the class' properties. */ private function populateExtensionInfo() { require_once dirname(__FILE__) . '/xmlslurp.php'; $xmlslurp = new LiveUpdateXMLSlurp(); $data = $xmlslurp->getInfo($this->_extensionName, $this->_xmlFilename); if (empty($this->_currentVersion)) { $this->_currentVersion = $data['version']; } if (empty($this->_currentReleaseDate)) { $this->_currentReleaseDate = $data['date']; } }