first commit

This commit is contained in:
2024-07-15 11:28:08 +02:00
commit f52d538ea5
21891 changed files with 6161164 additions and 0 deletions

View File

@@ -0,0 +1,77 @@
<?php
/**
* @package solo
* @copyright Copyright (c)2014-2022 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Solo\Alice\Check\Requirements;
use Awf\Container\Container;
use Solo\Alice\Check\Base;
use Akeeba\Engine\Factory;
use Exception;
use Awf\Text\Text;
/**
* Checks for database permissions (SHOW permissions)
*/
class DatabasePermissions extends Base
{
public function __construct(Container $container, $logFile = null)
{
$this->priority = 40;
$this->checkLanguageKey = 'COM_AKEEBA_ALICE_ANALYZE_REQUIREMENTS_DBPERMISSIONS';
parent::__construct($container, $logFile);
}
public function check()
{
$db = Factory::getDatabase();
// Can I execute SHOW statements?
try
{
$result = $db->setQuery('SHOW TABLES')->query();
}
catch (Exception $e)
{
$result = false;
}
if (!$result)
{
$this->setResult(-1);
$this->setErrorLanguageKey([
'COM_AKEEBA_ALICE_ANALYZE_REQUIREMENTS_DBPERMISSIONS_ERROR',
]);
return;
}
try
{
$result = $db->setQuery('SHOW CREATE TABLE ' . $db->nameQuote('#__ak_profiles'))->query();
}
catch (Exception $e)
{
$result = false;
}
if (!$result)
{
$this->setResult(-1);
$this->setErrorLanguageKey([
'COM_AKEEBA_ALICE_ANALYZE_REQUIREMENTS_DBPERMISSIONS_ERROR',
]);
return;
}
}
public function getSolution()
{
return Text::_('COM_AKEEBA_ALICE_ANALYZE_REQUIREMENTS_DBPERMISSIONS_SOLUTION');
}
}

View File

@@ -0,0 +1,67 @@
<?php
/**
* @package solo
* @copyright Copyright (c)2014-2022 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Solo\Alice\Check\Requirements;
use Awf\Container\Container;
use Solo\Alice\Check\Base;
use Awf\Text\Text;
/**
* Checks for supported DB type and version
*/
class DatabaseVersion extends Base
{
public function __construct(Container $container, $logFile = null)
{
$this->priority = 20;
$this->checkLanguageKey = 'COM_AKEEBA_ALICE_ANALYZE_REQUIREMENTS_DATABASE';
parent::__construct($container, $logFile);
}
public function check()
{
// Instead of reading the log, I can simply take the JDatabase object and test it
$db = $this->container->db;
$connector = strtolower($db->name);
$version = $db->getVersion();
switch ($connector)
{
case 'mysql':
case 'mysqli':
case 'pdomysql':
if (version_compare($version, '5.0.47', 'lt'))
{
$this->setResult(-1);
$this->setErrorLanguageKey([
'COM_AKEEBA_ALICE_ANALYZE_REQUIREMENTS_DATABASE_VERSION_TOO_OLD', $version,
]);
}
break;
case 'pdo':
case 'sqlite':
$this->setResult(-1);
$this->setErrorLanguageKey([
'COM_AKEEBA_ALICE_ANALYZE_REQUIREMENTS_DATABASE_UNSUPPORTED', $connector,
]);
break;
default:
$this->setResult(-1);
$this->setErrorLanguageKey(['COM_AKEEBA_ALICE_ANALYZE_REQUIREMENTS_DATABASE_UNKNOWN', $connector]);
break;
}
}
public function getSolution()
{
return Text::_('COM_AKEEBA_ALICE_ANALYZE_REQUIREMENTS_DATABASE_SOLUTION');
}
}

View File

@@ -0,0 +1,91 @@
<?php
/**
* @package solo
* @copyright Copyright (c)2014-2022 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Solo\Alice\Check\Requirements;
use Awf\Container\Container;
use Solo\Alice\Check\Base;
use Solo\Alice\Exception\StopScanningEarly;
use Awf\Text\Text;
/**
* Checks if we have enough memory to perform backup; at least 16Mb
*/
class Memory extends Base
{
public function __construct(Container $container, $logFile = null)
{
$this->priority = 30;
$this->checkLanguageKey = 'COM_AKEEBA_ALICE_ANALYZE_REQUIREMENTS_MEMORY';
parent::__construct($container, $logFile);
}
public function check()
{
$limit = null;
$usage = false;
$this->scanLines(function ($line) use (&$limit, &$usage) {
if (is_null($limit))
{
$pos = strpos($line, '|Memory limit');
if ($pos !== false)
{
$limit = trim(substr($line, strpos($line, ':', $pos) + 1));
$limit = str_ireplace('M', '', $limit);
// Convert to integer for better handling and checks
$limit = (int) $limit;
}
}
if (!$usage)
{
$pos = strpos($line, '|Current mem. usage');
if ($pos !== false)
{
$usage = trim(substr($line, strpos($line, ':', $pos) + 1));
// Converting to Mb for better handling
$usage = round($usage / 1024 / 1024, 2);
}
}
throw new StopScanningEarly();
});
if (empty($limit) || empty($usage))
{
// Inconclusive check. Cannot get the memory information.
return;
}
$available = $limit - $usage;
if ($limit < 0)
{
// Stupid host uses a negative memory limit. This is the same as setting no memory limit. Bleh.
return;
}
if ($available >= 16)
{
// We have enough memory.
return;
}
$this->setResult(-1);
$this->setErrorLanguageKey(['COM_AKEEBA_ALICE_ANALYZE_REQUIREMENTS_MEMORY_TOO_FEW', $available]);
}
public function getSolution()
{
return Text::_('COM_AKEEBA_ALICE_ANALYZE_REQUIREMENTS_MEMORY_SOLUTION');
}
}

View File

@@ -0,0 +1,57 @@
<?php
/**
* @package solo
* @copyright Copyright (c)2014-2022 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Solo\Alice\Check\Requirements;
use Awf\Container\Container;
use Solo\Alice\Check\Base;
use Solo\Alice\Exception\StopScanningEarly;
use Awf\Text\Text;
/**
* Checks if the user is using a too old or too new PHP version
*/
class PHPVersion extends Base
{
public function __construct(Container $container, $logFile = null)
{
$this->priority = 10;
$this->checkLanguageKey = 'COM_AKEEBA_ALICE_ANALYZE_REQUIREMENTS_PHP_VERSION';
parent::__construct($container, $logFile);
}
public function check()
{
$this->scanLines(function ($line) {
$pos = strpos($line, '|PHP Version');
if ($pos === false)
{
return;
}
$version = trim(substr($line, strpos($line, ':', $pos) + 1));
// PHP too old (well, this should never happen)
if (version_compare($version, '5.6', 'lt'))
{
$this->setResult(-1);
$this->setErrorLanguageKey([
'COM_AKEEBA_ALICE_ANALYZE_REQUIREMENTS_PHP_VERSION_ERR_TOO_OLD',
]);
}
throw new StopScanningEarly();
});
}
public function getSolution()
{
return Text::_('COM_AKEEBA_ALICE_ANALYZE_REQUIREMENTS_PHP_VERSION_SOLUTION');
}
}