Example #1
0
 protected function onAdd($tpl = null)
 {
     /** @var AkeebaModelCpanels $model */
     $model = $this->getModel();
     $aeconfig = Factory::getConfiguration();
     // Load the helper classes
     $this->loadHelper('utils');
     $this->loadHelper('status');
     $statusHelper = AkeebaHelperStatus::getInstance();
     // Load the model
     if (!class_exists('AkeebaModelStatistics')) {
         JLoader::import('models.statistics', JPATH_COMPONENT_ADMINISTRATOR);
     }
     $statmodel = new AkeebaModelStatistics();
     $this->profileid = $model->getProfileID();
     // Active profile ID
     $this->profilelist = $model->getProfilesList();
     // List of available profiles
     $this->statuscell = $statusHelper->getStatusCell();
     // Backup status
     $this->detailscell = $statusHelper->getQuirksCell();
     // Details (warnings)
     $this->statscell = $statmodel->getLatestBackupDetails();
     $this->fixedpermissions = $model->fixMediaPermissions();
     // Fix media/com_akeeba permissions
     $this->needsdlid = $model->needsDownloadID();
     $this->needscoredlidwarning = $model->mustWarnAboutDownloadIDInCore();
     $this->extension_id = $model->getState('extension_id', 0, 'int');
     // 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;
     $this->statsIframe = F0FModel::getTmpInstance('Stats', 'AkeebaModel')->collectStatistics(true);
     return $this->onDisplay($tpl);
 }
 /**
  * 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);
 }
Example #3
0
 /**
  * Get an array with the names of all log files in this backup profile
  *
  * @return  string[]
  */
 public function getLogFiles()
 {
     $configuration = Factory::getConfiguration();
     $outdir = $configuration->get('akeeba.basic.output_directory');
     $files = Factory::getFileLister()->getFiles($outdir);
     $ret = array();
     if (!empty($files) && is_array($files)) {
         foreach ($files as $filename) {
             $basename = basename($filename);
             if (substr($basename, 0, 7) == 'akeeba.' && substr($basename, -4) == '.log' && $basename != 'akeeba.log') {
                 $tag = str_replace('akeeba.', '', str_replace('.log', '', $basename));
                 if (!empty($tag)) {
                     $parts = explode('.', $tag);
                     $key = array_pop($parts);
                     $key = str_replace('id', '', $key);
                     $key = is_numeric($key) ? sprintf('%015u', $key) : $key;
                     if (empty($parts)) {
                         $key = str_repeat('0', 15) . '.' . $key;
                     } else {
                         $key .= '.' . implode('.', $parts);
                     }
                     $ret[$key] = $tag;
                 }
             }
         }
     }
     krsort($ret);
     return $ret;
 }
Example #4
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;
 }
 protected function is_excluded_by_api($test, $root)
 {
     static $from_datetime;
     $config = Factory::getConfiguration();
     if (is_null($from_datetime)) {
         $user_setting = $config->get('core.filters.dateconditional.start');
         $from_datetime = strtotime($user_setting);
     }
     // Get the filesystem path for $root
     $fsroot = $config->get('volatile.filesystem.current_root', '');
     $ds = $fsroot == '' || $fsroot == '/' ? '' : DIRECTORY_SEPARATOR;
     $filename = $fsroot . $ds . $test;
     // Get the timestamp of the file
     $timestamp = @filemtime($filename);
     // If we could not get this information, include the file in the archive
     if ($timestamp === false) {
         return false;
     }
     // Compare it with the user-defined minimum timestamp and exclude if it's older than that
     if ($timestamp <= $from_datetime) {
         return true;
     }
     // No match? Just include the file!
     return false;
 }
