예제 #1
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');
 }
예제 #2
0
파일: default.php 프로젝트: JozefAB/neoacu
	</div>

	<div class="span4">

		<h3><?php 
echo JText::_('CPANEL_LABEL_STATUSSUMMARY');
?>
</h3>
		<div>
			<?php 
echo $this->statuscell;
?>

			<?php 
$quirks = Factory::getConfigurationChecks()->getDetailedStatus();
?>
			<?php 
if (!empty($quirks)) {
    ?>
			<div>
				<?php 
    echo $this->detailscell;
    ?>
			</div>
			<hr/>
			<?php 
}
?>

			<?php 
예제 #3
0
 /**
  * This mess of a code is probably not one of my highlights in my code
  * writing career. It's logically organized, badly architectured but I can
  * still maintain it - and it works!
  */
 public function onAdd($tpl = null)
 {
     /** @var AkeebaModelBackups $model */
     $model = $this->getModel();
     // Load the Status Helper
     if (!class_exists('AkeebaHelperStatus')) {
         JLoader::import('helpers.status', JPATH_COMPONENT_ADMINISTRATOR);
     }
     $helper = AkeebaHelperStatus::getInstance();
     // Determine default description
     JLoader::import('joomla.utilities.date');
     $jregistry = JFactory::getConfig();
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $tzDefault = $jregistry->get('offset');
     } else {
         $tzDefault = $jregistry->getValue('config.offset');
     }
     $user = JFactory::getUser();
     $tz = $user->getParam('timezone', $tzDefault);
     $dateNow = new JDate('now', $tz);
     $default_description = JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->format(JText::_('DATE_FORMAT_LC2'), true);
     $default_description = AkeebaHelperEscape::escapeJS($default_description, "'");
     $backup_description = $model->getState('description', $default_description);
     $comment = $model->getState('comment', '');
     // Get a potential return URL
     $returnurl = $model->getState('returnurl');
     if (empty($returnurl)) {
         $returnurl = '';
     }
     // If a return URL is set *and* the profile's name is "Site Transfer
     // Wizard", we are running the Site Transfer Wizard
     if (!class_exists('AkeebaModelProfiles')) {
         JLoader::import('models.profiles', JPATH_COMPONENT_ADMINISTRATOR);
     }
     /** @var AkeebaModelCpanels $cpanelmodel */
     $cpanelmodel = F0FModel::getAnInstance('Cpanels', 'AkeebaModel');
     $profilemodel = new AkeebaModelProfiles();
     $profilemodel->setId($cpanelmodel->getProfileID());
     $profile_data = $profilemodel->getProfile();
     $isSTW = $profile_data->description == 'Site Transfer Wizard (do not rename)' && !empty($returnurl);
     $this->isSTW = $isSTW;
     // Get the domain details from scripting facility
     $registry = Factory::getConfiguration();
     $tag = $model->getState('tag');
     $script = $tag == 'restorepoint' ? 'full' : $registry->get('akeeba.basic.backup_type', 'full');
     $scripting = Factory::getEngineParamsProvider()->loadScripting();
     $domains = array();
     if (!empty($scripting)) {
         foreach ($scripting['scripts'][$script]['chain'] as $domain) {
             $description = JText::_($scripting['domains'][$domain]['text']);
             $domain_key = $scripting['domains'][$domain]['domain'];
             if ($isSTW && $domain_key == 'Packing') {
                 $description = JText::_('BACKUP_LABEL_DOMAIN_PACKING_STW');
             }
             $domains[] = array($domain_key, $description);
         }
     }
     $json_domains = AkeebaHelperEscape::escapeJS(json_encode($domains), '"\\');
     // Get the maximum execution time and bias
     $maxexec = $registry->get('akeeba.tuning.max_exec_time', 14) * 1000;
     $bias = $registry->get('akeeba.tuning.run_time_bias', 75);
     // Check if the output directory is writable
     $quirks = Factory::getConfigurationChecks()->getDetailedStatus();
     $unwritableOutput = array_key_exists('001', $quirks);
     // Pass on data
     $this->haserrors = !$helper->status;
     $this->hasquirks = $helper->hasQuirks();
     $this->quirks = $helper->getQuirksCell(!$helper->status);
     $this->description = $backup_description;
     $this->default_descr = $default_description;
     $this->comment = $comment;
     $this->domains = $json_domains;
     $this->maxexec = $maxexec;
     $this->bias = $bias;
     $this->useiframe = $registry->get('akeeba.basic.useiframe', 0) ? 'true' : 'false';
     $this->returnurl = $returnurl;
     $this->unwritableoutput = $unwritableOutput;
     if ($registry->get('akeeba.advanced.archiver_engine', 'jpa') == 'jps') {
         $this->showjpskey = 1;
         $this->jpskey = $registry->get('engine.archiver.jps.key', '');
     } else {
         $this->showjpskey = 0;
     }
     if (AKEEBA_PRO) {
         $this->showangiekey = 1;
         $this->angiekey = $registry->get('engine.installer.angie.key', '');
     } else {
         $this->showangiekey = 0;
         $this->angiekey = '';
     }
     $this->autostart = $model->getState('autostart');
     // Pass on profile info
     $this->profileid = $cpanelmodel->getProfileID();
     // Active profile ID
     $this->profilelist = $cpanelmodel->getProfilesList();
     // List of available profiles
     // Pass on state information pertaining to SRP
     $this->srpinfo = $model->getState('srpinfo');
     // Add live help
     AkeebaHelperIncludes::addHelp('backup');
     // Set the toolbar title
     if ($this->srpinfo['tag'] == 'restorepoint') {
         $subtitle = JText::_('AKEEBASRP');
     } elseif ($isSTW) {
         $subtitle = JText::_('SITETRANSFERWIZARD');
     } else {
         $subtitle = JText::_('BACKUP');
     }
     JToolBarHelper::title(JText::_('AKEEBA') . ':: <small>' . $subtitle . '</small>', 'akeeba');
     return true;
 }
