public function __construct($message = null, $code = 500, Exception $previous = null)
 {
     if (empty($message)) {
         $message = Platform::getInstance()->translate('COM_AKEEBA_CONFIG_ERR_DECRYPTION');
     }
     parent::__construct($message, $code, $previous);
 }
示例#2
0
 /**
  * Execute the JSON API task
  *
  * @param   array $parameters The parameters to this task
  *
  * @return  mixed
  *
  * @throws  \RuntimeException  In case of an error
  */
 public function execute(array $parameters = array())
 {
     $filter = \JFilterInput::getInstance();
     // Get the passed configuration values
     $defConfig = array('profile' => 0, 'name' => '', 'connection' => array(), 'test' => true);
     $defConfig = array_merge($defConfig, $parameters);
     $profile = $filter->clean($defConfig['profile'], 'int');
     $name = $filter->clean($defConfig['name'], 'string');
     $connection = $filter->clean($defConfig['connection'], 'array');
     $test = $filter->clean($defConfig['test'], 'bool');
     // We need a valid profile ID
     if ($profile <= 0) {
         $profile = 1;
     }
     if (empty($connection) || !isset($connection['host']) || !isset($connection['driver']) || !isset($connection['database']) || !isset($connection['user']) || !isset($connection['password'])) {
         throw new \RuntimeException('Connection information missing or incomplete', 500);
     }
     // Set the active profile
     $session = $this->container->session;
     $session->set('profile', $profile);
     // Load the configuration
     Platform::getInstance()->load_configuration($profile);
     /** @var MultipleDatabases $model */
     $model = $this->container->factory->model('MultipleDatabases')->tmpInstance();
     if ($test) {
         $result = $model->test($connection);
         if (!$result['status']) {
             throw new \RuntimeException('Connection test failed: ' . $result['message'], 500);
         }
     }
     return $model->setFilter($name, $connection);
 }
示例#3
0
 public function onBrowse($tpl = null)
 {
     AkeebaStrapper::addJSfile('media://com_akeeba/js/fsfilter.js');
     $model = $this->getModel();
     $task = $model->getState('browse_task', 'normal');
     // Add custom submenus
     $toolbar = F0FToolbar::getAnInstance($this->input->get('option', 'com_foobar', 'cmd'), $this->config);
     $toolbar->appendLink(JText::_('FILTERS_LABEL_NORMALVIEW'), JUri::base() . 'index.php?option=com_akeeba&view=fsfilter&task=normal', $task == 'normal');
     $toolbar->appendLink(JText::_('FILTERS_LABEL_TABULARVIEW'), JUri::base() . 'index.php?option=com_akeeba&view=fsfilter&task=tabular', $task == 'tabular');
     $media_folder = JUri::base() . '../media/com_akeeba/';
     // Get the root URI for media files
     $this->mediadir = AkeebaHelperEscape::escapeJS($media_folder . 'theme/');
     // Get a JSON representation of the available roots
     $filters = Factory::getFilters();
     $root_info = $filters->getInclusions('dir');
     $roots = array();
     $options = array();
     if (!empty($root_info)) {
         // Loop all dir definitions
         foreach ($root_info as $dir_definition) {
             if (is_null($dir_definition[1])) {
                 // Site root definition has a null element 1. It is always pushed on top of the stack.
                 array_unshift($roots, $dir_definition[0]);
             } else {
                 $roots[] = $dir_definition[0];
             }
             $options[] = JHTML::_('select.option', $dir_definition[0], $dir_definition[0]);
         }
     }
     $site_root = $roots[0];
     $attribs = 'onchange="akeeba.Fsfilters.activeRootChanged();"';
     $this->root_select = JHTML::_('select.genericlist', $options, 'root', $attribs, 'value', 'text', $site_root, 'active_root');
     $this->roots = $roots;
     switch ($task) {
         case 'normal':
         default:
             $this->setLayout('default');
             // Get a JSON representation of the directory data
             $model = $this->getModel();
             $json = json_encode($model->make_listing($site_root, array(), ''));
             $this->json = $json;
             break;
         case 'tabular':
             $this->setLayout('tabular');
             // Get a JSON representation of the tabular filter data
             $model = $this->getModel();
             $json = json_encode($model->get_filters($site_root));
             $this->json = $json;
             break;
     }
     // Get profile ID
     $profileid = Platform::getInstance()->get_active_profile();
     $this->profileid = $profileid;
     // Get profile name
     $pmodel = F0FModel::getAnInstance('Profiles', 'AkeebaModel');
     $pmodel->setId($profileid);
     $profile_data = $pmodel->getItem();
     $this->profilename = $this->escape($profile_data->description);
     return true;
 }
