From 681197a265f1dd3873780fdcf0b5f1e8fa0150ab Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 20 Jan 2009 00:54:02 +0000 Subject: Web based installer. It's still got some rough edges, but you can now do a complete CLI or web based install. --- installer/web.php | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 installer/web.php (limited to 'installer/web.php') diff --git a/installer/web.php b/installer/web.php new file mode 100644 index 00000000..ddabcd19 --- /dev/null +++ b/installer/web.php @@ -0,0 +1,105 @@ + $errors)); + } else { + $content = render("pages/get_db_info.html.php"); + } + break; + + case "save_db_info": + $config = array("host" => $_POST["dbhost"], + "user" => $_POST["dbuser"], + "password" => $_POST["dbpass"], + "dbname" => $_POST["dbname"], + "prefix" => "", + "type" => function_exists("mysqli_init") ? "mysqli" : "mysql"); + + if (!installer::connect($config)) { + $content = render("pages/invalid_db_info.html.php"); + } else if (!installer::select_db($config)) { + $content = render("pages/missing_db.html.php"); + } else if (!installer::db_empty($config)) { + $content = render("pages/db_not_empty.html.php"); + } else if (!installer::unpack_var()) { + $content = oops("Unable to create files inside the var directory"); + } else if (!installer::unpack_sql()) { + $content = oops("Failed to create tables in your database:" . mysql_error()); + } else if (!installer::create_database_config($config)) { + $content = oops("Couldn't create var/database.php"); + } else { + list ($user, $password) = installer::create_admin($config); + $content = render("pages/success.html.php", array("user" => $user, "password" => $password)); + } + break; + } +} + +include("install.html.php"); + +function render($page, $args=array()) { + ob_start(); + extract($args); + include($page); + return ob_get_clean(); +} + +function oops($error) { + return render("pages/oops.html.php", array("error" => $error)); +} + +function check_environment() { + if (version_compare(PHP_VERSION, "5.2", "<")) { + $errors[] = "Gallery 3 requires PHP 5.2 or newer, current version: " . PHP_VERSION; + } + + if (!function_exists("mysql_query") && !function_exists("mysqli_init")) { + $errors[] = "Gallery 3 requires a MySQL database, but PHP doesn't have either the the MySQL or the MySQLi extension."; + } + + if (!@preg_match("/^.$/u", utf8_encode("\xF1"))) { + $errors[] = "PHP is missing Perl-Compatible Regular Expression support."; + } + + if (!(class_exists("ReflectionClass"))) { + $errors[] = "PHP is missing reflection support"; + } + + if (!(function_exists("filter_list"))) { + $errors[] = "PHP is missing the filter extension"; + } + + if (!(extension_loaded("iconv"))) { + $errors[] = "PHP is missing the iconv extension"; + } + + if (extension_loaded("mbstring") && (ini_get("mbstring.func_overload") & MB_OVERLOAD_STRING)) { + $errors[] = "The mbstring extension is overloading PHP's native string functions. Please disable it."; + } + + return $errors; +} -- cgit v1.2.3