예제 #4
0
 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;
     }
 }
예제 #5
0
파일: browsers.php 프로젝트: esorone/efcpw
 function makeListing()
 {
     JLoader::import('joomla.filesystem.folder');
     JLoader::import('joomla.filesystem.path');
     // Get the folder to browse
     $folder = $this->getState('folder', '');
     $processfolder = $this->getState('processfolder', 0);
     if (empty($folder)) {
         $folder = JPATH_SITE;
     }
     $stock_dirs = Platform::getInstance()->get_stock_directories();
     arsort($stock_dirs);
     if ($processfolder == 1) {
         foreach ($stock_dirs as $find => $replace) {
             $folder = str_replace($find, $replace, $folder);
         }
     }
     // Normalise name, but only if realpath() really, REALLY works...
     $old_folder = $folder;
     $folder = @realpath($folder);
     if ($folder === false) {
         $folder = $old_folder;
     }
     if (@is_dir($folder)) {
         $isFolderThere = true;
     } else {
         $isFolderThere = false;
     }
     // Check if it's a subdirectory of the site's root
     $isInRoot = strpos($folder, JPATH_SITE) === 0;
     // Check open_basedir restrictions
     $isOpenbasedirRestricted = Factory::getConfigurationChecks()->checkOpenBasedirs($folder);
     // -- Get the meta form of the directory name, if applicable
     $folder_raw = $folder;
     foreach ($stock_dirs as $replace => $find) {
         $folder_raw = str_replace($find, $replace, $folder_raw);
     }
     // Writable check and contents listing if it's in site root and not restricted
     if ($isFolderThere && !$isOpenbasedirRestricted) {
         // Get writability status
         $isWritable = is_writable($folder);
         // Get contained folders
         $subfolders = JFolder::folders($folder);
     } else {
         if ($isFolderThere && !$isOpenbasedirRestricted) {
             $isWritable = is_writable($folder);
         } else {
             $isWritable = false;
         }
         $subfolders = array();
     }
     // Get parent directory
     $pathparts = explode(DIRECTORY_SEPARATOR, $folder);
     if (is_array($pathparts)) {
         $path = '';
         foreach ($pathparts as $part) {
             $path .= empty($path) ? $part : DIRECTORY_SEPARATOR . $part;
             if (empty($part)) {
                 if (DIRECTORY_SEPARATOR != '\\') {
                     $path = DIRECTORY_SEPARATOR;
                 }
                 $part = DIRECTORY_SEPARATOR;
             }
             $crumb['label'] = $part;
             $crumb['folder'] = $path;
             $breadcrumbs[] = $crumb;
         }
         $junk = array_pop($pathparts);
         $parent = implode(DIRECTORY_SEPARATOR, $pathparts);
     } else {
         // Can't identify parent dir, use ourselves.
         $parent = $folder;
         $breadcrumbs = array();
     }
     $this->setState('folder', $folder);
     $this->setState('folder_raw', $folder_raw);
     $this->setState('parent', $parent);
     $this->setState('exists', $isFolderThere);
     $this->setState('inRoot', $isInRoot);
     $this->setState('openbasedirRestricted', $isOpenbasedirRestricted);
     $this->setState('writable', $isWritable);
     $this->setState('subfolders', $subfolders);
     $this->setState('breadcrumbs', $breadcrumbs);
 }