示例#4
0
 /**
  * Check that the user has sufficient permissions, or die in error
  *
  */
 private function _checkPermissions()
 {
     // Is frontend backup enabled?
     $febEnabled = Platform::getInstance()->get_platform_configuration_option('failure_frontend_enable', 0) != 0;
     // Is the Secret Key strong enough?
     $validKey = Platform::getInstance()->get_platform_configuration_option('frontend_secret_word', '');
     if (!\Akeeba\Engine\Util\Complexify::isStrongEnough($validKey, false)) {
         $febEnabled = false;
     }
     if (!$febEnabled) {
         @ob_end_clean();
         echo '403 ' . JText::_('ERROR_NOT_ENABLED');
         flush();
         JFactory::getApplication()->close();
     }
     // Is the key good?
     $key = $this->input->get('key', '', 'none', 2);
     $validKeyTrim = trim($validKey);
     if ($key != $validKey || empty($validKeyTrim)) {
         @ob_end_clean();
         echo '403 ' . JText::_('ERROR_INVALID_KEY');
         flush();
         JFactory::getApplication()->close();
     }
 }
示例#5
0
 public function __construct()
 {
     $this->object = 'dir';
     $this->subtype = 'inclusion';
     $this->method = 'direct';
     $this->filter_name = 'Libraries';
     // 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();
 }
 /**
  * Execute the JSON API task
  *
  * @param   array $parameters The parameters to this task
  *
  * @return  mixed
  *
  * @throws  \RuntimeException  In case of an error
  */
 public function execute(array $parameters = array())
 {
     // Get the passed configuration values
     $defConfig = array('profile' => -1, 'engineconfig' => array());
     $defConfig = array_merge($defConfig, $parameters);
     $profile = (int) $defConfig['profile'];
     $data = $defConfig['engineconfig'];
     if (empty($profile)) {
         throw new \RuntimeException('Invalid profile ID', 404);
     }
     // Forbid stupidly selecting the site's root as the output or temporary directory
     if (array_key_exists('akeeba.basic.output_directory', $data)) {
         $folder = $data['akeeba.basic.output_directory'];
         $folder = Factory::getFilesystemTools()->translateStockDirs($folder, true, true);
         $check = Factory::getFilesystemTools()->translateStockDirs('[SITEROOT]', true, true);
         if ($check == $folder) {
             $data['akeeba.basic.output_directory'] = '[DEFAULT_OUTPUT]';
         }
     }
     // Merge it
     $config = Factory::getConfiguration();
     $protectedKeys = $config->getProtectedKeys();
     $config->resetProtectedKeys();
     $config->mergeArray($data, false, false);
     $config->setProtectedKeys($protectedKeys);
     // Save configuration
     return Platform::getInstance()->save_configuration($profile);
 }
示例#7
0
 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;
 }
