| Current Path : /home/w/u/e/wuectly/www/03cbe/ |
| Current File : /home/w/u/e/wuectly/www/03cbe/BackupPlatform.tar |
.htaccess 0000604 00000000246 15245630146 0006346 0 ustar 00 <IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
<IfModule mod_authz_core.c>
<RequireAll>
Require all denied
</RequireAll>
</IfModule>
Joomla3x/Platform.php 0000604 00000072323 15245630146 0010546 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Engine\Platform;
// Protection against direct access
defined('AKEEBAENGINE') || die();
use Akeeba\Engine\Driver\Joomla;
use Akeeba\Engine\Driver\Mysql;
use Akeeba\Engine\Driver\Mysqli;
use Akeeba\Engine\Driver\Pdomysql;
use Akeeba\Engine\Factory;
use Akeeba\Engine\Finalization\TestExtract;
use Akeeba\Engine\Platform;
use Akeeba\Engine\Platform\Base as BasePlatform;
use Akeeba\Engine\Psr\Log\LogLevel;
use DateTimeZone;
use Exception;
use FOF40\Container\Container;
use FOF40\Date\Date;
use JLoader;
use JMail;
use Joomla\CMS\Access\Access;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Mail\Mail;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Version;
if (!defined('DS'))
{
define('DS', DIRECTORY_SEPARATOR); // Still required by Joomla! :(
}
/**
* Joomla! 3.x platform class
*/
class Joomla3x extends BasePlatform
{
/**
* Override profile ID, for use in automated testing only
*
* @var int|null
*/
public static $profile_id = null;
/**
* Platform class priority
*
* @var int
*/
public $priority = 53;
/**
* This platform's name
*
* @var string
*/
public $platformName = 'joomla3x';
/**
* The container of the Akeeba Backup component
*
* @var Container
*/
protected $container = null;
/**
* Flash variables for the CLI application. We use this array since we're hell bent on NOT using Joomla's broken
* session package.
*
* @var array
*
* @since 5.3.5
*/
protected $flashVariables = [];
/**
* Public constructor
*/
function __construct()
{
$this->container = Container::getInstance('com_akeeba');
}
public static function quirk_013()
{
$stock_dirs = Platform::getInstance()->get_stock_directories();
$default_out = @realpath($stock_dirs['[DEFAULT_OUTPUT]']);
$registry = Factory::getConfiguration();
$outdir = $registry->get('akeeba.basic.output_directory');
foreach ($stock_dirs as $macro => $replacement)
{
$outdir = str_replace($macro, $replacement, $outdir);
}
$outdir_real = @realpath($outdir);
// If the output folder is the default one (or any subdir), we are safe
if (strpos($outdir_real, $default_out) !== false)
{
return false;
}
$component_path = @realpath(JPATH_ADMINISTRATOR . '/components/com_akeeba');
$forbiddenPaths = [
'akeeba',
'AliceChecks',
'AliceEngine',
'alice',
'assets',
'Assets',
'BackupEngine',
'BackupPlatform',
'Controller',
'controllers',
'Dispatcher',
'engine',
'fields',
'Helper',
'helpers',
'Master',
'Model',
'models',
'platform',
'plugins',
'sql',
'tables',
'Toolbar',
'View',
'views',
'ViewTemplates',
];
foreach ($forbiddenPaths as $subdir)
{
$checkPath = realpath($component_path . '/' . $subdir);
if ($checkPath === false)
{
continue;
}
$checkPath .= DIRECTORY_SEPARATOR;
if (strpos($outdir_real, $checkPath) === 0)
{
return true;
}
}
return false;
}
public static function quirk_400()
{
return version_compare(JVERSION, '4.0', 'ge');
}
/**
* Loads the current configuration off the database table
*
* @param int $profile_id The profile where to read the configuration from, defaults to current profile
*
* @return bool True if everything was read properly
*/
public function load_configuration($profile_id = null, $reset = true)
{
// Load the configuration
parent::load_configuration($profile_id, $reset);
// 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([]);
$config->set('akeeba.advanced.embedded_installer', 'angie');
$config->setProtectedKeys($protectedKeys);
}
return true;
}
/**
* 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([]);
$config->set('akeeba.advanced.embedded_installer', 'angie');
$config->setProtectedKeys($protectedKeys);
}
// Save the configuration
return parent::save_configuration($profile_id);
}
/**
* Performs heuristics to determine if this platform object is the ideal
* candidate for the environment Akeeba Engine is running in.
*
* @return bool
*/
public function isThisPlatform()
{
// Make sure _JEXEC is defined
if (!defined('_JEXEC'))
{
return false;
}
// We need JVERSION to be defined
if (!defined('JVERSION'))
{
return false;
}
// Check if the Joomla Factory class exists
if (!class_exists('JFactory') && !class_exists('Joomla\CMS\Factory'))
{
return false;
}
// Check if a valid application class exists
$appExists = class_exists('Joomla\CMS\Application\CMSApplication')
|| class_exists('Joomla\CMS\Application\CliApplication')
|| class_exists('FOFApplicationCLI');
if (!$appExists)
{
return false;
}
return true;
}
/**
* Returns an associative array of stock platform directories
*
* @return array
*/
public function get_stock_directories()
{
static $stock_directories = [];
if (empty($stock_directories))
{
$jreg = $this->container->platform->getConfig();
$tmpdir = $jreg->get('tmp_path');
$stock_directories['[SITEROOT]'] = $this->get_site_root();
$stock_directories['[ROOTPARENT]'] = @realpath($this->get_site_root() . '/..');
$stock_directories['[SITETMP]'] = $tmpdir;
$stock_directories['[DEFAULT_OUTPUT]'] = $this->get_site_root() . '/administrator/components/com_akeeba/backup';
}
return $stock_directories;
}
/**
* Returns the absolute path to the site's root
*
* @return string
*/
public function get_site_root()
{
static $root = null;
if (empty($root) || is_null($root))
{
$root = JPATH_ROOT;
if (empty($root) || ($root == DIRECTORY_SEPARATOR) || ($root == '/'))
{
// Try to get the current root in a different way
if (function_exists('getcwd'))
{
$root = getcwd();
}
if ($this->container->platform->isBackend())
{
if (empty($root))
{
$root = '../';
}
else
{
$adminPos = strpos($root, 'administrator');
if ($adminPos !== false)
{
$root = substr($root, 0, $adminPos);
}
else
{
$root = '../';
}
// Degenerate case where $root = 'administrator'
// without a leading slash before entering this
// if-block
if (empty($root))
{
$root = '../';
}
}
}
else
{
if (empty($root) || ($root == DIRECTORY_SEPARATOR) || ($root == '/'))
{
$root = './';
}
}
}
if (!in_array(substr($root, -1), ['/', '\\']))
{
$root .= DIRECTORY_SEPARATOR;
}
}
return $root;
}
/**
* Returns the absolute path to the installer images directory
*
* @return string
*/
public function get_installer_images_path()
{
return JPATH_ADMINISTRATOR . '/components/com_akeeba/Master/Installers';
}
/**
* Returns the active profile number
*
* @return int
*/
public function get_active_profile()
{
// Automated testing override
if (!is_null(self::$profile_id) && (self::$profile_id > 0))
{
return self::$profile_id;
}
// Constant override
elseif (defined('AKEEBA_PROFILE'))
{
return AKEEBA_PROFILE;
}
// Use the session. If it's a CLI app always default to profile #1 (unless explicitly set otherwise)
else
{
$defaultProfile = $this->container->platform->isCli() ? 1 : null;
return $this->container->platform->getSessionVar('profile', $defaultProfile, 'akeeba');
}
}
/**
* Returns the selected profile's name. If no ID is specified, the current
* profile's name is returned.
*
* @return string
*/
public function get_profile_name($id = null)
{
if (empty($id))
{
$id = $this->get_active_profile();
}
$id = (int) $id;
$db = Factory::getDatabase($this->get_platform_database_options());
$sql = $db->getQuery(true)
->select($db->qn('description'))
->from($db->qn('#__ak_profiles'))
->where($db->qn('id') . ' = ' . $db->q($id));
$db->setQuery($sql);
return $db->loadResult();
}
/**
* Returns the backup origin
*
* @return string Backup origin: backend|frontend
*/
public function get_backup_origin()
{
if (defined('AKEEBA_BACKUP_ORIGIN'))
{
return AKEEBA_BACKUP_ORIGIN;
}
if ($this->container->platform->isBackend())
{
return 'backend';
}
if ($this->container->platform->isFrontend())
{
return 'frontend';
}
return 'cli';
}
/**
* Returns a MySQL-formatted timestamp out of the current date
*
* @param string $date [optional] The timestamp to use. Omit to use current timestamp.
*
* @return string
*/
public function get_timestamp_database($date = 'now')
{
$date = new Date($date);
if (method_exists($date, 'toSql'))
{
return $date->toSql();
}
if (method_exists($date, 'toMySQL'))
{
return $date->toMySQL();
}
return '0000-00-00 00:00:00';
}
/**
* Returns the current timestamp, taking into account any TZ information,
* in the format specified by $format.
*
* @param string $format Timestamp format string (standard PHP format string)
*
* @return string
*/
public function get_local_timestamp($format)
{
// Do I have a forced timezone?
$tz = $this->get_platform_configuration_option('forced_backup_timezone', 'AKEEBA/DEFAULT');
// No forced timezone set? Use the default Joomla! behavior.
if (empty($tz) || ($tz == 'AKEEBA/DEFAULT'))
{
$tz = $this->getJoomlaTimezone();
}
$utcTimeZone = new DateTimeZone('UTC');
$dateNow = new Date('now', $utcTimeZone);
$timezone = new DateTimeZone($tz);
$dateNow->setTimezone($timezone);
return $dateNow->format($format, true);
}
/**
* Returns the current host name
*
* @return string
*/
public function get_host()
{
if ($this->container->platform->isCli())
{
$url = Platform::getInstance()->get_platform_configuration_option('siteurl', '');
$oURI = new Uri($url);
}
else
{
// Running under the web server
$oURI = Uri::getInstance();
}
return $oURI->getHost();
}
public function get_site_name()
{
$jconfig = $this->container->platform->getConfig();
return $jconfig->get('sitename', '');
}
/**
* Gets the best matching database driver class, according to CMS settings
*
* @param bool $use_platform If set to false, it will forcibly try to assign one of the primitive type
* (Mysql/Mysqli) and NEVER tell you to use a platform driver.
*
* @return string
*/
public function get_default_database_driver($use_platform = true)
{
$jconfig = $this->container->platform->getConfig();
$driver = $jconfig->get('dbtype');
$driver = strtolower($driver);
$hasPdo = class_exists('\PDO');
$hasMySQL = function_exists('mysql_connect');
$hasMySQLi = function_exists('mysqli_connect');
// Prime with a default return value, favoring PDO MySQL if available
$defaultDriver = Pdomysql::class;
if (!$hasPdo)
{
// Second best choice is MySQLi
$defaultDriver = Mysqli::class;
// Third best choice is MySQL
if (!$hasMySQLi && $hasMySQL)
{
$defaultDriver = Mysql::class;
}
}
// Let's see what driver Joomla! uses...
if ($use_platform)
{
$hasNookuContent = file_exists(JPATH_ROOT . '/plugins/system/nooku.php');
switch ($driver)
{
// MySQL or MySQLi drivers are known to be working; use their
// Akeeba Engine extended version, Akeeba\Engine\Driver\Joomla
case 'mysql':
// So, Joomla! 4's "mysql" is, actually, "pdomysql". Therefore I can use our own wrapper driver
if (version_compare(JVERSION, '3.999.999', 'gt'))
{
return Joomla::class;
}
// The piece of crap called FaLang is lying about the database driver
if (!$hasMySQL)
{
return Mysqli::class;
}
if ($hasNookuContent)
{
return Mysql::class;
}
return Joomla::class;
break;
case 'mysqli':
if ($hasNookuContent)
{
return Mysqli::class;
}
return Joomla::class;
break;
// Any other case, use our platform-specific driver
default:
return Joomla::class;
break;
}
}
// Is this a subcase of mysqli or mysql drivers?
if (substr($driver, 0, 8) == 'pdomysql')
{
return Pdomysql::class;
}
elseif (substr($driver, 0, 6) == 'mysqli')
{
return Mysqli::class;
}
elseif (substr($driver, 0, 5) == 'mysql')
{
// The piece of crap called FaLang is lying about the database driver
if (!$hasMySQL)
{
return Mysqli::class;
}
return Mysql::class;
}
// Sometimes we get driver names in the form of foomysql instead of mysqlfoo. Let's look for that too.
if (substr($driver, -8) == 'pdomysql')
{
return Pdomysql::class;
}
elseif (substr($driver, -6) == 'mysqli')
{
return Mysqli::class;
}
elseif (substr($driver, -5) == 'mysql')
{
/**
* Apparently there are some folks of dubious intelligence out there writing custom database drivers without
* understanding or caring about the differences between mysql and mysqli drivers in PHP. They don't play
* nice but I have my way to work around their ignorance, FORCING mysqli when they erroneously report mysql
* on servers which no longer support this ancient, obsolete database connector. Of course the proper way
* to address this would be having these folks fix their broken software but I think I'm asking for too
* much. They know who they are, fa la la...
*/
if (!$hasMySQL)
{
return Mysqli::class;
}
return Mysql::class;
}
// I give up! You'd better be usign a MySQL db server.
return $defaultDriver;
}
/**
* Returns a set of options to connect to the default database of the current CMS
*
* @return array
*/
public function get_platform_database_options()
{
static $options;
if (empty($options))
{
$conf = $this->container->platform->getConfig();
$options = [
'host' => $conf->get('host'),
'user' => $conf->get('user'),
'password' => $conf->get('password'),
'database' => $conf->get('db'),
'prefix' => $conf->get('dbprefix'),
];
}
return $options;
}
/**
* Provides a platform-specific translation function
*
* @param string $key The translation key
*
* @return string
*/
public function translate($key)
{
return Text::_($key);
}
/**
* Populates global constants holding the Akeeba version
*/
public function load_version_defines()
{
$basePath = JPATH_ADMINISTRATOR . '/components/com_akeeba';
if (file_exists($basePath . '/version.php'))
{
require_once($basePath . '/version.php');
}
if (!defined('AKEEBA_VERSION'))
{
define("AKEEBA_VERSION", "dev");
}
if (!defined('AKEEBA_PRO'))
{
define('AKEEBA_PRO', false);
}
if (!defined('AKEEBA_DATE'))
{
$date = new Date();
define("AKEEBA_DATE", $date->format('Y-m-d'));
}
}
/**
* Returns the platform name and version
*
* @param string $platform_name Name of the platform, e.g. Joomla!
* @param string $version Full version of the platform
*/
public function getPlatformVersion()
{
$v = new Version();
return [
'name' => 'Joomla!',
'version' => $v->getShortVersion(),
];
}
/**
* Logs platform-specific directories with LogLevel::INFO log level
*/
public function log_platform_special_directories()
{
$ret = [];
Factory::getLog()->log(LogLevel::INFO, "JPATH_BASE :" . JPATH_BASE, ['translate_root' => false]);
Factory::getLog()->log(LogLevel::INFO, "JPATH_SITE :" . JPATH_SITE, ['translate_root' => false]);
Factory::getLog()->log(LogLevel::INFO, "JPATH_ROOT :" . JPATH_ROOT, ['translate_root' => false]);
Factory::getLog()->log(LogLevel::INFO, "JPATH_CACHE :" . JPATH_CACHE, ['translate_root' => false]);
Factory::getLog()->log(LogLevel::INFO, "Computed <root> :" . $this->get_site_root(), ['translate_root' => false]);
// If the release is older than 3 months, issue a warning
if (defined('AKEEBA_DATE'))
{
$releaseDate = new Date(AKEEBA_DATE);
if (time() - $releaseDate->toUnix() > 10368000)
{
if (!isset($ret['warnings']))
{
$ret['warnings'] = [];
$ret['warnings'] = array_merge($ret['warnings'], [
'Your version of Akeeba Backup is more than 120 days old and most likely already out of date. Please check if a newer version is published and install it.',
]);
}
}
}
// Detect UNC paths and warn the user
if (DIRECTORY_SEPARATOR == '\\')
{
if ((substr(JPATH_ROOT, 0, 2) == '\\\\') || (substr(JPATH_ROOT, 0, 2) == '//'))
{
if (!isset($ret['warnings']))
{
$ret['warnings'] = [];
}
$ret['warnings'] = array_merge($ret['warnings'], [
'Your site\'s root is using a UNC path (e.g. \\\\SERVER\\path\\to\\root). PHP has known bugs which may',
'prevent it from working properly on a site like this. Please take a look at',
'https://bugs.php.net/bug.php?id=40163 and https://bugs.php.net/bug.php?id=52376. As a result your',
'backup may fail.',
]);
}
}
if (empty($ret))
{
$ret = null;
}
return $ret;
}
/**
* Loads a platform-specific software configuration option
*
* @param string $key
* @param mixed $default
*
* @return mixed
*/
public function get_platform_configuration_option($key, $default)
{
$value = $this->container->params->get($key, $default);
// Some configuration options may have to be decrypted
switch ($key)
{
case 'frontend_secret_word':
$secureSettings = Factory::getSecureSettings();
$value = $secureSettings->decryptSettings($value);
break;
}
return $value;
}
/**
* Returns a list of emails to the Super Administrators
*
* @return array
*/
public function get_administrator_emails()
{
$options = $this->get_platform_database_options();
$db = Factory::getDatabase($options);
// Get all usergroups with Super User access
$q = $db->getQuery(true)
->select([$db->qn('id')])
->from($db->qn('#__usergroups'));
$groups = $db->setQuery($q)->loadColumn();
// Get the groups that are Super Users
$groups = array_filter($groups, function ($gid) {
return Access::checkGroup($gid, 'core.admin');
});
$mails = [];
foreach ($groups as $gid)
{
$uids = Access::getUsersByGroup($gid);
array_walk($uids, function ($uid, $index) use (&$mails) {
$mails[] = $this->container->platform->getUser($uid)->email;
});
}
return array_unique($mails);
}
/**
* Sends a very simple email using the platform's mailer facility
*
* @param string $to The recipient's email address
* @param string $subject The subject of the email
* @param string $body The body of the email
* @param string $attachFile The file to attach (null to not attach any files)
*
* @return boolean
*/
public function send_email($to, $subject, $body, $attachFile = null)
{
Factory::getLog()->log(LogLevel::DEBUG, "-- Fetching mailer object");
/** @var JMail $mailer */
try
{
$mailer = Platform::getInstance()->getMailer();
}
catch (Exception $e)
{
$mailer = null;
}
if (!is_object($mailer))
{
Factory::getLog()->log(LogLevel::WARNING, "Could not send email to $to - Joomla! cannot send e-mails. Please check your From EMail and From Name fields in Global Configuration.");
return false;
}
Factory::getLog()->log(LogLevel::DEBUG, "-- Creating email message");
try
{
$recipient = [$to];
$mailer->addRecipient($recipient);
$mailer->setSubject($subject);
$mailer->setBody($body);
}
catch (Exception $e)
{
Factory::getLog()->log(LogLevel::WARNING, "Could not send email to $to - Problem setting up the email. Joomla! reports error: " . $e->getMessage());
return false;
}
try
{
if (!empty($attachFile))
{
Factory::getLog()->log(LogLevel::INFO, "-- Attaching $attachFile");
if (!file_exists($attachFile) || !(is_file($attachFile) || is_link($attachFile)))
{
Factory::getLog()->log(LogLevel::WARNING, "The file does not exist, or it's not a file; no email sent");
return false;
}
if (!is_readable($attachFile))
{
Factory::getLog()->log(LogLevel::WARNING, "The file is not readable; no email sent");
return false;
}
$filesize = @filesize($attachFile);
if ($filesize)
{
// Check that we have AT LEAST 2.5 times free RAM as the filesize (that's how much we'll need)
if (!function_exists('ini_get'))
{
// Assume 8Mb of PHP memory limit (worst case scenario)
$totalRAM = 8388608;
}
else
{
$totalRAM = ini_get('memory_limit');
if (strstr($totalRAM, 'M'))
{
$totalRAM = (int) $totalRAM * 1048576;
}
elseif (strstr($totalRAM, 'K'))
{
$totalRAM = (int) $totalRAM * 1024;
}
elseif (strstr($totalRAM, 'G'))
{
$totalRAM = (int) $totalRAM * 1073741824;
}
else
{
$totalRAM = (int) $totalRAM;
}
if ($totalRAM <= 0)
{
// No memory limit? Cool! Assume 1Gb of available RAM (which is absurdely abundant as of March 2011...)
$totalRAM = 1086373952;
}
}
if (!function_exists('memory_get_usage'))
{
$usedRAM = 8388608;
}
else
{
$usedRAM = memory_get_usage();
}
$availableRAM = $totalRAM - $usedRAM;
if ($availableRAM < 2.5 * $filesize)
{
Factory::getLog()->log(LogLevel::WARNING, "The file is too big to be sent by email. Please use a smaller Part Size for Split Archives setting.");
Factory::getLog()->log(LogLevel::DEBUG, "Memory limit $totalRAM bytes -- Used memory $usedRAM bytes -- File size $filesize -- Attachment requires approx. " . (2.5 * $filesize) . " bytes");
return false;
}
}
else
{
Factory::getLog()->log(LogLevel::WARNING, "Your server fails to report the file size of $attachFile. If the backup crashes, please use a smaller Part Size for Split Archives setting");
}
$mailer->addAttachment($attachFile);
}
}
catch (Exception $e)
{
Factory::getLog()->log(LogLevel::WARNING, "Could not send email to $to - Problem attaching file. Joomla! reports error: " . $e->getMessage());
return false;
}
Factory::getLog()->log(LogLevel::DEBUG, "-- Sending message");
try
{
$result = $mailer->Send();
}
catch (Exception $e)
{
$result = $e;
}
if ($result instanceof Exception)
{
Factory::getLog()->log(LogLevel::WARNING, "Could not email $to:");
Factory::getLog()->log(LogLevel::WARNING, $result->getMessage());
$ret = $result->getMessage();
unset($result);
unset($mailer);
return $ret;
}
Factory::getLog()->log(LogLevel::DEBUG, "-- Email sent");
return true;
}
/**
* Deletes a file from the local server using direct file access or FTP
*
* @param string $file
*
* @return bool
*/
public function unlink($file)
{
if (function_exists('jimport'))
{
$result = File::delete($file);
if (!$result)
{
$result = @unlink($file);
}
}
else
{
$result = parent::unlink($file);
}
return $result;
}
/**
* Moves a file around within the local server using direct file access or FTP
*
* @param string $from
* @param string $to
*
* @return bool
*/
public function move($from, $to)
{
if (function_exists('jimport'))
{
$result = File::move($from, $to);
// JFile failed. Let's try rename()
if (!$result)
{
$result = @rename($from, $to);
}
// Rename failed, too. Let's try copy/delete
if (!$result)
{
// Try copying with JFile. If it fails, use copy().
$result = File::copy($from, $to);
if (!$result)
{
$result = @copy($from, $to);
}
// If the copy succeeded, try deleting the original with JFile. If it fails, use unlink().
if ($result)
{
$result = $this->unlink($from);
}
}
}
else
{
$result = parent::move($from, $to);
}
return $result;
}
/**
* Joomla!-specific function to get an instance of the mailer class
*
* @return Mail
*/
public function &getMailer()
{
$mailer = \Joomla\CMS\Factory::getMailer();
if (!is_object($mailer))
{
Factory::getLog()->log(LogLevel::WARNING, "Fetching Joomla!'s mailer was impossible; imminent crash!");
}
else
{
$emailMethod = $mailer->Mailer;
Factory::getLog()->log(LogLevel::DEBUG, "-- Joomla!'s mailer is using $emailMethod mail method.");
}
return $mailer;
}
/**
* Stores a flash (temporary) variable in the session.
*
* @param string $name The name of the variable to store
* @param string $value The value of the variable to store
*
* @return void
*/
public function set_flash_variable($name, $value)
{
if ($this->container->platform->isCli())
{
$this->flashVariables[$name] = $value;
return;
}
$this->container->platform->setSessionVar($name, $value, 'akeeba');
}
/**
* Return the value of a flash (temporary) variable from the session and
* immediately removes it.
*
* @param string $name The name of the flash variable
* @param mixed $default Default value, if the variable is not defined
*
* @return mixed The value of the variable or $default if it's not set
*/
public function get_flash_variable($name, $default = null)
{
if ($this->container->platform->isCli())
{
$ret = $default;
if (isset($this->flashVariables[$name]))
{
$ret = $this->flashVariables[$name];
unset($this->flashVariables[$name]);
}
return $ret;
}
$ret = $this->container->platform->getSessionVar($name, $default, 'akeeba');
$this->container->platform->setSessionVar($name, null, 'akeeba');
return $ret;
}
/**
* Perform an immediate redirection to the defined URL
*
* @param string $url The URL to redirect to
*
* @return void
*/
public function redirect($url)
{
$this->container->platform->redirect($url);
}
public function apply_quirk_definitions()
{
Factory::getConfigurationChecks()->addConfigurationCheckDefinition('013', 'critical', 'COM_AKEEBA_CPANEL_WARNING_Q013', [
Joomla3x::class, 'quirk_013',
]);
Factory::getConfigurationChecks()->addConfigurationCheckDefinition('400', 'critical', 'COM_AKEEBA_CPANEL_WARNING_Q400', [
Joomla3x::class, 'quirk_400',
]);
}
/** @inheritdoc */
protected function detectProxySettings()
{
try
{
$app = \Joomla\CMS\Factory::getApplication();
}
catch (Exception $e)
{
$this->proxyEnabled = false;
$this->hasInitialisedProxySettings = true;
}
$enabled = $app->get('proxy_enable', false);
$host = $app->get('proxy_host', '');
$port = (int) $app->get('proxy_port', 8080);
$user = $app->get('proxy_user', '');
$pass = $app->get('proxy_pass', '');
$this->setProxySettings($enabled, $host, $port, $user, $pass);
}
/**
* Registers Akeeba Engine's core classes with JLoader
*
* @param string $path_prefix The path prefix to look in
*/
protected function register_akeeba_engine_classes($path_prefix)
{
global $Akeeba_Class_Map;
foreach ($Akeeba_Class_Map as $class_prefix => $path_suffix)
{
// Bail out if there is such directory, so as not to have Joomla! throw errors
if (!@is_dir($path_prefix . '/' . $path_suffix))
{
continue;
}
$file_list = Folder::files($path_prefix . '/' . $path_suffix, '.*\.php');
if (is_array($file_list) && !empty($file_list))
{
foreach ($file_list as $file)
{
$class_suffix = ucfirst(basename($file, '.php'));
JLoader::register($class_prefix . $class_suffix, $path_prefix . '/' . $path_suffix . '/' . $file);
}
}
}
}
/**
* Get the applicable timezone in the same way Joomla! calculates it: if there is a logged in
* user with a specific timezone set, use it. Otherwise use the Server Timezone defined in the
* site's Global Configuration. If nothing is set there, use GMT instead.
*
* @return string
*/
private function getJoomlaTimezone()
{
// Out ultimate default is the server timezone set up in the Global Configuration
$jregistry = $this->container->platform->getConfig();
$tz = $jregistry->get('offset', 'GMT');
// If this is a CLI script, tough luck, we can't use a different TZ
if ($this->container->platform->isCli())
{
return $tz;
}
// If it's a guest user they can't have a special TZ set, return.
$user = $this->container->platform->getUser();
if ($user->guest)
{
return $tz;
}
$tz = $user->getParam('timezone', $tz);
return $tz;
}
}
Joomla3x/Driver/Joomla.php 0000604 00000010513 15245630146 0011427 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Engine\Driver;
// Protection against direct access
defined('AKEEBAENGINE') || die();
use Akeeba\Engine\Platform;
use Exception;
use Joomla\CMS\Factory;
class Joomla
{
/** @var Base The real database connection object */
private $dbo;
/**
* Database object constructor
*
* @param array $options List of options used to configure the connection
*/
public function __construct($options = [])
{
// Get best matching Akeeba Backup driver instance
if (class_exists('JFactory'))
{
// Get the database driver *AND* make sure it's connected.
$db = Factory::getDBO();
$db->connect();
$options['connection'] = $db->getConnection();
switch ($db->name)
{
case 'mysql':
// So, Joomla! 4's "mysql" is, actually, "pdomysql".
$driver = 'mysql';
if (version_compare(JVERSION, '3.999.999', 'gt'))
{
$driver = 'pdomysql';
}
break;
case 'mysqli':
$driver = 'mysqli';
break;
case 'pdomysql':
$driver = 'pdomysql';
break;
default:
throw new \RuntimeException("Unsupported database driver {$db->name}");
break;
}
$driver = '\\Akeeba\\Engine\\Driver\\' . ucfirst($driver);
}
else
{
$driver = Platform::getInstance()->get_default_database_driver(false);
}
$this->dbo = new $driver($options);
}
public function close()
{
/**
* We should not, in fact, try to close the connection by calling the parent method.
*
* If you close the connection we ask PHP's mysql / mysqli / pdomysql driver to disconnect the MySQL connection
* resource from the database server inside our instance of Akeeba Engine's database driver. However, this
* identical resource is also present in Joomla's database driver. Joomla will also try to close the connection
* to a now invalid resource, causing a PHP notice to be recorded.
*
* By setting the connection resource to null in our own driver object we prevent closing the resource,
* delegating that responsibility to Joomla. It will gladly do so at the very least automatically, through its
* db driver's __destruct.
*/
$this->dbo->setConnection(null);
}
public function open()
{
if (method_exists($this->dbo, 'open'))
{
$this->dbo->open();
}
elseif (method_exists($this->dbo, 'connect'))
{
$this->dbo->connect();
}
}
/**
* Magic method to proxy all calls to the loaded database driver object
*
* @throws Exception
*/
public function __call($name, array $arguments)
{
if (is_null($this->dbo))
{
throw new Exception('Akeeba Engine database driver is not loaded');
}
if (method_exists($this->dbo, $name) || in_array($name, ['q', 'nq', 'qn']))
{
// Call_user_func_array is ~3 times slower than direct method calls.
// (thank you, Nooku Framework, for the tip!)
switch (count($arguments))
{
case 0 :
$result = $this->dbo->$name();
break;
case 1 :
$result = $this->dbo->$name($arguments[0]);
break;
case 2:
$result = $this->dbo->$name($arguments[0], $arguments[1]);
break;
case 3:
$result = $this->dbo->$name($arguments[0], $arguments[1], $arguments[2]);
break;
case 4:
$result = $this->dbo->$name($arguments[0], $arguments[1], $arguments[2], $arguments[3]);
break;
case 5:
$result = $this->dbo->$name($arguments[0], $arguments[1], $arguments[2], $arguments[3], $arguments[4]);
break;
default:
// Resort to using call_user_func_array for many segments
$result = call_user_func_array([$this->dbo, $name], $arguments);
}
return $result;
}
else
{
throw new Exception('Method ' . $name . ' not found in Akeeba Platform');
}
}
public function __get($name)
{
if (isset($this->dbo->$name) || property_exists($this->dbo, $name))
{
return $this->dbo->$name;
}
else
{
$this->dbo->$name = null;
user_error('Database driver does not support property ' . $name);
}
return null;
}
public function __set($name, $value)
{
if (isset($this->dbo->name) || property_exists($this->dbo, $name))
{
$this->dbo->$name = $value;
}
else
{
$this->dbo->$name = null;
user_error('Database driver not support property ' . $name);
}
}
}
Joomla3x/Config/02.advanced.json 0000604 00000002732 15245630146 0012333 0 ustar 00 {
"_group": {
"description": "COM_AKEEBA_CONFIG_ADVANCED"
},
"akeeba.advanced.dump_engine": {
"default": "native",
"type": "engine",
"subtype": "dump",
"title": "COM_AKEEBA_CONFIG_DUMPENGINE_TITLE",
"description": "COM_AKEEBA_CONFIG_DUMPENGINE_DESCRIPTION",
"protected": "0"
},
"akeeba.advanced.scan_engine": {
"default": "smart",
"type": "engine",
"subtype": "scan",
"protected": "1",
"title": "COM_AKEEBA_CONFIG_SCANENGINE_TITLE",
"description": "COM_AKEEBA_CONFIG_SCANENGINE_DESCRIPTION"
},
"akeeba.advanced.archiver_engine": {
"default": "jpa",
"type": "engine",
"subtype": "archiver",
"title": "COM_AKEEBA_CONFIG_ARCHIVERENGINE_TITLE",
"description": "COM_AKEEBA_CONFIG_ARCHIVERENGINE_DESCRIPTION"
},
"akeeba.advanced.postproc_engine": {
"default": "none",
"type": "none",
"protected": "1"
},
"akeeba.advanced.embedded_installer": {
"default": "angie",
"type": "installer",
"title": "COM_AKEEBA_CONFIG_INSTALLER_TITLE",
"description": "COM_AKEEBA_CONFIG_INSTALLER_DESCRIPTION",
"protected": "0"
},
"engine.installer.angie.key": {
"default": "",
"type": "password",
"title": "COM_AKEEBA_CONFIG_ANGIE_KEY_TITLE",
"description": "COM_AKEEBA_CONFIG_ANGIE_KEY_DESCRIPTION",
"protected": "0"
}
} Joomla3x/Filter/Joomlaskipfiles.php 0000604 00000010141 15245630146 0013330 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Engine\Filter;
// Protection against direct access
defined('AKEEBAENGINE') || die();
use Akeeba\Engine\Factory;
use Akeeba\Engine\Platform;
use FOF40\Container\Container;
/**
* Subdirectories exclusion filter. Excludes temporary, cache and backup output
* directories' contents from being backed up.
*/
class Joomlaskipfiles extends Base
{
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();
$container = Container::getInstance('com_akeeba');
$jreg = $container->platform->getConfig();
$tmpdir = $jreg->get('tmp_path');
$logsdir = $jreg->get('log_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] = [
// Output & temp directory of the component
$this->treatDirectory($configuration->get('akeeba.basic.output_directory')),
// Joomla! temporary directory
$this->treatDirectory($tmpdir),
// Joomla! logs directory
$this->treatDirectory($logsdir),
// default temp directory
$this->treatDirectory(JPATH_SITE . '/tmp'),
'tmp',
$this->treatDirectory(Platform::getInstance()->get_site_root() . '/tmp'),
// Joomla! front- and back-end cache, as reported by Joomla!
$this->treatDirectory(JPATH_CACHE),
$this->treatDirectory(JPATH_ADMINISTRATOR . '/cache'),
$this->treatDirectory(JPATH_ROOT . '/cache'),
// cache directories fallback
'cache',
'administrator/cache',
// Joomla! front- and back-end cache, as calculated by us (redundancy, for funky server setups)
$this->treatDirectory(Platform::getInstance()->get_site_root() . '/cache'),
$this->treatDirectory(Platform::getInstance()->get_site_root() . '/administrator/cache'),
// This is not needed except on sites running SVN or beta releases
$this->treatDirectory(JPATH_ROOT . '/installation'),
// ...and the fallbacks
'installation',
$this->treatDirectory(Platform::getInstance()->get_site_root() . '/installation'),
// Default backup output (many people change it, forget to remove old backup archives and they end up backing up old backups)
$this->treatDirectory(JPATH_ADMINISTRATOR . '/components/com_akeeba/backup'),
'administrator/components/com_akeeba/backup',
$this->treatDirectory(Platform::getInstance()->get_site_root() . '/administrator/components/com_akeeba/backup'),
// MyBlog's cache
$this->treatDirectory(JPATH_SITE . '/components/libraries/cmslib/cache'),
// ...and fallbacks
'components/libraries/cmslib/cache',
$this->treatDirectory(Platform::getInstance()->get_site_root() . '/components/libraries/cmslib/cache'),
// Used by Plesk to store its logs. It's in the public root, owned by root and read-only. Yipee!
$this->treatDirectory(JPATH_ROOT . '/logs'),
'logs',
$this->treatDirectory(Platform::getInstance()->get_site_root() . '/logs'),
// Some developers hardcode this path for their log files. I guess they never heard of Joomla!'s Global Configuration?
$this->treatDirectory(JPATH_ROOT . '/log'),
'log',
$this->treatDirectory(Platform::getInstance()->get_site_root() . '/log'),
// Joomla! 3.6 is loads of fun. It changed the logs folder location.
$this->treatDirectory(JPATH_ADMINISTRATOR . '/logs'),
'administrator/logs',
$this->treatDirectory(Platform::getInstance()->get_site_root() . '/administrator/logs'),
// Also in case a Joomla! 3.6 site admin cocks up, let's try a singular folder name.
$this->treatDirectory(JPATH_ADMINISTRATOR . '/log'),
'administrator/log',
$this->treatDirectory(Platform::getInstance()->get_site_root() . '/administrator/log'),
];
parent::__construct();
}
}
Joomla3x/Filter/Excludetabledata.php 0000604 00000001643 15245630146 0013437 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Engine\Filter;
// Protection against direct access
defined('AKEEBAENGINE') || die();
use Akeeba\Engine\Factory;
/**
* Subdirectories exclusion filter. Excludes temporary, cache and backup output
* directories' contents from being backed up.
*/
class Excludetabledata extends Base
{
public function __construct()
{
$this->object = 'dbobject';
$this->subtype = 'content';
$this->method = 'direct';
$this->filter_name = 'Excludetabledata';
// We take advantage of the filter class magic to inject our custom filters
$this->filter_data['[SITEDB]'] = array(
'#__session', // Sessions table
'#__guardxt_runs' // Guard XT's run log (bloated to the bone)
);
parent::__construct();
}
}
Joomla3x/Filter/Joomlaskipdirs.php 0000604 00000010140 15245630146 0013166 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Engine\Filter;
// Protection against direct access
defined('AKEEBAENGINE') || die();
use Akeeba\Engine\Factory;
use Akeeba\Engine\Platform;
use FOF40\Container\Container;
/**
* Subdirectories exclusion filter. Excludes temporary, cache and backup output
* directories' contents from being backed up.
*/
class Joomlaskipdirs extends Base
{
public function __construct()
{
$this->object = 'dir';
$this->subtype = 'children';
$this->method = 'direct';
$this->filter_name = 'Joomlaskipdirs';
// We take advantage of the filter class magic to inject our custom filters
$configuration = Factory::getConfiguration();
$container = Container::getInstance('com_akeeba');
$jreg = $container->platform->getConfig();
$tmpdir = $jreg->get('tmp_path');
$logsdir = $jreg->get('log_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] = [
// Output & temp directory of the component
$this->treatDirectory($configuration->get('akeeba.basic.output_directory')),
// Joomla! temporary directory
$this->treatDirectory($tmpdir),
// Joomla! logs directory
$this->treatDirectory($logsdir),
// default temp directory
$this->treatDirectory(JPATH_SITE . '/tmp'),
'tmp',
$this->treatDirectory(Platform::getInstance()->get_site_root() . '/tmp'),
// Joomla! front- and back-end cache, as reported by Joomla!
$this->treatDirectory(JPATH_CACHE),
$this->treatDirectory(JPATH_ADMINISTRATOR . '/cache'),
$this->treatDirectory(JPATH_ROOT . '/cache'),
// cache directories fallback
'cache',
'administrator/cache',
// Joomla! front- and back-end cache, as calculated by us (redundancy, for funky server setups)
$this->treatDirectory(Platform::getInstance()->get_site_root() . '/cache'),
$this->treatDirectory(Platform::getInstance()->get_site_root() . '/administrator/cache'),
// This is not needed except on sites running SVN or beta releases
$this->treatDirectory(JPATH_ROOT . '/installation'),
// ...and the fallbacks
'installation',
$this->treatDirectory(Platform::getInstance()->get_site_root() . '/installation'),
// Default backup output (many people change it, forget to remove old backup archives and they end up backing up old backups)
$this->treatDirectory(JPATH_ADMINISTRATOR . '/components/com_akeeba/backup'),
'administrator/components/com_akeeba/backup',
$this->treatDirectory(Platform::getInstance()->get_site_root() . '/administrator/components/com_akeeba/backup'),
// MyBlog's cache
$this->treatDirectory(JPATH_SITE . '/components/libraries/cmslib/cache'),
// ...and fallbacks
'components/libraries/cmslib/cache',
$this->treatDirectory(Platform::getInstance()->get_site_root() . '/components/libraries/cmslib/cache'),
// Used by Plesk to store its logs. It's in the public root, owned by root and read-only. Yipee!
$this->treatDirectory(JPATH_ROOT . '/logs'),
'logs',
$this->treatDirectory(Platform::getInstance()->get_site_root() . '/logs'),
// Some developers hardcode this path for their log files. I guess they never heard of Joomla!'s Global Configuration?
$this->treatDirectory(JPATH_ROOT . '/log'),
'log',
$this->treatDirectory(Platform::getInstance()->get_site_root() . '/log'),
// Joomla! 3.6 is loads of fun. It changed the logs folder location.
$this->treatDirectory(JPATH_ADMINISTRATOR . '/logs'),
'administrator/logs',
$this->treatDirectory(Platform::getInstance()->get_site_root() . '/administrator/logs'),
// Also in case a Joomla! 3.6 site admin cocks up, let's try a singular folder name.
$this->treatDirectory(JPATH_ADMINISTRATOR . '/log'),
'administrator/log',
$this->treatDirectory(Platform::getInstance()->get_site_root() . '/administrator/log'),
];
parent::__construct();
}
}
Joomla3x/Filter/Cvsfolders.php 0000604 00000002051 15245630146 0012310 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Engine\Filter;
// Protection against direct access
defined('AKEEBAENGINE') || die();
use Akeeba\Engine\Factory;
/**
* Folder exclusion filter based on regular expressions
*/
class Cvsfolders extends Base
{
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$#'
);
}
}
Joomla3x/Filter/Siteroot.php 0000604 00000002225 15245630146 0012011 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Engine\Filter;
// Protection against direct access
defined('AKEEBAENGINE') || die();
use Akeeba\Engine\Factory;
/**
* Add site's root to the backup set.
*/
class Siteroot extends Base
{
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();
}
}
Joomla3x/Filter/Systemcachefiles.php 0000604 00000002150 15245630146 0013471 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Engine\Filter;
// Protection against direct access
defined('AKEEBAENGINE') || die();
use Akeeba\Engine\Factory;
/**
* Files exclusion filter based on regular expressions
*/
class Systemcachefiles extends Base
{
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',
'#^core\.[\d]{1,10}$#i',
);
}
}
Joomla3x/Filter/Libraries.php 0000604 00000003750 15245630146 0012121 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Engine\Filter;
// Protection against direct access
defined('AKEEBAENGINE') || die();
use Akeeba\Engine\Factory;
use Akeeba\Engine\Platform;
/**
* Joomla! 1.6 libraries off-site relocation workaround
*
* After the application of patch 23377
* (http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=23377)
* it is possible for the webmaster to move the libraries directory of his Joomla!
* site to an arbitrary location in the folder tree. This filter works around this
* new feature by creating a new extra directory inclusion filter.
*/
class Libraries extends Base
{
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();
}
}
Joomla3x/Filter/Stack/finder.json 0000604 00000000424 15245630146 0012676 0 ustar 00 {
"core.filters.finder.enabled": {
"default": "1",
"type": "bool",
"title": "COM_AKEEBA_CONFIG_OPTIONALFILTERS_FINDER_ENABLED_TITLE",
"description": "COM_AKEEBA_CONFIG_OPTIONALFILTERS_FINDER_ENABLED_DESCRIPTION",
"bold": "1"
}
} Joomla3x/Filter/Stack/actionlogs.json 0000604 00000000440 15245630146 0013567 0 ustar 00 {
"core.filters.actionlogs.enabled": {
"default": "1",
"type": "bool",
"title": "COM_AKEEBA_CONFIG_OPTIONALFILTERS_ACTIONLOGS_ENABLED_TITLE",
"description": "COM_AKEEBA_CONFIG_OPTIONALFILTERS_ACTIONLOGS_ENABLED_DESCRIPTION",
"bold": "1"
}
} Joomla3x/Filter/Stack/StackFinder.php 0000604 00000006407 15245630146 0013451 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Engine\Filter\Stack;
// Protection against direct access
defined('AKEEBAENGINE') || die();
use Akeeba\Engine\Factory;
use Akeeba\Engine\Filter\Base as FilterBase;
/**
* Date conditional filter
*
* It will only backup files modified after a specific date and time
*
* @since 3.4.0
*/
class StackFinder extends FilterBase
{
/** @inheritDoc */
public function __construct()
{
parent::__construct();
$this->object = 'dbobject';
$this->subtype = 'content';
$this->method = 'api';
}
/**
* Extra SQL statements to append to the SQL dump file.
*
* Joomla 4's #__finder_taxonomy table is a tree. We always need a root node. This adds the root node back to the
* tree even though we just excluded it.
*
* @param string $root The database for which to get the extra SQL statements
*
* @return string Extra SQL statements
*
* @since 7.2.0
*/
public function getExtraSQL(string $root): array
{
// Only run on Joomla! 4 and for the main site database
if (($root != '[SITEDB]') || !version_compare(JVERSION, '3.999.999', 'gt'))
{
return [];
}
// Get the SQL query, constructed correctly for the DB technology in use.
$db = Factory::getDatabase();
$sql = (string) $db->getQuery(true)
->insert($db->quoteName('#__finder_taxonomy'))
->columns(array_map([$db, 'quoteName'], [
'id', 'parent_id', 'lft', 'rgt', 'level', 'path', 'title', 'alias', 'state', 'access', 'language',
]))
->values(implode(", ", array_map([$db, 'quote'], [
1, 0, 0, 1, 0, '', 'ROOT', 'root', 1, 1, '*',
])));
// Make sure there's a trailing semicolon before returning the SQL query.
$sql = rtrim(trim($sql), ';') . ';';
return [$sql];
}
/**
* This method must be overriden by API-type exclusion filters.
*
* @param string $test The object to test for exclusion
* @param string $root The object's root
*
* @return bool Return true if it matches your filters
*
* @since 3.4.0
*/
protected function is_excluded_by_api($test, $root)
{
static $finderTables = [
/**
* Common tables, J3 and J4.
*
* Note that the taxonomy table contents are removed BUT the root node for Joomla 4 is added back with the
* getExtraSQL() method trick.
*/
'#__finder_links', '#__finder_taxonomy', '#__finder_taxonomy_map', '#__finder_terms',
// Joomla 3 only
'#__finder_links_terms0', '#__finder_links_terms1',
'#__finder_links_terms2', '#__finder_links_terms3', '#__finder_links_terms4',
'#__finder_links_terms5', '#__finder_links_terms6', '#__finder_links_terms7',
'#__finder_links_terms8', '#__finder_links_terms9', '#__finder_links_termsa',
'#__finder_links_termsb', '#__finder_links_termsc', '#__finder_links_termsd',
'#__finder_links_termse', '#__finder_links_termsf',
// Joomla 4 only
'#__finder_links_terms', '#__finder_logging',
];
// Not the site's database? Include the tables
if ($root != '[SITEDB]')
{
return false;
}
// Is it one of the blacklisted tables?
if (in_array($test, $finderTables))
{
return true;
}
// No match? Just include the file!
return false;
}
}
Joomla3x/Filter/Stack/StackActionlogs.php 0000604 00000001471 15245630146 0014340 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Engine\Filter\Stack;
use Akeeba\Engine\Filter\Base;
// Protection against direct access
defined('AKEEBAENGINE') || die();
/**
* Exclude Joomla 3.9+ actions log table
*/
class StackActionlogs extends Base
{
public function __construct()
{
$this->object = 'dbobject';
$this->subtype = 'content';
$this->method = 'api';
parent::__construct();
}
protected function is_excluded_by_api($test, $root)
{
static $excluded = [
'#__action_logs',
];
// Is it one of the blacklisted tables?
if (in_array($test, $excluded))
{
return true;
}
// No match? Just include the file!
return false;
}
}
Joomla3x/Filter/Sitedb.php 0000604 00000005352 15245630146 0011417 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Engine\Filter;
// Protection against direct access
defined('AKEEBAENGINE') || die();
use Akeeba\Engine\Factory;
use Akeeba\Engine\Platform;
/**
* Add site's main database to the backup set.
*/
class Sitedb extends Base
{
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();
}
}
Joomla3x/Filter/Excludefiles.php 0000604 00000002144 15245630146 0012615 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Engine\Filter;
// Protection against direct access
defined('AKEEBAENGINE') || die();
use Akeeba\Engine\Factory;
/**
* Subdirectories exclusion filter. Excludes temporary, cache and backup output
* directories' contents from being backed up.
*/
class Excludefiles extends Base
{
public function __construct()
{
$this->object = 'file';
$this->subtype = 'all';
$this->method = 'direct';
$this->filter_name = 'Excludefiles';
// 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(
'kickstart.php',
'error_log',
'administrator/error_log'
);
parent::__construct();
}
}
Joomla3x/Filter/Excludefolders.php 0000604 00000002016 15245630146 0013147 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Engine\Filter;
// Protection against direct access
defined('AKEEBAENGINE') || die();
use Akeeba\Engine\Factory;
/**
* Folder exclusion filter. Excludes certain hosting directories.
*/
class Excludefolders extends Base
{
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] = [
'.cagefs',
'awstats',
'cgi-bin',
];
parent::__construct();
}
}
web.config 0000604 00000001025 15245630146 0006510 0 ustar 00 <?xml version="1.0"?>
<!--
This only works on IIS 7 or later. See https://www.iis.net/configreference/system.webserver/security/requestfiltering/fileextensions
-->
<configuration>
<system.webServer>
<security>
<requestFiltering>
<fileExtensions allowUnlisted="false" >
<clear />
<add fileExtension=".html" allowed="true"/>
</fileExtensions>
</requestFiltering>
</security>
</system.webServer>
</configuration>