예제 #6
0
 /**
  * Returns a boolean value, indicating if warnings have been detected.
  *
  * @return  bool  True if there is at least one detected warnings
  */
 public function hasQuirks()
 {
     $quirks = Factory::getConfigurationChecks()->getDetailedStatus();
     return !empty($quirks);
 }
예제 #7
0
파일: Html.php 프로젝트: BillVGN/PortalPRP
 /**
  * Executes before displaying the control panel page
  */
 public function onBeforeMain()
 {
     /** @var ControlPanel $model */
     $model = $this->getModel();
     $statusHelper = Status::getInstance();
     $this->statsIframe = '';
     try {
         /** @var UsageStatistics $usageStatsModel */
         $usageStatsModel = $this->container->factory->model('UsageStatistics')->tmpInstance();
         if (is_object($usageStatsModel) && class_exists('Akeeba\\Backup\\Admin\\Model\\UsageStatistics') && $usageStatsModel instanceof UsageStatistics && method_exists($usageStatsModel, 'collectStatistics')) {
             $this->statsIframe = $usageStatsModel->collectStatistics(true);
         }
     } catch (\Exception $e) {
         // Don't give a crap if usage stats ain't loaded
     }
     $this->getProfileList();
     $this->getProfileIdAndName();
     $this->quickIconProfiles = $model->getQuickIconProfiles();
     $this->statusCell = $statusHelper->getStatusCell();
     $this->detailsCell = $statusHelper->getQuirksCell();
     $this->latestBackupCell = $statusHelper->getLatestBackupDetails();
     $this->areMediaPermissionsFixed = $model->fixMediaPermissions();
     $this->checkMbstring = $model->checkMbstring();
     $this->needsDownloadID = $model->needsDownloadID() ? 1 : 0;
     $this->coreWarningForDownloadID = $model->mustWarnAboutDownloadIDInCore();
     $this->extension_id = $model->getState('extension_id', 0, 'int');
     $this->frontEndSecretWordIssue = $model->getFrontendSecretWordError();
     $this->newSecretWord = $this->container->session->get('newSecretWord', null, 'akeeba.cpanel');
     $this->desktopNotifications = $this->container->params->get('desktop_notifications', '0') ? 1 : 0;
     $this->formattedChangelog = $this->formatChangelog();
     $this->promptForConfigurationWizard = Factory::getConfiguration()->get('akeeba.flag.confwiz', 0) == 0;
     $this->countWarnings = count(Factory::getConfigurationChecks()->getDetailedStatus());
     // Load the version constants
     Platform::getInstance()->load_version_defines();
     // Set up the GUI behaviours
     JHtml::_('behavior.modal');
     JHtml::_('formbehavior.chosen');
     // Add the Javascript to the document
     $this->addJavascriptFile('media://com_akeeba/js/ControlPanel.min.js');
     $this->inlineJavascript();
 }