示例#8
0
 public function onAdd($tpl = null)
 {
     $media_folder = JUri::base() . '../media/com_akeeba/';
     // Get a JSON representation of GUI data
     $json = AkeebaHelperEscape::escapeJS(Factory::getEngineParamsProvider()->getJsonGuiDefinition(), '"\\');
     $this->json = $json;
     // Get profile ID
     $profileid = Platform::getInstance()->get_active_profile();
     $this->profileid = $profileid;
     // Get profile name
     $profileName = F0FModel::getTmpInstance('Profiles', 'AkeebaModel')->setId($profileid)->getItem()->description;
     $this->profilename = $profileName;
     // Get the root URI for media files
     $this->mediadir = AkeebaHelperEscape::escapeJS($media_folder . 'theme/');
     // Are the settings secured?
     if (Platform::getInstance()->get_platform_configuration_option('useencryption', -1) == 0) {
         $this->securesettings = -1;
     } elseif (!Factory::getSecureSettings()->supportsEncryption()) {
         $this->securesettings = 0;
     } else {
         JLoader::import('joomla.filesystem.file');
         $filename = JPATH_COMPONENT_ADMINISTRATOR . '/engine/serverkey.php';
         if (JFile::exists($filename)) {
             $this->securesettings = 1;
         } else {
             $this->securesettings = 0;
         }
     }
     // Add live help
     AkeebaHelperIncludes::addHelp('config');
 }
 /**
  * Execute the JSON API task
  *
  * @param   array $parameters The parameters to this task
  *
  * @return  mixed
  *
  * @throws  \RuntimeException  In case of an error
  */
 public function execute(array $parameters = array())
 {
     $filter = \JFilterInput::getInstance();
     // Get the passed configuration values
     $defConfig = array('profile' => 0, 'root' => '[SITEROOT]');
     $defConfig = array_merge($defConfig, $parameters);
     $profile = $filter->clean($defConfig['profile'], 'int');
     $root = $filter->clean($defConfig['root'], 'string');
     // We need a valid profile ID
     if ($profile <= 0) {
         $profile = 1;
     }
     // We need a root
     if (empty($root)) {
         throw new \RuntimeException('Unknown database root', 500);
     }
     // Set the active profile
     $session = $this->container->session;
     $session->set('profile', $profile);
     // Load the configuration
     Platform::getInstance()->load_configuration($profile);
     /** @var RegExFileFilters $model */
     $model = $this->container->factory->model('RegExFileFilters')->tmpInstance();
     return $model->get_regex_filters($root);
 }
 /**
  * Execute the JSON API task
  *
  * @param   array $parameters The parameters to this task
  *
  * @return  mixed
  *
  * @throws  \RuntimeException  In case of an error
  */
 public function execute(array $parameters = array())
 {
     $filter = \JFilterInput::getInstance();
     // Get the passed configuration values
     $defConfig = array('profile' => 0, 'uuid' => '');
     $defConfig = array_merge($defConfig, $parameters);
     $profile = $filter->clean($defConfig['profile'], 'int');
     $uuid = $filter->clean($defConfig['uuid'], 'string');
     // We need a valid profile ID
     if ($profile <= 0) {
         $profile = 1;
     }
     // We need a uuid
     if (empty($uuid)) {
         throw new \RuntimeException('UUID is required', 500);
     }
     // Set the active profile
     $session = $this->container->session;
     $session->set('profile', $profile);
     // Load the configuration
     Platform::getInstance()->load_configuration($profile);
     /** @var IncludeFolders $model */
     $model = $this->container->factory->model('IncludeFolders')->tmpInstance();
     return $model->remove($uuid);
 }
示例#11
0
 /**
  * Default task; shows the initial page where the user selects a profile and enters description and comment
  */
 protected function onBeforeMain()
 {
     // Did the user ask to switch the active profile?
     $newProfile = $this->input->get('profileid', -10, 'int');
     if (is_numeric($newProfile) && $newProfile > 0) {
         $this->csrfProtection();
         $this->container->session->set('profile', $newProfile, 'akeeba');
         /**
          * DO NOT REMOVE!
          *
          * The Model will only try to load the configuration after nuking the factory. This causes Profile 1 to be
          * loaded first. Then it figures out it needs to load a different profile and it does – but the protected keys
          * are NOT replaced, meaning that certain configuration parameters are not replaced. Most notably, the chain.
          * This causes backups to behave weirdly. So, DON'T REMOVE THIS UNLESS WE REFACTOR THE MODEL.
          */
         Platform::getInstance()->load_configuration($newProfile);
     }
     // Deactivate the menus
     \JFactory::getApplication()->input->set('hidemainmenu', 1);
     /** @var \Akeeba\Backup\Admin\Model\Backup $model */
     $model = $this->getModel();
     // Push data to the model
     $model->setState('profile', $this->input->get('profileid', -10, 'int'));
     $model->setState('description', $this->input->get('description', '', 'string', 2));
     $model->setState('comment', $this->input->get('comment', '', 'html', 2));
     $model->setState('ajax', $this->input->get('ajax', '', 'cmd'));
     $model->setState('autostart', $this->input->get('autostart', 0, 'int'));
     $model->setState('jpskey', $this->input->get('jpskey', '', 'raw', 2));
     $model->setState('angiekey', $this->input->get('angiekey', '', 'raw', 2));
     $model->setState('returnurl', $this->input->get('returnurl', '', 'raw', 2));
     $model->setState('backupid', $this->input->get('backupid', null, 'cmd'));
 }