Example #6
0
 protected function scanFolder($folder, &$position, $forFolders = true, $threshold_key = 'dir', $threshold_default = 50)
 {
     $registry = Factory::getConfiguration();
     // Initialize variables
     $arr = array();
     $false = false;
     if (!is_dir($folder) && !is_dir($folder . '/')) {
         return $false;
     }
     try {
         $di = new \DirectoryIterator($folder);
     } catch (\Exception $e) {
         $this->setWarning('Unreadable directory ' . $folder);
         return $false;
     }
     if (!$di->valid()) {
         $this->setWarning('Unreadable directory ' . $folder);
         return $false;
     }
     if (!empty($position)) {
         $di->seek($position);
         if ($di->key() != $position) {
             $position = null;
             return $arr;
         }
     }
     $counter = 0;
     $maxCounter = $registry->get("engine.scan.large.{$threshold_key}_threshold", $threshold_default);
     while ($di->valid()) {
         if ($di->isDot()) {
             $di->next();
             continue;
         }
         if ($di->isDir() != $forFolders) {
             $di->next();
             continue;
         }
         $ds = $folder == '' || $folder == '/' || @substr($folder, -1) == '/' || @substr($folder, -1) == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR;
         $dir = $folder . $ds . $di->getFilename();
         $data = _AKEEBA_IS_WINDOWS ? Factory::getFilesystemTools()->TranslateWinPath($dir) : $dir;
         if ($data) {
             $counter++;
             $arr[] = $data;
         }
         if ($counter == $maxCounter) {
             break;
         } else {
             $di->next();
         }
     }
     // Determine the new value for the position
     $di->next();
     if ($di->valid()) {
         $position = $di->key() - 1;
     } else {
         $position = null;
     }
     return $arr;
 }
Example #7
0
 public function onAdd($tpl = null)
 {
     $aeconfig = Factory::getConfiguration();
     // Load the Configuration Wizard Javascript file
     AkeebaStrapper::addJSfile('media://com_akeeba/js/confwiz.js');
     $this->setLayout('wizard');
     return true;
 }
Example #8
0
 public function __construct()
 {
     $this->object = 'file';
     $this->subtype = 'all';
     $this->method = 'direct';
     $this->filter_name = 'Excludefiles';
     // We take advantage of the filter class magic to inject our custom filters
     $allFiles = explode('|', Factory::getConfiguration()->get('akeeba.basic.exclude_files'));
     $this->filter_data['[SITEROOT]'] = array_unique($allFiles);
     parent::__construct();
 }
Example #9
0
 public function __construct()
 {
     $this->object = 'file';
     $this->subtype = 'all';
     $this->method = 'regex';
     $this->filter_name = 'Regexfilesext';
     $extensions = Factory::getConfiguration()->get('akeeba.basic.file_extensions', 'php|phps|php3|inc');
     $extensions = str_replace('.', '\\.', $extensions);
     $this->filter_data['[SITEROOT]'] = array("!#\\.(" . $extensions . ")\$#");
     parent::__construct();
 }
Example #10
0
 public function __construct($config = array())
 {
     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');
     // Load the engine configuration
     \Akeeba\Engine\Platform::getInstance()->load_configuration(1);
     $this->aeconfig = \Akeeba\Engine\Factory::getConfiguration();
 }
Example #11
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;
 }
Example #12
0
 /**
  * Saves the current configuration to the database table
  *
  * @param   int  $profile_id  The profile where to save the configuration to, defaults to current profile
  *
  * @return  bool  True if everything was saved properly
  */
 public function save_configuration($profile_id = null)
 {
     // If there is no embedded installer or the wrong embedded installer is selected, fix it automatically
     $config = Factory::getConfiguration();
     $embedded_installer = $config->get('akeeba.advanced.embedded_installer', null);
     if (empty($embedded_installer) || $embedded_installer == 'angie-joomla') {
         $protectedKeys = $config->getProtectedKeys();
         $config->setProtectedKeys(array());
         $config->set('akeeba.advanced.embedded_installer', 'angie');
         $config->setProtectedKeys($protectedKeys);
     }
     // Save the configuration
     return parent::save_configuration($profile_id);
     // TODO: Change the autogenerated stub
 }
Example #13
0
 /**
  * Returns the fully qualified path to the storage file
  *
  * @param   string  $tag
  *
  * @return string
  */
 public function get_storage_filename($tag = null)
 {
     static $basepath = null;
     if ($this->storageEngine == 'db') {
         return empty($tag) ? 'storage' : $tag;
     } else {
         if (is_null($basepath)) {
             $registry = Factory::getConfiguration();
             $basepath = $registry->get('akeeba.basic.output_directory') . DIRECTORY_SEPARATOR;
         }
         if (empty($tag)) {
             $tag = 'storage';
         }
         return $basepath . 'akeeba_' . $tag;
     }
 }
