/** * Tries to authenticate the user and start the backup, or send him back to the default task */ public function authenticate() { // Enforce raw mode - I need to be in full control! $document =& JFactory::getDocument(); $document->setType('raw'); if (!$this->_checkPermissions()) { parent::redirect(); } else { $session =& JFactory::getSession(); $session->set('litemodeauthorized', 1, 'akeeba'); $this->_setProfile(); jimport('joomla.utilities.date'); AECoreKettenrad::reset(); $memory_filename = AEUtilTempvars::get_storage_filename(AKEEBA_BACKUP_ORIGIN); @unlink($memory_filename); $kettenrad =& AECoreKettenrad::load(AKEEBA_BACKUP_ORIGIN); $user =& JFactory::getUser(); $userTZ = $user->getParam('timezone', 0); $dateNow = new JDate(); $dateNow->setOffset($userTZ); if (AKEEBA_JVERSION == '16') { $description = JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->format(JText::_('DATE_FORMAT_LC2'), true); } else { $description = JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->toFormat(JText::_('DATE_FORMAT_LC2')); } $options = array('description' => $description, 'comment' => ''); $kettenrad->setup($options); $ret = $kettenrad->tick(); AECoreKettenrad::save(AKEEBA_BACKUP_ORIGIN); $this->setRedirect(JURI::base() . 'index.php?option=com_akeeba&view=light&task=step&key=' . urlencode(JRequest::getVar('key')) . '&profile=' . JRequest::getInt('profile') . '&format=raw'); } }
public function display() { // Check permissions $this->_checkPermissions(); // Set the profile $this->_setProfile(); // Start the backup jimport('joomla.utilities.date'); AECoreKettenrad::reset(); $memory_filename = AEUtilTempvars::get_storage_filename(AKEEBA_BACKUP_ORIGIN); @unlink($memory_filename); $kettenrad =& AECoreKettenrad::load(AKEEBA_BACKUP_ORIGIN); $user =& JFactory::getUser(); $userTZ = $user->getParam('timezone',0); $dateNow = new JDate(); $dateNow->setOffset($userTZ); if( AKEEBA_JVERSION == '16' ) { $description = JText::_('BACKUP_DEFAULT_DESCRIPTION').' '.$dateNow->format(JText::_('DATE_FORMAT_LC2'), true); } else { $description = JText::_('BACKUP_DEFAULT_DESCRIPTION').' '.$dateNow->toFormat(JText::_('DATE_FORMAT_LC2')); } $options = array( 'description' => $description, 'comment' => '' ); $kettenrad->setup($options); $array = $kettenrad->tick(); $array = $kettenrad->tick(); AECoreKettenrad::save(AKEEBA_BACKUP_ORIGIN); if($array['Error'] != '') { // An error occured die('500 ERROR -- '.$array['Error']); } else { $noredirect = JRequest::getInt('noredirect', 0); if($noredirect != 0) { @ob_end_clean(); echo "301 More work required"; flush(); JFactory::getApplication()->close(); } else { $this->setRedirect(JURI::base().'index.php?option=com_akeeba&view=backup&task=step&key='.JRequest::getVar('key').'&profile='.JRequest::getInt('profile',1)); } } }
private function _apiStartBackup($config) { // Get the passed configuration values $defConfig = array('profile' => 1, 'description' => '', 'comment' => ''); $config = array_merge($defConfig, $config); foreach ($config as $key => $value) { if (!array_key_exists($key, $defConfig)) { unset($config[$key]); } } extract($config); // Nuke the factory AEFactory::nuke(); // Set the profile $profile = (int) $profile; if (!is_numeric($profile)) { $profile = 1; } $session =& JFactory::getSession(); $session->set('profile', $profile, 'akeeba'); AEPlatform::getInstance()->load_configuration($profile); // Use the default description if none specified if (empty($description)) { jimport('joomla.utilities.date'); $user =& JFactory::getUser(); $userTZ = $user->getParam('timezone', 0); $dateNow = new JDate(); $dateNow->setOffset($userTZ); if (AKEEBA_JVERSION == '16') { $description = JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->format(JText::_('DATE_FORMAT_LC2'), true); } else { $description = JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->toFormat(JText::_('DATE_FORMAT_LC2')); } } // Start the backup AECoreKettenrad::reset(); $memory_filename = AEUtilTempvars::get_storage_filename(AKEEBA_BACKUP_ORIGIN); @unlink($memory_filename); $kettenrad =& AECoreKettenrad::load(AKEEBA_BACKUP_ORIGIN); $options = array('description' => $description, 'comment' => $comment, 'tag' => AKEEBA_BACKUP_ORIGIN); $kettenrad->setup($options); // Setting up the engine $array = $kettenrad->tick(); // Initializes the init domain AECoreKettenrad::save(AKEEBA_BACKUP_ORIGIN); $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 =& AEFactory::getStatistics(); $array['BackupID'] = $statistics->getId(); $array['HasRun'] = 1; // Force the backup to go on. return $array; } }