示例#12
0
 /**
  * Download the log file as a text file
  *
  * @return  void
  */
 public function download()
 {
     Platform::getInstance()->load_configuration(Platform::getInstance()->get_active_profile());
     $tag = $this->input->get('tag', null, 'cmd');
     if (empty($tag)) {
         $tag = null;
     }
     $asAttachment = $this->input->getBool('attachment', true);
     @ob_end_clean();
     // In case some braindead plugin spits its own HTML
     header("Cache-Control: no-cache, must-revalidate");
     // HTTP/1.1
     header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
     // Date in the past
     header("Content-Description: File Transfer");
     header('Content-Type: text/plain');
     if ($asAttachment) {
         header('Content-Disposition: attachment; filename="Akeeba Backup Debug Log.txt"');
     }
     /** @var LogModel $model */
     $model = $this->getModel();
     $model->setState('tag', $tag);
     $model->echoRawLog();
     flush();
     $this->container->platform->closeApplication();
 }
示例#13
0
 /**
  * Creates the push messaging object
  */
 public function __construct()
 {
     $pushPreference = Platform::getInstance()->get_platform_configuration_option('push_preference', '0');
     $apiKey = Platform::getInstance()->get_platform_configuration_option('push_apikey', '');
     // No API key? No push messages are enabled, so no point continuing really...
     if (empty($apiKey)) {
         $pushPreference = 0;
     }
     // We use a switch in case we add support for more push APIs in the future. The push_preference platform
     // option will tell us which service to use. In that case we'll have to refactor this class, but the public
     // API will remain the same.
     switch ($pushPreference) {
         default:
         case 0:
             $this->enabled = false;
             break;
         case 1:
             try {
                 $this->connector = new Connector($apiKey);
                 $this->connector->getDevices();
             } catch (\Exception $e) {
                 Factory::getLog()->warning('Push messages cannot be sent. Error received when trying to establish PushBullet connection:' . $e->getMessage());
                 $this->enabled = false;
             }
             break;
     }
 }
示例#14
0
 /**
  * Execute the JSON API task
  *
  * @param   array $parameters The parameters to this task
  *
  * @return  mixed
  *
  * @throws  \RuntimeException  In case of an error
  */
 public function execute(array $parameters = array())
 {
     // Get the passed configuration values
     $defConfig = array('backup_id' => 0);
     $defConfig = array_merge($defConfig, $parameters);
     $backup_id = (int) $defConfig['backup_id'];
     // Get the basic statistics
     $record = Platform::getInstance()->get_statistics($backup_id);
     // Get a list of filenames
     $backup_stats = Platform::getInstance()->get_statistics($backup_id);
     // Backup record doesn't exist
     if (empty($backup_stats)) {
         throw new \RuntimeException('Invalid backup record identifier', 404);
     }
     $filenames = Factory::getStatistics()->get_all_filenames($record);
     if (empty($filenames)) {
         // Archives are not stored on the server or no files produced
         $record['filenames'] = array();
     } else {
         $filedata = array();
         $i = 0;
         // Get file sizes per part
         foreach ($filenames as $file) {
             $i++;
             $size = @filesize($file);
             $size = is_numeric($size) ? $size : 0;
             $filedata[] = array('part' => $i, 'name' => basename($file), 'size' => $size);
         }
         // Add the file info to $record['filenames']
         $record['filenames'] = $filedata;
     }
     return $record;
 }
