summaryrefslogtreecommitdiff
path: root/installer
diff options
context:
space:
mode:
Diffstat (limited to 'installer')
-rw-r--r--installer/controllers/installer.php80
-rw-r--r--installer/helpers/system_check.php180
-rw-r--r--installer/views/installer.html.php48
-rw-r--r--installer/views/installer.txt.2.php119
-rw-r--r--installer/views/installer.txt.php44
5 files changed, 471 insertions, 0 deletions
diff --git a/installer/controllers/installer.php b/installer/controllers/installer.php
new file mode 100644
index 00000000..9c9491b7
--- /dev/null
+++ b/installer/controllers/installer.php
@@ -0,0 +1,80 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2008 Bharat Mediratta
+ *
+ * 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 2 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
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class Installer_Controller extends Template_Controller {
+ public $template = "welcome.html";
+
+ function index() {
+ $this->template->syscheck = new View("install.html");
+ $this->template->syscheck->errors = $this->_get_config_errors();
+ $this->template->syscheck->modules = array();
+ }
+
+ private function _get_config_errors() {
+ $errors = array();
+ if (!file_exists(VARPATH)) {
+ $error = new stdClass();
+ $error->message = "Missing: " . VARPATH;
+ $error->instructions[] = "mkdir " . VARPATH;
+ $error->instructions[] = "chmod 777 " . VARPATH;
+ $errors[] = $error;
+ } else if (!is_writable(VARPATH)) {
+ $error = new stdClass();
+ $error->message = "Not writable: " . VARPATH;
+ $error->instructions[] = "chmod 777 " . VARPATH;
+ $errors[] = $error;
+ }
+
+ $db_php = VARPATH . "database.php";
+ if (!file_exists($db_php)) {
+ $error = new stdClass();
+ $error->message = "Missing: $db_php <br/> Run the following commands...";
+ $error->instructions[] = "cp " . DOCROOT . "kohana/config/database.php $db_php";
+ $error->instructions[] = "chmod 644 $db_php";
+ $error->message2 = "...then edit this file and enter your database configuration settings.";
+ $errors[] = $error;
+ } else if (!is_readable($db_php)) {
+ $error = new stdClass();
+ $error->message = "Not readable: $db_php";
+ $error->instructions[] = "chmod 644 $db_php";
+ $error->message2 = "Then edit this file and enter your database configuration settings.";
+ $errors[] = $error;
+ } else {
+ $old_handler = set_error_handler(array("Welcome_Controller", "_error_handler"));
+ try {
+ Database::instance()->connect();
+ } catch (Exception $e) {
+ $error = new stdClass();
+ $error->message = "Database error: {$e->getMessage()}";
+ $db_name = Kohana::config("database.default.connection.database");
+ if (strchr($error->message, "Unknown database")) {
+ $error->instructions[] = "mysqladmin -uroot create $db_name";
+ } else {
+ $error->instructions = array();
+ $error->message2 = "Check " . VARPATH . "database.php";
+ }
+ $errors[] = $error;
+ }
+ set_error_handler($old_handler);
+ }
+
+ return $errors;
+ }
+
+} \ No newline at end of file
diff --git a/installer/helpers/system_check.php b/installer/helpers/system_check.php
new file mode 100644
index 00000000..b0bd7e12
--- /dev/null
+++ b/installer/helpers/system_check.php
@@ -0,0 +1,180 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2008 Bharat Mediratta
+ *
+ * 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 2 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
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class system_check {
+ private static $messages = array();
+
+ public function failed() {
+ $failed = false;
+ if (version_compare(PHP_VERSION, "5.2", "<")) {
+ self::$messages["PHP Version"] = array("error" => true,
+ "text" => sprintf("Gallery3 requires PHP 5.2 or newer, current version: %s.", PHP_VERSION));
+ $failed = true;
+ } else {
+ self::$messages["PHP Version"] = array("error" => false,
+ "text" => PHP_VERSION);
+ }
+
+
+ if (!(is_dir(SYSPATH) AND is_file(SYSPATH.'core/Bootstrap'.EXT))) {
+ self::$messages["Kohana Directory"] = array("error" => true,
+ "text" => "The configured Kohana directory does not exist or does not contain the required files.");
+ } else {
+ self::$messages["Kohana Directory"] = array("error" => false,
+ "text" => SYSPATH);
+ }
+
+ if (!(is_dir(APPPATH) AND is_file(APPPATH.'config/config'.EXT))) {
+ self::$messages["Application Directory"] = array("error" => true,
+ "text" => "The configured Gallery3 application directory does not exist or does not contain the required files.");
+ $failed = true;
+ } else {
+ self::$messages["Application Directory"] = array("error" => false,
+ "text" => APPPATH);
+ }
+
+ if (!(is_dir(MODPATH))) {
+ self::$messages["Modules Directory"] = array("error" => true,
+ "text" => "The configured Gallery3 modules directory does not exist or does not contain the required files.");
+ $failed = true;
+ } else {
+ self::$messages["Modules Directory"] = array("error" => false,
+ "text" => MODPATH);
+ }
+
+ if (!(is_dir(THEMEPATH))) {
+ self::$messages["Theme Directory"] = array("error" => true,
+ "text" => "The configured Gallery3 themes directory does not exist or does not contain the required files.");
+ $failed = true;
+ } else {
+ self::$messages["Themes Directory"] = array("error" => false,
+ "text" => THEMEPATH);
+ }
+
+ if (!@preg_match("/^.$/u", utf8_encode("\xF1"))) {
+ self::$messages["PCRE UTF-8"] = array("error" => true,
+ "text" => "Perl-Compatible Regular Expressions has not been compiled with UTF-8 support.",
+ "html" => "<a href=\"http://php.net/pcre\">PCRE</a> has not been compiled with UTF-8 support.");
+ $failed = true;
+ } else if (!@preg_match("/^\pL$/u", utf8_encode("\xF1"))) {
+ self::$messages["PCRE UTF-8"] = array("error" => true,
+ "text" => "Perl-Compatible Regular Expressions has not been compiled with Unicode support.",
+ "html" => "<a href=\"http://php.net/pcre\">PCRE</a> has not been compiled with Unicode property support.");
+ $failed = true;
+ } else {
+ self::$messages["PCRE UTF-8"] = array("error" => false,
+ "text" => "Pass");
+ }
+
+ if (!(class_exists("ReflectionClass"))) {
+ self::$messages["Reflection Enabled"] = array("error" => true,
+ "text" => "PHP relection is either not loaded or not compiled in.",
+ "html" => "PHP <a href=\"http://php.net/reflection\">relection<a> is either not loaded or not compiled in.");
+ $failed = true;
+ } else {
+ self::$messages["Reflection Enabled"] = array("error" => false,
+ "text" => "Pass");
+ }
+
+ if (!(function_exists("filter_list"))) {
+ self::$messages["Filters Enabled"] = array("error" => true,
+ "text" => "The filter extension is either not loaded or not compiled in.",
+ "html" => "The <a href=\"http://php.net/filter\">filter</a> extension is either not loaded or not compiled in.");
+ $failed = true;
+ } else {
+ self::$messages["Filters Enabled"] = array("error" => false,
+ "text" => "Pass");
+ }
+
+ if (!(extension_loaded("iconv"))) {
+ self::$messages["Iconv Loaded"] = array("error" => true,
+ "text" => "The iconv extension is not loaded.",
+ "html" => "The <a href=\"http://php.net/iconv\">iconv</a> extension is not loaded.");
+ $failed = true;
+ } else {
+ self::$messages["Iconv Enabled"] = array("error" => false,
+ "text" => "Pass");
+ }
+
+ if (extension_loaded("mbstring") &&
+ (ini_get("mbstring.func_overload") & MB_OVERLOAD_STRING)) {
+ self::$messages["Mbstring Overloaded"] = array("error" => true,
+ "text" => "The mbstring extension is overloading PHP's native string functions.",
+ "html" => "The <a href=\"http://php.net/mbstring\">mbstring</a> extension is overloading PHP's native string functions.");
+ $failed = true;
+ } else {
+ self::$messages["MbString Overloaded"] = array("error" => false,
+ "text" => "Pass");
+ }
+
+ if (!(isset($_SERVER["REQUEST_URI"]) || isset($_SERVER["PHP_SELF"]))) {
+ self::$messages["URI Determination"] = array("error" => true,
+ "text" => "Neither \$_SERVER['REQUEST_URI'] or \$_SERVER['PHP_SELF'] is available.",
+ "html" => "Neither <code>\$_SERVER['REQUEST_URI']</code> or <code>\$_SERVER['PHP_SELF']<code> is available.");
+ $failed = true;
+ } else {
+ self::$messages["URI Determination"] = array("error" => false,
+ "text" => "Pass");
+ }
+
+ $short_tags = ini_get("short_open_tag");
+ if (empty($short_tags)) {
+ self::$messages["Short Tags"] = array("error" => true,
+ "text" => "Gallery3 requires that PHP short tags be enabled.",
+ "html" => "Gallery3 requires that PHP <a href=\"http://ca2.php.net/manual/en/ini.core.php\">short tags</a> be enabled");
+ $failed = true;
+ } else {
+ self::$messages["Short Tags"] = array("error" => false,
+ "text" => "Pass");
+ }
+ return $failed;
+ }
+
+ public static function display_requirements() {
+ if (PHP_SAPI == 'cli') {
+ print self::_render("installer/views/installer.txt");
+ } else {
+ print self::_render("installer/views/installer.html");
+ }
+ }
+
+ private static function _render($view) {
+ if ($view == '')
+ return;
+
+ // Buffering on
+ ob_start();
+
+ try
+ {
+ // Views are straight HTML pages with embedded PHP, so importing them
+ // this way insures that $this can be accessed as if the user was in
+ // the controller, which gives the easiest access to libraries in views
+ include realpath($view . EXT);
+ }
+ catch (Exception $e)
+ {
+ // Display the exception using its internal __toString method
+ echo $e;
+ }
+
+ // Fetch the output and close the buffer
+ return ob_get_clean();
+ }
+} \ No newline at end of file
diff --git a/installer/views/installer.html.php b/installer/views/installer.html.php
new file mode 100644
index 00000000..fef71834
--- /dev/null
+++ b/installer/views/installer.html.php
@@ -0,0 +1,48 @@
+<?php defined("SYSPATH") or die("No direct script access."); ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+
+ <title>Gallery3 Requirements Verification</title>
+
+ <style type="text/css">
+ body { width: 42em; margin: 0 auto; font-family: sans-serif; font-size: 90%; }
+
+ #tests table { border-collapse: collapse; width: 100%; }
+ #tests table th,
+ #tests table td { padding: 0.2em 0.4em; text-align: left; vertical-align: top; }
+ #tests table th { width: 12em; font-weight: normal; font-size: 1.2em; }
+ #tests table tr:nth-child(odd) { background: #eee; }
+ #tests table td.pass { color: #191; }
+ #tests table td.fail { color: #911; }
+ #tests #results { color: #fff; }
+ #tests #results p { padding: 0.8em 0.4em; }
+ #tests #results p.pass { background: #191; }
+ #tests #results p.fail { background: #911; }
+ </style>
+
+ </head>
+ <body>
+ <h1>Environment Tests</h1>
+
+ <p>The following tests have been run to determine if Gallery3 will work in your environment. If any of the tests have failed, consult the
+ <a href="http://gallery.menalto.com">documentation</a> for more information on how to correct the problem.</p>
+
+ <div id="tests">
+
+ <table cellspacing="0">
+ <?php foreach (self::$messages as $header => $msg): ?>
+
+ <tr>
+ <th><?php echo $header ?></th>
+ <td class="<?php echo empty($msg["error"]) ? "pass" : "fail" ?>">
+ <?php echo empty($msg["html"]) ? $msg["text"] : $msg["html"] ?>
+ </td>
+ </tr>
+ <?php endforeach ?>
+ </table>
+ </div>
+ </body>
+ </html> \ No newline at end of file
diff --git a/installer/views/installer.txt.2.php b/installer/views/installer.txt.2.php
new file mode 100644
index 00000000..b40373c0
--- /dev/null
+++ b/installer/views/installer.txt.2.php
@@ -0,0 +1,119 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+function green_start() {
+ return "\x1B[32m";
+}
+
+function color_end() {
+ return "\x1B[0m";
+}
+
+function red_start() {
+ return "\x1B[31m";
+}
+
+function magenta_start() {
+ return "\x1B[35m";
+}
+
+echo "+", str_repeat("-", 98), "+\n";
+printf("| %-96.96s |\n", "Environment Tests");
+printf("| %-96.96s |\n", "The following tests have been run to determine if Gallery3 will work\n");
+printf("in your environment. If any of the tests have failed, consult the documention on\n");
+printf("http://gallery.menalto.com for more information on how to correct the problem.");
+echo "+", str_repeat("-", 98), "+\n";
+
+
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // <th>PHP Version</th> // //
+ // // //
+ // <? if (empty(self::$errors["php_version"])): ?> // //
+ // <td class="pass"><?php echo PHP_VERSION ?></td> // //
+ // <?php else: ?> // //
+ // <td class="fail">Gallery3 requires PHP 5.2 or newer, this version is <?php echo PHP_VERSION ?>.</td> // //
+ // <?php endif ?> // //
+ // </tr> // //
+ // <tr> // //
+ // <th>System Directory</th> // //
+ // <?php if (empty(self::$errors["syspath"])): ?> // //
+ // <td class="pass"><?php echo SYSPATH ?></td> // //
+ // <?php else: ?> // //
+ // <td class="fail">The configured <code>system</code> directory does not exist or does not contain required files.</td> // //
+ // <?php endif ?> // //
+ // </tr> // //
+ // <tr> // //
+ // <th>Application Directory</th> // //
+ // <?php if (empty(self::$errors["apppath"])): ?> // //
+ // <td class="pass"><?php echo APPPATH ?></td> // //
+ // <?php else: ?> // //
+ // <td class="fail">The configured <code>application</code> directory does not exist or does not contain required files.</td> // //
+ // <?php endif ?> // //
+ // </tr> // //
+ // <tr> // //
+ // <th>Modules Directory</th> // //
+ // <?php if (empty(self::$errors["modpath"])): ?> // //
+ // <td class="pass"><?php echo MODPATH ?></td> // //
+ // <?php else: ?> // //
+ // <td class="fail">The configured <code>modules</code> directory does not exist or does not contain required files.</td> // //
+ // <?php endif ?> // //
+ // </tr> // //
+ // <tr> // //
+ // <th>PCRE UTF-8</th> // //
+ // <?php if (!empty(self::$errors["utf-8"])): ?> // //
+ // <td class="fail"><a href="http://php.net/pcre">PCRE</a> has not been compiled with UTF-8 support.</td> // //
+ // <?php elseif (!empty(self::$errors["unicode"])): ?> // //
+ // <td class="fail"><a href="http://php.net/pcre">PCRE</a> has not been compiled with Unicode property support.</td> // //
+ // <?php else: ?> // //
+ // <td class="pass">Pass</td> // //
+ // <?php endif ?> // //
+ // </tr> // //
+ // <tr> // //
+ // <th>Reflection Enabled</th> // //
+ // <?php if (empty(self::$errors["reflection"])): ?> // //
+ // <td class="pass">Pass</td> // //
+ // <?php else: ?> // //
+ // <td class="fail">PHP <a href="http://www.php.net/reflection">reflection</a> is either not loaded or not compiled in.</td> // //
+ // <?php endif ?> // //
+ // </tr> // //
+ // <tr> // //
+ // <th>Filters Enabled</th> // //
+ // <?php if (empty(self::$errors["filter_list"])): ?> // //
+ // <td class="pass">Pass</td> // //
+ // <?php else: ?> // //
+ // <td class="fail">The <a href="http://www.php.net/filter">filter</a> extension is either not loaded or not compiled in.</td> // //
+ // <?php endif ?> // //
+ // </tr> // //
+ // <tr> // //
+ // <th>Iconv Extension Loaded</th> // //
+ // <?php if (empty(self::$errors["iconv"])): ?> // //
+ // <td class="pass">Pass</td> // //
+ // <?php else: ?> // //
+ // <td class="fail">The <a href="http://php.net/iconv">iconv</a> extension is not loaded.</td> // //
+ // <?php endif ?> // //
+ // </tr> // //
+ // // //
+ // <tr> // //
+ // <th>Mbstring Not Overloaded</th> // //
+ // <?php if (empty(self::$errors["mbstring"])): ?> // //
+ // <td class="pass">Pass</td> // //
+ // <?php else: ?> // //
+ // <td class="fail">The <a href="http://php.net/mbstring">mbstring</a> extension is overloading PHP's native string functions.</td> // //
+ // <?php endif ?> // //
+ // </tr> // //
+ // <tr> // //
+ // <th>URI Determination</th> // //
+ // <?php if (empty(self::$errors["uri"])): ?> // //
+ // <td class="pass">Pass</td> // //
+ // <?php else: ?> // //
+ // <td class="fail">Neither <code>$_SERVER['REQUEST_URI']</code> or <code>$_SERVER['PHP_SELF']</code> is available.</td> // //
+ // <?php endif ?> // //
+ // </tr> // //
+ // <tr> // //
+ // <th>PHP Short Tags</th> // //
+ // <?php if (empty(self::$errors["short tags"])): ?> // //
+ // <td class="pass">Pass</td> // //
+ // <?php else: ?> // //
+ // <td class="fail">Gallery3 needs php short tags enabled.</td> // //
+ // <?php endif ?> // //
+ // </tr> // //
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
diff --git a/installer/views/installer.txt.php b/installer/views/installer.txt.php
new file mode 100644
index 00000000..5c98752f
--- /dev/null
+++ b/installer/views/installer.txt.php
@@ -0,0 +1,44 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+function green_start() {
+ return "\x1B[32m";
+}
+
+function color_end() {
+ return "\x1B[0m";
+}
+
+function red_start() {
+ return "\x1B[31m";
+}
+
+function magenta_start() {
+ return "\x1B[35m";
+}
+
+function print_msg($header, $msg, $error) {
+ $format = "| %-21.21s | %-81.81s |\n";
+ foreach (explode("\n", wordwrap($msg, 72)) as $text) {
+ if ($error) {
+ printf($format, $header, red_start() . $text . color_end());
+ } else {
+ printf($format, $header, green_start() . $text . color_end());
+ }
+ $header = "";
+ }
+}
+
+echo "+", str_repeat("-", 98), "+\n";
+printf("| %-96.96s |\n", "Environment Tests");
+printf("| %-96.96s |\n", "The following tests have been run to determine if Gallery3 will work " .
+ "in your environment.");
+printf("| %-96.96s |\n", "If any of the tests have failed, consult the documention on " .
+ "http://gallery.menalto.com");
+printf("| %-96.96s |\n", "for more information on how to correct the problem.");
+echo "+", str_repeat("-", 98), "+\n";
+
+foreach (self::$messages as $header => $msg) {
+ print_msg($header, $msg["text"], $msg["error"]);
+}
+
+echo "+", str_repeat("-", 98), "+\n";
+flush(); \ No newline at end of file