예제 #8
0
 /**
  * This mess of a code is probably not one of my highlights in my code
  * writing career. It's logically organized, badly architectured but I can
  * still maintain it - and it works!
  */
 public function onAdd($tpl = null)
 {
     AkeebaStrapper::addJSfile('media://com_akeeba/js/backup.js');
     /** @var AkeebaModelBackups $model */
     $model = $this->getModel();
     // Load the Status Helper
     if (!class_exists('AkeebaHelperStatus')) {
         JLoader::import('helpers.status', JPATH_COMPONENT_ADMINISTRATOR);
     }
     $helper = AkeebaHelperStatus::getInstance();
     // Determine default description
     JLoader::import('joomla.utilities.date');
     $jregistry = JFactory::getConfig();
     $tzDefault = $jregistry->get('offset');
     $user = JFactory::getUser();
     $tz = $user->getParam('timezone', $tzDefault);
     $dateNow = new JDate('now', $tz);
     $default_description = JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->format(JText::_('DATE_FORMAT_LC2'), true);
     $default_description = AkeebaHelperEscape::escapeJS($default_description, "'");
     $backup_description = $model->getState('description', $default_description);
     $comment = $model->getState('comment', '');
     // Get a potential return URL
     $returnurl = $model->getState('returnurl');
     if (empty($returnurl)) {
         $returnurl = '';
     }
     // Only allow internal URLs for the redirection
     if (!JUri::isInternal($returnurl)) {
         $returnurl = '';
     }
     // If a return URL is set *and* the profile's name is "Site Transfer
     // Wizard", we are running the Site Transfer Wizard
     if (!class_exists('AkeebaModelProfiles')) {
         JLoader::import('models.profiles', JPATH_COMPONENT_ADMINISTRATOR);
     }
     /** @var AkeebaModelCpanels $cpanelmodel */
     $cpanelmodel = F0FModel::getAnInstance('Cpanels', 'AkeebaModel');
     $profilemodel = new AkeebaModelProfiles();
     $profilemodel->setId($cpanelmodel->getProfileID());
     $profile_data = $profilemodel->getProfile();
     // Get the domain details from scripting facility
     $registry = Factory::getConfiguration();
     $tag = $model->getState('tag');
     $script = $registry->get('akeeba.basic.backup_type', 'full');
     $scripting = Factory::getEngineParamsProvider()->loadScripting();
     $domains = array();
     if (!empty($scripting)) {
         foreach ($scripting['scripts'][$script]['chain'] as $domain) {
             $description = JText::_($scripting['domains'][$domain]['text']);
             $domain_key = $scripting['domains'][$domain]['domain'];
             $domains[] = array($domain_key, $description);
         }
     }
     $json_domains = AkeebaHelperEscape::escapeJS(json_encode($domains), '"\\');
     // Get the maximum execution time and bias
     $maxexec = $registry->get('akeeba.tuning.max_exec_time', 14) * 1000;
     $bias = $registry->get('akeeba.tuning.run_time_bias', 75);
     // Check if the output directory is writable
     $quirks = Factory::getConfigurationChecks()->getDetailedStatus();
     $unwritableOutput = array_key_exists('001', $quirks);
     // Pass on data
     $this->haserrors = !$helper->status;
     $this->hasquirks = $helper->hasQuirks();
     $this->quirks = $helper->getQuirksCell(!$helper->status);
     $this->description = $backup_description;
     $this->default_descr = $default_description;
     $this->comment = $comment;
     $this->domains = $json_domains;
     $this->maxexec = $maxexec;
     $this->bias = $bias;
     $this->useiframe = $registry->get('akeeba.basic.useiframe', 0) ? 'true' : 'false';
     $this->returnurl = $returnurl;
     $this->unwritableoutput = $unwritableOutput;
     if ($registry->get('akeeba.advanced.archiver_engine', 'jpa') == 'jps') {
         $this->showjpskey = 1;
         $this->jpskey = $registry->get('engine.archiver.jps.key', '');
     } else {
         $this->showjpskey = 0;
     }
     if (AKEEBA_PRO) {
         $this->showangiekey = 1;
         $this->angiekey = $registry->get('engine.installer.angie.key', '');
     } else {
         $this->showangiekey = 0;
         $this->angiekey = '';
     }
     $this->autostart = $model->getState('autostart');
     // Pass on profile info
     $this->profileid = $cpanelmodel->getProfileID();
     // Active profile ID
     $this->profilelist = $cpanelmodel->getProfilesList();
     // List of available profiles
     // Should I ask for permission to display desktop notifications?
     JLoader::import('joomla.application.component.helper');
     $this->desktop_notifications = \Akeeba\Engine\Util\Comconfig::getValue('desktop_notifications', '0') ? 1 : 0;
     // Set the toolbar title
     $subtitle = JText::_('BACKUP');
     JToolBarHelper::title(JText::_('AKEEBA') . ':: <small>' . $subtitle . '</small>', 'akeeba');
     return true;
 }
