2022-01-11 18:54:32 +00:00
|
|
|
<?php
|
2022-01-11 11:45:36 +00:00
|
|
|
|
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
$required_extentions = array("openssl", "gd", "mysql", "PDO", "mbstring", "tokenizer", "bcmath", "xml", "curl", "zip", "fpm");
|
2022-01-11 11:45:36 +00:00
|
|
|
|
2022-01-11 13:09:20 +00:00
|
|
|
$requirements = [
|
2022-01-11 18:54:32 +00:00
|
|
|
"php" => "7.4",
|
|
|
|
"mysql" => "5.7.22",
|
2022-01-11 11:45:36 +00:00
|
|
|
|
|
|
|
|
2022-01-11 13:09:20 +00:00
|
|
|
];
|
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
function checkPhpVersion()
|
|
|
|
{
|
|
|
|
global $requirements;
|
|
|
|
if (version_compare(phpversion(), $requirements["php"], '>=')) {
|
|
|
|
return "OK";
|
|
|
|
}
|
|
|
|
return "not OK";
|
2022-01-11 11:45:36 +00:00
|
|
|
}
|
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
function getMySQLVersion()
|
|
|
|
{
|
|
|
|
global $requirements;
|
2022-01-11 11:45:36 +00:00
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
$output = shell_exec('mysql -V');
|
|
|
|
preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $output, $version);
|
2022-01-11 11:45:36 +00:00
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
$versionoutput = $version[0] ?? "0";
|
2022-01-11 11:45:36 +00:00
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
return (intval($versionoutput) > intval($requirements["mysql"]) ? "OK" : $versionoutput);
|
2022-01-11 13:09:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
function getZipVersion()
|
|
|
|
{
|
|
|
|
global $requirements;
|
2022-01-11 13:09:20 +00:00
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
$output = shell_exec('zip -v');
|
|
|
|
preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $output, $version);
|
2022-01-11 13:09:20 +00:00
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
$versionoutput = $version[0] ?? 0;
|
2022-01-11 13:09:20 +00:00
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
return ($versionoutput != 0 ? "OK" : "not OK");
|
2022-01-11 13:09:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
function getGitVersion()
|
|
|
|
{
|
|
|
|
global $requirements;
|
2022-01-11 13:09:20 +00:00
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
$output = shell_exec('git --version');
|
|
|
|
preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $output, $version);
|
2022-01-11 13:09:20 +00:00
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
$versionoutput = $version[0] ?? 0;
|
2022-01-11 13:09:20 +00:00
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
return ($versionoutput != 0 ? "OK" : "not OK");
|
2022-01-11 11:45:36 +00:00
|
|
|
}
|
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
function getTarVersion()
|
|
|
|
{
|
|
|
|
global $requirements;
|
2022-01-11 13:09:20 +00:00
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
$output = shell_exec('tar --version');
|
|
|
|
preg_match('@[0-9]+\.[0-9]+@', $output, $version);
|
2022-01-11 13:09:20 +00:00
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
$versionoutput = $version[0] ?? 0;
|
2022-01-11 13:09:20 +00:00
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
return ($versionoutput != 0 ? "OK" : "not OK");
|
2022-01-11 13:09:20 +00:00
|
|
|
}
|
2022-01-11 11:45:36 +00:00
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
function checkExtensions()
|
|
|
|
{
|
|
|
|
global $required_extentions;
|
2022-01-11 13:09:20 +00:00
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
$not_ok = [];
|
|
|
|
$extentions = get_loaded_extensions();
|
2022-01-11 11:45:36 +00:00
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
foreach ($required_extentions as $ext) {
|
|
|
|
if (!in_array($ext, $extentions)) {
|
|
|
|
array_push($not_ok, $ext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $not_ok;
|
2022-01-11 11:45:36 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
function setEnvironmentValue($envKey, $envValue)
|
|
|
|
{
|
2022-01-11 13:09:20 +00:00
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
$envFile = dirname(__FILE__, 3) . "/.env";
|
|
|
|
$str = file_get_contents($envFile);
|
2022-01-11 13:09:20 +00:00
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
$str .= "\n"; // In case the searched variable is in the last line without \n
|
|
|
|
$keyPosition = strpos($str, "{$envKey}=");
|
|
|
|
$endOfLinePosition = strpos($str, PHP_EOL, $keyPosition);
|
|
|
|
$oldLine = substr($str, $keyPosition, $endOfLinePosition - $keyPosition);
|
|
|
|
$str = str_replace($oldLine, "{$envKey}={$envValue}", $str);
|
|
|
|
$str = substr($str, 0, -1);
|
2022-01-11 13:09:20 +00:00
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
$fp = fopen($envFile, 'w');
|
|
|
|
fwrite($fp, $str);
|
|
|
|
fclose($fp);
|
|
|
|
}
|
2022-01-11 13:09:20 +00:00
|
|
|
|
|
|
|
|
2022-01-11 18:54:32 +00:00
|
|
|
?>
|