exam support valid multiple

This commit is contained in:
xiaomlove
2022-04-17 16:38:44 +08:00
parent bacfdd0df1
commit e0a515b66c
59 changed files with 950 additions and 79 deletions
+30 -8
View File
@@ -25,6 +25,14 @@ class Install
protected $envNames = ['TIMEZONE', 'DB_HOST', 'DB_PORT', 'DB_USERNAME', 'DB_PASSWORD', 'DB_DATABASE', 'REDIS_HOST', 'REDIS_PORT', 'REDIS_DB'];
protected array $requiredExtensions = ['ctype', 'fileinfo', 'json', 'mbstring', 'openssl', 'pdo_mysql', 'tokenizer', 'xml', 'mysqli', 'bcmath', 'redis', 'gd', ];
protected array $optionalExtensions = [
['name' => 'pcntl', 'desc' => "If use Octane and 'Current' showing 0, make sure it's on php -m"],
['name' => 'posix', 'desc' => "If use Octane and 'Current' showing 0, make sure it's on php -m"],
['name' => 'sockets', 'desc' => "If use roadrunner for Octane, make sure 'current' shows 1"],
['name' => 'swoole', 'desc' => "If use swoole for Octane, make sure 'current' shows 1"],
];
public function __construct()
{
if (!session_id()) {
@@ -128,7 +136,6 @@ class Install
public function listRequirementTableRows()
{
$gdInfo = function_exists('gd_info') ? gd_info() : [];
$extensions = ['ctype', 'fileinfo', 'json', 'mbstring', 'openssl', 'pdo_mysql', 'tokenizer', 'xml', 'mysqli', 'bcmath', 'redis', 'gd', 'sockets', 'posix'];
$tableRows = [];
$tableRows[] = [
'label' => 'PHP version',
@@ -136,7 +143,8 @@ class Install
'current' => PHP_VERSION,
'result' => $this->yesOrNo(version_compare(PHP_VERSION, $this->minimumPhpVersion, '>=')),
];
foreach ($extensions as $extension) {
foreach ($this->requiredExtensions as $extension) {
$tableRows[] = [
'label' => "PHP extension $extension",
'required' => 'enabled',
@@ -144,12 +152,6 @@ class Install
'result' => $this->yesOrNo(extension_loaded($extension)),
];
}
$tableRows[] = [
'label' => 'PHP extension pcntl',
'required' => 'true',
'current' => (int)extension_loaded('pcntl'),
'result' => "If 'current' showing 0, make sure it's on php -m",
];
$tableRows[] = [
'label' => 'PHP extension gd JPEG Support',
@@ -170,6 +172,17 @@ class Install
'result' => $this->yesOrNo($gdInfo['GIF Read Support'] ?? ''),
];
foreach ($this->optionalExtensions as $extension) {
$tableRows[] = [
'label' => "PHP extension " . $extension['name'],
'required' => 'enabled',
'current' => (int)extension_loaded($extension['name']),
'result' => $extension['desc'],
];
}
$fails = array_filter($tableRows, function ($value) {return in_array($value['required'], ['true', 'enabled']) && $value['result'] == 'NO';});
$pass = empty($fails);
@@ -610,4 +623,13 @@ class Install
return $results;
}
public function getMysqlVersionInfo(): array
{
$res = mysql_query('select version() as v');
$result = mysql_fetch_assoc($res);
$version = $result['v'];
$match = version_compare($version, '5.7.7', '>=');
return compact('version', 'match');
}
}
+5 -1
View File
@@ -103,6 +103,7 @@ if ($currentStep == 4) {
$symbolicLinks = $settingTableRows['symbolic_links'];
$tableRows = $settingTableRows['table_rows'];
$pass = $settingTableRows['pass'];
$mysqlInfo = $install->getMysqlVersionInfo();
while ($isPost) {
set_time_limit(300);
try {
@@ -135,7 +136,7 @@ if ($currentStep == 5) {
];
}
if (!empty($error)) {
if (!empty($error) || (isset($mysqlInfo) && !$mysqlInfo['match'])) {
$pass = false;
}
?>
@@ -180,6 +181,9 @@ if (!empty($error)) {
echo '<div class="text-blue-500 pt-10">';
echo sprintf('This step will merge <code>%s</code> to <code>%s</code>, then insert into database', $tableRows[1]['label'], $tableRows[0]['label']);
echo '</div>';
if (!$mysqlInfo['match']) {
echo sprintf('<div class="text-red-700 pt-10">MySQL version: %s is too low, please use the newest version of 5.7 or above.</div>', $mysqlInfo['version']);
}
} elseif ($currentStep == 5) {
echo $install->renderForm($userFormControls, '1/2', '1/4', '3/4');
} elseif ($currentStep > $maxStep) {
+5 -1
View File
@@ -154,6 +154,7 @@ if ($currentStep == 4) {
$symbolicLinks = $settingTableRows['symbolic_links'];
$tableRows = $settingTableRows['table_rows'];
$pass = $settingTableRows['pass'];
$mysqlInfo = $update->getMysqlVersionInfo();
while ($isPost) {
set_time_limit(300);
try {
@@ -172,7 +173,7 @@ if ($currentStep == 4) {
}
}
if (!empty($error)) {
if (!empty($error) || (isset($mysqlInfo) && !$mysqlInfo['match'])) {
$pass = false;
}
?>
@@ -218,6 +219,9 @@ if (!empty($error)) {
echo '<div class="text-blue-500 pt-10">';
echo sprintf('This step will merge <code>%s</code> to <code>%s</code>, then insert into database.', $tableRows[1]['label'], $tableRows[0]['label']);
echo '</div>';
if (!$mysqlInfo['match']) {
echo sprintf('<div class="text-red-700 pt-10">MySQL version: %s is too low, please use the newest version of 5.7 or above.</div>', $mysqlInfo['version']);
}
} elseif ($currentStep > $maxStep) {
echo '<div class="text-green-900 text-6xl p-10">Congratulations, everything is ready!</div>';
echo '<div class="mb-6">For questions, consult the upgrade log at: <code>' . $update->getLogFile() . '</code></div>';