Example #14
0
 /**
  * Executes before dispatching the request to the appropriate controller
  */
 public function onBeforeDispatch()
 {
     $this->onBeforeDispatchViewAliases();
     // Load the FOF language
     $lang = $this->container->platform->getLanguage();
     $lang->load('lib_fof30', JPATH_SITE, 'en-GB', true, true);
     $lang->load('lib_fof30', JPATH_SITE, null, true, false);
     // Necessary defines for Akeeba Engine
     if (!defined('AKEEBAENGINE')) {
         define('AKEEBAENGINE', 1);
         define('AKEEBAROOT', $this->container->backEndPath . '/BackupEngine');
         define('ALICEROOT', $this->container->backEndPath . '/AliceEngine');
     }
     // Make sure we have a profile set throughout the component's lifetime
     $session = $this->container->session;
     $profile_id = $session->get('profile', null, 'akeeba');
     if (is_null($profile_id)) {
         $session->set('profile', 1, 'akeeba');
     }
     // Load Akeeba Engine
     $basePath = $this->container->backEndPath;
     require_once $basePath . '/BackupEngine/Factory.php';
     // Load the Akeeba Engine configuration
     Platform::addPlatform('joomla3x', JPATH_COMPONENT_ADMINISTRATOR . '/BackupPlatform/Joomla3x');
     $akeebaEngineConfig = Factory::getConfiguration();
     Platform::getInstance()->load_configuration();
     unset($akeebaEngineConfig);
     // Prevents the "SQLSTATE[HY000]: General error: 2014" due to resource sharing with Akeeba Engine
     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     // !!!!! WARNING: ALWAYS GO THROUGH JFactory; DO NOT GO THROUGH $this->container->db !!!!!
     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     $jDbo = JFactory::getDbo();
     if ($jDbo->name == 'pdomysql') {
         @JFactory::getDbo()->disconnect();
     }
     // Load the utils helper library
     Platform::getInstance()->load_version_defines();
     // Make sure we have a version loaded
     @(include_once $this->container->backEndPath . '/components/com_akeeba/version.php');
     if (!defined('AKEEBA_VERSION')) {
         define('AKEEBA_VERSION', 'dev');
         define('AKEEBA_DATE', date('Y-m-d'));
     }
     // Create a media file versioning tag
     $this->container->mediaVersion = md5(AKEEBA_VERSION . AKEEBA_DATE);
 }
Example #15
0
 public function __construct()
 {
     $this->object = 'dir';
     $this->subtype = 'all';
     $this->method = 'direct';
     $this->filter_name = 'Excludefolders';
     // Get the site's root
     $configuration = Factory::getConfiguration();
     if ($configuration->get('akeeba.platform.override_root', 0)) {
         $root = $configuration->get('akeeba.platform.newroot', '[SITEROOT]');
     } else {
         $root = '[SITEROOT]';
     }
     // We take advantage of the filter class magic to inject our custom filters
     $this->filter_data[$root] = array('awstats', 'cgi-bin');
     parent::__construct();
 }
Example #16
0
 protected function onAdd($tpl = null)
 {
     /** @var AkeebaModelCpanels $model */
     $model = $this->getModel();
     /**
     		$selfhealModel = F0FModel::getTmpInstance('Selfheal','AkeebaModel');
     		$schemaok = $selfhealModel->healSchema();
     		/**/
     $schemaok = true;
     $this->schemaok = $schemaok;
     $aeconfig = Factory::getConfiguration();
     if ($schemaok) {
         // Load the helper classes
         $this->loadHelper('utils');
         $this->loadHelper('status');
         $statusHelper = AkeebaHelperStatus::getInstance();
         // Load the model
         if (!class_exists('AkeebaModelStatistics')) {
             JLoader::import('models.statistics', JPATH_COMPONENT_ADMINISTRATOR);
         }
         $statmodel = new AkeebaModelStatistics();
         $this->icondefs = $model->getIconDefinitions();
         // Icon definitions
         $this->profileid = $model->getProfileID();
         // Active profile ID
         $this->profilelist = $model->getProfilesList();
         // List of available profiles
         $this->statuscell = $statusHelper->getStatusCell();
         // Backup status
         $this->detailscell = $statusHelper->getQuirksCell();
         // Details (warnings)
         $this->statscell = $statmodel->getLatestBackupDetails();
         $this->fixedpermissions = $model->fixMediaPermissions();
         // Fix media/com_akeeba permissions
         $this->update_plugin = $model->isUpdatePluginEnabled();
         $this->needsdlid = $model->needsDownloadID();
         $this->needscoredlidwarning = $model->mustWarnAboutDownloadIDInCore();
         $this->hasPostInstallationMessages = $model->hasPostInstallMessages();
         $this->extension_id = $model->getState('extension_id', 0, 'int');
         // Add live help
         AkeebaHelperIncludes::addHelp('cpanel');
         $this->statsIframe = F0FModel::getTmpInstance('Stats', 'AkeebaModel')->collectStatistics(true);
     }
     return $this->onDisplay($tpl);
 }
