2020-06-05 14:26:57 -05:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* InstallationChecksController.php
|
|
|
|
*
|
|
|
|
* -Description-
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-02-09 00:29:04 +01:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2020-06-05 14:26:57 -05:00
|
|
|
*
|
2021-02-09 00:29:04 +01:00
|
|
|
* @link https://www.librenms.org
|
2020-06-05 14:26:57 -05:00
|
|
|
* @copyright 2020 Tony Murray
|
|
|
|
* @author Tony Murray <murraytony@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Install;
|
|
|
|
|
2020-06-15 00:45:40 -05:00
|
|
|
use LibreNMS\Interfaces\InstallerStep;
|
2020-06-07 00:03:57 -05:00
|
|
|
use LibreNMS\Validations\Php;
|
|
|
|
|
2020-06-15 00:45:40 -05:00
|
|
|
class ChecksController extends InstallationController implements InstallerStep
|
2020-06-05 14:26:57 -05:00
|
|
|
{
|
2020-06-15 00:45:40 -05:00
|
|
|
const MODULES = ['pdo_mysql', 'mysqlnd', 'gd'];
|
2020-06-21 01:07:56 -05:00
|
|
|
protected $step = 'checks';
|
2020-06-15 00:45:40 -05:00
|
|
|
|
2020-06-11 01:06:16 -05:00
|
|
|
public function index()
|
2020-06-05 14:26:57 -05:00
|
|
|
{
|
2020-06-21 01:07:56 -05:00
|
|
|
$this->initInstallStep();
|
|
|
|
|
2020-06-15 00:45:40 -05:00
|
|
|
if ($this->complete()) {
|
2020-06-21 01:07:56 -05:00
|
|
|
$this->markStepComplete();
|
2020-06-07 00:03:57 -05:00
|
|
|
}
|
|
|
|
|
2020-06-29 00:58:06 -05:00
|
|
|
preg_match('/\d+\.\d+\.\d+/', PHP_VERSION, $matches);
|
|
|
|
$version = $matches[0] ?? PHP_VERSION;
|
|
|
|
|
2020-06-11 01:06:16 -05:00
|
|
|
return view('install.checks', $this->formatData([
|
2020-06-29 00:58:06 -05:00
|
|
|
'php_version' => $version,
|
2020-06-07 00:03:57 -05:00
|
|
|
'php_required' => Php::PHP_MIN_VERSION,
|
2020-06-15 00:45:40 -05:00
|
|
|
'php_ok' => $this->checkPhpVersion(),
|
|
|
|
'modules' => $this->moduleResults(),
|
2020-06-11 01:06:16 -05:00
|
|
|
]));
|
2020-06-05 15:44:10 -05:00
|
|
|
}
|
|
|
|
|
2020-06-15 00:45:40 -05:00
|
|
|
private function moduleResults()
|
2020-06-05 15:44:10 -05:00
|
|
|
{
|
2020-06-15 00:45:40 -05:00
|
|
|
$results = [];
|
2020-06-07 00:03:57 -05:00
|
|
|
|
2020-06-15 00:45:40 -05:00
|
|
|
foreach (self::MODULES as $module) {
|
|
|
|
$status = extension_loaded($module);
|
|
|
|
$results[] = [
|
|
|
|
'name' => str_replace('install.checks.php_module.', '', trans('install.checks.php_module.' . $module)),
|
|
|
|
'status' => $status,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
return $results;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function checkPhpVersion()
|
|
|
|
{
|
|
|
|
return version_compare(PHP_VERSION, Php::PHP_MIN_VERSION, '>=');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function complete(): bool
|
|
|
|
{
|
2020-06-21 11:27:07 -05:00
|
|
|
if ($this->stepCompleted('checks')) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-09-21 14:54:51 +02:00
|
|
|
if (! $this->checkPhpVersion()) {
|
2020-06-15 00:45:40 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (self::MODULES as $module) {
|
2020-09-21 14:54:51 +02:00
|
|
|
if (! extension_loaded($module)) {
|
2020-06-15 00:45:40 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2020-06-05 14:26:57 -05:00
|
|
|
}
|
2020-06-07 14:53:40 -05:00
|
|
|
|
2020-06-15 00:45:40 -05:00
|
|
|
public function enabled(): bool
|
2020-06-07 14:53:40 -05:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-06-15 00:45:40 -05:00
|
|
|
public function icon(): string
|
2020-06-07 14:53:40 -05:00
|
|
|
{
|
|
|
|
return 'fa-list-ul fa-flip-horizontal';
|
|
|
|
}
|
2020-06-05 14:26:57 -05:00
|
|
|
}
|