requirements check in SystemUtil

This commit is contained in:
Steffen Schröder 2014-06-17 22:25:33 +02:00
parent 621c795a54
commit 1e641f69c6
2 changed files with 46 additions and 35 deletions

View File

@ -49,40 +49,8 @@ function logMessage($message, $eol = true) {
logMessage('Starting ManiaControl...');
/**
* Check for the requirements to run ManiaControl
*/
function checkRequirements() {
// Check for min PHP version
$phpVersion = phpversion();
$message = 'Checking for minimum required PHP-Version ' . MIN_PHP_VERSION . ' ... ';
if ($phpVersion < MIN_PHP_VERSION) {
logMessage($message . $phpVersion . ' TOO OLD VERSION!');
logMessage(' -- Make sure that you install at least PHP ' . MIN_PHP_VERSION . '!');
exit();
}
logMessage($message . MIN_PHP_VERSION . ' OK!');
// Check for MySQLi
$message = 'Checking for installed MySQLi ... ';
if (!extension_loaded('mysqli')) {
logMessage($message . 'NOT FOUND!');
logMessage(" -- You don't have MySQLi installed! Check: http://www.php.net/manual/en/mysqli.installation.php");
exit();
}
logMessage($message . 'FOUND!');
// Check for cURL
$message = 'Checking for installed cURL ... ';
if (!extension_loaded('curl')) {
logMessage($message . 'NOT FOUND!');
logMessage(" -- You don't have cURL installed! Check: http://www.php.net/manual/en/curl.installation.php");
exit();
}
logMessage($message . 'FOUND!');
}
checkRequirements();
// Check requirements
\ManiaControl\Utils\SystemUtil::checkRequirements();
// Start ManiaControl
$maniaControl = new \ManiaControl\ManiaControl();

View File

@ -61,8 +61,51 @@ class SystemUtil {
*
* @return array
*/
public static function getDisabledFunctions() {
protected static function getDisabledFunctions() {
$disabledText = ini_get('disable_functions');
return explode(',', $disabledText);
}
/**
* Check for the Requirements to run ManiaControl
*/
public static function checkRequirements() {
$success = true;
// Check for min PHP version
$phpVersion = phpversion();
$message = 'Checking for minimum required PHP-Version ' . MIN_PHP_VERSION . ' ... ';
if ($phpVersion < MIN_PHP_VERSION) {
logMessage($message . $phpVersion . ' TOO OLD VERSION!');
logMessage(' -- Make sure that you install at least PHP ' . MIN_PHP_VERSION . '!');
$success = false;
} else {
logMessage($message . MIN_PHP_VERSION . ' OK!');
}
// Check for MySQLi
$message = 'Checking for installed MySQLi ... ';
if (!extension_loaded('mysqli')) {
logMessage($message . 'NOT FOUND!');
logMessage(" -- You don't have MySQLi installed! Check: http://www.php.net/manual/en/mysqli.installation.php");
$success = false;
} else {
logMessage($message . 'FOUND!');
}
// Check for cURL
$message = 'Checking for installed cURL ... ';
if (!extension_loaded('curl')) {
logMessage($message . 'NOT FOUND!');
logMessage(" -- You don't have cURL installed! Check: http://www.php.net/manual/en/curl.installation.php");
$success = false;
} else {
logMessage($message . 'FOUND!');
}
if (!$success) {
// Missing requirements
exit;
}
}
}