Example #17
0
 public function __construct()
 {
     // This is a directory inclusion filter.
     $this->object = 'db';
     $this->subtype = 'inclusion';
     $this->method = 'direct';
     $this->filter_name = 'Sitedb';
     // Add a new record for the core Joomla! database
     // Get core database options
     $configuration = Factory::getConfiguration();
     if ($configuration->get('akeeba.platform.override_db', 0)) {
         $options = array('port' => $configuration->get('akeeba.platform.dbport', ''), 'host' => $configuration->get('akeeba.platform.dbhost', ''), 'user' => $configuration->get('akeeba.platform.dbusername', ''), 'password' => $configuration->get('akeeba.platform.dbpassword', ''), 'database' => $configuration->get('akeeba.platform.dbname', ''), 'prefix' => $configuration->get('akeeba.platform.dbprefix', ''));
         $driver = '\\Akeeba\\Engine\\Driver\\' . ucfirst($configuration->get('akeeba.platform.dbdriver', 'mysqli'));
     } else {
         $options = Platform::getInstance()->get_platform_database_options();
         $driver = Platform::getInstance()->get_default_database_driver(true);
     }
     $host = $options['host'];
     $port = array_key_exists('port', $options) ? $options['port'] : null;
     if (empty($port)) {
         $port = null;
     }
     $socket = null;
     $targetSlot = substr(strstr($host, ":"), 1);
     if (!empty($targetSlot)) {
         // Get the port number or socket name
         if (is_numeric($targetSlot) && is_null($port)) {
             $port = $targetSlot;
         } else {
             $socket = $targetSlot;
         }
         // Extract the host name only
         $host = substr($host, 0, strlen($host) - (strlen($targetSlot) + 1));
         // This will take care of the following notation: ":3306"
         if ($host == '') {
             $host = 'localhost';
         }
     }
     // This is the format of the database inclusion filters
     $entry = array('host' => $host, 'port' => is_null($socket) ? is_null($port) ? '' : $port : $socket, 'username' => $options['user'], 'password' => $options['password'], 'database' => $options['database'], 'prefix' => $options['prefix'], 'dumpFile' => 'site.sql', 'driver' => $driver);
     // We take advantage of the filter class magic to inject our custom filters
     $configuration = Factory::getConfiguration();
     $this->filter_data['[SITEDB]'] = $entry;
     parent::__construct();
 }
Example #18
0
 function __construct()
 {
     $this->object = 'dir';
     $this->subtype = 'all';
     $this->method = 'regex';
     $this->filter_name = 'Cvsfolders';
     if (empty($this->filter_name)) {
         $this->filter_name = strtolower(basename(__FILE__, '.php'));
     }
     parent::__construct();
     // Get the site's root
     $configuration = Factory::getConfiguration();
     if ($configuration->get('akeeba.platform.override_root', 0)) {
         $root = $configuration->get('akeeba.platform.newroot', '[SITEROOT]');
     } else {
         $root = '[SITEROOT]';
     }
     $this->filter_data[$root] = array('#/\\.git$#', '#^\\.git$#', '#/\\.svn$#', '#^\\.svn$#');
 }
Example #19
0
 function __construct()
 {
     $this->object = 'file';
     $this->subtype = 'all';
     $this->method = 'regex';
     $this->filter_name = 'Systemcachefiles';
     if (empty($this->filter_name)) {
         $this->filter_name = strtolower(basename(__FILE__, '.php'));
     }
     parent::__construct();
     // Get the site's root
     $configuration = Factory::getConfiguration();
     if ($configuration->get('akeeba.platform.override_root', 0)) {
         $root = $configuration->get('akeeba.platform.newroot', '[SITEROOT]');
     } else {
         $root = '[SITEROOT]';
     }
     $this->filter_data[$root] = array('#/Thumbs.db$#', '#^Thumbs.db$#', '#/.DS_Store$#i', '#^.DS_Store$#i');
 }