示例#15
0
 /**
  * Execute the JSON API task
  *
  * @param   array $parameters The parameters to this task
  *
  * @return  mixed
  *
  * @throws  \RuntimeException  In case of an error
  */
 public function execute(array $parameters = array())
 {
     $filter = \JFilterInput::getInstance();
     // Get the passed configuration values
     $defConfig = array('profile' => 0, 'root' => '[SITEROOT]', 'subdirectory' => '');
     $defConfig = array_merge($defConfig, $parameters);
     $profile = $filter->clean($defConfig['profile'], 'int');
     $root = $filter->clean($defConfig['root'], 'string');
     $subdirectory = $filter->clean($defConfig['subdirectory'], 'path');
     $crumbs = array();
     // We need a valid profile ID
     if ($profile <= 0) {
         $profile = 1;
     }
     // We need a root
     if (empty($root)) {
         throw new \RuntimeException('Unknown filesystem root', 500);
     }
     // Get the subdirectory and explode it to its parts
     if (!empty($subdirectory)) {
         $subdirectory = trim($subdirectory, '/');
     }
     if (!empty($subdirectory)) {
         $crumbs = explode('/', $subdirectory);
     }
     // Set the active profile
     $session = $this->container->session;
     $session->set('profile', $profile);
     // Load the configuration
     Platform::getInstance()->load_configuration($profile);
     /** @var FileFilters $model */
     $model = $this->container->factory->model('FileFilters')->tmpInstance();
     return $model->make_listing($root, $crumbs);
 }
示例#16
0
 /**
  * Opens the OAuth window
  *
  * @param   array   $params  Passed by the backup extension, used for the callback URI
  *
  * @return  boolean  False on failure, redirects on success
  */
 public function oauthOpen($params = array())
 {
     $callback = $params['callbackURI'] . '&method=oauthCallback';
     $url = ConnectorDropboxV2::helperUrl;
     $url .= strpos($url, '?') !== false ? '&' : '?';
     $url .= 'callback=' . urlencode($callback);
     Platform::getInstance()->redirect($url);
 }
示例#17
0
 public function onBrowse($tpl = null)
 {
     AkeebaStrapper::addJSfile('media://com_akeeba/js/fsfilter.js');
     AkeebaStrapper::addJSfile('media://com_akeeba/js/dbef.js');
     $model = $this->getModel();
     $task = $model->getState('browse_task', 'normal');
     // Add custom submenus
     $toolbar = F0FToolbar::getAnInstance($this->input->get('option', 'com_foobar', 'cmd'), $this->config);
     $toolbar->appendLink(JText::_('FILTERS_LABEL_NORMALVIEW'), JUri::base() . 'index.php?option=com_akeeba&view=dbef&task=normal', $task == 'normal');
     $toolbar->appendLink(JText::_('FILTERS_LABEL_TABULARVIEW'), JUri::base() . 'index.php?option=com_akeeba&view=dbef&task=tabular', $task == 'tabular');
     $media_folder = JUri::base() . '../media/com_akeeba/';
     // Get the root URI for media files
     $this->mediadir = AkeebaHelperEscape::escapeJS($media_folder . 'theme/');
     // Get a JSON representation of the available roots
     $model = $this->getModel();
     $root_info = $model->get_roots();
     $roots = array();
     if (!empty($root_info)) {
         // Loop all dir definitions
         foreach ($root_info as $def) {
             $roots[] = $def->value;
             $options[] = JHTML::_('select.option', $def->value, $def->text);
         }
     }
     $site_root = '[SITEDB]';
     $attribs = 'onchange="akeeba.Dbfilters.activeRootChanged ();"';
     $this->root_select = JHTML::_('select.genericlist', $options, 'root', $attribs, 'value', 'text', $site_root, 'active_root');
     $this->roots = $roots;
     switch ($task) {
         case 'normal':
         default:
             $this->setLayout('default');
             // Get a JSON representation of the database data
             $model = $this->getModel();
             $json = json_encode($model->make_listing($site_root));
             $this->json = $json;
             break;
         case 'tabular':
             $this->setLayout('tabular');
             // Get a JSON representation of the tabular filter data
             $model = $this->getModel();
             $json = json_encode($model->get_filters($site_root));
             $this->json = $json;
             break;
     }
     // Get profile ID
     $profileid = Platform::getInstance()->get_active_profile();
     $this->profileid = $profileid;
     // Get profile name
     if (!class_exists('AkeebaModelProfiles')) {
         JLoader::import('models.profiles', JPATH_COMPONENT_ADMINISTRATOR);
     }
     $model = new AkeebaModelProfiles();
     $model->setId($profileid);
     $profile_data = $model->getProfile();
     $this->profilename = $this->escape($profile_data->description);
     return true;
 }