예제 #9
0
 /**
  * Runs before displaying the backup page
  */
 public function onBeforeMain()
 {
     // Load the view-specific Javascript
     $this->addJavascriptFile('media://com_akeeba/js/Backup.min.js');
     // Preload Joomla! behaviours
     JLoader::import('joomla.utilities.date');
     JHtml::_('formbehavior.chosen');
     // Load the models
     /** @var  Backup $model */
     $model = $this->getModel();
     /** @var ControlPanel $cpanelmodel */
     $cpanelmodel = $this->container->factory->model('ControlPanel')->tmpInstance();
     // Load the Status Helper
     $helper = Status::getInstance();
     // Determine default description
     $default_description = $this->getDefaultDescription();
     // Load data from the model state
     $backup_description = $model->getState('description', $default_description);
     $comment = $model->getState('comment', '');
     $returnurl = $model->getState('returnurl');
     // Only allow non-empty, internal URLs for the redirection
     if (empty($returnurl)) {
         $returnurl = '';
     }
     if (!JUri::isInternal($returnurl)) {
         $returnurl = '';
     }
     // Get the maximum execution time and bias
     $engineConfiguration = Factory::getConfiguration();
     $maxexec = $engineConfiguration->get('akeeba.tuning.max_exec_time', 14) * 1000;
     $bias = $engineConfiguration->get('akeeba.tuning.run_time_bias', 75);
     // Check if the output directory is writable
     $warnings = Factory::getConfigurationChecks()->getDetailedStatus();
     $unwritableOutput = array_key_exists('001', $warnings);
     // Pass on data
     $this->getProfileList();
     $this->getProfileIdAndName();
     $this->hasErrors = !$helper->status;
     $this->hasWarnings = $helper->hasQuirks();
     $this->warningsCell = $helper->getQuirksCell(!$helper->status);
     $this->description = $backup_description;
     $this->defaultDescription = $default_description;
     $this->comment = $comment;
     $this->domains = json_encode($this->getDomains());
     $this->maxExecutionTime = $maxexec;
     $this->runtimeBias = $bias;
     $this->useIFRAME = $engineConfiguration->get('akeeba.basic.useiframe', 0) == 1;
     $this->returnURL = $returnurl;
     $this->unwriteableOutput = $unwritableOutput;
     $this->autoStart = $model->getState('autostart');
     $this->desktopNotifications = $this->container->params->get('desktop_notifications', '0') ? 1 : 0;
     $this->autoResume = $engineConfiguration->get('akeeba.advanced.autoresume', 1);
     $this->autoResumeTimeout = $engineConfiguration->get('akeeba.advanced.autoresume_timeout', 10);
     $this->autoResumeRetries = $engineConfiguration->get('akeeba.advanced.autoresume_maxretries', 3);
     $this->promptForConfigurationWizard = $engineConfiguration->get('akeeba.flag.confwiz', 0) == 0;
     if ($engineConfiguration->get('akeeba.advanced.archiver_engine', 'jpa') == 'jps') {
         $this->showJPSPassword = 1;
         $this->jpsPassword = $engineConfiguration->get('engine.archiver.jps.key', '');
     }
     if (AKEEBA_PRO) {
         $this->showANGIEPassword = 1;
         $this->ANGIEPassword = $engineConfiguration->get('engine.installer.angie.key', '');
     }
     // Push language strings to Javascript
     JText::script('COM_AKEEBA_BACKUP_TEXT_LASTRESPONSE');
     JText::script('COM_AKEEBA_BACKUP_TEXT_BACKUPSTARTED');
     JText::script('COM_AKEEBA_BACKUP_TEXT_BACKUPFINISHED');
     JText::script('COM_AKEEBA_BACKUP_TEXT_BACKUPHALT');
     JText::script('COM_AKEEBA_BACKUP_TEXT_BACKUPRESUME');
     JText::script('COM_AKEEBA_BACKUP_TEXT_BACKUPHALT_DESC');
     JText::script('COM_AKEEBA_BACKUP_TEXT_BACKUPFAILED');
     JText::script('COM_AKEEBA_BACKUP_TEXT_BACKUPWARNING');
     JText::script('COM_AKEEBA_BACKUP_TEXT_AVGWARNING');
 }
예제 #10
0
 public function apply_quirk_definitions()
 {
     Factory::getConfigurationChecks()->addConfigurationCheckDefinition('013', 'critical', 'COM_AKEEBA_CPANEL_WARNING_Q013', array('\\Akeeba\\Engine\\Platform\\Joomla3x', 'quirk_013'));
 }
예제 #11
0
 /**
  * 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.
      *
      * THEREFORE, DO NOT REMOVE THE SECOND tick(), IT IS THERE ON PURPOSE!
      */
     $kettenrad->setIgnoreMinimumExecutionTime(true);
     $kettenrad->tick();
     // Do not remove the first call to tick()!!!
     $kettenrad->setIgnoreMinimumExecutionTime(false);
     $kettenrad->tick();
     // Do not remove the second call to tick()!!!
     $ret_array = $kettenrad->getStatusArray();
     // So as not to have duplicate warnings reports
     $kettenrad->resetWarnings();
     try {
         Factory::saveState($tag, $backupId);
     } catch (\RuntimeException $e) {
         $ret_array['Error'] = $e->getMessage();
     }
     return $ret_array;
 }