From a78ca78c9b0210f1eac1ebe798d6b3a55c9ac191 Mon Sep 17 00:00:00 2001 From: "green-ponies (jgen)" Date: Sun, 5 Feb 2012 16:35:34 -0500 Subject: [PATCH] More changes to the install script. More error checking, better formating, etc.. --- core/database.class.php | 2 +- install.php | 65 +++++++++++++++++++++++++++++++---------- 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/core/database.class.php b/core/database.class.php index 27805521..53abd16e 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -310,7 +310,7 @@ class Database { } $matches = array(); - if(CACHE_DSN && preg_match("#(memcache|apc)://(.*)#", CACHE_DSN, $matches)) { + if( defined("CACHE_DSN") && CACHE_DSN && preg_match("#(memcache|apc)://(.*)#", CACHE_DSN, $matches)) { if($matches[1] == "memcache") { $this->cache = new MemcacheCache($matches[2]); } diff --git a/install.php b/install.php index 61a1bf69..a14c4c7a 100755 --- a/install.php +++ b/install.php @@ -54,10 +54,32 @@ if(is_readable("config.php")) {

Shimmie Repair Console

Basic Checks"; @@ -81,14 +103,14 @@ if(is_readable("config.php")) { "; */ echo "

Database Fix for User deletion

"; - echo "This is a database fix for those who instaled shimmie before 2012 January 22rd.
"; - echo "This is only for users with MySQL databases!
"; - echo "Note: Some things needs to be done manually, to work properly.
"; + echo "

This is a database fix for those who instaled shimmie before 2012 January 22rd.

"; + echo "

This is only for users with MySQL databases!

"; + echo "

Note: Some things needs to be done manually, to work properly.
"; echo "Please BACKUP YOUR DATABASE before performing this fix!
"; - echo "WARNING: ONLY PROCEEDS IF YOU KNOW WHAT YOU ARE DOING!
"; + echo "WARNING: ONLY PROCEED IF YOU KNOW WHAT YOU ARE DOING!

"; echo "
- +
"; @@ -101,6 +123,7 @@ if(is_readable("config.php")) { } else if($_GET["action"] == "logout") { session_destroy(); + echo "

Logged Out

You have been logged out.

Main Shimmie Page"; } else if($_GET["action"] == "Database_user_deletion_fix") { Database_user_deletion_fix(); @@ -123,13 +146,24 @@ if(is_readable("config.php")) { echo "\t\t
"; exit; } -require_once "core/compat.inc.php"; -require_once "core/util.inc.php"; -require_once "core/database.class.php"; do_install(); // utilities {{{ + +/** + * Strips off any kind of slash at the end so as to normalise the path. + * @param string $path Path to normalise. + * @return string Path without trailing slash. + */ +function remove_trailing_slash($path) { + if ((substr($path, -1) === '/') || (substr($path, -1) === '\\')) { + return substr($path, 0, -1); + } else { + return $path; + } +} + function check_gd_version() { $gdversion = 0; @@ -394,15 +428,14 @@ EOD; } } // }}} -function Database_user_deletion_fix() { +function Database_user_deletion_fix() { // {{{ try { - require_once "core/database.class.php"; $db = new Database(); - if ($database->db->getAttribute(PDO::ATTR_DRIVER_NAME) !== 'mysql') { + if ($db->db->getAttribute(PDO::ATTR_DRIVER_NAME) !== 'mysql') { echo "

Database is not MySQL - Aborting changes.

"; echo 'Go Back'; - return; + throw new PDOException("Database is not MySQL."); } else { echo "

Performing Database Fix Operations


"; } @@ -443,7 +476,7 @@ function Database_user_deletion_fix() { // FIXME: Make the error message user friendly exit($e->getMessage()); } -} +} // }}} ?>