示例#18
0
 public function __construct(array $config)
 {
     parent::__construct($config);
     // Load the Akeeba Engine autoloader
     define('AKEEBAENGINE', 1);
     require_once JPATH_ADMINISTRATOR . '/components/com_admintools/engine/Autoloader.php';
     // Load the platform
     \Akeeba\Engine\Platform::addPlatform('filescan', JPATH_ADMINISTRATOR . '/components/com_admintools/platform/Filescan');
 }
示例#19
0
 public function onEdit($tpl = null)
 {
     $model = $this->getModel();
     $id = $model->getId();
     $record = Platform::getInstance()->get_statistics($id);
     $this->record = $record;
     $this->record_id = $id;
     $this->setLayout('comment');
 }
示例#20
0
 public function onAdd($tpl = null)
 {
     // Get profile ID
     $profileid = Platform::getInstance()->get_active_profile();
     $this->profileid = $profileid;
     // Get profile name
     $profileName = F0FModel::getTmpInstance('Profiles', 'AkeebaModel')->setId($profileid)->getItem()->description;
     $this->profilename = $this->escape($profileName);
     // Get the CRON paths
     $this->croninfo = $this->getModel()->getPaths();
     $this->checkinfo = $this->getModel()->getCheckPaths();
 }
示例#21
0
 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;
 }
示例#22
0
 /**
  * Execute the JSON API task
  *
  * @param   array $parameters The parameters to this task
  *
  * @return  mixed
  *
  * @throws  \RuntimeException  In case of an error
  */
 public function execute(array $parameters = array())
 {
     $filter = \JFilterInput::getInstance();
     // Get the passed configuration values
     $defConfig = array('profile' => 0, 'root' => '[SITEROOT]', 'path' => '', 'type' => '', 'status' => 1);
     $defConfig = array_merge($defConfig, $parameters);
     $profile = $filter->clean($defConfig['profile'], 'int');
     $root = $filter->clean($defConfig['root'], 'string');
     $path = $filter->clean($defConfig['path'], 'path');
     $type = $filter->clean($defConfig['type'], 'cmd');
     $status = $filter->clean($defConfig['status'], 'bool');
     $crumbs = array();
     $node = '';
     // We need a valid profile ID
     if ($profile <= 0) {
         $profile = 1;
     }
     // We need a root
     if (empty($root)) {
         throw new \RuntimeException('Unknown filesystem root', 500);
     }
     // We need a path
     if (empty($path)) {
         throw new \RuntimeException('Unknown path', 500);
     }
     // Get the subdirectory and explode it to its parts
     $path = trim($path, '/');
     if (!empty($path)) {
         $crumbs = explode('/', $root);
         $node = array_pop($crumbs);
     }
     if (empty($node)) {
         throw new \RuntimeException('Unknown path', 500);
     }
     // We need a table name
     if (empty($type)) {
         throw new \RuntimeException('Filter type is mandatory', 500);
     }
     // Set the active profile
     $session = $this->container->session;
     $session->set('profile', $profile);
     // Load the configuration
     Platform::getInstance()->load_configuration($profile);
     /** @var FileFilters $model */
     $model = $this->container->factory->model('FileFilters')->tmpInstance();
     if ($status) {
         $ret = $model->setFilter($root, $crumbs, $node, $type);
     } else {
         $ret = $model->remove($root, $crumbs, $node, $type);
     }
     return $ret;
 }