Example #20
0
 function getLogFiles()
 {
     $configuration = Factory::getConfiguration();
     $outdir = $configuration->get('akeeba.basic.output_directory');
     $files = Factory::getFileLister()->getFiles($outdir);
     $ret = array();
     if (!empty($files) && is_array($files)) {
         foreach ($files as $filename) {
             $basename = basename($filename);
             if (substr($basename, 0, 7) == 'akeeba.' && substr($basename, -4) == '.log' && $basename != 'akeeba.log') {
                 $tag = str_replace('akeeba.', '', str_replace('.log', '', $basename));
                 if (!empty($tag)) {
                     $ret[] = $tag;
                 }
             }
         }
     }
     return $ret;
 }
Example #21
0
 public function __construct()
 {
     $this->object = 'dir';
     $this->subtype = 'content';
     $this->method = 'direct';
     $this->filter_name = 'Joomlaskipfiles';
     // We take advantage of the filter class magic to inject our custom filters
     $configuration = Factory::getConfiguration();
     $jreg = \JFactory::getConfig();
     $tmpdir = $jreg->get('tmp_path');
     // Get the site's root
     if ($configuration->get('akeeba.platform.override_root', 0)) {
         $root = $configuration->get('akeeba.platform.newroot', '[SITEROOT]');
     } else {
         $root = '[SITEROOT]';
     }
     $this->filter_data[$root] = array($this->treatDirectory($configuration->get('akeeba.basic.output_directory')), $this->treatDirectory($tmpdir), 'tmp', $this->treatDirectory(JPATH_CACHE), $this->treatDirectory(JPATH_ADMINISTRATOR . '/cache'), $this->treatDirectory(JPATH_ROOT . '/cache'), 'cache', 'administrator/cache', $this->treatDirectory(JPATH_ROOT . '/installation'), 'installation', $this->treatDirectory(Platform::getInstance()->get_site_root() . '/cache'), $this->treatDirectory(Platform::getInstance()->get_site_root() . '/administrator/cache'), $this->treatDirectory(Platform::getInstance()->get_site_root() . '/components/libraries/cmslib/cache'), 'components/libraries/cmslib/cache', 'logs');
     parent::__construct();
 }
Example #22
0
 /**
  * Save the engine configuration
  *
  * @return  void
  */
 public function saveEngineConfig()
 {
     $data = $this->getState('engineconfig', array());
     // 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]';
         }
     }
     // Unprotect the configuration and merge it
     $config = Factory::getConfiguration();
     $protectedKeys = $config->getProtectedKeys();
     $config->resetProtectedKeys();
     $config->mergeArray($data, false, false);
     $config->setProtectedKeys($protectedKeys);
     // Save configuration
     Platform::getInstance()->save_configuration();
 }
Example #23
0
 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();
 }
Example #24
0
 public function __construct()
 {
     // This is a directory inclusion filter.
     $this->object = 'dir';
     $this->subtype = 'inclusion';
     $this->method = 'direct';
     $this->filter_name = 'Siteroot';
     // Directory inclusion format:
     // array(real_directory, add_path)
     $add_path = null;
     // A null add_path means that we dump this dir's contents in the archive's root
     // We take advantage of the filter class magic to inject our custom filters
     $configuration = Factory::getConfiguration();
     if ($configuration->get('akeeba.platform.override_root', 0)) {
         $root = $configuration->get('akeeba.platform.newroot', '[SITEROOT]');
     } else {
         $root = '[SITEROOT]';
     }
     $this->filter_data[] = array($root, $add_path);
     parent::__construct();
 }
