本文整理汇总了PHP中Akeeba\Engine\Factory::resetState方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::resetState方法的具体用法?PHP Factory::resetState怎么用?PHP Factory::resetState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Akeeba\Engine\Factory
的用法示例。
在下文中一共展示了Factory::resetState方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onBeforeBrowse
public function onBeforeBrowse()
{
$result = parent::onBeforeBrowse();
if ($result) {
$params = JComponentHelper::getParams('com_akeeba');
$model = $this->getThisModel();
$view = $this->getThisView();
/** @var AkeebaModelCpanels $model */
$view->setModel($model);
$aeconfig = Factory::getConfiguration();
// Invalidate stale backups
Factory::resetState(array('global' => true, 'log' => false, 'maxrun' => $params->get('failure_timeout', 180)));
// Just in case the reset() loaded a stale configuration...
Platform::getInstance()->load_configuration();
// Let's make sure the temporary and output directories are set correctly and writable...
$wizmodel = F0FModel::getAnInstance('Confwiz', 'AkeebaModel');
$wizmodel->autofixDirectories();
// Check if we need to toggle the settings encryption feature
$model->checkSettingsEncryption();
// Update the magic component parameters
$model->updateMagicParameters();
// Run the automatic database check
$model->checkAndFixDatabase();
// Run the automatic update site refresh
/** @var AkeebaModelUpdates $updateModel */
$updateModel = F0FModel::getTmpInstance('Updates', 'AkeebaModel');
$updateModel->refreshUpdateSite();
}
return $result;
}
示例2: onBeforeBrowse
public function onBeforeBrowse()
{
$result = parent::onBeforeBrowse();
if ($result) {
$params = JComponentHelper::getParams('com_akeeba');
$model = $this->getThisModel();
$view = $this->getThisView();
/** @var AkeebaModelCpanels $model */
$view->setModel($model);
$aeconfig = Factory::getConfiguration();
// Invalidate stale backups
Factory::resetState(array('global' => true, 'log' => false, 'maxrun' => $params->get('failure_timeout', 180)));
// Just in case the reset() loaded a stale configuration...
Platform::getInstance()->load_configuration();
// Let's make sure the temporary and output directories are set correctly and writable...
$wizmodel = F0FModel::getAnInstance('Confwiz', 'AkeebaModel');
$wizmodel->autofixDirectories();
// Check if we need to toggle the settings encryption feature
$model->checkSettingsEncryption();
// Update the magic component parameters
$model->updateMagicParameters();
// Run the automatic database check
$model->checkAndFixDatabase();
// Run the automatic update site refresh
/** @var AkeebaModelUpdates $updateModel */
$updateModel = F0FModel::getTmpInstance('Updates', 'AkeebaModel');
$updateModel->refreshUpdateSite();
// Check the last installed version and show the post-setup page on Joomla! 3.1 or earlier
if (!version_compare(JVERSION, '3.2.0', 'ge')) {
$versionLast = null;
if (file_exists(JPATH_COMPONENT_ADMINISTRATOR . '/akeeba.lastversion.php')) {
include_once JPATH_COMPONENT_ADMINISTRATOR . '/akeeba.lastversion.php';
if (defined('AKEEBA_LASTVERSIONCHECK')) {
$versionLast = AKEEBA_LASTVERSIONCHECK;
}
}
if (is_null($versionLast)) {
$component = JComponentHelper::getComponent('com_akeeba');
if (is_object($component->params) && $component->params instanceof JRegistry) {
$params = $component->params;
} else {
$params = new JRegistry($component->params);
}
$versionLast = $params->get('lastversion', '');
}
if (version_compare(AKEEBA_VERSION, $versionLast, 'ne') || empty($versionLast)) {
$this->setRedirect('index.php?option=com_akeeba&view=postsetup');
return true;
}
}
}
return $result;
}
示例3: onBeforeMain
protected function onBeforeMain()
{
/** @var \Akeeba\Backup\Admin\Model\ControlPanel $model */
$model = $this->getModel();
$engineConfig = Factory::getConfiguration();
// Invalidate stale backups
$params = $this->container->params;
Factory::resetState(array('global' => true, 'log' => false, 'maxrun' => $params->get('failure_timeout', 180)));
// Just in case the reset() loaded a stale configuration...
Platform::getInstance()->load_configuration();
// Let's make sure the temporary and output directories are set correctly and writable...
/** @var ConfigurationWizard $wizmodel */
$wizmodel = $this->container->factory->model('ConfigurationWizard')->tmpInstance();
$wizmodel->autofixDirectories();
// Check if we need to toggle the settings encryption feature
$model->checkSettingsEncryption();
// Run the automatic update site refresh
/** @var Updates $updateModel */
$updateModel = $this->container->factory->model('Updates')->tmpInstance();
$updateModel->refreshUpdateSite();
}
示例4: notifyFailed
/**
* Send an email notification for failed backups
*
* @return array See the CLI script
*/
public function notifyFailed()
{
// Invalidate stale backups
Factory::resetState(array('global' => true, 'log' => false, 'maxrun' => $this->container->params->get('failure_timeout', 180)));
// Get the last execution and search for failed backups AFTER that date
$last = $this->getLastCheck();
// Get failed backups
$filters[] = array('field' => 'status', 'operand' => '=', 'value' => 'fail');
$filters[] = array('field' => 'origin', 'operand' => '<>', 'value' => 'restorepoint');
$filters[] = array('field' => 'backupstart', 'operand' => '>', 'value' => $last);
$failed = Platform::getInstance()->get_statistics_list(array('filters' => $filters));
// Well, everything went ok.
if (!$failed) {
return array('message' => array("No need to run: no failed backups or notifications were already sent."), 'result' => true);
}
// Whops! Something went wrong, let's start notifing
$superAdmins = array();
$superAdminEmail = $this->container->params->get('failure_email_address', '');
if (!empty($superAdminEmail)) {
$superAdmins = $this->getSuperUsers($superAdminEmail);
}
if (empty($superAdmins)) {
$superAdmins = $this->getSuperUsers();
}
if (empty($superAdmins)) {
return array('message' => array("WARNING! Failed backup(s) detected, but there are no configured Super Administrators to receive notifications"), 'result' => false);
}
$failedReport = array();
foreach ($failed as $fail) {
$string = "Description : " . $fail['description'] . "\n";
$string .= "Start time : " . $fail['backupstart'] . "\n";
$string .= "Origin : " . $fail['origin'] . "\n";
$string .= "Type : " . $fail['type'] . "\n";
$string .= "Profile ID : " . $fail['profile_id'];
$failedReport[] = $string;
}
$failedReport = implode("\n#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+#\n", $failedReport);
$email_subject = $this->container->params->get('failure_email_subject', '');
if (!$email_subject) {
$email_subject = <<<ENDSUBJECT
THIS EMAIL IS SENT FROM YOUR SITE "[SITENAME]" - Failed backup(s) detected
ENDSUBJECT;
}
$email_body = $this->container->params->get('failure_email_body', '');
if (!$email_body) {
$email_body = <<<ENDBODY
================================================================================
FAILED BACKUP ALERT
================================================================================
Your site has determined that there are failed backups.
The following backups are found to be failing:
[FAILEDLIST]
================================================================================
WHY AM I RECEIVING THIS EMAIL?
================================================================================
This email has been automatically sent by scritp you, or the person who built
or manages your site, has installed and explicitly configured. This script looks
for failed backups and sends an email notification to all Super Users.
If you do not understand what this means, please do not contact the authors of
the software. They are NOT sending you this email and they cannot help you.
Instead, please contact the person who built or manages your site.
================================================================================
WHO SENT ME THIS EMAIL?
================================================================================
This email is sent to you by your own site, [SITENAME]
ENDBODY;
}
$jconfig = JFactory::getConfig();
$mailfrom = $jconfig->get('mailfrom');
$fromname = $jconfig->get('fromname');
$email_subject = Factory::getFilesystemTools()->replace_archive_name_variables($email_subject);
$email_body = Factory::getFilesystemTools()->replace_archive_name_variables($email_body);
$email_body = str_replace('[FAILEDLIST]', $failedReport, $email_body);
foreach ($superAdmins as $sa) {
try {
$mailer = JFactory::getMailer();
$mailer->setSender(array($mailfrom, $fromname));
$mailer->addRecipient($sa->email);
$mailer->setSubject($email_subject);
$mailer->setBody($email_body);
$mailer->Send();
} catch (\Exception $e) {
// Joomla! 3.5 is written by incompetent bonobos
}
}
// Let's update the last time we check, so we will avoid to send
//.........这里部分代码省略.........
示例5: _apiStartBackup
private function _apiStartBackup($config)
{
// Get the passed configuration values
$defConfig = array('profile' => 1, 'description' => '', 'comment' => '', 'backupid' => null);
$config = array_merge($defConfig, $config);
$profile = $config['profile'];
$description = $config['description'];
$comment = $config['comment'];
$backupid = $config['backupid'];
// Nuke the factory
Factory::nuke();
// Set the profile
$profile = (int) $profile;
if (!is_numeric($profile)) {
$profile = 1;
}
if (strtoupper($backupid) == '[DEFAULT]') {
$db = F0FPlatform::getInstance()->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');
Platform::getInstance()->load_configuration($profile);
// Check if there are critical issues preventing the backup
if (!Factory::getConfigurationChecks()->getShortStatus()) {
$configChecks = Factory::getConfigurationChecks()->getDetailedStatus();
foreach ($configChecks as $checkItem) {
if ($checkItem['severity'] != 'critical') {
continue;
}
$this->status = self::STATUS_ERROR;
$this->encapsulation = self::ENCAPSULATION_RAW;
return 'Failed configuration check Q' . $checkItem['code'] . ': ' . $checkItem['description'] . '. Please refer to https://www.akeebabackup.com/warnings/q' . $checkItem['code'] . '.html for more information and troubleshooting instructions.';
}
}
// 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
Factory::resetState(array('maxrun' => 0));
Factory::getTempFiles()->deleteTempFiles();
$tempVarsTag = AKEEBA_BACKUP_ORIGIN;
$tempVarsTag .= empty($backupid) ? '' : '.' . $backupid;
Factory::getFactoryStorage()->reset($tempVarsTag);
Factory::loadState(AKEEBA_BACKUP_ORIGIN, $backupid);
$kettenrad = Factory::getKettenrad();
$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
try {
Factory::saveState(AKEEBA_BACKUP_ORIGIN, $backupid);
} catch (\RuntimeException $e) {
$array['Error'] = $e->getMessage();
}
$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;
}
}
示例6: runBackup
/**
* 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;
}
示例7: browse
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');
Factory::resetState(array('maxrun' => 0));
Factory::getTempFiles()->deleteTempFiles();
$tempVarsTag = AKEEBA_BACKUP_ORIGIN;
$tempVarsTag .= empty($backupId) ? '' : '.' . $backupId;
Factory::getFactoryStorage()->reset($tempVarsTag);
Factory::loadState(AKEEBA_BACKUP_ORIGIN, $backupId);
$kettenrad = Factory::getKettenrad();
$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();
try {
Factory::saveState(AKEEBA_BACKUP_ORIGIN, $backupId);
} catch (\RuntimeException $e) {
$array['Error'] = $e->getMessage();
}
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();
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);
}
}
}
示例8: runBackup
/**
* 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();
//.........这里部分代码省略.........
示例9: _apiStartBackup
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
Factory::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');
Platform::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
Factory::resetState(array('maxrun' => 0));
Factory::getTempFiles()->deleteTempFiles();
$tempVarsTag = AKEEBA_BACKUP_ORIGIN;
$tempVarsTag .= empty(${$backupid}) ? '' : '.' . ${$backupid};
Factory::getFactoryStorage()->reset($tempVarsTag);
Factory::loadState(AKEEBA_BACKUP_ORIGIN, $backupid);
$kettenrad = Factory::getKettenrad();
$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
Factory::saveState(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 = Factory::getStatistics();
$array['BackupID'] = $statistics->getId();
$array['HasRun'] = 1;
// Force the backup to go on.
return $array;
}
}
示例10: runBackup
/**
* 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;
}
示例11: startScan
/**
* Starts a new file scan
*
* @return array
*/
public function startScan()
{
if (!$this->scanEngineSetup()) {
return array('status' => false, 'error' => 'Could not load the file scanning engine; please try reinstalling the component', 'done' => true);
}
\Akeeba\Engine\Platform::getInstance()->load_configuration(1);
\Akeeba\Engine\Factory::resetState();
\Akeeba\Engine\Factory::getFactoryStorage()->reset(AKEEBA_BACKUP_ORIGIN);
$configOverrides['volatile.core.finalization.action_handlers'] = array(new Akeeba\Engine\Finalization\Email());
$configOverrides['volatile.core.finalization.action_queue'] = array('remove_temp_files', 'update_statistics', 'update_filesizes', 'apply_quotas', 'send_scan_email');
// Apply the configuration overrides, please
$platform = \Akeeba\Engine\Platform::getInstance();
$platform->configOverrides = $configOverrides;
$kettenrad = \Akeeba\Engine\Factory::getKettenrad();
$options = array('description' => '', 'comment' => '', 'jpskey' => '');
$kettenrad->setup($options);
\Akeeba\Engine\Factory::getLog()->open(AKEEBA_BACKUP_ORIGIN);
\Akeeba\Engine\Factory::getLog()->log(true, '');
$kettenrad->tick();
$kettenrad->tick();
\Akeeba\Engine\Factory::saveState(AKEEBA_BACKUP_ORIGIN);
return $this->parseScanArray($kettenrad->getStatusArray());
}
示例12: startBackup
/**
* Starts a new backup.
*
* State variables expected
* backupid The ID of the backup. If none is set up we will create a new one in the form id123
* tag The backup tag, e.g. "frontend". If none is set up we'll get it through the Platform.
* description The description of the backup (optional)
* comment The comment of the backup (optional)
* jpskey JPS password
* angiekey ANGIE password
*
* @param array $overrides Configuration overrides
*
* @return array An Akeeba Engine return array
*/
public function startBackup(array $overrides = [])
{
// Get information from the session
$tag = $this->getState('tag', null, 'string');
$backupId = $this->getState('backupid', null, 'string');
$description = $this->getState('description', '', 'string');
$comment = $this->getState('comment', '', 'html');
$jpskey = $this->getState('jpskey', null, 'raw');
$angiekey = $this->getState('angiekey', null, 'raw');
// Try to get a backup ID if none is provided
if (is_null($backupId)) {
$db = $this->container->db;
$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);
}
// Use the default description if none specified
if (empty($description)) {
JLoader::import('joomla.utilities.date');
$dateNow = new JDate();
$description = JText::_('COM_AKEEBA_BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->format(JText::_('DATE_FORMAT_LC2'), true);
}
// 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::nuke();
Factory::getLog()->log(LogLevel::DEBUG, " -- Resetting Akeeba Engine factory ({$tag}.{$backupId})");
Platform::getInstance()->load_configuration();
// Should I apply any configuration overrides?
if (is_array($overrides) && !empty($overrides)) {
$config = Factory::getConfiguration();
$protectedKeys = $config->getProtectedKeys();
$config->resetProtectedKeys();
foreach ($overrides as $k => $v) {
$config->set($k, $v);
}
$config->setProtectedKeys($protectedKeys);
}
// Check if there are critical issues preventing the backup
if (!Factory::getConfigurationChecks()->getShortStatus()) {
$configChecks = Factory::getConfigurationChecks()->getDetailedStatus();
foreach ($configChecks as $checkItem) {
if ($checkItem['severity'] != 'critical') {
continue;
}
return ['HasRun' => 0, 'Error' => 'Failed configuration check Q' . $checkItem['code'] . ': ' . $checkItem['description'] . '. Please refer to https://www.akeebabackup.com/documentation/warnings/q' . $checkItem['code'] . '.html for more information and troubleshooting instructions.'];
}
}
// Set up Kettenrad
$options = ['description' => $description, 'comment' => $comment, 'jpskey' => $jpskey, 'angiekey' => $angiekey];
if (is_null($jpskey)) {
unset($options['jpskey']);
}
if (is_null($angiekey)) {
unset($options['angiekey']);
}
$kettenrad = Factory::getKettenrad();
$kettenrad->setBackupId($backupId);
$kettenrad->setup($options);
$this->setState('backupid', $backupId);
// Run the first backup step. We need to run tick() twice
/**
* We need to run tick() twice in the first backup step.
*
* The first tick() will reset the backup engine and start a new backup. However, no backup record is created
* at this point. This means that Factory::loadState() cannot find a backup record, therefore it cannot read
* the backup profile being used, therefore it will assume it's profile #1.
*
* The second tick() creates the backup record without doing much else, fixing this issue.
*
* However, if you have conservative settings where the min exec time is MORE than the max exec time the second
* tick would never run. Therefore we need to tell the first tick to ignore the time settings (since it only
* takes a few milliseconds to execute anyway) and then apply the time settings on the second tick (which also
* only takes a few milliseconds). This is why we have setIgnoreMinimumExecutionTime before and after the first
* tick. DO NOT REMOVE THESE.
//.........这里部分代码省略.........