示例#23
0
 /**
  * Sets or updates the statistics record of the current backup attempt
  *
  * @param array $data
  */
 public function setStatistics($data)
 {
     $ret = Platform::getInstance()->set_or_update_statistics($this->statistics_id, $data, $this);
     if ($ret !== false) {
         if (!is_null($ret)) {
             $this->statistics_id = $ret;
         }
         $this->cached_data = array_merge($this->cached_data, $data);
         $result = true;
     } elseif ($ret === false) {
         $result = false;
     }
     return $result;
 }
示例#24
0
 /**
  * Find the currently active profile ID and name and put them in properties accessible by the view template
  */
 protected function getProfileIdAndName()
 {
     /** @var Profiles $profilesModel */
     $profilesModel = $this->container->factory->model('Profiles')->tmpInstance();
     $profileId = Platform::getInstance()->get_active_profile();
     try {
         $this->profilename = $profilesModel->findOrFail($profileId)->description;
         $this->profileid = $profileId;
     } catch (\Exception $e) {
         $this->container->session->set('profile', 1, 'akeeba');
         $this->profileid = 1;
         $this->profilename = $profilesModel->findOrFail(1)->description;
     }
 }
示例#25
0
 /**
  * Handle the save & new task which saves settings, creates a new backup profile, activates it and proceed to the
  * configuration page once more.
  */
 public function savenew()
 {
     // Save the current profile
     $this->apply();
     // Create a new profile
     $profileid = Platform::getInstance()->get_active_profile();
     /** @var Profiles $profile */
     $profile = $this->container->factory->model('Profiles')->tmpInstance();
     $profile->findOrFail($profileid)->getClone()->save(['id' => null, 'description' => JText::_('COM_AKEEBA_CONFIG_SAVENEW_DEFAULT_PROFILE_NAME')]);
     // Activate and edit the new profile
     $returnUrl = base64_encode($this->redirect);
     $token = JFactory::getSession()->getFormToken();
     $url = JUri::base() . 'index.php?option=com_akeeba&task=SwitchProfile&profileid=' . $profile->getId() . '&returnurl=' . $returnUrl . '&' . $token . '=1';
     $this->setRedirect($url);
 }
示例#26
0
 /**
  * The default layout, shows a list of profiles
  *
  */
 function onBrowse($tpl = null)
 {
     // Get reference to profiles model
     $model = $this->getModel();
     // Get profile ID
     $profileid = Platform::getInstance()->get_active_profile();
     $this->profileid = $profileid;
     // Get profile name
     $model->setId($profileid);
     $profile_data = $model->getProfile();
     $this->profilename = $this->escape($profile_data->description);
     // Get Sort By fields
     $this->sortFields = array('id' => JText::_('JGRID_HEADING_ID'), 'description' => JText::_('PROFILE_COLLABEL_DESCRIPTION'));
     return parent::onBrowse($tpl);
 }
示例#27
0
 /**
  * Set the active profile from the input parameters
  */
 protected function setProfile()
 {
     $profile = $this->input->get('profile', 1, 'int');
     $profile = max(1, $profile);
     $this->container->session->set('profile', $profile, 'akeeba');
     /**
      * DO NOT REMOVE!
      *
      * The Model will only try to load the configuration after nuking the factory. This causes Profile 1 to be
      * loaded first. Then it figures out it needs to load a different profile and it does – but the protected keys
      * are NOT replaced, meaning that certain configuration parameters are not replaced. Most notably, the chain.
      * This causes backups to behave weirdly. So, DON'T REMOVE THIS UNLESS WE REFACTOR THE MODEL.
      */
     Platform::getInstance()->load_configuration($profile);
 }
 /**
  * Execute the JSON API task
  *
  * @param   array $parameters The parameters to this task
  *
  * @return  mixed
  *
  * @throws  \RuntimeException  In case of an error
  */
 public function execute(array $parameters = array())
 {
     // Get the passed configuration values
     $defConfig = array('profile' => 0);
     $defConfig = array_merge($defConfig, $parameters);
     $profile = (int) $defConfig['profile'];
     if ($profile <= 0) {
         $profile = 1;
     }
     // Set the active profile
     $session = $this->container->session;
     $session->set('profile', $profile);
     // Load the configuration
     Platform::getInstance()->load_configuration($profile);
     return Factory::getEngineParamsProvider()->getJsonGuiDefinition();
 }