Example #25
0
 /**
  * Validates the data passed to the request.
  *
  * @return  mixed  True if all is OK, an error string if something is wrong
  */
 function validateRequest()
 {
     // Is this a valid backup entry?
     $ids = $this->getIDsFromRequest();
     $id = array_pop($ids);
     if (empty($id)) {
         return JText::_('COM_AKEEBA_RESTORE_ERROR_INVALID_RECORD');
     }
     $data = Platform::getInstance()->get_statistics($id);
     if (empty($data)) {
         return JText::_('COM_AKEEBA_RESTORE_ERROR_INVALID_RECORD');
     }
     if ($data['status'] != 'complete') {
         return JText::_('COM_AKEEBA_RESTORE_ERROR_INVALID_RECORD');
     }
     // Load the profile ID (so that we can find out the output directory)
     $profile_id = $data['profile_id'];
     Platform::getInstance()->load_configuration($profile_id);
     $path = $data['absolute_path'];
     $exists = @file_exists($path);
     if (!$exists) {
         // Let's try figuring out an alternative path
         $config = Factory::getConfiguration();
         $path = $config->get('akeeba.basic.output_directory', '') . '/' . $data['archivename'];
         $exists = @file_exists($path);
     }
     if (!$exists) {
         return JText::_('COM_AKEEBA_RESTORE_ERROR_ARCHIVE_MISSING');
     }
     $filename = basename($path);
     $lastdot = strrpos($filename, '.');
     $extension = strtoupper(substr($filename, $lastdot + 1));
     if (!in_array($extension, array('JPS', 'JPA', 'ZIP'))) {
         return JText::_('COM_AKEEBA_RESTORE_ERROR_INVALID_TYPE');
     }
     $this->data = $data;
     $this->path = $path;
     $this->extension = $extension;
     return true;
 }
Example #26
0
 /**
  * Returns an associative array with profile IDs as keys and the post-processing engine as values
  *
  * @return  array
  */
 public function getPostProcessingEnginePerProfile()
 {
     // Cache the current profile's ID
     $session = $this->container->session;
     $currentProfileID = $session->get('profile', null, 'akeeba');
     // Get the IDs of all profiles
     $db = $this->getDbo();
     $query = $db->getQuery(true)->select($db->qn('id'))->from($db->qn('#__ak_profiles'));
     $db->setQuery($query);
     $profiles = $db->loadColumn();
     // Initialise return;
     $engines = [];
     // Loop all profiles
     foreach ($profiles as $profileId) {
         Platform::getInstance()->load_configuration($profileId);
         $profileConfiguration = Factory::getConfiguration();
         $engines[$profileId] = $profileConfiguration->get('akeeba.advanced.postproc_engine');
     }
     // Reload the current profile
     Platform::getInstance()->load_configuration($currentProfileID);
     return $engines;
 }
Example #27
0
 protected function init()
 {
     // Fetch the configuration
     $config = Factory::getConfiguration();
     $this->params = (object) array('type' => $config->get('core.filters.srp.type', 'component'), 'group' => $config->get('core.filters.srp.group', 'group'), 'name' => $config->get('core.filters.srp.name', 'name'), 'customdirs' => $config->get('core.filters.srp.customdirs', array()), 'customfiles' => $config->get('core.filters.srp.customfiles', array()), 'langfiles' => $config->get('core.filters.srp.langfiles', array()));
     $this->alloweddirs = array();
     // Process custom directories
     if (is_array($this->params->customdirs)) {
         foreach ($this->params->customdirs as $dir) {
             $dir = $this->treatDirectory($dir);
             $this->alloweddirs[] = $dir;
         }
     }
     // Process custom files
     if (is_array($this->params->customfiles)) {
         foreach ($this->params->customfiles as $file) {
             $dir = dirname($file);
             $dir = $this->treatDirectory($dir);
             if (!in_array($dir, $this->strictalloweddirs)) {
                 $this->strictalloweddirs[] = $dir;
             }
             if (!in_array($dir, $this->alloweddirs)) {
                 $this->alloweddirs[] = $dir;
             }
         }
     }
     $this->alloweddirs[] = 'language';
     $this->alloweddirs[] = 'administrator/language';
     // Process core directories
     $this->params->type = (array) $this->params->type;
     $this->params->name = (array) $this->params->name;
     $this->params->group = (array) $this->params->group;
     for ($i = 0; $i < count($this->params->type); $i++) {
         $info['name'] = $this->params->name[$i];
         $info['group'] = $this->params->group[$i];
         $this->addDirs($this->params->type[$i], $info);
     }
 }
