mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-04-25 23:19:15 -04:00
Move the check_environment into the installer helper and call it from the command line installer as well as the web installer.
This commit is contained in:
@@ -30,6 +30,11 @@ if (installer::already_installed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$errors = installer::check_environment();
|
||||
if ($errors) {
|
||||
oops(implode("errors", "\n"));
|
||||
}
|
||||
|
||||
$config = parse_cli_params();
|
||||
if (!installer::connect($config)) {
|
||||
oops("Unable to connect to the database.\n" . mysql_error() . "\n");
|
||||
|
||||
@@ -178,4 +178,45 @@ class installer {
|
||||
static function prepend_prefix($prefix, $sql) {
|
||||
return preg_replace("#{([a-zA-Z0-9_]+)}#", "{$prefix}$1", $sql);
|
||||
}
|
||||
|
||||
static function check_environment() {
|
||||
if (!function_exists("mysql_query") && !function_exists("mysqli_set_charset")) {
|
||||
$errors[] = "Gallery 3 requires a MySQL database, but PHP doesn't have either the <a href=\"http://php.net/mysql\">MySQL</a> or the <a href=\"http://php.net/mysqli\">MySQLi</a> extension.";
|
||||
}
|
||||
|
||||
if (!@preg_match("/^.$/u", utf8_encode("\xF1"))) {
|
||||
$errors[] = "PHP is missing <a href=\"http://php.net/pcre\">Perl-Compatible Regular Expression</a> support.";
|
||||
}
|
||||
|
||||
if (!(function_exists("spl_autoload_register"))) {
|
||||
$errors[] = "PHP is missing <a href=\"http://php.net/spl\">Standard PHP Library (SPL)</a> support";
|
||||
}
|
||||
|
||||
if (!(class_exists("ReflectionClass"))) {
|
||||
$errors[] = "PHP is missing <a href=\"http://php.net/reflection\">reflection</a> support";
|
||||
}
|
||||
|
||||
if (!(function_exists("filter_list"))) {
|
||||
$errors[] = "PHP is missing the <a href=\"http://php.net/filter\">filter extension</a>";
|
||||
}
|
||||
|
||||
if (!(extension_loaded("iconv"))) {
|
||||
$errors[] = "PHP is missing the <a href=\"http://php.net/iconv\">iconv extension</a>";
|
||||
}
|
||||
|
||||
if (!(extension_loaded("simplexml"))) {
|
||||
$errors[] = "PHP is missing the <a href=\"http://php.net/simplexml\">SimpleXML extension</a>";
|
||||
}
|
||||
|
||||
if (extension_loaded("mbstring") && (ini_get("mbstring.func_overload") & MB_OVERLOAD_STRING)) {
|
||||
$errors[] = "The <a href=\"http://php.net/mbstring\">mbstring extension</a> is overloading PHP's native string functions. Please disable it.";
|
||||
}
|
||||
|
||||
if (!function_exists("json_encode")) {
|
||||
$errors[] = "PHP is missing the <a href=\"http://php.net/manual/en/book.json.php\">JavaScript Object Notation (JSON) extension</a>. Please install it.";
|
||||
}
|
||||
|
||||
return @$errors;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ if (installer::already_installed()) {
|
||||
switch (@$_GET["step"]) {
|
||||
default:
|
||||
case "welcome":
|
||||
$errors = check_environment();
|
||||
$errors = installer::check_environment();
|
||||
if ($errors) {
|
||||
$content = render("environment_errors.html.php", array("errors" => $errors));
|
||||
} else {
|
||||
@@ -80,43 +80,3 @@ function render($view, $args=array()) {
|
||||
function oops($error) {
|
||||
return render("oops.html.php", array("error" => $error));
|
||||
}
|
||||
|
||||
function check_environment() {
|
||||
if (!function_exists("mysql_query") && !function_exists("mysqli_set_charset")) {
|
||||
$errors[] = "Gallery 3 requires a MySQL database, but PHP doesn't have either the <a href=\"http://php.net/mysql\">MySQL</a> or the <a href=\"http://php.net/mysqli\">MySQLi</a> extension.";
|
||||
}
|
||||
|
||||
if (!@preg_match("/^.$/u", utf8_encode("\xF1"))) {
|
||||
$errors[] = "PHP is missing <a href=\"http://php.net/pcre\">Perl-Compatible Regular Expression</a> support.";
|
||||
}
|
||||
|
||||
if (!(function_exists("spl_autoload_register"))) {
|
||||
$errors[] = "PHP is missing <a href=\"http://php.net/spl\">Standard PHP Library (SPL)</a> support";
|
||||
}
|
||||
|
||||
if (!(class_exists("ReflectionClass"))) {
|
||||
$errors[] = "PHP is missing <a href=\"http://php.net/reflection\">reflection</a> support";
|
||||
}
|
||||
|
||||
if (!(function_exists("filter_list"))) {
|
||||
$errors[] = "PHP is missing the <a href=\"http://php.net/filter\">filter extension</a>";
|
||||
}
|
||||
|
||||
if (!(extension_loaded("iconv"))) {
|
||||
$errors[] = "PHP is missing the <a href=\"http://php.net/iconv\">iconv extension</a>";
|
||||
}
|
||||
|
||||
if (!(extension_loaded("simplexml"))) {
|
||||
$errors[] = "PHP is missing the <a href=\"http://php.net/simplexml\">SimpleXML extension</a>";
|
||||
}
|
||||
|
||||
if (extension_loaded("mbstring") && (ini_get("mbstring.func_overload") & MB_OVERLOAD_STRING)) {
|
||||
$errors[] = "The <a href=\"http://php.net/mbstring\">mbstring extension</a> is overloading PHP's native string functions. Please disable it.";
|
||||
}
|
||||
|
||||
if (!function_exists("json_encode")) {
|
||||
$errors[] = "PHP is missing the <a href=\"http://php.net/manual/en/book.json.php\">JavaScript Object Notation (JSON) extension</a>. Please install it.";
|
||||
}
|
||||
|
||||
return @$errors;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user