示例#29
0
 public function getPaths()
 {
     $ret = (object) array('cli' => (object) array('supported' => false, 'path' => false), 'altcli' => (object) array('supported' => false, 'path' => false), 'frontend' => (object) array('supported' => false, 'path' => false), 'info' => (object) array('windows' => false, 'php_path' => false, 'root_url' => false, 'secret' => '', 'feenabled' => false));
     // Get the profile ID
     $profileid = Platform::getInstance()->get_active_profile();
     // Get the absolute path to the site's root
     $absolute_root = rtrim(realpath(JPATH_ROOT), DIRECTORY_SEPARATOR);
     // Is this Windows?
     $ret->info->windows = DIRECTORY_SEPARATOR == '\\' || substr(strtoupper(PHP_OS), 0, 3) == 'WIN';
     // Get the pseudo-path to PHP CLI
     $ret->info->php_path = '/path/to/php';
     if ($ret->info->windows) {
         $ret->info->php_path = 'c:\\path\\to\\php.exe';
     }
     // Get front-end backup secret key
     $ret->info->secret = $this->container->params->get('frontend_secret_word', '');
     $ret->info->feenabled = $this->container->params->get('frontend_enable', false);
     // Get root URL
     $ret->info->root_url = rtrim($this->container->params->get('siteurl', ''), '/');
     // Get information for CLI CRON script
     if (AKEEBA_PRO) {
         $ret->cli->supported = true;
         $ret->cli->path = $absolute_root . DIRECTORY_SEPARATOR . 'cli' . DIRECTORY_SEPARATOR . 'akeeba-backup.php';
         if ($profileid != 1) {
             $ret->cli->path .= ' --profile=' . $profileid;
         }
     }
     // Get information for alternative CLI CRON script
     if (AKEEBA_PRO) {
         $ret->altcli->supported = true;
         if (trim($ret->info->secret) && $ret->info->feenabled) {
             $ret->altcli->path = $absolute_root . DIRECTORY_SEPARATOR . 'cli' . DIRECTORY_SEPARATOR . 'akeeba-altbackup.php';
             if ($profileid != 1) {
                 $ret->altcli->path .= ' --profile=' . $profileid;
             }
         }
     }
     // Get information for front-end backup
     $ret->frontend->supported = true;
     if (trim($ret->info->secret) && $ret->info->feenabled) {
         $ret->frontend->path = 'index.php?option=com_akeeba&view=Backup&key=' . urlencode($ret->info->secret);
         if ($profileid != 1) {
             $ret->frontend->path .= '&profile=' . $profileid;
         }
     }
     return $ret;
 }
示例#30
0
 /**
  * Execute the JSON API task
  *
  * @param   array $parameters The parameters to this task
  *
  * @return  mixed
  *
  * @throws  \RuntimeException  In case of an error
  */
 public function execute(array $parameters = array())
 {
     // Get the passed configuration values
     $defConfig = array('profile' => 0);
     $defConfig = array_merge($defConfig, $parameters);
     $profile = (int) $defConfig['profile'];
     if ($profile <= 0) {
         $profile = 1;
     }
     $session = $this->container->session;
     $session->set('profile', $profile);
     // Load the configuration
     Platform::getInstance()->load_configuration($profile);
     /** @var DatabaseFilters $model */
     $model = $this->container->factory->model('DatabaseFilters')->tmpInstance();
     return $model->get_roots();
 }