Example #28
0
 /**
  * Executes when displaying the page
  */
 public function onBeforeMain()
 {
     $this->addJavascriptFile('media://com_akeeba/js/Configuration.min.js');
     JHtml::_('behavior.modal');
     // Get a JSON representation of GUI data
     $json = Factory::getEngineParamsProvider()->getJsonGuiDefinition();
     $this->json = $json;
     $this->getProfileIdAndName();
     // Are the settings secured?
     $this->securesettings = $this->getSecureSettingsOption();
     // Should I show the Configuration Wizard popup prompt?
     $this->promptForConfigurationWizard = Factory::getConfiguration()->get('akeeba.flag.confwiz', 0) != 1;
     // Push translations
     JText::script('COM_AKEEBA_CONFIG_UI_BROWSE');
     JText::script('COM_AKEEBA_CONFIG_UI_CONFIG');
     JText::script('COM_AKEEBA_CONFIG_UI_REFRESH');
     JText::script('COM_AKEEBA_FILEFILTERS_LABEL_UIROOT');
     JText::script('COM_AKEEBA_CONFIG_UI_FTPBROWSER_TITLE');
     JText::script('COM_AKEEBA_CONFIG_DIRECTFTP_TEST_OK');
     JText::script('COM_AKEEBA_CONFIG_DIRECTFTP_TEST_FAIL');
     JText::script('COM_AKEEBA_CONFIG_DIRECTSFTP_TEST_OK');
     JText::script('COM_AKEEBA_CONFIG_DIRECTSFTP_TEST_FAIL');
 }
Example #29
0
 /**
  * Returns the CRC32 of a file, selecting the more appropriate algorithm.
  *
  * @param string  $filename                   Absolute path to the file being processed
  * @param integer $AkeebaPackerZIP_CHUNK_SIZE Obsoleted
  *
  * @return integer The CRC32 in numerical form
  */
 public function crc32_file($filename, $AkeebaPackerZIP_CHUNK_SIZE)
 {
     static $configuration;
     if (!$configuration) {
         $configuration = Factory::getConfiguration();
     }
     if (function_exists("hash_file")) {
         $res = $this->crc32_file_php512($filename);
         Factory::getLog()->log(LogLevel::DEBUG, "File {$filename} - CRC32 = " . dechex($res) . " [HASH_FILE]");
     } else {
         if (function_exists("file_get_contents") && @filesize($filename) <= $AkeebaPackerZIP_CHUNK_SIZE) {
             $res = $this->crc32_file_getcontents($filename);
             Factory::getLog()->log(LogLevel::DEBUG, "File {$filename} - CRC32 = " . dechex($res) . " [FILE_GET_CONTENTS]");
         } else {
             $res = 0;
             Factory::getLog()->log(LogLevel::DEBUG, "File {$filename} - CRC32 = " . dechex($res) . " [FAKE - CANNOT CALCULATE]");
         }
     }
     if ($res === false) {
         $res = 0;
         $this->setWarning("File {$filename} - NOT READABLE: CRC32 IS WRONG!");
     }
     return $res;
 }
Example #30
0
 /**
  * Try to determine the next root folder to scan
  *
  * @return  boolean  True if there was a new root to scan
  */
 protected function getNextRoot()
 {
     // We have finished with our directory list. Hmm... Do we have extra directories?
     if (count($this->root_definitions) > 0) {
         Factory::getLog()->log(LogLevel::DEBUG, "More off-site directories detected");
         $registry = Factory::getConfiguration();
         $dir_definition = array_shift($this->root_definitions);
         $this->remove_path_prefix = $dir_definition[0];
         // Remove absolute path to directory when storing the file
         if (is_null($dir_definition[1])) {
             $this->path_prefix = '';
             // No added path for main site
         } else {
             $dir_definition[1] = trim($dir_definition[1]);
             if (empty($dir_definition[1]) || $dir_definition[1] == '/') {
                 $this->path_prefix = '';
             } else {
                 $this->path_prefix = $registry->get('akeeba.advanced.virtual_folder') . '/' . $dir_definition[1];
             }
         }
         $this->done_scanning = false;
         // Make sure we process this file list!
         $this->root = $dir_definition[0];
         // Translate the root into an absolute path
         $stock_dirs = Platform::getInstance()->get_stock_directories();
         $absolute_dir = substr($this->root, 0);
         if (!empty($stock_dirs)) {
             foreach ($stock_dirs as $key => $replacement) {
                 $absolute_dir = str_replace($key, $replacement, $absolute_dir);
             }
         }
         $this->directory_list[] = $absolute_dir;
         $this->remove_path_prefix = $absolute_dir;
         $registry->set('volatile.filesystem.current_root', $absolute_dir);
         $this->total_files = 0;
         $this->done_files = 0;
         $this->total_folders = 0;
         $this->done_folders = 0;
         Factory::getLog()->log(LogLevel::INFO, "Including new off-site directory to " . $dir_definition[1]);
         return true;
     } else {
         $this->setState('postrun');
         return false;
     }
 }