From bb2e13015fa670f2ae168728c078e7a6c67cb83d Mon Sep 17 00:00:00 2001
From: misilot <misilot@fit.edu>
Date: Tue, 31 May 2011 16:40:40 -0400
Subject: [PATCH 1/4] Converted Patch mantis-1.2.1_cas.patch to work with
 Mantis 1.2.5

Signed-off-by: misilot <misilot@fit.edu>
---
 config_defaults_inc.php     |   77 +++++++++++++++++-
 core/authentication_api.php |  188 ++++++++++++++++++++++++++++++++++++++++++-
 core/constant_inc.php       |    1 +
 login.php                   |    7 ++
 4 files changed, 270 insertions(+), 3 deletions(-)

diff --git a/config_defaults_inc.php b/config_defaults_inc.php
index fcab4c8..4f8a36b 100644
--- a/config_defaults_inc.php
+++ b/config_defaults_inc.php
@@ -1646,6 +1646,81 @@
 	 */
 	$g_hr_width				= 50;
 
+      	/**************************
+	 * MantisBT LDAP Settings *
+	 **************************/
+
+         # --- using phpCAS -------------
+         /**
+          * @global string $g_cas_server
+          */
+         $g_cas_server = 'school.edu';
+
+         /**
+          * @global int $g_cas_port
+          */
+         $g_cas_port = 443;
+
+         /**
+          * The CAS path on the server. E.g. '/cas'
+          * @global int $g_cas_uri
+          */
+         $g_cas_uri = '';
+
+         /**
+          * @global $g_cas_version string
+          */
+         $g_cas_version = '2.0';
+
+         # --- CAS  LDAP -------------
+         /**
+          * Translate CAS username through LDAP.
+          * @global $g_cas_use_ldap int
+          */
+         $g_cas_use_ldap     = OFF;
+
+         /**
+          * The LDAP field matching the Mantis username.
+          * @global $g_ldap_mantis_udi string
+          */
+         $g_ldap_mantis_uid  = 'uid';
+
+         /**
+          * Should Mantis update user details from LDAP while authenticating with CAS?
+          * @global $g_cas_ldap_update int
+          */
+         $g_cas_ldap_update  = OFF;
+
+         /**
+          * E.g. 'cn,userpassword'.
+          * @global $g_cas_ldap_update_fields string
+          */
+         $g_cas_ldap_update_fields = '';
+
+         /**
+          * E.g. 'realname,password'.
+          * @global $g_cas_ldap_update_map string
+          */
+         $g_cas_ldap_update_map    = '';
+
+         /**
+          * This is the field in LDAP to use to set the user's language preference.
+          * @global $g_ldap_language_field string
+          */
+         $g_ldap_language_field = '';
+
+         /**
+          * E.g. 'en,zh_hans,ko'.
+          * @global $g_ldap_language_keys string
+          */
+         $g_ldap_language_keys = '';
+
+         /**
+          * E.g. 'english,chinese_simplified,korean'.
+          * @global $g_ldap_language_values string
+          */
+         $g_cas_ldap_update_values    = '';
+
 	/**************************
 	 * MantisBT LDAP Settings *
 	 **************************/
@@ -2502,7 +2577,7 @@
 
 	/**
 	 * login method
-	 * CRYPT or PLAIN or MD5 or LDAP or BASIC_AUTH
+         * CRYPT or PLAIN or MD5 or LDAP or BASIC_AUTH or CAS_AUTH
 	 * You can simply change this at will. MantisBT will try to figure out how the passwords were encrypted.
 	 * @global int $g_login_method
 	 */
diff --git a/core/authentication_api.php b/core/authentication_api.php
index c091300..a8cb4f6 100644
--- a/core/authentication_api.php
+++ b/core/authentication_api.php
@@ -53,6 +53,178 @@ $g_cache_cookie_valid = null;
 $g_cache_current_user_id = null;
 
 /**
+ * Initialize phpCAS.
+ */
+function auth_cas_init() {
+        # phpCAS must be installed in the include path
+        # or in the Mantis directory.
+        require_once('CAS/CAS.php');
+
+        static $s_initialized=false;
+
+        if (! $s_initialized ) {
+                phpCAS::setDebug();
+        ## These should be set in config_inc.php
+                $t_server_version = config_get( 'cas_version' );
+                $t_server_cas_server = config_get( 'cas_server' );
+                $t_server_port = config_get( 'cas_port' );
+                $t_server_uri = config_get( 'cas_uri' );
+                $t_start_session = (boolean)FALSE; # Mantis takes care of its own session
+
+                phpCAS::client($t_server_version, $t_server_cas_server, $t_server_port, $t_server_uri, $t_start_session);
+                if (method_exists('phpCAS', 'setNoCasServerValidation')) {
+                        // no SSL validation for the CAS server
+                        phpCAS::setNoCasServerValidation();
+                }
+
+                $s_initialized = true;
+        }
+
+}
+
+
+/**
+ * Fetches the user's CAS name, authenticating if needed.
+ * Can translate CAS login name to Mantis username through LDAP.
+ */
+function auth_cas_get_name()
+{
+        # Get CAS username from phpCAS
+        auth_cas_init();
+        phpCAS::forceAuthentication();
+        $t_cas_id = phpCAS::getUser();
+
+        # If needed, translate the CAS username through LDAP
+        $t_username = $t_cas_id;
+        if (config_get( 'cas_use_ldap', false )) {
+                $t_username = auth_cas_ldap_translate( $t_cas_id );
+        }
+        return $t_username;
+}
+
+
+/**
+ * Takes an ID string, and looks up the LDAP directory to find
+ * the matching username for Mantis.
+ *
+ * Optionally, also update the user information in the Mantis user
+ * table.
+ *
+ * @param $p_cas_id string Typically, the username given by phpCAS.
+ * @param $p_update_user bool Whether or not to update user details from LDAP.
+ */
+function auth_cas_ldap_translate( $p_cas_id, $p_update_user='' )
+{
+
+        # Please make sure the Mantis CAS and LDAP settings are set in config_inc.php
+
+        $t_ldap_organization    = config_get( 'ldap_organization' );
+        $t_ldap_root_dn                 = config_get( 'ldap_root_dn' );
+
+        # Required fields in LDAP for CAS
+        $t_ldap_language_field = config_get( 'ldap_language_field', '' );
+        $t_ldap_uid_field = config_get( 'ldap_uid_field', 'uid' ) ;
+        $t_ldap_mantis_uid = config_get( 'ldap_mantis_uid', 'uid' );
+        $t_ldap_required = array( $t_ldap_uid_field, $t_ldap_mantis_uid, 'dn' );
+        if ($t_ldap_language_field) {
+                // Add language field to attributes list only if it is configured.
+                $t_ldap_required[] = $t_ldap_language_field;
+        }
+        $t_ldap_required = array_combine( $t_ldap_required, $t_ldap_required );
+
+        # User-defined fields to fetch from LDAP...
+        $t_ldap_fields = explode( ',', config_get( 'cas_ldap_update_fields' ) );
+        $t_ldap_fields = array_combine( $t_ldap_fields, $t_ldap_fields );
+        # ...which are mapped to Mantis user fields
+        $t_ldap_map = explode( ',', config_get( 'cas_ldap_update_map' ) );
+        $t_ldap_map = array_combine( $t_ldap_map, $t_ldap_map );
+
+        # Build LDAP search filter, attribute list from CAS ID
+        $t_search_filter = "(&$t_ldap_organization($t_ldap_uid_field=$p_cas_id))";
+        $t_search_attrs = array_values($t_ldap_required + $t_ldap_fields);      # array union
+
+        # Use Mantis ldap_api to connect to LDAP
+        $t_ds = ldap_connect_bind();
+        $t_sr   = ldap_search( $t_ds, $t_ldap_root_dn, $t_search_filter, $t_search_attrs );
+        $t_info = ldap_get_entries( $t_ds, $t_sr );
+        # Parse the LDAP entry to find the Mantis username
+        if ( $t_info ) {
+                # Get Mantis username
+                $t_username = $t_info[0][$t_ldap_mantis_uid][0];
+
+                # @@@ The fact that we got here means the user is authenticated
+                # @@@ by CAS, and has an LDAP entry.
+                # @@@ We might as well update other user details since we are here.
+
+                # If no argument given, check settings
+                if ( '' == $p_update_user ) {
+                        $p_update_user = config_get( 'cas_ldap_update', FALSE );
+                }
+                # If there's a user record, then update it
+                if ( $p_update_user ) {
+                        # Only proceed if the field map arrays are the same length
+                        $t_field_map = array_combine( $t_ldap_fields, $t_ldap_map );
+                        if ($t_field_map) {
+                                # If user is new, then we must create their account before updating it
+                                # @@@ ( make sure $g_allow_blank_email == ON )
+                                $t_userid = user_get_id_by_name($t_username);
+                                if ( false == $t_userid ) {
+                                        user_create( $t_username, '' );
+                                        # @@@ Wow, this is pretty lame
+                                        $t_userid = user_get_id_by_name($t_username);
+                                }
+                                # @@@ maybe we can optimize this to write all fields at once?
+                                foreach ( $t_field_map as $key=>$t_userfield ) {
+                                        if (isset($t_info[0][$key][0])) {
+                                                user_set_field( $t_userid, $t_userfield, $t_info[0][$key][0] );
+                                        }
+                                }
+                        }
+
+                        // Update user's overall language preference
+                        if ($t_ldap_language_field) {
+                                $t_language = $t_info[0][$t_ldap_language_field][0];
+                                // Map the LDAP language field to Mantis' language field if needed
+                                $t_language_keys = config_get( 'ldap_language_keys', '');
+                                $t_language_values = config_get( 'ldap_language_values', '');
+                                $t_language_map = array_combine(
+                                        explode(',', $t_language_keys),
+                                        explode(',', $t_language_values)
+                                );
+                                if (isset($t_language_map[$t_language])) {
+                                        $t_language = $t_language_map[$t_language];
+                                }
+                                user_pref_set_pref($t_userid, 'language', $t_language);
+                        }
+                }
+        }
+        ldap_free_result( $t_sr );
+        ldap_unbind( $t_ds );
+
+        return $t_username;
+}
+
+
+/**
+ * Logs out of CAS, redirecting to Mantis on re-login.
+ * User should already be logged out of Mantis by the time this is called.
+ * @see auth_logout()
+ */
+function auth_cas_logout()
+{
+        $t_path = config_get('path');
+
+        auth_cas_init();
+        if (method_Exists('phpCAS', 'logoutWithUrl')) {
+                phpCAS::logoutWithUrl($t_path);
+        } else {
+                phpCAS::logout($t_path);
+        }
+}
+
+
+
+/**
  * Check that there is a user logged-in and authenticated
  * If the user's account is disabled they will be logged out
  * If there is no user logged in, redirect to the login page
@@ -183,6 +355,9 @@ function auth_attempt_login( $p_username, $p_password, $p_perm_login = false ) {
 
 	if ( false === $t_user_id ) {
 		if ( BASIC_AUTH == $t_login_method ) {
+                        if ( in_array( $t_login_method, array( BASIC_AUTH, CAS_AUTH ) ) ) {
+                        # attempt to create the user if using BASIC_AUTH or CAS_AUTH
+                        # ( note: CAS_AUTH must have $g_allow_blank_email == ON )
 			$t_auto_create = true;
 		} else if ( LDAP == $t_login_method && ldap_authenticate_by_username( $p_username, $p_password ) ) {
 			$t_auto_create = true;
@@ -311,7 +486,10 @@ function auth_logout() {
 	if( HTTP_AUTH == config_get( 'login_method' ) ) {
 		auth_http_set_logout_pending( true );
 	}
-
+        elseif ( CAS_AUTH == config_get( 'login_method' ) ) {
+        # Redirect to CAS page to logout
+        auth_cas_logout();
+        }
 	session_clean();
 }
 
@@ -324,6 +502,8 @@ function auth_automatic_logon_bypass_form() {
 	switch( config_get( 'login_method' ) ) {
 		case HTTP_AUTH:
 			return true;
+                case CAS_AUTH:
+                        return true;
 	}
 	return false;
 }
@@ -342,6 +522,10 @@ function auth_does_password_match( $p_user_id, $p_test_password ) {
 	if( LDAP == $t_configured_login_method ) {
 		return ldap_authenticate( $p_user_id, $p_test_password );
 	}
+        elseif ( CAS_AUTH == $t_configured_login_method ) {
+                # CAS already took care of password verification for us
+                return true;
+        }
 
 	$t_password = user_get_field( $p_user_id, 'password' );
 	$t_login_methods = Array(
@@ -617,7 +801,7 @@ function auth_set_tokens( $p_user_id ) {
  * @access public
  */
 function auth_reauthenticate() {
-	if( config_get_global( 'reauthentication' ) == OFF || BASIC_AUTH == config_get( 'login_method' ) || HTTP_AUTH == config_get( 'login_method' ) ) {
+        if( config_get_global( 'reauthentication' ) == OFF || in_array(config_get('login_method'), array(BASIC_AUTH, HTTP_AUTH, CAS_AUTH)) ) {
 		return true;
 	}
 
diff --git a/core/constant_inc.php b/core/constant_inc.php
index c47a93c..50bc036 100644
--- a/core/constant_inc.php
+++ b/core/constant_inc.php
@@ -134,6 +134,7 @@ define( 'MD5', 3 );
 define( 'LDAP', 4 );
 define( 'BASIC_AUTH', 5 );
 define( 'HTTP_AUTH', 6 );
+define( 'CAS_AUTH', 7);
 
 # file upload methods
 define( 'DISK', 1 );
diff --git a/login.php b/login.php
index 3d14bc2..094bb2d 100644
--- a/login.php
+++ b/login.php
@@ -33,6 +33,13 @@
 	$f_from			= gpc_get_string( 'from', '' );
 	$f_secure_session = gpc_get_bool( 'secure_session', false );
 
+        if ( CAS_AUTH == config_get( 'login_method' ) ) {
+           # This will detour to the CAS login page if needed
+           $f_password = '';
+           $f_username = auth_cas_get_name();
+           # User is always authenticated by this point
+        }
+
 	$f_username = auth_prepare_username($f_username);
 	$f_password = auth_prepare_password($f_password);
 
-- 
1.7.5.2


From b77f2129a532aa06b7f1b07c754526bc58ff0f21 Mon Sep 17 00:00:00 2001
From: misilot <misilot@fit.edu>
Date: Tue, 31 May 2011 18:14:44 -0400
Subject: [PATCH 2/4] s

Signed-off-by: misilot <misilot@fit.edu>
---
 admin/admin.css                    |   27 -
 admin/check.php                    |  409 ---------------
 admin/copy_field.php               |  128 -----
 admin/db_stats.php                 |   56 --
 admin/email_queue.php              |   75 ---
 admin/index.php                    |   80 ---
 admin/install.php                  | 1015 ------------------------------------
 admin/install_functions.php        |  262 ----------
 admin/install_helper_functions.php |   68 ---
 admin/move_db2disk.php             |  200 -------
 admin/schema.php                   |  610 ----------------------
 admin/system_utils.php             |   98 ----
 admin/test_email.php               |   77 ---
 admin/test_icons.php               |   47 --
 admin/test_langs.php               |  363 -------------
 admin/upgrade_unattended.php       |  154 ------
 admin/upgrade_warning.php          |   84 ---
 core/authentication_api.php        |    7 +-
 18 files changed, 2 insertions(+), 3758 deletions(-)
 delete mode 100644 admin/admin.css
 delete mode 100644 admin/check.php
 delete mode 100644 admin/copy_field.php
 delete mode 100644 admin/db_stats.php
 delete mode 100644 admin/email_queue.php
 delete mode 100644 admin/index.php
 delete mode 100644 admin/install.php
 delete mode 100644 admin/install_functions.php
 delete mode 100644 admin/install_helper_functions.php
 delete mode 100644 admin/move_db2disk.php
 delete mode 100644 admin/schema.php
 delete mode 100644 admin/system_utils.php
 delete mode 100644 admin/test_email.php
 delete mode 100644 admin/test_icons.php
 delete mode 100644 admin/test_langs.php
 delete mode 100644 admin/upgrade_unattended.php
 delete mode 100644 admin/upgrade_warning.php

diff --git a/admin/admin.css b/admin/admin.css
deleted file mode 100644
index 31cba82..0000000
--- a/admin/admin.css
+++ /dev/null
@@ -1,27 +0,0 @@
-body { background-color: #ffffff; font-family:Verdana, Arial; font-size: 10pt }
-
-td { font-family:Verdana, Arial; font-size: 10pt }
-
-p { font-family:Verdana, Arial; font-size: 10pt }
-
-.title    { font-family:Verdana, Arial; font-size: 12pt; color: #000000; font-weight: bold; }
-
-tr.top-bar { background-color: #98b8e8; padding: 3px; padding: 3px; color: #204888 }
-
-tr.top-bar td { border-top: 1px solid #222222; border-bottom: 1px solid #222222 }
-
-tr.top-bar td.title { text-align: right; font-size: 10pt; font-weight: bold; letter-spacing: 1.0em; }
-
-tr.top-bar td.links { text-align: left; font-size: 8pt }
-
-tr.row-1 { background-color: #d8d8d8; color: #000000; }
-
-tr.row-2 { background-color: #e8e8e8; color: #000000; }
-
-table.width100		{ width: 100%; border: solid 1px #000000; }
-
-table.width50		{ width: 50%; border: solid 1px #000000; }
-
-td.center			{ text-align: center; }
-
-.error { background-color: red; color: black; }
diff --git a/admin/check.php b/admin/check.php
deleted file mode 100644
index 5b26c55..0000000
--- a/admin/check.php
+++ /dev/null
@@ -1,409 +0,0 @@
-<?php
-# MantisBT - a php based bugtracking system
-
-# MantisBT 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.
-#
-# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * @package MantisBT
- * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
- * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
- * @link http://www.mantisbt.org
- */
-
-error_reporting( E_ALL );
-
-$g_skip_open_db = true;  # don't open the database in database_api.php
-
-/**
- * MantisBT Core API's
- */
-require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
-
-require_once( 'email_api.php' );
-require_once( 'database_api.php' );
-
-$f_showall = gpc_get_int( 'showall', false );
-
-$g_failed_test = false;
-
-function print_test_result( $p_result ) {
-	global $g_failed_test;
-	switch ( $p_result ) {
-		case BAD:
-			echo '<td bgcolor="#ff0088">BAD</td>';
-			$g_failed_test = true;
-			break;
-		case GOOD:
-			echo '<td bgcolor="#00ff88">GOOD</td>';
-			break;
-		case WARN:
-			echo '<td bgcolor="#E56717">WARN</td>';
-			break;
-	}
-}
-
-function print_info_row( $p_description, $p_info = null ) {
-	if( $p_info == null ) {
-		echo '<tr><td bgcolor="#ffffff" colspan="2">' . $p_description . '</td></tr>';
-	} else {
-		echo '<tr><td bgcolor="#ffffff">' . $p_description . '</td>';
-		echo '<td bgcolor="#ffffff">' . $p_info . '</td></tr>';
-	}
-}
-
-function print_test_row( $p_description, $p_pass, $p_info = null ) {
-	global $f_showall;
-	if ( $f_showall == false && $p_pass == true ) {
-		return $p_pass;
-	}
-	echo '<tr><td bgcolor="#ffffff">' .$p_description;
-	if( $p_info != null) {
-		if( is_array( $p_info ) ) {
-			if( isset( $p_info[$p_pass] ) ) {
-				echo '<br /><i>' . $p_info[$p_pass] . '</i>';
-			}
-		} else {
-			echo '<br /><i>' . $p_info . '</i>';
-		}
-	}
-	echo '</td>';
-
-	if( $p_pass ) {
-		print_test_result( GOOD );
-	} else {
-		print_test_result( BAD );
-	}
-
-	echo '</tr>';
-
-	return $p_pass;
-}
-
-function print_test_warn_row( $p_description, $p_pass, $p_info = null ) {
-	global $f_showall;
-	if ( $f_showall == false && $p_pass == true ) {
-		return $p_pass;
-	}
-	echo '<tr><td bgcolor="#ffffff">' . $p_description;
-	if( $p_info != null) {
-		if( is_array( $p_info ) ) {
-			echo '<br /><i>' . $p_info[$p_pass] . '</i>';
-		} else {
-			echo '<br /><i>' . $p_info . '</i>';
-		}
-	}
-	echo '</td>';
-
-	if( $p_pass ) {
-		print_test_result( GOOD );
-	} else {
-		print_test_result( WARN );
-	}
-
-	echo '</tr>';
-
-	return $p_pass;
-}
-
-function test_bug_download_threshold() {
-	$t_pass = true;
-
-	$t_view_threshold = config_get_global( 'view_attachments_threshold' );
-	$t_download_threshold = config_get_global( 'download_attachments_threshold' );
-	$t_delete_threshold = config_get_global( 'delete_attachments_threshold' );
-
-	if( $t_view_threshold > $t_download_threshold ) {
-		$t_pass = false;
-	} else {
-		if( $t_download_threshold > $t_delete_threshold ) {
-			$t_pass = false;
-		}
-	}
-
-	print_test_row( 'Bug attachments download thresholds (view_attachments_threshold, ' .
-		'download_attachments_threshold, delete_attachments_threshold)', $t_pass );
-
-	return $t_pass;
-}
-
-function test_bug_attachments_allow_flags() {
-	$t_pass = true;
-
-	$t_own_view = config_get_global( 'allow_view_own_attachments' );
-	$t_own_download = config_get_global( 'allow_download_own_attachments' );
-	$t_own_delete = config_get_global( 'allow_delete_own_attachments' );
-
-	if(( $t_own_delete == ON ) && ( $t_own_download == FALSE ) ) {
-		$t_pass = false;
-	} else {
-		if(( $t_own_download == ON ) && ( $t_own_view == OFF ) ) {
-			$t_pass = false;
-		}
-	}
-
-	print_test_row( 'Bug attachments allow own flags (allow_view_own_attachments, ' .
-		'allow_download_own_attachments, allow_delete_own_attachments)', $t_pass );
-
-	return $t_pass;
-}
-
-function check_zend_optimiser_version() {
-	$t_pass = false;
-
-	ob_start();
-	phpinfo(INFO_GENERAL);
-	$t_output = ob_get_contents();
-	ob_end_clean();
-
-	$t_output = str_replace(array("&gt;", "&lt;", "&quot;", "&amp;", "&#039;", "&#160;"), array(">", "<", "\"", "&", "'", " "), $t_output);
-
-	$t_zend_optimizer_min_version = '3.3.3';
-
-	$t_info = '';
-
-	if ( preg_match( '/with Zend Optimizer\+? v([\d\.]*)/', $t_output, $t_matches ) === 1 ) {
-		if ( version_compare( $t_matches[1], $t_zend_optimizer_min_version, '>=' ) ) {
-			$t_pass = true;
-		} else {
-			$t_info = 'Fail - Installed Version: ' . $t_matches[1] . '. Zend Optimizer should be version be version ' . $t_zend_optimizer_min_version . ' or greater! Some old versions cause the view issues page not to display completely. The latest version of Zend Optimizer can be found at www.zend.com';
-		}
-	} else {
-		$t_pass = true;
-		$t_info = 'Zend Optimizer not detected.';
-	}
-
-	print_test_row( 'Checking Zend Optimizer version (if installed)...', $t_pass, $t_info );
-
-	return $t_pass;
-}
-
-function test_database_utf8() {
-	if ( !db_is_mysql() ) {
-		return;
-	}
-
-	// table collation/character set check
-	$result = db_query_bound( 'SHOW TABLE STATUS' );
-	while( $row = db_fetch_array( $result ) ) {
-		if( $row['Comment'] !== 'VIEW' ) {
-			print_test_row( 'Checking Table Collation is utf8 for ' . $row['Name'] . '....', substr( $row['Collation'], 0, 5 ) === 'utf8_', $row['Collation'] );
-		}
-	}
-
-	foreach( db_get_table_list() as $t_table ) {
-		if( db_table_exists( $t_table ) ) {
-			$result = db_query_bound( 'SHOW FULL FIELDS FROM ' . $t_table );
-			while( $row = db_fetch_array( $result ) ) {
-				if ( $row['Collation'] === null ) {
-					continue;
-				}
-				print_test_row( 'Checking Non-null Column Collation in ' . $t_table . ' is utf8 for ' . $row['Field'] . '....', substr( $row['Collation'], 0, 5 ) === 'utf8_', $row['Collation'] . ' ( ' . $row['Type'] . ')' );
-			}
-		}
-	}
-}
-
-
-
-	html_page_top( 'MantisBT Administration - Check Installation' );
-
-?>
-<table class="width75" align="center" cellspacing="1">
-<tr>
-<td class="form-title" width="30%" colspan="2"><?php echo 'Checking your installation' ?></td>
-</tr>
-
-<?php 
-
-	require_once( 'obsolete.php' );
-
-print_test_row( 'MantisBT requires at least <b>PHP ' . PHP_MIN_VERSION . '</b>. You are running <b>PHP ' . phpversion(), $result = version_compare( phpversion(), PHP_MIN_VERSION, '>=' ) );
-
-if ( !print_test_row( 'Checking Config File Exists', file_exists( $g_absolute_path . 'config_inc.php' ), array( false => 'Please use install.php to perform initial installation <a href="install.php">Click here</a>' ) ) ) {
-	die;
-}
-
-print_test_row( 'Opening connection to database [' . config_get_global( 'database_name' ) . '] on host [' . config_get_global( 'hostname' ) . '] with username [' . config_get_global( 'db_username' ) . ']', @db_connect( config_get_global( 'dsn', false ), config_get_global( 'hostname' ), config_get_global( 'db_username' ), config_get_global( 'db_password' ), config_get_global( 'database_name' ) ) != false );
-if( !db_is_connected() ) {
-	print_info_row( 'Database is not connected - Can not continue checks' );
-}
-
-if( isset( $ADODB_vers ) ) {
-	# ADOConnection::Version() is broken as it treats v5.1 the same as v5.10
-	# Therefore we must extract the correct version ourselves
-	# Upstream bug report: http://phplens.com/lens/lensforum/msgs.php?id=18320
-	if( preg_match( '/^[Vv]([0-9\.]+)/', $ADODB_vers, $t_matches ) == 1 ) {
-		$t_adodb_version_check_ok = version_compare( $t_matches[1], '5.10', '>=' );
-	}
-}
-print_test_warn_row( 'Checking adodb version...', $t_adodb_version_check_ok, $ADODB_vers );
-
-print_test_row('Checking using bundled adodb with some drivers...', !(db_is_pgsql() || db_is_mssql() || db_is_db2()) || strstr($ADODB_vers, 'MantisBT Version') !== false );
-$t_serverinfo = $g_db->ServerInfo();
-	
-print_info_row( 'Database Type (adodb)', $g_db->databaseType );
-print_info_row( 'Database Provider (adodb)', $g_db->dataProvider );
-print_info_row( 'Database Server Description (adodb)', $t_serverinfo['description'] );
-print_info_row( 'Database Server Description (version)', $t_serverinfo['version'] );
-
-print_test_row( 'Checking to see if your absolute_path config option has a trailing slash: "' . config_get_global( 'absolute_path' ) . '"', ( "\\" == substr( config_get_global( 'absolute_path' ), -1, 1 ) ) || ( "/" == substr( config_get_global( 'absolute_path' ), -1, 1 ) ) );
-
-// Windows-only checks
-if( is_windows_server() ) {
-	print_test_row( 'validate_email (if ON) requires php 5.3 on windows...',
-		OFF == config_get_global( 'validate_email' ) || ON == config_get_global( 'validate_email' ) && version_compare( phpversion(), '5.3.0', '>=' ) );
-	print_test_row( 'check_mx_record (if ON) requires php 5.3 on windows...',
-		OFF == config_get_global( 'check_mx_record' ) || ON == config_get_global( 'check_mx_record' ) && version_compare( phpversion(), '5.3.0', '>=' ) );
-}
-
-$t_vars = array(
-	'magic_quotes_gpc',
-	'include_path',
-);
-
-while( list( $t_foo, $t_var ) = each( $t_vars ) ) {
-	print_info_row( $t_var, ini_get( $t_var ) );
-}
-
-if ( db_is_mssql() ) {
-	if ( print_test_row( 'check mssql textsize in php.ini...', ini_get( 'mssql.textsize' ) != 4096, ini_get( 'mssql.textsize' ) ) ) {
-		print_test_warn_row( 'check mssql textsize in php.ini...', ini_get( 'mssql.textsize' ) == 2147483647, ini_get( 'mssql.textsize' ) );
-	}
-	if ( print_test_row( 'check mssql textsize in php.ini...', ini_get( 'mssql.textlimit' ) != 4096 , ini_get( 'mssql.textlimit' ) ) ) {
-		print_test_warn_row( 'check mssql textsize in php.ini...', ini_get( 'mssql.textsize' ) == 2147483647, ini_get( 'mssql.textsize' ) );
-	}
-}
-print_test_row( 'check variables_order includes GPCS', stristr( ini_get( 'variables_order' ), 'G' ) && stristr( ini_get( 'variables_order' ), 'P' ) && stristr( ini_get( 'variables_order' ), 'C' ) && stristr( ini_get( 'variables_order' ), 'S' ), ini_get( 'variables_order' ) );
-
-
-test_bug_download_threshold();
-test_bug_attachments_allow_flags();
-
-print_test_row( 'check mail configuration: send_reset_password = ON requires allow_blank_email = OFF',
-	( ( OFF == config_get_global( 'send_reset_password' ) ) || ( OFF == config_get_global( 'allow_blank_email' ) ) ) );
-print_test_row( 'check mail configuration: send_reset_password = ON requires enable_email_notification = ON',
-	( OFF == config_get_global( 'send_reset_password' ) ) || ( ON == config_get_global( 'enable_email_notification' ) ) );
-print_test_row( 'check mail configuration: allow_signup = ON requires enable_email_notification = ON',
-	( OFF == config_get_global( 'allow_signup' ) ) || ( ON == config_get_global( 'enable_email_notification' ) ) );
-print_test_row( 'check mail configuration: allow_signup = ON requires send_reset_password = ON',
-	( OFF == config_get_global( 'allow_signup' ) ) || ( ON == config_get_global( 'send_reset_password' ) ) );
-print_test_row( 'check language configuration: fallback_language is not \'auto\'',
-	'auto' <> config_get_global( 'fallback_language' ) );
-print_test_row( 'check configuration: allow_anonymous_login = ON requires anonymous_account to be set',
-	( OFF == config_get_global( 'allow_anonymous_login' ) ) || ( strlen( config_get_global( 'anonymous_account') ) > 0 ) );
-
-$t_anon_user = false;
-
-print_test_row( 'check configuration: anonymous_account is a valid username if set',
-	( (strlen( config_get_global( 'anonymous_account') ) > 0 ) ? ( ($t_anon_user = user_get_id_by_name( config_get_global( 'anonymous_account') ) ) !== false ) : TRUE ) );
-print_test_row( 'check configuration: anonymous_account should not be an administrator',
-	( $t_anon_user ? ( !user_is_administrator( $t_anon_user ) ) : TRUE ) );
-print_test_row( '$g_bug_link_tag is not empty ("' . config_get_global( 'bug_link_tag' ) . '")',
-	'' <> config_get_global( 'bug_link_tag' ) );
-print_test_row( '$g_bugnote_link_tag is not empty ("' . config_get_global( 'bugnote_link_tag' ) . '")',
-	'' <> config_get_global( 'bugnote_link_tag' ) );
-print_test_row( 'filters: dhtml_filters = ON requires use_javascript = ON',
-	( OFF == config_get_global( 'dhtml_filters' ) ) || ( ON == config_get_global( 'use_javascript' ) ) );
-print_test_row( 'Phpmailer sendmail configuration requires escapeshellcmd. Please use a different phpmailer method if this is blocked.',
-	( PHPMAILER_METHOD_SENDMAIL != config_get( 'phpMailer_method' ) || ( PHPMAILER_METHOD_SENDMAIL == config_get( 'phpMailer_method' ) ) && function_exists( 'escapeshellcmd' ) ) );
-print_test_row( 'Phpmailer sendmail configuration requires escapeshellarg. Please use a different phpmailer method if this is blocked.',
-	( PHPMAILER_METHOD_SENDMAIL != config_get( 'phpMailer_method' ) || ( PHPMAILER_METHOD_SENDMAIL == config_get( 'phpMailer_method' ) ) && function_exists( 'escapeshellarg' ) ) );
-
-check_zend_optimiser_version();
-
-if( plugin_is_installed( 'MantisGraph' ) ) {
-	plugin_push_current( 'MantisGraph' );
-
-	print_test_row( 'checking gd is enabled, and version 2...', get_gd_version() == 2 );
-	if ( plugin_config_get( 'eczlibrary', OFF ) == OFF ) {
-		$t_jpgraph_path = config_get( 'absolute_path' ) . 'library' . DIRECTORY_SEPARATOR . 'jpgraph' . DIRECTORY_SEPARATOR;
-
-		if( !file_exists( $t_jpgraph_path . 'jpgraph.php') ) {
-			print_test_row( 'checking we can find jpgraph class files...', false );
-		} else {
-			require_once( $t_jpgraph_path . 'jpgraph.php' );
-			print_test_row( 'Checking Jpgraph version (if installed)...', version_compare(JPG_VERSION, '2.3.0') ? true : false, JPG_VERSION );
-		}
-
-		print_test_row( 'check configuration: jpgraph (if used) requires php bundled gd for antialiasing support',
-			( plugin_config_get( 'jpgraph_antialias', OFF ) == OFF || function_exists('imageantialias') ) );
-	}
-	plugin_pop_current();
-}
-
-print_test_row( 'Checking if ctype is enabled in php (required for rss feeds)....', extension_loaded('ctype') );
-
-print_test_row( 'Checking for mysql is at least version 4.1...', !(db_is_mysql() && version_compare( $t_serverinfo['version'], '4.1.0', '<' ) ) );
-print_test_row( 'Checking for broken mysql version ( bug 10250)...', !(db_is_mysql() && $t_serverinfo['version'] == '4.1.21') );
-
-if ( !is_blank ( config_get_global( 'default_timezone' ) ) ) {
-	if ( print_test_row( 'Checking if a timezone is set in config.inc.php....', !is_blank ( config_get_global( 'default_timezone' ) ), config_get_global( 'default_timezone' ) ) ) {
-		print_test_row( 'Checking if timezone is valid from config.inc.php....', in_array( config_get_global( 'default_timezone' ), timezone_identifiers_list() ), config_get_global( 'default_timezone' ) );
-	}
-} else {
-	if( print_test_row( 'Checking if timezone is set in php.ini....', ini_get( 'date.timezone' ) !== '' ) ) {
-		print_test_row( 'Checking if timezone is valid in php.ini....', in_array( ini_get( 'date.timezone' ), timezone_identifiers_list() ), ini_get( 'date.timezone' ) );
-	}
-}
-
-test_database_utf8();
-
-print_test_row( 'Checking Register Globals is set to off', ! ini_get_bool( 'register_globals' ) );
-
-print_test_row( 'Checking CRYPT_FULL_SALT is NOT logon method', ! ( CRYPT_FULL_SALT == config_get_global( 'login_method' ) ) );
-
-print_test_warn_row( 'Warn if passwords are stored in PLAIN text', ! ( PLAIN == config_get_global( 'login_method' ) ) );
-print_test_warn_row( 'Warn if CRYPT is used (not MD5) for passwords', ! ( CRYPT == config_get_global( 'login_method' ) ) );
-
-if ( config_get_global( 'allow_file_upload' ) ) {
-	print_test_row( 'Checking that fileuploads are allowed in php (enabled in mantis config)', ini_get_bool( 'file_uploads' ) );
-	
-	print_info_row( 'PHP variable "upload_max_filesize"', ini_get_number( 'upload_max_filesize' ) );
-	print_info_row( 'PHP variable "post_max_size"', ini_get_number( 'post_max_size' ) );
-	print_info_row( 'MantisBT variable "max_file_size"', config_get_global( 'max_file_size' ) );
-
-	print_test_row( 'Checking MantisBT upload file size is less than php', ( config_get_global( 'max_file_size' ) <= ini_get_number( 'post_max_size' ) ) && ( config_get_global( 'max_file_size' ) <= ini_get_number( 'upload_max_filesize' ) ) );
-
-	if( DATABASE == config_get_global( 'file_upload_method' ) ) {
-		print_info_row( 'There may also be settings in your web server and database that prevent you from  uploading files or limit the maximum file size.  See the documentation for those packages if you need more information.');
-		if( 500 < min( ini_get_number( 'upload_max_filesize' ), ini_get_number( 'post_max_size' ), config_get_global( 'max_file_size' ) ) ) {
-			print_info_row( '<span class="error">Your current settings will most likely need adjustments to the PHP max_execution_time or memory_limit settings, the MySQL max_allowed_packet setting, or equivalent.' );
-		}
-	}
-	
-	print_info_row( 'There may also be settings in your web server that prevent you from  uploading files or limit the maximum file size.  See the documentation for those packages if you need more information.');
-}
-?>
-</table>
-<?php
-	if ( $g_failed_test ) {
-?>
-	 <table width="100%" bgcolor="#222222" border="0" cellpadding="20" cellspacing="1">
-	<tr>
-		<td bgcolor="#f4f4f4">Some Tests Failed. Please correct failed tests before using MantisBT.</td>
-	</tr>
-	</table>
-<?php
-	} else {
-?>
-	 <table width="100%" bgcolor="#222222" border="0" cellpadding="20" cellspacing="1">
-	<tr>
-		<td bgcolor="#f4f4f4">All Tests Passed. If you would like to view passed tests click <a href="check.php?showall=1">here</a>.</td>
-	</tr>
-	</table>
-<?php	
-	}
-?>
-</body>
-</html>
diff --git a/admin/copy_field.php b/admin/copy_field.php
deleted file mode 100644
index a45381a..0000000
--- a/admin/copy_field.php
+++ /dev/null
@@ -1,128 +0,0 @@
-<?php
-# MantisBT - a php based bugtracking system
-
-# MantisBT 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.
-#
-# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
-# This upgrade moves attachments from the database to the disk
-
-/**
- * @package MantisBT
- * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
- * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
- * @link http://www.mantisbt.org
- */
-/**
- * MantisBT Core API's
- */
-require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
-
-access_ensure_global_level( config_get_global( 'admin_site_threshold' ) );
-
-$f_source_field_id = gpc_get_int( 'source_id' );
-$f_dest_field = gpc_get( 'dest_id' );
-?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
-<head>
-<title> MantisBT Administration - Copy Custom Fields to Built-in </title>
-<link rel="stylesheet" type="text/css" href="admin.css" />
-</head>
-<body>
-
-<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
-	<tr class="top-bar">
-		<td class="links">
-			[ <a href="system_utils.php">Back to System Utilities</a> ]
-			[ <a href="copy_field.php?source_id=<?php echo $f_source_field_id?>&amp;dest_id=<?php echo $f_dest_field?>">Refresh view</a> ]
-		</td>
-		<td class="title">
-			MantisBT Administration - Copy Custom Fields to Built-in
-		</td>
-	</tr>
-</table>
-<br /><br />
-
-<?php
-# checks on validity
-$t_valid_fields = array(
-	'fixed_in_version',
-);
-if( !in_array( $f_dest_field, $t_valid_fields ) ) {
-	echo '<p>Invalid destination field (' . $f_dest_field . ') specified.</p>';
-	echo '</body></html>';
-	exit;
-}
-
-# @@@ check that source and destination are compatible
-
-$t_string_table = db_get_table( 'mantis_custom_field_string_table' );
-$t_bug_table = db_get_table( 'mantis_bug_table' );
-$query = 'SELECT * FROM ' . $t_string_table . ' WHERE field_id = ' . db_param() . ' and value <> ' . db_param();
-
-$result = @db_query_bound( $query, Array( $f_source_field_id, '' ) );
-if( FALSE == $result ) {
-	echo '<p>No fields need to be updated.</p>';
-}
-else {
-
-	$count = db_num_rows( $result );
-	echo '<p>Found ' . $count . ' fields to be updated.</p>';
-	$t_failures = 0;
-
-	if( $count > 0 ) {
-		echo '<table width="80%" bgcolor="#222222" border="0" cellpadding="10" cellspacing="1">';
-
-		# Headings
-		echo '<tr bgcolor="#ffffff"><th width="10%">Bug Id</th><th width="20%">Field Value</th><th width="70%">Status</th></tr>';
-	}
-
-	for( $i = 0;$i < $count;$i++ ) {
-		$row = db_fetch_array( $result );
-		extract( $row, EXTR_PREFIX_ALL, 'v' );
-
-		# trace bug id back to project
-		$t_project_id = bug_get_field( $v_bug_id, 'project_id' );
-		$t_cust_value = $v_value;
-		printf("\n<tr %s><td><a href=\"../view.php?id=%d\">%07d</a></td><td>%s</td><td>",
-			helper_alternate_class(), $v_bug_id, $v_bug_id, $v_value);
-
-		# validate field contents
-		switch( $f_dest_field ) {
-			case 'fixed_in_version':
-				$t_valid = ( version_get_id( $t_cust_value, $t_project_id ) == FALSE ) ? FALSE : TRUE;
-				break;
-			default:
-				$t_valid = FALSE;
-		}
-		if( $t_valid ) {
-
-			# value was valid, update value
-			if( !bug_set_field( $v_bug_id, $f_dest_field, $t_cust_value ) ) {
-				echo 'database update failed';
-				$t_failures++;
-			} else {
-				echo 'applied';
-			}
-		} else {
-			echo 'field value was not valid or previously defined';
-			$t_failures++;
-		}
-		echo '</td></tr>';
-	}
-
-	echo '</table><br />' . $count . ' fields processed, ' . $t_failures . ' failures';
-}
-echo '<p> Completed...<p>';
-?>
-</body>
-</html>
diff --git a/admin/db_stats.php b/admin/db_stats.php
deleted file mode 100644
index c50efff..0000000
--- a/admin/db_stats.php
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-# MantisBT - a php based bugtracking system
-
-# MantisBT 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.
-#
-# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * @package MantisBT
- * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
- * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
- * @link http://www.mantisbt.org
- */
-/**
- * MantisBT Core API's
- */
-require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
-
-access_ensure_global_level( config_get_global( 'admin_site_threshold' ) );
-
-# --------------------
-function helper_table_row_count( $p_table ) {
-	$t_table = $p_table;
-	$query = "SELECT COUNT(*) FROM $t_table";
-	$result = db_query_bound( $query );
-	$t_users = db_result( $result );
-
-	return $t_users;
-}
-
-# --------------------
-function print_table_stats( $p_table_name ) {
-	$t_count = helper_table_row_count( $p_table_name );
-	echo "$p_table_name = $t_count records<br />";
-}
-
-echo '<html><head><title>MantisBT Database Statistics</title></head><body>';
-
-echo '<h1>MantisBT Database Statistics</h1>';
-
-foreach( db_get_table_list() as $t_table ) {
-	if( db_table_exists( $t_table ) ) {
-		print_table_stats( $t_table );
-	}
-}
-
-echo '</body></html>';
diff --git a/admin/email_queue.php b/admin/email_queue.php
deleted file mode 100644
index 6527b57..0000000
--- a/admin/email_queue.php
+++ /dev/null
@@ -1,75 +0,0 @@
-<?php
-# MantisBT - a php based bugtracking system
-
-# Mantis 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.
-#
-# Mantis 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * @package MantisBT
- * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
- * @copyright Copyright (C) 2002 - 2011  Mantis Team   - mantisbt-dev@lists.sourceforge.net
- * @link http://www.mantisbt.org
- */
-/**
- * Mantis Core API's
- */
-require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
-
-access_ensure_global_level( config_get_global( 'admin_site_threshold' ) );
-
-$f_to = gpc_get( 'send', null );
-
-if ( $f_to !== null ) {
-	if ( $f_to == 'all' ) {
-		echo "Sending emails...<br />";
-		email_send_all();
-		echo "Done";
-	} else if ( $f_to == 'sendordelall' ) {
-		echo "Sending or deleting emails...<br />";
-		email_send_all(true);
-		echo "Done";
-		
-	} else {
-		$t_email_data = email_queue_get( (int) $f_to );
-
-		// check if email was found.  This can fail if another request picks up the email first and sends it.
-		echo 'Sending email...<br />';
-		if( $t_email_data !== false ) {
-			if( !email_send( $t_email_data ) ) {
-				echo 'Email Not Sent - Deleting from queue<br />';
-				email_queue_delete( $t_email_data->email_id );
-			} else {
-				echo 'Email Sent<br />';
-			}
-		} else {
-			echo 'Email not found in queue<br />';
-		}
-	}
-}
-
-$t_ids = email_queue_get_ids();
-
-if( count( $t_ids ) > 0 ) {
-
-	echo '<table><tr><th>' . lang_get('id') . '</th><th>' . lang_get('email') . '</th><th>' . lang_get('timestamp') . '</th><th>Send Or Delete</th></tr>';
-	foreach( $t_ids as $t_id ) {
-		$row = email_queue_get( $t_id );
-
-		echo '<tr><td>' . $row->email_id . '</td><td>' . $row->email . '</td><td>' . $row->submitted . '</td><td>' , html_button( 'email_queue.php', 'Send Or Delete', array( 'send' => $row->email_id ) ) , '</td></tr>';
-	}
-	echo '</table>';
-} else {
-}
-
-html_button( 'email_queue.php', 'Send All', array( 'send' => 'all') );
-html_button( 'email_queue.php', 'Send Or Delete All', array( 'send' => 'sendordelall') );
diff --git a/admin/index.php b/admin/index.php
deleted file mode 100644
index 36ec3f0..0000000
--- a/admin/index.php
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-# MantisBT - a php based bugtracking system
-
-# MantisBT 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.
-#
-# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * @package MantisBT
- * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
- * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
- * @link http://www.mantisbt.org
- */
-/**
- * MantisBT Core API's
- */
-require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
-require_once( 'schema.php' );
-
-access_ensure_global_level( config_get_global( 'admin_site_threshold' ) );
-
-html_page_top( 'MantisBT Administration' );
-
-function print_info_row( $p_description, $p_value ) {
-	echo '<tr ' . helper_alternate_class() . '>';
-	echo '<td class="category">' . $p_description . '</td>';
-	echo '<td>' . $p_value . '</td>';
-	echo '</tr>';
-}
-
-?>
-<br />
-
-<div align="center">
-		<p>[ <a href="check.php">Check your installation</a> ]</p>
-	<?php if ( count($upgrade) - 1 != config_get( 'database_version' ) ) { ?>
-		<p>[ <a href="upgrade_warning.php"><b>Upgrade your installation</b></a> ]</p>
-	<?php } ?>
-		<p>[ <a href="system_utils.php">System Utilities</a> ]</p>
-		<p>[ <a href="test_icons.php">Test Icons</a> ]</p>
-		<p>[ <a href="test_langs.php">Test Langs</a> ]</p>
-		<p>[ <a href="test_email.php">Test Email</a> ]</p>
-		<p>[ <a href="email_queue.php">Email Queue</a> ]</p>
-</div>
-
-<table class="width75" align="center" cellspacing="1">
-<tr>
-<td class="form-title" width="30%" colspan="2"><?php echo lang_get( 'install_information' ) ?></td>
-</tr>
-<?php 
-	print_info_row( lang_get( 'mantis_version' ), MANTIS_VERSION, ( $t_version_suffix ? " $t_version_suffix" : '' ) );
-	print_info_row( 'php_version', phpversion());
-?>
-<tr>
-<td class="form-title" width="30%" colspan="2"><?php echo lang_get( 'database_information' ) ?></td>
-</tr>
-<?php 
-	print_info_row( lang_get( 'schema_version' ), config_get( 'database_version' ) );
-	print_info_row( 'adodb_version', $g_db->Version() );
-?>
-<tr>
-<td class="form-title" width="30%" colspan="2"><?php echo lang_get( 'path_information' ) ?></td>
-</tr>
-<?php 
-	print_info_row( lang_get( 'site_path' ), config_get( 'absolute_path' ) );
-	print_info_row( lang_get( 'core_path' ), config_get( 'core_path' ) );
-	print_info_row( lang_get( 'plugin_path' ), config_get( 'plugin_path' ) );
-?>
-</table>
-<?php
-	html_page_bottom();
diff --git a/admin/install.php b/admin/install.php
deleted file mode 100644
index 5b58843..0000000
--- a/admin/install.php
+++ /dev/null
@@ -1,1015 +0,0 @@
-<?php
-# MantisBT - a php based bugtracking system
-
-# MantisBT 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.
-#
-# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * @package MantisBT
- * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
- * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
- * @link http://www.mantisbt.org
- */
-
-error_reporting( E_ALL );
-
-/** @todo put this somewhere */
-@set_time_limit( 0 );
-$g_skip_open_db = true;  # don't open the database in database_api.php
-define( 'MANTIS_INSTALLER', true );
-define( 'PLUGINS_DISABLED', true );
-@require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
-@require_once( 'install_functions.php' );
-@require_once( 'install_helper_functions.php' );
-$g_error_send_page_header = false; # bypass page headers in error handler
-
-$g_failed = false;
-$g_database_upgrade = false;
-
-# -------
-# print test result
-function print_test_result( $p_result, $p_hard_fail = true, $p_message = '' ) {
-	global $g_failed;
-	echo '<td ';
-	if( BAD == $p_result ) {
-		if( $p_hard_fail ) {
-			$g_failed = true;
-			echo 'bgcolor="red">BAD';
-		} else {
-			echo 'bgcolor="pink">POSSIBLE PROBLEM';
-		}
-		if( '' != $p_message ) {
-			echo '<br />' . $p_message;
-		}
-	}
-
-	if( GOOD == $p_result ) {
-		echo 'bgcolor="green">GOOD';
-	}
-	echo '</td>';
-}
-
-# -------
-# print test header and result
-function print_test( $p_test_description, $p_result, $p_hard_fail = true, $p_message = '' ) {
-
-	echo "\n<tr><td bgcolor=\"#ffffff\">$p_test_description</td>";
-	print_test_result( $p_result, $p_hard_fail, $p_message );
-	echo "</tr>\n";
-}
-
-# --------
-# create an SQLArray to insert data
-function InsertData( $p_table, $p_data ) {
-	$query = "INSERT INTO " . $p_table . $p_data;
-	return Array( $query );
-}
-
-# install_state
-#   0 = no checks done
-#   1 = server ok, get database information
-#   2 = check the database information
-#   3 = install the database
-#   4 = get additional config file information
-#   5 = write the config file
-#	6 = post install checks
-#	7 = done, link to login or db updater
-$t_install_state = gpc_get_int( 'install', 0 );
-?>
-<html>
-<head>
-<title> MantisBT Administration - Installation  </title>
-<link rel="stylesheet" type="text/css" href="admin.css" />
-</head>
-<body>
-<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
-	<tr class="top-bar">
-		<td class="links">
-			[ <a href="index.php">Back to Administration</a> ]
-		</td>
-		<td class="title">
-		<?php
-switch( $t_install_state ) {
-	case 6:
-		echo "Post Installation Checks";
-		break;
-	case 5:
-		echo "Install Configuration File";
-		break;
-	case 4:
-		echo "Additional Configuration Information";
-		break;
-	case 3:
-		echo "Install Database";
-		break;
-	case 2:
-		echo "Check and Install Database";
-		break;
-	case 1:
-		echo "Database Parameters";
-		break;
-	case 0:
-	default:
-		echo "Pre-Installation Check";
-		break;
-}
-?>
-		</td>
-	</tr>
-</table>
-<br /><br />
-
-<form method='POST'>
-<?php
-if( 0 == $t_install_state ) {
-	?>
-<table width="100%" bgcolor="#222222" border="0" cellpadding="10" cellspacing="1">
-<tr>
-	<td bgcolor="#e8e8e8" colspan="2">
-		<span class="title">Checking Installation...</span>
-	</td>
-</tr>
-<?php
-}
-
-$t_config_filename = $g_absolute_path . 'config_inc.php';
-$t_config_exists = file_exists( $t_config_filename );
-$f_hostname = null;
-$f_db_type = null;
-$f_database_name = null;
-$f_db_username = null;
-$f_db_password = null;
-if( $t_config_exists ) {
-	if( 0 == $t_install_state ) {
-		print_test( "Config File Exists - Upgrade", true );
-	}
-
-	# config already exists - probably an upgrade
-
-	$f_dsn = config_get( 'dsn', '' );
-	$f_hostname = config_get( 'hostname', '' );
-	$f_db_type = config_get( 'db_type', '' );
-	$f_database_name = config_get( 'database_name', '' );
-	$f_db_username = config_get( 'db_username', '' );
-	$f_db_password = config_get( 'db_password', '' );
-
-	if( 0 == $t_install_state ) {
-		print_test( 'Setting Database Type', '' !== $f_db_type, true, 'database type is blank?' );
-		print_test( 'Checking Database connection settings exist', ( $f_dsn !== '' || ( $f_database_name !== '' && $f_db_username !== '' && $f_hostname !== '' ) ), true, 'database connection settings do not exist?' );
-		print_test( 'Checking PHP support for database type', db_check_database_support( $f_db_type ), true, 'database is not supported by PHP. Check that it has been compiled into your server.' );
-	}
-
-	$g_db = ADONewConnection( $f_db_type );
-	$t_result = @$g_db->Connect( $f_hostname, $f_db_username, $f_db_password, $f_database_name );
-	if( $g_db->IsConnected() ) {
-		$g_db_connected = true;
-	}
-	$t_cur_version = config_get( 'database_version', -1 );
-	if( $t_cur_version > 1 ) {
-		$g_database_upgrade = true;
-		$f_db_exists = true;
-	} else {
-		if( 0 == $t_install_state ) {
-			print_test( 'Config File Exists but Database does not', false, false, 'Bad config_inc.php?' );
-		}
-	}
-} else {
-	# read control variables with defaults
-	$f_hostname = gpc_get( 'hostname', config_get( 'hostname', 'localhost' ) );
-	$f_db_type = gpc_get( 'db_type', config_get( 'db_type', '' ) );
-	$f_database_name = gpc_get( 'database_name', config_get( 'database_name', 'bugtrack' ) );
-	$f_db_username = gpc_get( 'db_username', config_get( 'db_username', '' ) );
-	$f_db_password = gpc_get( 'db_password', config_get( 'db_password', '' ) );
-	if( CONFIGURED_PASSWORD == $f_db_password ) {
-		$f_db_password = config_get( 'db_password' );
-	}
-}
-$f_admin_username = gpc_get( 'admin_username', '' );
-$f_admin_password = gpc_get( 'admin_password', '' );
-$f_log_queries = gpc_get_bool( 'log_queries', false );
-$f_db_exists = gpc_get_bool( 'db_exists', false );
-
-$f_db_schema = '';
-if( $f_db_type == 'db2' ) {
-
-	# If schema name is supplied, then separate it from database name.
-	if( strpos( $f_database_name, '/' ) != false ) {
-		$f_db2AS400 = $f_database_name;
-		list( $f_database_name, $f_db_schema ) = explode( '/', $f_db2AS400, 2 );
-	}
-}
-
-if( 0 == $t_install_state ) {
-	?>
-
-<!-- Check PHP Version -->
-<?php print_test( ' Checking PHP version (your version is ' . phpversion() . ')', check_php_version( phpversion() ), true, 'Upgrade to a more recent version of PHP' );?>
-
-<!-- Check Safe Mode -->
-<?php
-print_test( 'Checking if safe mode is enabled for install script',
-	! ini_get ( 'SAFE_MODE' ),
-	true,
-	'Disable safe_mode in php.ini before proceeding' ) ?>
-
-</table>
-<?php
-	if( false == $g_failed ) {
-		$t_install_state++;
-	}
-} # end install_state == 0
-
-# got database information, check and install
-if( 2 == $t_install_state ) {
-	?>
-
-<table width="100%" border="0" cellpadding="10" cellspacing="1">
-<!-- Setting config variables -->
-<?php print_test( 'Setting Database Hostname', '' !== $f_hostname, true, 'host name is blank' )?>
-
-<!-- Setting config variables -->
-<?php print_test( 'Setting Database Type', '' !== $f_db_type, true, 'database type is blank?' )?>
-
-<!-- Checking DB support-->
-<?php print_test( 'Checking PHP support for database type', db_check_database_support( $f_db_type ), true, 'database is not supported by PHP. Check that it has been compiled into your server.' )?>
-
-<?php print_test( 'Setting Database Username', '' !== $f_db_username, true, 'database username is blank' )?>
-<?php print_test( 'Setting Database Password', '' !== $f_db_password, false, 'database password is blank' )?>
-<?php print_test( 'Setting Database Name', '' !== $f_database_name, true, 'database name is blank' )?>
-<?php
-	if( $f_db_type == 'db2' ) {
-		print_test( 'Setting Database Schema', !is_blank( $f_db_schema ), true, 'must have a schema name for AS400 in the form of DBNAME/SCHEMA' );
-	}
-	?>
-<tr>
-	<td bgcolor="#ffffff">
-		Setting Admin Username
-	</td>
-	<?php
-		if( '' !== $f_admin_username ) {
-		print_test_result( GOOD );
-	} else {
-		print_test_result( BAD, false, 'admin user name is blank, using database user instead' );
-		$f_admin_username = $f_db_username;
-	}
-	?>
-</tr>
-<tr>
-	<td bgcolor="#ffffff">
-		Setting Admin Password
-	</td>
-	<?php
-		if( '' !== $f_admin_password ) {
-		print_test_result( GOOD );
-	} else {
-		if( '' != $f_db_password ) {
-			print_test_result( BAD, false, 'admin user password is blank, using database user password instead' );
-			$f_admin_password = $f_db_password;
-		} else {
-			print_test_result( GOOD );
-		}
-	}
-	?>
-</tr>
-
-<!-- connect to db -->
-<tr>
-	<td bgcolor="#ffffff">
-		Attempting to connect to database as admin
-	</td>
-	<?php
-		$t_db_open = false;
-	$g_db = ADONewConnection( $f_db_type );
-	$t_result = @$g_db->Connect( $f_hostname, $f_admin_username, $f_admin_password );
-
-	if( $t_result ) {
-
-		# check if db exists for the admin
-		$t_result = @$g_db->Connect( $f_hostname, $f_admin_username, $f_admin_password, $f_database_name );
-		if( $t_result ) {
-			$t_db_open = true;
-			$f_db_exists = true;
-		}
-		if( $f_db_type == 'db2' ) {
-			$result = &$g_db->execute( 'set schema ' . $f_db_schema );
-			if( $result === false ) {
-				print_test_result( BAD, true, 'set schema failed: ' . $g_db->errorMsg() );
-			}
-		} else {
-			print_test_result( GOOD );
-		}
-	} else {
-		print_test_result( BAD, true, 'Does administrative user have access to the database? ( ' . db_error_msg() . ' )' );
-	}
-	?>
-</tr>
-<?php
-	if( $f_db_exists ) {
-		?>
-<tr>
-	<td bgcolor="#ffffff">
-		Attempting to connect to database as user
-	</td>
-	<?php
-		$g_db = ADONewConnection( $f_db_type );
-		$t_result = @$g_db->Connect( $f_hostname, $f_db_username, $f_db_password, $f_database_name );
-
-		if( $t_result == true ) {
-			$t_db_open = true;
-			if( $f_db_type == 'db2' ) {
-				$result = &$g_db->execute( 'set schema ' . $f_db_schema );
-				if( $result === false ) {
-					print_test_result( BAD, true, 'set schema failed: ' . $g_db->errorMsg() );
-				}
-			} else {
-				print_test_result( GOOD );
-			}
-		} else {
-			print_test_result( BAD, false, 'Database user doesn\'t have access to the database ( ' . db_error_msg() . ' )' );
-		}
-		?>
-</tr>
-
-<?php
-	}
-	if( $t_db_open ) {
-		?>
-<!-- display database version -->
-<tr>
-	<td bgcolor="#ffffff">
-		Checking Database Server Version
-		<?php
-		# due to a bug in ADODB, this call prompts warnings, hence the @
-		# the check only works on mysql if the database is open
-		$t_version_info = @$g_db->ServerInfo();
-		echo '<br /> Running ' . $f_db_type . ' version ' . $t_version_info['description'];
-		?>
-	</td>
-	<?php
-		$t_warning = '';
-		$t_error = '';
-		switch( $f_db_type ) {
-			case 'mysql':
-			case 'mysqli':
-				if( version_compare( $t_version_info['version'], '4.1.0', '<' ) ) {
-					$t_error = 'MySQL 4.1.0 or later is required for installation.';
-				}
-				break;
-			case 'pgsql':
-			case 'mssql':
-			case 'db2':
-			default:
-				break;
-		}
-
-		print_test_result(( '' == $t_error ) && ( '' == $t_warning ), ( '' != $t_error ), $t_error . ' ' . $t_warning );
-		?>
-</tr>
-<?php
-	}
-	if( false == $g_failed ) {
-		$t_install_state++;
-	} else {
-		$t_install_state--; # a check failed, redisplay the questions
-	}
-} # end 2 == $t_install_state
-
-# system checks have passed, get the database information
-if( 1 == $t_install_state ) {
-	?>
-
-<table width="100%" border="0" cellpadding="10" cellspacing="1">
-<tr>
-	<td bgcolor="#e8e8e8" colspan="2">
-		<span class="title"><?php echo $g_database_upgrade ? 'Upgrade Options' : 'Installation Options'?></span>
-	</td>
-</tr>
-
-<?php if( !$g_database_upgrade ) {?>
-<tr>
-	<td>
-		Type of Database
-	</td>
-	<td>
-		<select name="db_type">
-		<?php
-			if( $f_db_type == 'mysql' ) {
-			echo '<option value="mysql" selected="selected">MySQL (default)</option>';
-		} else {
-			echo '<option value="mysql">MySQL (default)</option>';
-		}
-
-		if( $f_db_type == 'mysqli' ) {
-			echo '<option value="mysqli" selected="selected">MySQLi</option>';
-		} else {
-			echo '<option value="mysqli">MySQLi</option>';
-		}
-
-		if( $f_db_type == 'mssql' ) {
-			echo '<option value="mssql" selected="selected">Microsoft SQL Server</option>';
-		} else {
-			echo '<option value="mssql">Microsoft SQL Server</option>';
-		}
-
-		if( $f_db_type == 'pgsql' ) {
-			echo '<option value="pgsql" selected="selected">PostgreSQL</option>';
-		} else {
-			echo '<option value="pgsql">PostgreSQL</option>';
-		}
-
-		if( $f_db_type == 'oci8' ) {
-			echo '<option value="oci8" selected="selected">Oracle</option>';
-		} else {
-			echo '<option value="oci8">Oracle</option>';
-		}
-
-		if( $f_db_type == 'db2' ) {
-			echo '<option value="db2" selected="selected">IBM DB2</option>';
-		} else {
-			echo '<option value="db2">IBM DB2</option>';
-		}
-		?>
-		</select>
-	</td>
-</tr>
-<?php
-}
-
-if( !$g_database_upgrade ) {?>
-<tr>
-	<td>
-		Hostname (for Database Server)
-	</td>
-	<td>
-		<input name="hostname" type="textbox" value="<?php echo $f_hostname?>"></input>
-	</td>
-</tr>
-<?php
-}
-
-if( !$g_database_upgrade ) {?>
-<tr>
-	<td>
-		Username (for Database)
-	</td>
-	<td>
-		<input name="db_username" type="textbox" value="<?php echo $f_db_username?>"></input>
-	</td>
-</tr>
-<?php
-}
-
-if( !$g_database_upgrade ) {?>
-<tr>
-	<td>
-		Password (for Database)
-	</td>
-	<td>
-		<input name="db_password" type="password" value="<?php echo( !is_blank( $f_db_password ) ? CONFIGURED_PASSWORD : "" )?>"></input>
-	</td>
-</tr>
-<?php
-}
-
-if( !$g_database_upgrade ) {?>
-<tr>
-	<td>
-		Database name (for Database)
-	</td>
-	<td>
-		<input name="database_name" type="textbox" value="<?php echo $f_database_name?>"></input>
-	</td>
-</tr>
-<?php
-}?>
-
-<tr>
-	<td>
-		Admin Username (to <?php echo( !$g_database_upgrade ) ? 'create Database' : 'update Database'?> if required)
-	</td>
-	<td>
-		<input name="admin_username" type="textbox" value="<?php echo $f_admin_username?>"></input>
-	</td>
-</tr>
-
-<tr>
-	<td>
-		Admin Password (to <?php echo( !$g_database_upgrade ) ? 'create Database' : 'update Database'?> if required)
-	</td>
-	<td>
-		<input name="admin_password" type="password" value="<?php echo $f_admin_password?>"></input>
-	</td>
-</tr>
-
-<tr>
-	<td>
-		Print SQL Queries instead of Writing to the Database
-	</td>
-	<td>
-		<input name="log_queries" type="checkbox" value="1" <?php echo( $f_log_queries ? 'checked="checked"' : '' )?>></input>
-	</td>
-</tr>
-
-<tr>
-	<td>
-		Attempt Installation
-	</td>
-	<td>
-		<input name="go" type="submit" value="Install/Upgrade Database"></input>
-	</td>
-</tr>
-<input name="install" type="hidden" value="2"></input>
-
-</table>
-<?php
-}  # end install_state == 1
-
-# all checks have passed, install the database
-if( 3 == $t_install_state ) {
-	?>
-<table width="100%" border="0" cellpadding="10" cellspacing="1">
-<tr>
-	<td bgcolor="#e8e8e8" colspan="2">
-		<span class="title">Installing Database</span>
-	</td>
-</tr>
-<?php if( !$f_log_queries ) {?>
-<tr>
-	<td bgcolor="#ffffff">
-		Create database if it does not exist
-	</td>
-	<?php
-		$t_result = @$g_db->Connect( $f_hostname, $f_admin_username, $f_admin_password, $f_database_name );
-
-		if( $f_db_type == 'db2' ) {
-			$rs = $g_db->Execute( "select * from SYSIBM.SCHEMATA WHERE SCHEMA_NAME = '" . $f_db_schema . "' AND SCHEMA_OWNER = '" . $f_db_username . "'" );
-			if( $rs === false ) {
-				echo "<br />false";
-			}
-
-			if( $rs->EOF ) {
-				$t_result = false;
-				echo $g_db->errorMsg();
-			} else {
-				$t_result = &$g_db->execute( 'set schema ' . $f_db_schema );
-			}
-		}
-
-		$t_db_open = false;
-
-		if( $t_result == true ) {
-			print_test_result( GOOD );
-			$t_db_open = true;
-		} else {
-			// create db
-			$g_db = ADONewConnection( $f_db_type );
-			$t_result = $g_db->Connect( $f_hostname, $f_admin_username, $f_admin_password );
-
-			$dict = NewDataDictionary( $g_db );
-
-			if( $f_db_type == 'db2' ) {
-				$rs = &$g_db->Execute( "CREATE SCHEMA " . $f_db_schema );
-
-				if( !$rs ) {
-					$t_result = false;
-					print_test_result( BAD, true, 'Does administrative user have access to create the database? ( ' . db_error_msg() . ' )' );
-					$t_install_state--; # db creation failed, allow user to re-enter user/password info
-				} else {
-					print_test_result( GOOD );
-					$t_db_open = true;
-				}
-			} else {
-				$sqlarray = $dict->CreateDatabase( $f_database_name, Array( 'mysql' => 'DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci' ) );
-				$ret = $dict->ExecuteSQLArray( $sqlarray );
-				if( $ret == 2 ) {
-					print_test_result( GOOD );
-					$t_db_open = true;
-				} else {
-					$t_error = db_error_msg();
-					if( strstr( $t_error, 'atabase exists' ) ) {
-						print_test_result( BAD, false, 'Database already exists? ( ' . db_error_msg() . ' )' );
-					} else {
-						print_test_result( BAD, true, 'Does administrative user have access to create the database? ( ' . db_error_msg() . ' )' );
-						$t_install_state--; # db creation failed, allow user to re-enter user/password info
-					}
-				}
-			}
-		}
-		?>
-</tr>
-<?php
-	$g_db->Close();
-?>
-<tr>
-	<td bgcolor="#ffffff">
-		Attempting to connect to database as user
-	</td>
-	<?php
-		$g_db = ADONewConnection( $f_db_type );
-		$t_result = @$g_db->Connect( $f_hostname, $f_db_username, $f_db_password, $f_database_name );
-
-		if( $f_db_type == 'db2' ) {
-			$result = &$g_db->execute( 'set schema ' . $f_db_schema );
-			if( $result === false ) {
-				echo $g_db->errorMsg();
-			}
-		}
-
-		if( $t_result == true ) {
-			print_test_result( GOOD );
-		} else {
-			print_test_result( BAD, false, 'Database user doesn\'t have access to the database ( ' . db_error_msg() . ' )' );
-		}
-		$g_db->Close();
-		?>
-</tr>
-<?php
-	}
-
-	# install the tables
-	if( false == $g_failed ) {
-		$g_db_connected = false;
-
-		# fake out database access routines used by config_get
-		$GLOBALS['g_db_type'] = $f_db_type;
-
-		# database_api references this
-		require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'schema.php' );
-		$g_db = ADONewConnection( $f_db_type );
-		$t_result = @$g_db->Connect( $f_hostname, $f_admin_username, $f_admin_password, $f_database_name );
-		if( !$f_log_queries ) {
-			$g_db_connected = true;
-
-			# fake out database access routines used by config_get
-		}
-		$t_last_update = config_get( 'database_version', -1, ALL_USERS, ALL_PROJECTS );
-		$lastid = count( $upgrade ) - 1;
-		$i = $t_last_update + 1;
-		if( $f_log_queries ) {
-			echo '<tr><td bgcolor="#ffffff" col_span="2"> Database Creation Suppressed, SQL Queries follow <pre>';
-		}
-
-		# Make sure we do the upgrades using UTF-8 if needed
-		if ( $f_db_type === 'mysql' || $f_db_type === 'mysqli' ) {
-			$g_db->execute( 'SET NAMES UTF8' );
-		}
-
-		if( $f_db_type == 'db2' ) {
-			$result = &$g_db->execute( 'set schema ' . $f_db_schema );
-			if( $result === false ) {
-				echo $g_db->errorMsg();
-			}
-		}
-
-		while(( $i <= $lastid ) && !$g_failed ) {
-			if( !$f_log_queries ) {
-				echo '<tr><td bgcolor="#ffffff">';
-			}
-
-			$dict = NewDataDictionary( $g_db );
-			$t_sql = true;
-			$t_target = $upgrade[$i][1][0];
-			if( $upgrade[$i][0] == 'InsertData' ) {
-				$sqlarray = call_user_func_array( $upgrade[$i][0], $upgrade[$i][1] );
-			}
-			else if( $upgrade[$i][0] == 'UpdateSQL' ) {
-				$sqlarray = array(
-					$upgrade[$i][1],
-				);
-				$t_target = $upgrade[$i][1];
-			} else if( $upgrade[$i][0] == 'UpdateFunction' ) {
-				$sqlarray = array(
-					$upgrade[$i][1],					
-				);
-				if( isset( $upgrade[$i][2] ) ) {
-					$sqlarray[] = $upgrade[$i][2];
-				}
-				$t_sql = false;
-				$t_target = $upgrade[$i][1];
-			} else {
-				/* 0: function to call, 1: function params, 2: function to evaluate before calling upgrade, if false, skip upgrade. */
-				if( isset( $upgrade[$i][2] ) ) {
-					if( call_user_func_array( $upgrade[$i][2][0], $upgrade[$i][2][1] ) ) {
-						$sqlarray = call_user_func_array( Array( $dict, $upgrade[$i][0] ), $upgrade[$i][1] );
-					} else {
-						$sqlarray = array();
-					}
-				} else {
-					$sqlarray = call_user_func_array( Array( $dict, $upgrade[$i][0] ), $upgrade[$i][1] );
-				}
-			}
-			if( $f_log_queries ) {
-				if( $t_sql ) {
-					foreach( $sqlarray as $sql ) {
-						echo htmlentities( $sql ) . ";\r\n\r\n";
-					}
-				}
-			} else {
-				echo 'Schema ' . $upgrade[$i][0] . ' ( ' . $t_target . ' )</td>';
-				if( $t_sql ) {
-					$ret = $dict->ExecuteSQLArray( $sqlarray );
-				} else {
-					if( isset( $sqlarray[1] ) ) {
-						$ret = call_user_func( 'install_' . $sqlarray[0], $sqlarray[1] );
-					} else {
-						$ret = call_user_func( 'install_' . $sqlarray[0] );
-					}
-				}
-				if( $ret == 2 ) {
-					print_test_result( GOOD );
-					config_set( 'database_version', $i );
-				} else {
-					$all_sql = '';
-					foreach ( $sqlarray as $single_sql )
-						$all_sql .= $single_sql . '<br />';
-					print_test_result( BAD, true, $all_sql  . $g_db->ErrorMsg() );
-				}
-				echo '</tr>';
-			}
-			$i++;
-		}
-		if( $f_log_queries ) {
-			# add a query to set the database version
-			echo 'INSERT INTO mantis_config_table ( value, type, access_reqd, config_id, project_id, user_id ) VALUES (\'' . $lastid . '\', 1, 90, \'database_version\', 0, 0 );' . "\r\n";
-			echo '</pre></br /><p style="color:red">Your database has not been created yet. Please create the database, then install the tables and data using the information above before proceeding.</td></tr>';
-		}
-	}
-	if( false == $g_failed ) {
-		$t_install_state++;
-	} else {
-		$t_install_state--;
-	}
-
-	?>
-</table>
-<?php
-}  # end install_state == 3
-
-# database installed, get any additional information
-if( 4 == $t_install_state ) {
-
-	/** @todo to be written */
-	// must post data gathered to preserve it
-	?>
-		<input name="hostname" type="hidden" value="<?php echo $f_hostname?>"></input>
-		<input name="db_type" type="hidden" value="<?php echo $f_db_type?>"></input>
-		<input name="database_name" type="hidden" value="<?php echo $f_database_name?>"></input>
-		<input name="db_username" type="hidden" value="<?php echo $f_db_username?>"></input>
-		<input name="db_password" type="hidden" value="<?php echo $f_db_password?>"></input>
-		<input name="admin_username" type="hidden" value="<?php echo $f_admin_username?>"></input>
-		<input name="admin_password" type="hidden" value="<?php echo $f_admin_password?>"></input>
-		<input name="log_queries" type="hidden" value="<?php echo( $f_log_queries ? 1 : 0 )?>"></input>
-		<input name="db_exists" type="hidden" value="<?php echo( $f_db_exists ? 1 : 0 )?>"></input>
-<?php
-	# must post <input name="install" type="hidden" value="5"></input>
-	# rather than the following line
-	$t_install_state++;
-}  # end install_state == 4
-
-# all checks have passed, install the database
-if( 5 == $t_install_state ) {
-	$t_config_filename = $g_absolute_path . 'config_inc.php';
-	$t_config_exists = file_exists( $t_config_filename );
-	?>
-<table width="100%" border="0" cellpadding="10" cellspacing="1">
-<tr>
-	<td bgcolor="#e8e8e8" colspan="2">
-		<span class="title">Write Configuration File(s)</span>
-	</td>
-</tr>
-
-<tr>
-	<td bgcolor="#ffffff">
-		<?php
-			if( !$t_config_exists ) {
-		echo 'Creating Configuration File (config_inc.php)<br />';
-		echo '<font color="red">(if this file is not created, create it manually with the contents below)</font>';
-	} else {
-		echo 'Updating Configuration File (config_inc.php)<br />';
-	}
-	?>
-	</td>
-	<?php
-		$t_config = '<?php' . "\r\n";
-	$t_config .= "\t\$g_hostname = '$f_hostname';\r\n";
-	$t_config .= "\t\$g_db_type = '$f_db_type';\r\n";
-	$t_config .= "\t\$g_database_name = '$f_database_name';\r\n";
-	$t_config .= "\t\$g_db_username = '$f_db_username';\r\n";
-	$t_config .= "\t\$g_db_password = '$f_db_password';\r\n";
-
-	if( $f_db_type == 'db2' ) {
-		$t_config .= "\t\$g_db_schema = '$f_db_schema';\r\n";
-	}
-
-	$t_config .= '?>' . "\r\n";
-	$t_write_failed = true;
-
-	if( !$t_config_exists ) {
-		if( $fd = @fopen( $t_config_filename, 'w' ) ) {
-			fwrite( $fd, $t_config );
-			fclose( $fd );
-		}
-
-		if( file_exists( $t_config_filename ) ) {
-			print_test_result( GOOD );
-			$t_write_failed = false;
-		} else {
-			print_test_result( BAD, false, 'cannot write ' . $t_config_filename );
-		}
-	} else {
-		# already exists, see if the information is the same
-		if ( ( $f_hostname != config_get( 'hostname', '' ) ) ||
-			( $f_db_type != config_get( 'db_type', '' ) ) ||
-			( $f_database_name != config_get( 'database_name', '') ) ||
-			( $f_db_schema != config_get( 'db_schema', '') ) ||
-			( $f_db_username != config_get( 'db_username', '' ) ) ||
-			( $f_db_password != config_get( 'db_password', '' ) ) ) {
-			print_test_result( BAD, false, 'file ' . $g_absolute_path . 'config_inc.php' . ' already exists and has different settings' );
-		} else {
-			print_test_result( GOOD, false );
-			$t_write_failed = false;
-		}
-	}
-	?>
-</tr>
-<?php
-	if( true == $t_write_failed ) {
-		echo '<tr><table width="50%" border="0" cellpadding="10" cellspacing="1" align="center">';
-		echo '<tr><td>Please add the following lines to ' . $g_absolute_path . 'config_inc.php before continuing to the database upgrade check:</td></tr>';
-		echo '<tr><td><pre>' . htmlentities( $t_config ) . '</pre></td></tr></table></tr>';
-	}
-	?>
-
-</table>
-
-<?php
-	if( false == $g_failed ) {
-		$t_install_state++;
-	}
-}
-
-# end install_state == 5
-
-if( 6 == $t_install_state ) {
-
-	# post install checks
-	?>
-<table width="100%" bgcolor="#222222" border="0" cellpadding="10" cellspacing="1">
-<tr>
-	<td bgcolor="#e8e8e8" colspan="2">
-		<span class="title">Checking Installation...</span>
-	</td>
-</tr>
-
-<!-- Checking register_globals are off -->
-<?php print_test( 'Checking for register_globals are off for mantis', !ini_get_bool( 'register_globals' ), false, 'change php.ini to disable register_globals setting' )?>
-
-<tr>
-	<td bgcolor="#ffffff">
-		Attempting to connect to database as user
-	</td>
-	<?php
-		$g_db = ADONewConnection( $f_db_type );
-	$t_result = @$g_db->Connect( $f_hostname, $f_db_username, $f_db_password, $f_database_name );
-
-	if( $t_result == true ) {
-		print_test_result( GOOD );
-	} else {
-		print_test_result( BAD, false, 'Database user doesn\'t have access to the database ( ' . db_error_msg() . ' )' );
-	}
-
-	if( $f_db_type == 'db2' ) {
-		$result = &$g_db->execute( 'set schema ' . $f_db_schema );
-		if( $result === false ) {
-			echo $g_db->errorMsg();
-		}
-	}
-	?>
-</tr>
-<tr>
-	<td bgcolor="#ffffff">
-		checking ability to SELECT records
-	</td>
-	<?php
-		$t_mantis_config_table = db_get_table( 'mantis_config_table' );
-	$t_query = "SELECT COUNT(*) FROM $t_mantis_config_table";
-	$t_result = @$g_db->Execute( $t_query );
-
-	if( $t_result != false ) {
-		print_test_result( GOOD );
-	} else {
-		print_test_result( BAD, true, 'Database user doesn\'t have SELECT access to the database ( ' . db_error_msg() . ' )' );
-	}
-	?>
-</tr>
-<tr>
-	<td bgcolor="#ffffff">
-		checking ability to INSERT records
-	</td>
-	<?php
-		$t_query = "INSERT INTO $t_mantis_config_table ( value, type, access_reqd, config_id, project_id, user_id ) VALUES ('test', 1, 90, 'database_test', 20, 0 )";
-	$t_result = @$g_db->Execute( $t_query );
-
-	if( $t_result != false ) {
-		print_test_result( GOOD );
-	} else {
-		print_test_result( BAD, true, 'Database user doesn\'t have INSERT access to the database ( ' . db_error_msg() . ' )' );
-	}
-	?>
-</tr>
-<tr>
-	<td bgcolor="#ffffff">
-		checking ability to UPDATE records
-	</td>
-	<?php
-		$t_query = "UPDATE $t_mantis_config_table SET value='test_update' WHERE config_id='database_test'";
-	$t_result = @$g_db->Execute( $t_query );
-
-	if( $t_result != false ) {
-		print_test_result( GOOD );
-	} else {
-		print_test_result( BAD, true, 'Database user doesn\'t have UPDATE access to the database ( ' . db_error_msg() . ' )' );
-	}
-	?>
-</tr>
-<tr>
-	<td bgcolor="#ffffff">
-		checking ability to DELETE records
-	</td>
-	<?php
-		$t_query = "DELETE FROM $t_mantis_config_table WHERE config_id='database_test'";
-	$t_result = @$g_db->Execute( $t_query );
-
-	if( $t_result != false ) {
-		print_test_result( GOOD );
-	} else {
-		print_test_result( BAD, true, 'Database user doesn\'t have DELETE access to the database ( ' . db_error_msg() . ' )' );
-	}
-	?>
-</tr>
-</table>
-<?php
-	if( false == $g_failed ) {
-		$t_install_state++;
-	}
-}
-
-# end install_state == 6
-
-if( 7 == $t_install_state ) {
-	# cleanup and launch upgrade
-	?>
-<p>Install was successful.</p>
-<?php if( $f_db_exists ) {?>
-<p><a href="../login_page.php">Continue</a> to log into Mantis</p>
-<?php
-	} else {?>
-<p>Please log in as the administrator and <a href="../manage_proj_create_page.php">create</a> your first project.
-
-<?php
-	}
-}
-
-# end install_state == 7
-
-if( $g_failed ) {
-	?>
-<table width="100%" bgcolor="#222222" border="0" cellpadding="10" cellspacing="1">
-<tr>
-	<td bgcolor="#e8e8e8" colspan="2">
-		<span class="title">Checks Failed...</span>
-	</td>
-</tr>
-<tr>
-	<td bgcolor="#ffffff">Please correct failed checks</td>
-	<td bgcolor="#ffffff">
-		<input name="install" type="hidden" value="<?php echo $t_install_state?>"></input>
-		<input name="hostname" type="hidden" value="<?php echo $f_hostname?>"></input>
-		<input name="db_type" type="hidden" value="<?php echo $f_db_type?>"></input>
-		<input name="database_name" type="hidden" value="<?php echo $f_database_name?>"></input>
-		<input name="db_username" type="hidden" value="<?php echo $f_db_username?>"></input>
-		<input name="db_password" type="hidden" value="<?php echo $f_db_password?>"></input>
-		<input name="admin_username" type="hidden" value="<?php echo $f_admin_username?>"></input>
-		<input name="admin_password" type="hidden" value="<?php echo $f_admin_password?>"></input>
-		<input name="log_queries" type="hidden" value="<?php echo( $f_log_queries ? 1 : 0 )?>"></input>
-		<input name="retry" type="submit" value="Retry"></input>
-		<input name="db_exists" type="hidden" value="<?php echo( $f_db_exists ? 1 : 0 )?>"></input>
-	</td>
-</tr>
-</table>
-<?php
-}
-?>
-</form>
-</body>
-</html>
diff --git a/admin/install_functions.php b/admin/install_functions.php
deleted file mode 100644
index 7556322..0000000
--- a/admin/install_functions.php
+++ /dev/null
@@ -1,262 +0,0 @@
-<?php
-# MantisBT - a php based bugtracking system
-
-# MantisBT 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.
-#
-# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * Update functions for the installation schema's 'UpdateFunction' option.
- * All functions must be name install_<function_name> and referenced as just <function_name>.
- * @package MantisBT
- * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
- * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
- * @link http://www.mantisbt.org
- */
-
-/**
- * Migrate the legacy category data to the new category_id-based schema.
- */
-function install_category_migrate() {
-	global $g_db_log_queries;
-	
-	$t_bug_table = db_get_table( 'mantis_bug_table' );
-	$t_category_table = db_get_table( 'mantis_category_table' );
-	$t_project_category_table = db_get_table( 'mantis_project_category_table' );
-
-	// disable query logging (even if it's enabled in config for this)
-	if ( $g_db_log_queries !== 0 ) {
-		$t_log_queries = $g_db_log_queries;
-		$g_db_log_queries = 0;
-	} else {
-		$t_log_queries = null;
-	}
-
-	$query = "SELECT project_id, category, user_id FROM $t_project_category_table ORDER BY project_id, category";
-	$t_category_result = db_query_bound( $query );
-
-	$query = "SELECT project_id, category FROM $t_bug_table ORDER BY project_id, category";
-	$t_bug_result = db_query_bound( $query );
-
-	$t_data = Array();
-
-	# Find categories specified by project
-	while( $row = db_fetch_array( $t_category_result ) ) {
-		$t_project_id = $row['project_id'];
-		$t_name = $row['category'];
-		$t_data[$t_project_id][$t_name] = $row['user_id'];
-	}
-
-	# Find orphaned categories from bugs
-	while( $row = db_fetch_array( $t_bug_result ) ) {
-		$t_project_id = $row['project_id'];
-		$t_name = $row['category'];
-
-		if ( !isset( $t_data[$t_project_id][$t_name] ) ) {
-			$t_data[$t_project_id][$t_name] = 0;
-		}
-	}
-
-	# In every project, go through all the categories found, and create them and update the bug
-	foreach( $t_data as $t_project_id => $t_categories ) {
-		$t_inserted = array();
-		foreach( $t_categories as $t_name => $t_user_id ) {
-			$t_lower_name = utf8_strtolower( trim( $t_name ) );
-			if ( !isset( $t_inserted[$t_lower_name] ) ) {
-				$query = "INSERT INTO $t_category_table ( name, project_id, user_id ) VALUES ( " .
-					db_param() . ', ' . db_param() . ', ' . db_param() . ' )';
-				db_query_bound( $query, array( $t_name, $t_project_id, $t_user_id ) );
-				$t_category_id = db_insert_id( $t_category_table );
-				$t_inserted[$t_lower_name] = $t_category_id;
-			} else {
-				$t_category_id = $t_inserted[$t_lower_name];
-			}
-
-			$query = "UPDATE $t_bug_table SET category_id=" . db_param() . '
-						WHERE project_id=' . db_param() . ' AND category=' . db_param();
-			db_query_bound( $query, array( $t_category_id, $t_project_id, $t_name ) );
-		}
-	}
-
-	// re-enabled query logging if we disabled it
-	if ( $t_log_queries !== null ) {
-		$g_db_log_queries = $t_log_queries;
-	}
-
-	# return 2 because that's what ADOdb/DataDict does when things happen properly
-	return 2;
-}
-
-function install_date_migrate( $p_data) {
-	// $p_data[0] = tablename, [1] id column, [2] = old column, [3] = new column
-	global $g_db_log_queries;
-	
-	// disable query logging (even if it's enabled in config for this)
-	if ( $g_db_log_queries !== 0 ) {
-		$t_log_queries = $g_db_log_queries;
-		$g_db_log_queries = 0;
-	} else {
-		$t_log_queries = null;
-	}
-
-	$t_table = db_get_table( $p_data[0] );
-	$t_id_column = $p_data[1];
-
-	if ( is_array( $p_data[2] ) ) {
-		$t_old_column = implode( ',', $p_data[2] );
-		$t_date_array = true;
-		$t_cnt_fields = sizeof( $p_data[2] );
-		$t_pairs = array();
-		foreach( $p_data[3] as $var ) {
-			array_push( $t_pairs, "$var=" . db_param() ) ;
-		}		
-		$t_new_column = implode( ',', $t_pairs );
-		$query = "SELECT $t_id_column, $t_old_column FROM $t_table";
-
-		$t_first_column = true;
-
-		# In order to handle large databases where we may timeout during the upgrade, we don't
-		# start form the beginning everytime.  Here we will only pickup rows where at least one
-		# of the datetime fields wasn't upgraded yet and upgrade them all.
-		foreach ( $p_data[3] as $t_new_column_name ) {
-			if ( $t_first_column ) {
-				$t_first_column = false;
-				$query .= ' WHERE ';
-			} else {
-				$query .= ' OR ';
-			}
-
-			$query .= "$t_new_column_name = 1";
-		}
-	} else {
-		$t_old_column = $p_data[2];
-		$t_new_column = $p_data[3] . "=" . db_param();
-		$t_date_array = false;
-
-		# The check for timestamp being = 1 is to make sure the field wasn't upgraded
-		# already in a previous run - see bug #12601 for more details.
-		$t_new_column_name = $p_data[3];
-		$query = "SELECT $t_id_column, $t_old_column FROM $t_table WHERE $t_new_column_name = 1";
-	}
-	
-	$t_result = db_query_bound( $query );
-
-	while( $row = db_fetch_array( $t_result ) ) {
-		$t_id = (int)$row[$t_id_column];
-
-		if( $t_date_array ) {
-			for( $i=0; $i < $t_cnt_fields; $i++ ) {
-				$t_old_value = $row[$p_data[2][$i]];
-
-				$t_new_value[$i] = db_unixtimestamp($t_old_value);
-				if ($t_new_value[$i] < 100000 ) {
-					$t_new_value[$i] = 1;
-				}
-			}
-			$t_values = $t_new_value;
-			$t_values[] = $t_id;
-		} else {
-			$t_old_value = $row[$t_old_column];		
-
-			$t_new_value = db_unixtimestamp($t_old_value);
-			if ($t_new_value < 100000 ) {
-				$t_new_value = 1;
-			}
-			$t_values = array( $t_new_value, $t_id);
-		}
-		
-		$query = "UPDATE $t_table SET $t_new_column
-					WHERE $t_id_column=" . db_param();
-		db_query_bound( $query, $t_values );
-	}
-
-	// re-enabled query logging if we disabled it
-	if ( $t_log_queries !== null ) {
-		$g_db_log_queries = $t_log_queries;
-	}
-
-	# return 2 because that's what ADOdb/DataDict does when things happen properly
-	return 2;	
-
-}
-
-/**
- * Once upon a time multi-select custom field types (checkbox and multiselect)
- * were stored in the database in the format of "option1|option2|option3" where
- * they should have been stored in a format of "|option1|option2|option3|".
- * Additionally, radio custom field types were being stored in the database
- * with an unnecessary vertical pipe prefix and suffix when there is only ever
- * one possible value that can be assigned to a radio field.
- */
-function install_correct_multiselect_custom_fields_db_format() {
-	global $g_db_log_queries;
-
-	# Disable query logging due to possibility of mass spam.
-	if ( $g_db_log_queries !== 0 ) {
-		$t_log_queries = $g_db_log_queries;
-		$g_db_log_queries = 0;
-	} else {
-		$t_log_queries = null;
-	}
-
-	$t_value_table = db_get_table( 'mantis_custom_field_string_table' );
-	$t_field_table = db_get_table( 'mantis_custom_field_table' );
-
-	# Ensure multilist and checkbox custom field values have a vertical pipe |
-	# as a prefix and suffix.
-	$t_query = "SELECT v.field_id, v.bug_id, v.value from $t_value_table v
-		LEFT JOIN $t_field_table c
-		ON v.field_id = c.id
-		WHERE (c.type = " . CUSTOM_FIELD_TYPE_MULTILIST . " OR c.type = " . CUSTOM_FIELD_TYPE_CHECKBOX . ")
-			AND v.value != ''
-			AND v.value NOT LIKE '|%|'";
-	$t_result = db_query_bound( $t_query );
-
-	while( $t_row = db_fetch_array( $t_result ) ) {
-		$c_field_id = (int)$t_row['field_id'];
-		$c_bug_id = (int)$t_row['bug_id'];
-		$c_value = '|' . rtrim( ltrim( $t_row['value'], '|' ), '|' ) . '|';
-		$t_update_query = "UPDATE $t_value_table
-			SET value = '$c_value'
-			WHERE field_id = $c_field_id
-				AND bug_id = $c_bug_id";
-		$t_update_result = db_query_bound( $t_update_query );
-	}
-
-	# Remove vertical pipe | prefix and suffix from radio custom field values.
-	$t_query = "SELECT v.field_id, v.bug_id, v.value from $t_value_table v
-		LEFT JOIN $t_field_table c
-		ON v.field_id = c.id
-		WHERE c.type = " . CUSTOM_FIELD_TYPE_RADIO . "
-			AND v.value != ''
-			AND v.value LIKE '|%|'";
-	$t_result = db_query_bound( $t_query );
-
-	while( $t_row = db_fetch_array( $t_result ) ) {
-		$c_field_id = (int)$t_row['field_id'];
-		$c_bug_id = (int)$t_row['bug_id'];
-		$c_value = rtrim( ltrim( $t_row['value'], '|' ), '|' );
-		$t_update_query = "UPDATE $t_value_table
-			SET value = '$c_value'
-			WHERE field_id = $c_field_id
-				AND bug_id = $c_bug_id";
-		$t_update_result = db_query_bound( $t_update_query );
-	}
-
-	# Re-enable query logging if we disabled it.
-	if ( $t_log_queries !== null ) {
-		$g_db_log_queries = $t_log_queries;
-	}
-
-	# Return 2 because that's what ADOdb/DataDict does when things happen properly
-	return 2;
-}
diff --git a/admin/install_helper_functions.php b/admin/install_helper_functions.php
deleted file mode 100644
index fc6fe68..0000000
--- a/admin/install_helper_functions.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-# MantisBT - a php based bugtracking system
-
-# MantisBT 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.
-#
-# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * @package MantisBT
- * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
- * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
- * @link http://www.mantisbt.org
- */
-
-function check_php_version( $p_version ) {
-	if( $p_version == PHP_MIN_VERSION ) {
-		return true;
-	} else {
-		if( function_exists( 'version_compare' ) ) {
-			if( version_compare( phpversion(), PHP_MIN_VERSION, '>=' ) ) {
-				return true;
-			} else {
-				return false;
-			}
-		} else {
-			return false;
-		}
-	}
-}
-
-/**
- * legacy pre-1.2 date function  used by schema.php
- * return a DB compatible date, representing a unixtime(0) + 1 second. Internally considered a NULL date
- * @return string Formatted Date for DB insertion e.g. 1970-01-01 00:00:00 ready for database insertion
- */
-function db_null_date() {
-	global $g_db;
-
-	return $g_db->BindTimestamp( $g_db->UserTimeStamp( 1, 'Y-m-d H:i:s', true ) );
-}
-
-/**
- * legacy pre-1.2 date function  used by install_functions.php
- * generate a integer unixtimestamp of a date
- * @param $p_date Date
- * @param bool $p_gmt whether to use GMT or current timezone (default false)
- * @return int unix timestamp of a date
- * @todo review date handling
- */
-function db_unixtimestamp( $p_date = null, $p_gmt = false ) {
-	global $g_db;
-
-	if( null !== $p_date ) {
-		$p_timestamp = $g_db->UnixTimeStamp( $p_date, $p_gmt );
-	} else {
-		$p_timestamp = time();
-	}
-	return $p_timestamp;
-}
\ No newline at end of file
diff --git a/admin/move_db2disk.php b/admin/move_db2disk.php
deleted file mode 100644
index dd18207..0000000
--- a/admin/move_db2disk.php
+++ /dev/null
@@ -1,200 +0,0 @@
-<?php
-# MantisBT - a php based bugtracking system
-
-# MantisBT 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.
-#
-# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * This upgrade moves attachments from the database to the disk
- * @package MantisBT
- * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
- * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
- * @link http://www.mantisbt.org
- */
-/**
- * MantisBT Core API's
- */
-require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
-
-access_ensure_global_level( config_get_global( 'admin_site_threshold' ) );
-
-// Move type should be attachment or project.
-$f_move_type = gpc_get( 'doc' );
-
-function get_prefix( $file_path ) {
-	if( substr( $file_path, 0, 1 ) == '/' ) {
-
-		# Unix absolute
-		return '';
-	}
-	if( substr( $file_path, 0, 1 ) == '\\' ) {
-
-		# Windows absolute
-		return '';
-	}
-	if( substr( $file_path, 1, 2 ) == ':\\' ) {
-
-		# Windows absolute
-		return '';
-	}
-	return dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR;
-}
-
-# ------ move file attachments to issues from database to disk
-# select non-empty data fields
-# match with the project to get the file path
-# store the file in the correct folder
-#
-# Assumptions: only supports storage in local file system (not FTP)
-#              file paths are set up and working
-#
-# Re-running this is safe because the data
-# is not removed from the database until it is successfully copied.
-#
-function upgrade_move_att2disk( $p_source ) {
-
-	# $p_source is the string "attachment" or "project"
-	if( $p_source == 'attachment' ) {
-		$t_file_table = db_get_table( 'mantis_bug_file_table' );
-		$t_bug_label = "Bug";
-	}
-	if( $p_source == 'project' ) {
-		$t_file_table = db_get_table( 'mantis_project_file_table' );
-		$t_bug_label = "Project";
-	}
-
-	# check that the source was valid
-	if( !isset( $t_file_table ) ) {
-		echo 'Failure: Internal Error: File source not set';
-		return;
-	}
-
-	# check that the destination is set up properly
-	$t_upload_method = config_get_global( 'file_upload_method' );
-	if( $t_upload_method <> DISK ) {
-		echo 'Failure: Upload Method is not DISK';
-		return;
-	}
-
-	$query = 'SELECT * FROM ' . $t_file_table . ' WHERE content <> \'\'';
-
-	$result = @db_query_bound( $query );
-
-	if( false == $result ) {
-		echo '<p>No attachments need to be moved.</p>';
-		return;
-	}
-
-	$count = db_num_rows( $result );
-	echo '<p>Found ' . $count . ' attachments to be moved.</p>';
-	$t_failures = 0;
-
-	if( $count > 0 ) {
-		echo '<table width="80%" bgcolor="#222222" border="0" cellpadding="10" cellspacing="1">';
-
-		# Headings
-		echo '<tr bgcolor="#ffffff"><th width="10%">' . $t_bug_label . '</th><th width="20%">Attachment</th><th width="70%">Status</th></tr>';
-	}
-
-	for( $i = 0;$i < $count;$i++ ) {
-		$t_row = db_fetch_array( $result );
-
-		// trace bug id back to project to determine the proper file path
-		if( $p_source == 'attachment' ) {
-			$t_project_id = bug_get_field( $t_row['bug_id'], 'project_id' );
-			$t_bug_id = $t_row['bug_id'];
-		} else {
-			$t_project_id = (int) $t_row['project_id'];
-			$t_bug_id = $t_project_id;
-		}
-
-		$t_file_path = project_get_field( $t_project_id, 'file_path' );
-		$prefix = get_prefix( $t_file_path );
-		$t_real_file_path = $prefix . $t_file_path;
-		$c_filename = file_clean_name( $t_row['filename'] );
-
-		printf( "\n<tr %s><td>%8d</td><td>%s</td><td>", helper_alternate_class(), $t_bug_id, $t_row['filename'] );
-
-		if( is_blank( $t_real_file_path ) || !file_exists( $t_real_file_path ) || !is_dir( $t_real_file_path ) || !is_writable( $t_real_file_path ) ) {
-			echo 'Destination ' . $t_real_file_path . ' not writable';
-			$t_failures++;
-		} else {
-			$t_file_name = $t_real_file_path . $c_filename;
-
-			// write file to disk store after adjusting the path
-			if( file_put_contents( $t_file_name, $t_row['content'] ) ) {
-				// successful, update database
-				/** @todo do we want to check the size of data transfer matches here? */
-				$c_new_file_name = $t_file_path . $c_filename;
-				$query2 = "UPDATE $t_file_table SET diskfile = " . db_param() . ",
-						folder = " . db_param() . ", content = '' WHERE id = " . db_param();
-				$update = @db_query_bound( $query2, Array( $c_new_file_name, $t_file_path, $t_row['id'] ) );
-				if( !$update ) {
-					echo 'database update failed';
-					$t_failures++;
-				} else {
-					echo 'moved to ' . $t_file_name;
-				}
-			} else {
-				echo 'copy to ' . $t_file_name . ' failed';
-				$t_failures++;
-			}
-		}
-
-		echo '</td></tr>';
-	}
-
-	echo '</table><br />' . $count . ' attachments processed, ' . $t_failures . ' failures';
-}
-
-# ---------------------
-# main code
-#
-if( $f_move_type == 'attachment' ) {
-	$t_type = 'Attachments';
-} else {
-	if( $f_move_type == 'project' ) {
-		$t_type = 'Project Files';
-	} else {
-		echo "<p>Invalid value '$f_move_type' for parameter 'doc'.</p>";
-		exit;
-	}
-}
-?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
-<head>
-<title>MantisBT Administration - Move <?php echo $t_type?> to Disk</title>
-<link rel="stylesheet" type="text/css" href="admin.css" />
-</head>
-<body>
-
-<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
-	<tr class="top-bar">
-		<td class="links">
-			[ <a href="system_utils.php">Back to System Utilities</a> ]
-			[ <a href="move_db2disk.php">Refresh view</a> ]
-		</td>
-		<td class="title">
-			Move <?php echo $t_type?> to Disk
-		</td>
-	</tr>
-</table>
-<br /><br />
-
-<?php
-	upgrade_move_att2disk( $f_move_type );
-echo '<p>Completed...</p>';
-?>
-</body>
-</html>
diff --git a/admin/schema.php b/admin/schema.php
deleted file mode 100644
index d2b6940..0000000
--- a/admin/schema.php
+++ /dev/null
@@ -1,610 +0,0 @@
-<?php
-# MantisBT - a php based bugtracking system
-
-# MantisBT 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.
-#
-# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
-
-# Each entry below defines the schema. The upgrade array consists of
-#  two elements
-# The first is the function to generate SQL statements (see adodb schema doc for more details)
-#  e.g., CreateTableSQL, DropTableSQL, ChangeTableSQL, RenameTableSQL, RenameColumnSQL,
-#  DropTableSQL, ChangeTableSQL, RenameTableSQL, RenameColumnSQL, AlterColumnSQL, DropColumnSQL
-#  A local function "InsertData" has been provided to add data to the db
-# The second parameter is an array of the parameters to be passed to the function.
-
-# An update identifier is inferred from the ordering of this table. ONLY ADD NEW CHANGES TO THE
-#  END OF THE TABLE!!!
-
-if ( !function_exists( 'db_null_date' ) ) {
-	function db_null_date() {
-		return 0;
-	}
-}
-
-
-function installer_db_now() {
-        global $g_db;
- 
-       return $g_db->BindTimeStamp( time() );
-}
-
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table( 'mantis_config_table' ),"
-			  config_id C(64) NOTNULL PRIMARY,
-			  project_id I DEFAULT '0' PRIMARY,
-			  user_id I DEFAULT '0' PRIMARY,
-			  access_reqd I DEFAULT '0',
-			  type I DEFAULT '90',
-			  value XL NOTNULL",
-Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_config',db_get_table( 'mantis_config_table' ),'config_id'));
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_bug_file_table'),"
-  id			 I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
-  bug_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
-  title 		C(250) NOTNULL DEFAULT \" '' \",
-  description 		C(250) NOTNULL DEFAULT \" '' \",
-  diskfile 		C(250) NOTNULL DEFAULT \" '' \",
-  filename 		C(250) NOTNULL DEFAULT \" '' \",
-  folder 		C(250) NOTNULL DEFAULT \" '' \",
-  filesize 		 I NOTNULL DEFAULT '0',
-  file_type 		C(250) NOTNULL DEFAULT \" '' \",
-  date_added 		T NOTNULL DEFAULT '" . db_null_date() . "',
-  content 		B NOTNULL
-  ",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_bug_file_bug_id',db_get_table('mantis_bug_file_table'),'bug_id'));
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_bug_history_table'),"
-  id 			 I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
-  user_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
-  bug_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
-  date_modified 	T NOTNULL DEFAULT '" . db_null_date() . "',
-  field_name 		C(32) NOTNULL DEFAULT \" '' \",
-  old_value 		C(128) NOTNULL DEFAULT \" '' \",
-  new_value 		C(128) NOTNULL DEFAULT \" '' \",
-  type 			I2 NOTNULL DEFAULT '0'
-  ",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_bug_history_bug_id',db_get_table('mantis_bug_history_table'),'bug_id'));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_history_user_id',db_get_table('mantis_bug_history_table'),'user_id'));
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_bug_monitor_table'),"
-  user_id 		 I  UNSIGNED NOTNULL PRIMARY DEFAULT '0',
-  bug_id 		 I  UNSIGNED NOTNULL PRIMARY DEFAULT '0'
-",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_bug_relationship_table'),"
-  id 			 I  UNSIGNED NOTNULL AUTOINCREMENT PRIMARY,
-  source_bug_id		 I  UNSIGNED NOTNULL DEFAULT '0',
-  destination_bug_id 	 I  UNSIGNED NOTNULL DEFAULT '0',
-  relationship_type 	I2 NOTNULL DEFAULT '0'
-",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_relationship_source',db_get_table('mantis_bug_relationship_table'),'source_bug_id'));
-/* 10 */
-$upgrade[] = Array('CreateIndexSQL',Array('idx_relationship_destination',db_get_table('mantis_bug_relationship_table'),'destination_bug_id'));
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_bug_table'),"
-  id 			 I  UNSIGNED PRIMARY NOTNULL AUTOINCREMENT,
-  project_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
-  reporter_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
-  handler_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
-  duplicate_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
-  priority 		I2 NOTNULL DEFAULT '30',
-  severity 		I2 NOTNULL DEFAULT '50',
-  reproducibility 	I2 NOTNULL DEFAULT '10',
-  status 		I2 NOTNULL DEFAULT '10',
-  resolution 		I2 NOTNULL DEFAULT '10',
-  projection 		I2 NOTNULL DEFAULT '10',
-  category 		C(64) NOTNULL DEFAULT \" '' \",
-  date_submitted 	T NOTNULL DEFAULT '" . db_null_date() . "',
-  last_updated 		T NOTNULL DEFAULT '" . db_null_date() . "',
-  eta 			I2 NOTNULL DEFAULT '10',
-  bug_text_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
-  os 			C(32) NOTNULL DEFAULT \" '' \",
-  os_build 		C(32) NOTNULL DEFAULT \" '' \",
-  platform 		C(32) NOTNULL DEFAULT \" '' \",
-  version 		C(64) NOTNULL DEFAULT \" '' \",
-  fixed_in_version 	C(64) NOTNULL DEFAULT \" '' \",
-  build 		C(32) NOTNULL DEFAULT \" '' \",
-  profile_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
-  view_state 		I2 NOTNULL DEFAULT '10',
-  summary 		C(128) NOTNULL DEFAULT \" '' \",
-  sponsorship_total 	 I  NOTNULL DEFAULT '0',
-  sticky		L  NOTNULL DEFAULT  \"'0'\"
-",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_bug_sponsorship_total',db_get_table('mantis_bug_table'),'sponsorship_total'));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_bug_fixed_in_version',db_get_table('mantis_bug_table'),'fixed_in_version'));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_bug_status',db_get_table('mantis_bug_table'),'status'));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_project',db_get_table('mantis_bug_table'),'project_id'));
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_bug_text_table'),"
-  id 			 I  PRIMARY UNSIGNED NOTNULL AUTOINCREMENT,
-  description 		XL NOTNULL,
-  steps_to_reproduce 	XL NOTNULL,
-  additional_information XL NOTNULL
-",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_bugnote_table'),"
-  id 			 I  UNSIGNED PRIMARY NOTNULL AUTOINCREMENT,
-  bug_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
-  reporter_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
-  bugnote_text_id 	 I  UNSIGNED NOTNULL DEFAULT '0',
-  view_state 		I2 NOTNULL DEFAULT '10',
-  date_submitted 	T NOTNULL DEFAULT '" . db_null_date() . "',
-  last_modified 	T NOTNULL DEFAULT '" . db_null_date() . "',
-  note_type 		 I  DEFAULT '0',
-  note_attr 		C(250) DEFAULT \" '' \"
-",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_bug',db_get_table('mantis_bugnote_table'),'bug_id'));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_last_mod',db_get_table('mantis_bugnote_table'),'last_modified'));
-/* 20 */
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_bugnote_text_table'),"
-  id 			 I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
-  note 			XL NOTNULL
-",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_custom_field_project_table'),"
-  field_id 		 I  NOTNULL PRIMARY DEFAULT '0',
-  project_id 		 I  UNSIGNED PRIMARY NOTNULL DEFAULT '0',
-  sequence 		I2 NOTNULL DEFAULT '0'
-",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_custom_field_string_table'),"
-  field_id 		 I  NOTNULL PRIMARY DEFAULT '0',
-  bug_id 		 I  NOTNULL PRIMARY DEFAULT '0',
-  value 		C(255) NOTNULL DEFAULT \" '' \"
-",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_custom_field_bug',db_get_table('mantis_custom_field_string_table'),'bug_id'));
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_custom_field_table'),"
-  id 			 I  NOTNULL PRIMARY AUTOINCREMENT,
-  name 			C(64) NOTNULL DEFAULT \" '' \",
-  type 			I2 NOTNULL DEFAULT '0',
-  possible_values 	C(255) NOTNULL DEFAULT \" '' \",
-  default_value 	C(255) NOTNULL DEFAULT \" '' \",
-  valid_regexp 		C(255) NOTNULL DEFAULT \" '' \",
-  access_level_r 	I2 NOTNULL DEFAULT '0',
-  access_level_rw 	I2 NOTNULL DEFAULT '0',
-  length_min 		 I  NOTNULL DEFAULT '0',
-  length_max 		 I  NOTNULL DEFAULT '0',
-  advanced 		L NOTNULL DEFAULT \" '0' \",
-  require_report 	L NOTNULL DEFAULT \" '0' \",
-  require_update 	L NOTNULL DEFAULT \" '0' \",
-  display_report 	L NOTNULL DEFAULT \" '0' \",
-  display_update 	L NOTNULL DEFAULT \" '1' \",
-  require_resolved 	L NOTNULL DEFAULT \" '0' \",
-  display_resolved 	L NOTNULL DEFAULT \" '0' \",
-  display_closed 	L NOTNULL DEFAULT \" '0' \",
-  require_closed 	L NOTNULL DEFAULT \" '0' \"
-",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_custom_field_name',db_get_table('mantis_custom_field_table'),'name'));
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_filters_table'),"
-  id 			 I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
-  user_id 		 I  NOTNULL DEFAULT '0',
-  project_id 		 I  NOTNULL DEFAULT '0',
-  is_public 		L DEFAULT NULL,
-  name 			C(64) NOTNULL DEFAULT \" '' \",
-  filter_string 	XL NOTNULL
-",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_news_table'),"
-  id 			 I  UNSIGNED PRIMARY NOTNULL AUTOINCREMENT,
-  project_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
-  poster_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
-  date_posted 		T NOTNULL DEFAULT '" . db_null_date() . "',
-  last_modified 	T NOTNULL DEFAULT '" . db_null_date() . "',
-  view_state 		I2 NOTNULL DEFAULT '10',
-  announcement 		L NOTNULL DEFAULT \" '0' \",
-  headline 		C(64) NOTNULL DEFAULT \" '' \",
-  body 			XL NOTNULL
-",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_project_category_table'),"
-  project_id 		 I  UNSIGNED NOTNULL PRIMARY DEFAULT '0',
-  category 		C(64) NOTNULL PRIMARY DEFAULT \" '' \",
-  user_id 		 I  UNSIGNED NOTNULL DEFAULT '0'
-",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_project_file_table'),"
-  id 			 I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
-  project_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
-  title 		C(250) NOTNULL DEFAULT \" '' \",
-  description 		C(250) NOTNULL DEFAULT \" '' \",
-  diskfile 		C(250) NOTNULL DEFAULT \" '' \",
-  filename 		C(250) NOTNULL DEFAULT \" '' \",
-  folder 		C(250) NOTNULL DEFAULT \" '' \",
-  filesize 		 I NOTNULL DEFAULT '0',
-  file_type 		C(250) NOTNULL DEFAULT \" '' \",
-  date_added 		T NOTNULL DEFAULT '" . db_null_date() . "',
-  content 		B NOTNULL
-",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-/* 30 */
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_project_hierarchy_table'),"
-			  child_id I UNSIGNED NOTNULL,
-			  parent_id I UNSIGNED NOTNULL",
-Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_project_table'),"
-  id 			 I  UNSIGNED PRIMARY NOTNULL AUTOINCREMENT,
-  name 			C(128) NOTNULL DEFAULT \" '' \",
-  status 		I2 NOTNULL DEFAULT '10',
-  enabled 		L NOTNULL DEFAULT \" '1' \",
-  view_state 		I2 NOTNULL DEFAULT '10',
-  access_min 		I2 NOTNULL DEFAULT '10',
-  file_path 		C(250) NOTNULL DEFAULT \" '' \",
-  description 		XL NOTNULL
-",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_project_id',db_get_table('mantis_project_table'),'id'));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_project_name',db_get_table('mantis_project_table'),'name',Array('UNIQUE')));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_project_view',db_get_table('mantis_project_table'),'view_state'));
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_project_user_list_table'),"
-  project_id 		 I  UNSIGNED PRIMARY NOTNULL DEFAULT '0',
-  user_id 		 I  UNSIGNED PRIMARY NOTNULL DEFAULT '0',
-  access_level 		I2 NOTNULL DEFAULT '10'
-",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array( 'CreateIndexSQL',Array('idx_project_user',db_get_table('mantis_project_user_list_table'),'user_id'));
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_project_version_table'),"
-  id 			 I  NOTNULL PRIMARY AUTOINCREMENT,
-  project_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
-  version 		C(64) NOTNULL DEFAULT \" '' \",
-  date_order 		T NOTNULL DEFAULT '" . db_null_date() . "',
-  description 		XL NOTNULL,
-  released 		L NOTNULL DEFAULT \" '1' \"
-",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_project_version',db_get_table('mantis_project_version_table'),'project_id,version',Array('UNIQUE')));
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_sponsorship_table'),"
-  id 			 I  NOTNULL PRIMARY AUTOINCREMENT,
-  bug_id 		 I  NOTNULL DEFAULT '0',
-  user_id 		 I  NOTNULL DEFAULT '0',
-  amount 		 I  NOTNULL DEFAULT '0',
-  logo 			C(128) NOTNULL DEFAULT \" '' \",
-  url 			C(128) NOTNULL DEFAULT \" '' \",
-  paid 			L NOTNULL DEFAULT \" '0' \",
-  date_submitted 	T NOTNULL DEFAULT '" . db_null_date() . "',
-  last_updated 		T NOTNULL DEFAULT '" . db_null_date() . "'
-",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-/* 40 */
-$upgrade[] = Array('CreateIndexSQL',Array('idx_sponsorship_bug_id',db_get_table('mantis_sponsorship_table'),'bug_id'));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_sponsorship_user_id',db_get_table('mantis_sponsorship_table'),'user_id'));
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_tokens_table'),"
-			  id I NOTNULL PRIMARY AUTOINCREMENT,
-			  owner I NOTNULL,
-			  type I NOTNULL,
-			  timestamp T NOTNULL,
-			  expiry T,
-			  value XL NOTNULL",
-Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_user_pref_table'),"
-  id 			 I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
-  user_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
-  project_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
-  default_profile 	 I  UNSIGNED NOTNULL DEFAULT '0',
-  default_project 	 I  UNSIGNED NOTNULL DEFAULT '0',
-  advanced_report 	L NOTNULL DEFAULT \" '0' \",
-  advanced_view 	L NOTNULL DEFAULT \" '0' \",
-  advanced_update 	L NOTNULL DEFAULT \" '0' \",
-  refresh_delay 	 I  NOTNULL DEFAULT '0',
-  redirect_delay 	L NOTNULL DEFAULT \" '0' \",
-  bugnote_order 	C(4) NOTNULL DEFAULT 'ASC',
-  email_on_new 		L NOTNULL DEFAULT \" '0' \",
-  email_on_assigned 	L NOTNULL DEFAULT \" '0' \",
-  email_on_feedback 	L NOTNULL DEFAULT \" '0' \",
-  email_on_resolved	L NOTNULL DEFAULT \" '0' \",
-  email_on_closed 	L NOTNULL DEFAULT \" '0' \",
-  email_on_reopened 	L NOTNULL DEFAULT \" '0' \",
-  email_on_bugnote 	L NOTNULL DEFAULT \" '0' \",
-  email_on_status 	L NOTNULL DEFAULT \" '0' \",
-  email_on_priority 	L NOTNULL DEFAULT \" '0' \",
-  email_on_priority_min_severity 	I2 NOTNULL DEFAULT '10',
-  email_on_status_min_severity 	I2 NOTNULL DEFAULT '10',
-  email_on_bugnote_min_severity 	I2 NOTNULL DEFAULT '10',
-  email_on_reopened_min_severity 	I2 NOTNULL DEFAULT '10',
-  email_on_closed_min_severity 	I2 NOTNULL DEFAULT '10',
-  email_on_resolved_min_severity 	I2 NOTNULL DEFAULT '10',
-  email_on_feedback_min_severity	I2 NOTNULL DEFAULT '10',
-  email_on_assigned_min_severity 	I2 NOTNULL DEFAULT '10',
-  email_on_new_min_severity 	I2 NOTNULL DEFAULT '10',
-  email_bugnote_limit 	I2 NOTNULL DEFAULT '0',
-  language 		C(32) NOTNULL DEFAULT 'english'
-",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_user_print_pref_table'),"
-  user_id 		 I  UNSIGNED NOTNULL PRIMARY DEFAULT '0',
-  print_pref 		C(27) NOTNULL DEFAULT \" '' \"
-",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_user_profile_table'),"
-  id 			 I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
-  user_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
-  platform 		C(32) NOTNULL DEFAULT \" '' \",
-  os 			C(32) NOTNULL DEFAULT \" '' \",
-  os_build 		C(32) NOTNULL DEFAULT \" '' \",
-  description 		XL NOTNULL
-",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_user_table'),"
-  id 			 I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
-  username 		C(32) NOTNULL DEFAULT \" '' \",
-  realname 		C(64) NOTNULL DEFAULT \" '' \",
-  email 		C(64) NOTNULL DEFAULT \" '' \",
-  password 		C(32) NOTNULL DEFAULT \" '' \",
-  date_created 		T NOTNULL DEFAULT '" . db_null_date() . "',
-  last_visit 		T NOTNULL DEFAULT '" . db_null_date() . "',
-  enabled		L NOTNULL DEFAULT \" '1' \",
-  protected 		L NOTNULL DEFAULT \" '0' \",
-  access_level 		I2 NOTNULL DEFAULT '10',
-  login_count 		 I  NOTNULL DEFAULT '0',
-  lost_password_request_count 	I2 NOTNULL DEFAULT '0',
-  failed_login_count 	I2 NOTNULL DEFAULT '0',
-  cookie_string 	C(64) NOTNULL DEFAULT \" '' \"
-",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_user_cookie_string',db_get_table('mantis_user_table'),'cookie_string',Array('UNIQUE')));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_user_username',db_get_table('mantis_user_table'),'username',Array('UNIQUE')));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_enable',db_get_table('mantis_user_table'),'enabled'));
-/* 50 */
-$upgrade[] = Array('CreateIndexSQL',Array('idx_access',db_get_table('mantis_user_table'),'access_level'));
-$upgrade[] = Array('InsertData', Array( db_get_table('mantis_user_table'),
-    "(username, realname, email, password, date_created, last_visit, enabled, protected, access_level, login_count, lost_password_request_count, failed_login_count, cookie_string) VALUES
-        ('administrator', '', 'root@localhost', '63a9f0ea7bb98050796b649e85481845', '" . installer_db_now() . "', '" . installer_db_now() . "', '1', '0', 90, 3, 0, 0, '" .
-             md5( mt_rand( 0, mt_getrandmax() ) + mt_rand( 0, mt_getrandmax() ) ) . md5( time() ) . "')" ) );
-$upgrade[] = Array('AlterColumnSQL', Array( db_get_table( 'mantis_bug_history_table' ), "old_value C(255) NOTNULL" ) );
-$upgrade[] = Array('AlterColumnSQL', Array( db_get_table( 'mantis_bug_history_table' ), "new_value C(255) NOTNULL" ) );
-
-$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_email_table'),"
-  email_id 		I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
-  email		 	C(64) NOTNULL DEFAULT \" '' \",
-  subject		C(250) NOTNULL DEFAULT \" '' \",
-  submitted 	T NOTNULL DEFAULT '" . db_null_date() . "',
-  metadata 		XL NOTNULL,
-  body 			XL NOTNULL
-  ",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_email_id',db_get_table('mantis_email_table'),'email_id'));
-$upgrade[] = Array('AddColumnSQL',Array(db_get_table('mantis_bug_table'), "target_version C(64) NOTNULL DEFAULT \" '' \""));
-$upgrade[] = Array('AddColumnSQL',Array(db_get_table('mantis_bugnote_table'), "time_tracking I UNSIGNED NOTNULL DEFAULT \" 0 \""));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_diskfile',db_get_table('mantis_bug_file_table'),'diskfile'));
-$upgrade[] = Array('AlterColumnSQL', Array( db_get_table( 'mantis_user_print_pref_table' ), "print_pref C(64) NOTNULL" ) );
-/* 60 */
-$upgrade[] = Array('AlterColumnSQL', Array( db_get_table( 'mantis_bug_history_table' ), "field_name C(64) NOTNULL" ) );
-
-# Release marker: 1.1.0a4
-
-$upgrade[] = Array('CreateTableSQL', Array( db_get_table( 'mantis_tag_table' ), "
-	id				I		UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
-	user_id			I		UNSIGNED NOTNULL DEFAULT '0',
-	name			C(100)	NOTNULL PRIMARY DEFAULT \" '' \",
-	description		XL		NOTNULL,
-	date_created	T		NOTNULL DEFAULT '" . db_null_date() . "',
-	date_updated	T		NOTNULL DEFAULT '" . db_null_date() . "'
-	", Array( 'mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS' ) ) );
-$upgrade[] = Array('CreateTableSQL', Array( db_get_table( 'mantis_bug_tag_table' ), "
-	bug_id			I	UNSIGNED NOTNULL PRIMARY DEFAULT '0',
-	tag_id			I	UNSIGNED NOTNULL PRIMARY DEFAULT '0',
-	user_id			I	UNSIGNED NOTNULL DEFAULT '0',
-	date_attached	T	NOTNULL DEFAULT '" . db_null_date() . "'
-	", Array( 'mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS' ) ) );
-
-$upgrade[] = Array('CreateIndexSQL', Array( 'idx_typeowner', db_get_table( 'mantis_tokens_table' ), 'type, owner' ) );
-
-# Release marker: 1.2.0-SVN
-
-$upgrade[] = Array('CreateTableSQL', Array( db_get_table( 'mantis_plugin_table' ), "
-	basename		C(40)	NOTNULL PRIMARY,
-	enabled			L		NOTNULL DEFAULT \" '0' \"
-	", Array( 'mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS' ) ) );
-
-$upgrade[] = Array('AlterColumnSQL', Array( db_get_table( 'mantis_user_pref_table' ), "redirect_delay 	I NOTNULL DEFAULT 0" ) );
-
-/* apparently mysql now has a STRICT mode, where setting a DEFAULT value on a blob/text is now an error, instead of being silently ignored */
-if ( isset( $f_db_type ) && ( $f_db_type == 'mysql' || $f_db_type == 'mysqli' ) ) {
-	$upgrade[] = Array('AlterColumnSQL', Array( db_get_table( 'mantis_custom_field_table' ), "possible_values X NOTNULL" ) );
-} else {
-	$upgrade[] = Array('AlterColumnSQL', Array( db_get_table( 'mantis_custom_field_table' ), "possible_values X NOTNULL DEFAULT \" '' \"" ) );
-}
-
-$upgrade[] = Array( 'CreateTableSQL', Array( db_get_table( 'mantis_category_table' ), "
-	id				I		UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
-	project_id		I		UNSIGNED NOTNULL DEFAULT '0',
-	user_id			I		UNSIGNED NOTNULL DEFAULT '0',
-	name			C(128)	NOTNULL DEFAULT \" '' \",
-	status			I		UNSIGNED NOTNULL DEFAULT '0'
-	", Array( 'mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS' ) ) );
-$upgrade[] = Array( 'CreateIndexSQL', Array( 'idx_category_project_name', db_get_table( 'mantis_category_table' ), 'project_id, name', array( 'UNIQUE' ) ) );
-$upgrade[] = Array( 'InsertData', Array( db_get_table( 'mantis_category_table' ), "
-	( project_id, user_id, name, status ) VALUES
-	( '0', '0', 'General', '0' ) " ) );
-/* 70 */
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "category_id I UNSIGNED NOTNULL DEFAULT '1'" ) );
-$upgrade[] = Array( 'UpdateFunction', "category_migrate" );
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "category" ) );
-$upgrade[] = Array( 'DropTableSQL', Array( db_get_table( 'mantis_project_category_table' ) ) );
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_project_table' ), "category_id I UNSIGNED NOTNULL DEFAULT '1'" ) );
-// remove unnecessary indexes
-$upgrade[] = Array('CreateIndexSQL',Array('idx_project_id',db_get_table('mantis_project_table'),'id', array('DROP')), Array( 'db_index_exists', Array( db_get_table('mantis_project_table'), 'idx_project_id')));
-$upgrade[] = Array('CreateIndexSQL',Array('idx_config',db_get_table( 'mantis_config_table' ),'config_id', array('DROP')), Array( 'db_index_exists', Array( db_get_table('mantis_config_table'), 'idx_config')));
-
-$upgrade[] = Array( 'InsertData', Array( db_get_table( 'mantis_plugin_table' ), "
-	( basename, enabled ) VALUES
-	( 'MantisCoreFormatting', '1' )" ) );
-
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_project_table' ), "inherit_global I UNSIGNED NOTNULL DEFAULT '0'" ) );
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_project_hierarchy_table' ), "inherit_parent I UNSIGNED NOTNULL DEFAULT '0'" ) );
-/* 80 */
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_plugin_table' ), "
-	protected		L		NOTNULL DEFAULT \" '0' \",
-	priority		I		UNSIGNED NOTNULL DEFAULT '3'
-	" ) );
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_project_version_table' ), "
-	obsolete		L		NOTNULL DEFAULT \" '0' \"" ) );
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "
-    due_date        T       NOTNULL DEFAULT '" . db_null_date() . "' " ) );
-
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_custom_field_table' ), "
-  filter_by 		L 		NOTNULL DEFAULT \" '1' \"" ) );
-$upgrade[] = Array( 'CreateTableSQL', Array( db_get_table( 'mantis_bug_revision_table' ), "
-	id			I		UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
-	bug_id		I		UNSIGNED NOTNULL,
-	bugnote_id	I		UNSIGNED NOTNULL DEFAULT '0',
-	user_id		I		UNSIGNED NOTNULL,
-	timestamp	T		NOTNULL DEFAULT '" . db_null_date() . "',
-	type		I		UNSIGNED NOTNULL,
-	value		XL		NOTNULL
-	", Array( 'mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS' ) ) );
-$upgrade[] = Array( 'CreateIndexSQL', Array( 'idx_bug_rev_id_time', db_get_table( 'mantis_bug_revision_table' ), 'bug_id, timestamp' ) );
-$upgrade[] = Array( 'CreateIndexSQL', Array( 'idx_bug_rev_type', db_get_table( 'mantis_bug_revision_table' ), 'type' ) );
-
-#date conversion
-
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "
-	date_submitted_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "
-	due_date_int        			I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "
-	last_updated_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-/* 90 */
-$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_bug_table', 'id', array( 'date_submitted', 'due_date', 'last_updated' ), array( 'date_submitted_int', 'due_date_int', 'last_updated_int' ) ) );
-
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "date_submitted" ) );
-$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "date_submitted_int", "date_submitted", "date_submitted_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "due_date" ) );
-$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "due_date_int", "due_date", "due_date_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "last_updated" ) );
-$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "last_updated_int", "last_updated", "last_updated_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-
-$upgrade[] = Array('CreateIndexSQL',Array('idx_last_mod',db_get_table( 'mantis_bugnote_table' ),'last_modified', array('DROP')), Array( 'db_index_exists', Array( db_get_table('mantis_bugnote_table'), 'idx_last_mod')));
-
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bugnote_table' ), "
-	last_modified_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bugnote_table' ), "
-	date_submitted_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-/* 100 */
-$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_bugnote_table', 'id', array( 'last_modified', 'date_submitted' ), array( 'last_modified_int', 'date_submitted_int' ) ) );
-
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bugnote_table' ), "last_modified" ) );
-$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bugnote_table' ), "last_modified_int", "last_modified", "last_modified_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-$upgrade[] = Array('CreateIndexSQL',Array('idx_last_mod',db_get_table('mantis_bugnote_table'),'last_modified'));
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bugnote_table' ), "date_submitted" ) );
-$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bugnote_table' ), "date_submitted_int", "date_submitted", "date_submitted_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-	
-
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_file_table' ), "
-	date_added_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_bug_file_table', 'id', 'date_added', 'date_added_int' ) );
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_file_table' ), "date_added" ) );
-$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bug_file_table' ), "date_added_int", "date_added", "date_added_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-/* 110 */
-
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_project_file_table' ), "
-	date_added_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_project_file_table', 'id', 'date_added', 'date_added_int' ) );
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_project_file_table' ), "date_added" ) );
-$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_project_file_table' ), "date_added_int", "date_added", "date_added_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_history_table' ), "
-	date_modified_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_bug_history_table', 'id', 'date_modified', 'date_modified_int' ) );
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_history_table' ), "date_modified" ) );
-$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bug_history_table' ), "date_modified_int", "date_modified", "date_modified_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_user_table' ), "
-	last_visit_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_user_table' ), "
-	date_created_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-/* 120 */
-
-$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_user_table', 'id', array( 'last_visit', 'date_created' ), array( 'last_visit_int', 'date_created_int' ) ) );
-
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_user_table' ), "date_created" ) );
-$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_user_table' ), "date_created_int", "date_created", "date_created_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_user_table' ), "last_visit" ) );
-$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_user_table' ), "last_visit_int", "last_visit", "last_visit_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_email_table' ), "
-	submitted_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_email_table', 'email_id', 'submitted', 'submitted_int' ) );
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_email_table' ), "submitted" ) );
-$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_email_table' ), "submitted_int", "submitted", "submitted_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_tag_table' ), "
-	date_created_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-/* 130 */
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_tag_table' ), "
-	date_updated_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-
-$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_tag_table', 'id', array( 'date_created', 'date_updated' ), array( 'date_created_int', 'date_updated_int' ) ) );
-
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_tag_table' ), "date_created" ) );
-$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_tag_table' ), "date_created_int", "date_created", "date_created_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_tag_table' ), "date_updated" ) );
-$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_tag_table' ), "date_updated_int", "date_updated", "date_updated_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_tag_table' ), "
-	date_attached_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_bug_tag_table', 'bug_id', 'date_attached', 'date_attached_int' ) );
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_tag_table' ), "date_attached" ) );
-$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bug_tag_table' ), "date_attached_int", "date_attached", "date_attached_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-/* 140 */
-
-
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_tokens_table' ), "
-	timestamp_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_tokens_table' ), "
-	expiry_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-
-$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_tokens_table', 'id', array( 'timestamp', 'expiry' ), array( 'timestamp_int', 'expiry_int' ) ) );
-
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_tokens_table' ), "timestamp" ) );
-$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_tokens_table' ), "timestamp_int", "timestamp", "timestamp_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_tokens_table' ), "expiry" ) );
-$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_tokens_table' ), "expiry_int", "expiry", "expiry_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_news_table' ), "
-	last_modified_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_news_table' ), "
-	date_posted_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_news_table', 'id', array( 'date_posted', 'last_modified' ), array( 'date_posted_int', 'last_modified_int' ) ) );
-/* 150 */
-
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_news_table' ), "last_modified" ) );
-$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_news_table' ), "last_modified_int", "last_modified", "last_modified_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_news_table' ), "date_posted" ) );
-$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_news_table' ), "date_posted_int", "date_posted", "date_posted_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-
-$upgrade[] = Array('CreateIndexSQL',Array('idx_bug_rev_id_time',db_get_table( 'mantis_bug_revision_table' ),'bug_id, timestamp', array('DROP')), Array( 'db_index_exists', Array( db_get_table('mantis_bug_revision_table'), 'idx_bug_rev_id_time')));
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_revision_table' ), "
-	timestamp_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_bug_revision_table', 'id', 'timestamp', 'timestamp_int' ) );
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_revision_table' ), "timestamp" ) );
-$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bug_revision_table' ), "timestamp_int", "timestamp", "timestamp_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-$upgrade[] = Array( 'CreateIndexSQL', Array( 'idx_bug_rev_id_time', db_get_table( 'mantis_bug_revision_table' ), 'bug_id, timestamp' ) );
-/* 160 */
-
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_user_pref_table' ), "
-	 timezone C(32) NOTNULL DEFAULT '' " ) );
-
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_project_version_table' ), "
-	date_order_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_project_version_table', 'id', 'date_order', 'date_order_int' ) );
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_project_version_table' ), "date_order" ) );
-$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_project_version_table' ), "date_order_int", "date_order", "date_order_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_sponsorship_table' ), "
-	date_submitted_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_sponsorship_table' ), "
-	last_updated_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-
-$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_sponsorship_table', 'id', array( 'date_submitted', 'last_updated' ), array( 'date_submitted_int', 'last_updated_int' ) ) );
-
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_sponsorship_table' ), "last_updated" ) );
-$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_sponsorship_table' ), "last_updated_int", "last_updated", "last_updated_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-
-/* 170 */
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_sponsorship_table' ), "date_submitted" ) );
-$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_sponsorship_table' ), "date_submitted_int", "date_submitted", "date_submitted_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
-
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_project_file_table' ), "
-	user_id			I		UNSIGNED NOTNULL DEFAULT '0' " ) );
-$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_file_table' ), "
-	user_id		I  			UNSIGNED NOTNULL DEFAULT '0' " ) );
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_custom_field_table'), "advanced" ) );
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_user_pref_table'), "advanced_report" ) );
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_user_pref_table'), "advanced_view" ) );
-$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_user_pref_table'), "advanced_update" ) );
-$upgrade[] = Array( 'CreateIndexSQL', Array( 'idx_project_hierarchy_child_id', db_get_table( 'mantis_project_hierarchy_table' ), 'child_id' ) );
-$upgrade[] = Array( 'CreateIndexSQL', Array( 'idx_project_hierarchy_parent_id', db_get_table( 'mantis_project_hierarchy_table' ), 'parent_id' ) );
-
-/* 180 */
-$upgrade[] = Array( 'CreateIndexSQL', Array( 'idx_tag_name', db_get_table( 'mantis_tag_table' ), 'name' ) );
-$upgrade[] = Array( 'CreateIndexSQL', Array( 'idx_bug_tag_tag_id', db_get_table( 'mantis_bug_tag_table' ), 'tag_id' ) );
-$upgrade[] = Array( 'CreateIndexSQL', Array( 'idx_email_id', db_get_table( 'mantis_email_table' ), 'email_id', array( 'DROP' ) ), Array( 'db_index_exists', Array( db_get_table( 'mantis_email_table' ), 'idx_email_id') ) );
-$upgrade[] = Array( 'UpdateFunction', 'correct_multiselect_custom_fields_db_format' );
diff --git a/admin/system_utils.php b/admin/system_utils.php
deleted file mode 100644
index d86d77e..0000000
--- a/admin/system_utils.php
+++ /dev/null
@@ -1,98 +0,0 @@
-<?php
-# MantisBT - a php based bugtracking system
-
-# MantisBT 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.
-#
-# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * @todo FIXME: Looks like "From", "to", and "Copy" need i18n. Possibly more in this file.
- * @package MantisBT
- * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
- * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
- * @link http://www.mantisbt.org
- */
-/**
- * MantisBT Core API's
- */
-require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
-
-access_ensure_global_level( config_get_global( 'admin_site_threshold' ) );
-
-html_page_top( 'MantisBT Administration - System Utilities' );
-
-?>
-<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
-	<tr class="top-bar">
-		<td class="links">
-			[ <a href="index.php">Back to MantisBT Administration</a> ]
-		</td>
-		<td class="title">
-			System Utilities
-		</td>
-	</tr>
-</table>
-<br /><br />
-
-<table width="80%" bgcolor="#222222" border="0" cellpadding="10" cellspacing="1">
-	<tr><td bgcolor=\"#e8e8e8\" colspan=\"2\"><span class=\"title\">Upgrade Utilities</span></td></tr>
-
-	<!-- # Headings -->
-	<tr bgcolor="#ffffff"><th width="70%">Description</th><th width="30%">Execute</th></tr>
-
-	<!-- each row links to an upgrade
-		move database bug attachments to disk -->
-	<tr bgcolor="#ffffff"><td>Move attachments stored in database schema to disk files.</td><td><center>
-	<?php html_button( 'move_db2disk.php', 'Move Attachments to Disk', array( 'doc' => 'attachment' ) );?>
-	</center></td></tr>
-
-	<!-- move database project files to disk -->
-	<tr bgcolor="#ffffff"><td>Move project files stored in database schema to disk.</td><td><center>
-	<?php html_button( 'move_db2disk.php', 'Move Project Files to Disk', array( 'doc' => 'project' ) );?>
-	</center></td></tr>
-
-	<!-- move custom field content to standard field -->
-	<tr bgcolor="#ffffff"><td>Copy Custom Field to Standard Field.</td><td><center>
-	<form method="post" action="copy_field.php">
-		From
-		<SELECT name="source_id">
-			<?php
-				$t_custom_ids = custom_field_get_ids();
-foreach( $t_custom_ids as $t_id ) {
-	printf( "<OPTION VALUE=\"%d\">%s", $t_id, custom_field_get_field( $t_id, 'name' ) );
-}
-?>
-		</SELECT> to
-		<SELECT name="dest_id">
-			<?php
-/** @todo should be expanded and configurable */
-// list matches exact field name from database
-$t_dest_ids = array(
-	'fixed_in_version',
-);
-foreach( $t_dest_ids as $t_id ) {
-	printf( "<OPTION VALUE=\"%s\">%s", $t_id, $t_id );
-}
-?>
-		</SELECT>
-	<input type="submit" class="button" value="Copy" />
-	</form>
-	</center></td></tr>
-
-	<!-- Database Statistics -->
-	<tr bgcolor="#ffffff"><td>Show database statistics.</td><td><center>
-	<?php html_button( 'db_stats.php', 'Display', array() );?>
-	</center></td></tr>
-
-</table>
-<?php
-	html_page_bottom();
diff --git a/admin/test_email.php b/admin/test_email.php
deleted file mode 100644
index 4c8c041..0000000
--- a/admin/test_email.php
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-# MantisBT - a php based bugtracking system
-
-# MantisBT 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.
-#
-# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * @package MantisBT
- * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
- * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
- * @link http://www.mantisbt.org
- */
-/**
- * MantisBT Core API's
- */
-require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
-
-access_ensure_global_level( config_get_global( 'admin_site_threshold' ) );
-
-$f_mail_test = gpc_get_bool( 'mail_test' );
-
-html_page_top();
-
-?>
-
-<a name="email" id="email" />
-<table width="100%" bgcolor="#222222" border="0" cellpadding="20" cellspacing="1">
-<tr>
-	<td bgcolor="#f4f4f4">
-		<span class="title">Testing Email</span>
-		<p>You can test the ability for MantisBT to send email notifications with this form.  Just click "Send Mail".  If the page takes a very long time to reappear or results in an error then you will need to investigate your php/mail server settings (see PHPMailer related settings in your config_inc.php, if they don't exist, copy from config_defaults_inc.php).  Note that errors can also appear in the server error log.  More help can be found at the <a href="http://www.php.net/manual/en/ref.mail.php">PHP website</a> if you are using the mail() PHPMailer sending mode.</p>
-		<?php
-		if( $f_mail_test ) {
-			echo '<b><font color="#ff0000">Testing Mail</font></b> - ';
-
-			# @@@ thraxisp - workaround to ensure a language is set without authenticating
-			#  will disappear when this is properly localized
-			lang_push( 'english' );
-
-			$t_email_data = new EmailData;
-			$t_email_data->email = config_get_global( 'administrator_email' );
-			$t_email_data->subject = 'Testing PHP mail() function';
-			$t_email_data->body = 'Your PHP mail settings appear to be correctly set.';
-			$t_email_data->metadata['priority'] = config_get( 'mail_priority' );
-			$t_email_data->metadata['charset'] = 'utf-8';
-			$result = email_send( $t_email_data );
-
-			# $result = email_send( config_get_global( 'administrator_email' ), 'Testing PHP mail() function',	'Your PHP mail settings appear to be correctly set.');
-
-			if( !$result ) {
-				echo ' PROBLEMS SENDING MAIL TO: ' . config_get_global( 'administrator_email' ) . '. Please check your php/mail server settings.<br />';
-			} else {
-				echo ' mail() send successful.<br />';
-			}
-		}
-?>
-		<form method="post" action="<?php echo $_SERVER['SCRIPT_NAME']?>#email">
-		Email Address: <?php echo config_get_global( 'administrator_email' );?><br />
-		<input type="submit" value="Send Mail" name="mail_test" />
-		</form>
-	</td>
-</tr>
-</table>
-
-<?php
-
-html_page_bottom();
diff --git a/admin/test_icons.php b/admin/test_icons.php
deleted file mode 100644
index b289051..0000000
--- a/admin/test_icons.php
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-# MantisBT - a php based bugtracking system
-
-# MantisBT 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.
-#
-# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * @package MantisBT
- * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
- * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
- * @link http://www.mantisbt.org
- */
-/**
- * MantisBT Core API's
- */
-require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
-
-access_ensure_global_level( config_get_global( 'admin_site_threshold' ) );
-
-html_page_top();
-
-foreach( $g_file_type_icons as $t_ext => $t_filename ) {
-	$t_file_path = dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'fileicons' . DIRECTORY_SEPARATOR . $t_filename;
-
-	echo "Testing icon for extension '$t_ext'... $t_file_path ... ";
-	flush();
-
-	if( file_exists( $t_file_path ) ) {
-		echo 'OK';
-	} else {
-		echo '<font color="red">NOT FOUND</font>';
-	}
-
-	echo '<br />';
-}
-
-html_page_bottom();
diff --git a/admin/test_langs.php b/admin/test_langs.php
deleted file mode 100644
index 9e137dd..0000000
--- a/admin/test_langs.php
+++ /dev/null
@@ -1,363 +0,0 @@
-<?php
-# MantisBT - a php based bugtracking system
-
-# MantisBT 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.
-#
-# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * @package MantisBT
- * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
- * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
- * @link http://www.mantisbt.org
- */
-
-define( 'PLUGINS_DISABLED', true ); 
-$g_skip_lang_load = true;
-
-/**
- * MantisBT Core API's
- */
-require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
-
-access_ensure_global_level( config_get_global( 'admin_site_threshold' ) );
-
-if( function_exists( 'xdebug_disable' ) ) {
-	xdebug_disable();
-}
-
-if( !defined( 'T_ML_COMMENT' ) ) {
-	define( 'T_ML_COMMENT', T_COMMENT );
-}
-else {
-	define( 'T_DOC_COMMENT', T_ML_COMMENT );
-}
-
-if (!checkfile( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR, 'strings_english.txt', true)) {
-	print_error( "FAILED: Language file 'strings_english.txt' failed." );
-	die;
-}
-
-unset( $g_skip_lang_load ) ;
-lang_push( 'english' );
-
-set_time_limit( 0 );
-
-html_page_top();
-
-// check core language files
-if( function_exists( 'opendir' ) && function_exists( 'readdir' ) ) {
-	$t_lang_files = Array();
-	if( $t_handle = opendir( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'lang' ) ) {
-		while( false !== ( $t_file = readdir( $t_handle ) ) ) {
-			if ($t_file == 'strings_english.txt' ) {
-				echo "Testing english language file '$t_file' (phase 1)...<br />";
-				flush();
-				checkfile( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR, $t_file );
-			}
-			if( $t_file[0] != '.' && $t_file != 'langreadme.txt' && !is_dir( $t_file ) ) {
-				$t_lang_files[] = $t_file;
-			}
-		}
-		closedir( $t_handle );
-	}
-}
-else {
-	$t_lang_files = Array();
-	foreach( $g_language_choices_arr as $t_lang ) {
-		if( $t_lang == 'auto' ) {
-			continue;
-		}
-		$t_lang_files[] = $t_lang;
-	}
-}
-
-if( count( $t_lang_files ) > 0 ) {
-	echo 'Retrieved ', count( $t_lang_files ), ' languages<br />';
-
-	foreach( $t_lang_files as $t_file ) {
-		echo "Testing language file '$t_file' (phase 1)...<br />";
-		flush();
-
-		checkfile( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR, $t_file );
-	}
-}
-
-// attempt to find plugin language files
-echo "Trying to find+check plugin language files...<br />";
-if( function_exists( 'opendir' ) && function_exists( 'readdir' ) ) {
-	checklangdir ( config_get( 'plugin_path' ) );
-} else {
-	echo 'php opendir/readdir are disabled - skipping<br />';
-}
-
-function checklangdir( $p_path, $p_subpath = '' ) {
-	$p_path = $p_path . DIRECTORY_SEPARATOR . $p_subpath . DIRECTORY_SEPARATOR;
-	if( $handle = opendir( $p_path ) ) {
-		while( false !== ( $file = readdir( $handle ) ) ) {
-			if ( $file[0] == '.' )
-				continue;
-			if ( $p_subpath == '' ) {
-				echo "Checking language files for plugin $file:<br />";
-
-				if (file_exists( $p_path . DIRECTORY_SEPARATOR . $p_subpath . DIRECTORY_SEPARATOR . $file . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . 'strings_english.txt' ) ) {
-					echo "Testing english language for plugin '$file' (phase 1)...<br />";
-					flush();
-					checkfile( $p_path . DIRECTORY_SEPARATOR . $p_subpath . DIRECTORY_SEPARATOR . $file . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR,  'strings_english.txt' );			
-				}
-			}
-
-			if( !is_dir( $p_path . DIRECTORY_SEPARATOR . $file ) && $p_subpath == 'lang' ) {
-				checkfile( $p_path, $file );
-			} else {
-				if ( is_dir( $p_path . DIRECTORY_SEPARATOR . $file ) )
-					checklangdir( $p_path, $file);
-			}
-		}
-		closedir( $handle );
-	}
-}
-
-
-function checkfile( $p_path, $p_file, $p_quiet = false ) {
-		if( !$p_quiet) {
-			echo "Testing language file '$p_file' (phase 1)...<br />";
-			flush();
-		}
-
-		$file = $p_path . $p_file;
-
-		set_error_handler( 'lang_error_handler' );
-		$result = checktoken( $file, ($p_file == 'strings_english.txt' ? true : false) );
-		restore_error_handler();
-
-		if( !$result ) {
-			print_error( "FAILED: Language file '$p_file' failed at phase 1." );
-			if( $p_quiet ) {
-				return false;
-			}
-		}
-
-		if( !$p_quiet ) {
-			echo "Testing language file '$p_file' (phase 2)...<br />";
-			flush();
-		} else {
-			return true;
-		}
-
-		set_error_handler( 'lang_error_handler' );
-		ob_start();
-		$result = eval( "require_once( '$file' );" );
-		$data = ob_get_contents();
-		ob_end_clean();
-		restore_error_handler();
-
-		if( $result === false ) {
-			print_error( "FAILED: Language file '$p_file' failed at eval" );
-			if( $p_quiet ) {
-				return false;
-			}
-		}
-
-		if( !empty( $data ) ) {
-			print_error( "FAILED: Language file '$p_file' failed at require_once (data output: " . var_export( $data, true ) . ")" );
-			if( $p_quiet ) {
-				return false;
-			}
-		}
-		return true;
-}
-
-$basevariables = Array();
-
-function checktoken( $file, $base = false ) {
-	$in_php_code = false;
-	$variables = Array();
-	global $basevariables;	
-	$current_var = null;
-	$last_token = 0;
-	$set_variable = false;
-	$variablearr = false;
-	$twopartstring = false;
-	$need_end_variable = false;
-	$source = file_get_contents( $file );
-	$tokens = @token_get_all( $source );
-	$expectendarr = false;
-	$settingvariable = false;
-	$pass = true;
-	$fatal = false;
-	foreach( $tokens as $token ) {
-		$last_token2 = 0;
-		if( is_string( $token ) ) {
-			switch( $token ) {
-				case '=':
-					if( $last_token != T_VARIABLE ) {
-						print_error( "ERROR: = sign without variable" );
-						$pass = false;
-					}
-					$set_variable = true;
-					break;
-				case '[':
-					if( $last_token != T_VARIABLE ) {
-						$pass = false;
-					}
-					$variablearr = true;
-					break;
-				case ']':
-					if( !$expectendarr ) {
-						$pass = false;
-					}
-					$expectendarr = false;
-					break;
-				case ';':
-					if( !$need_end_variable ) {
-						print_error( "ERROR: function seperator found at unexpected location (line $line)" );
-						$pass = false;
-					}
-					$need_end_variable = false;
-					break;
-				case '.':
-					if( $last_token == T_CONSTANT_ENCAPSED_STRING ) {
-						$twopartstring = true;
-					} else {
-						print_error( "ERROR: string concat found at unexpected location (line $line)" );
-						$pass = false;
-					}
-					break;
-				default:
-					print_error( "UNKNOWN TOKEN" . $token );
-					$pass = false;
-					break;
-			}
-		} else {
-			// token array
-			list( $id, $text, $line ) = $token;
-
-			if( $id == T_WHITESPACE || $id == T_COMMENT || $id == T_DOC_COMMENT || $id == T_ML_COMMENT ) {
-				continue;
-			}
-			if( $need_end_variable ) {
-				if( $twopartstring && $id == T_CONSTANT_ENCAPSED_STRING ) {
-					$twopartstring = false;
-					continue;
-				}
-				if( $settingvariable && $id == T_STRING ) {
-					$last_token = T_VARIABLE;
-					$expectendarr = true;
-					continue;
-				}
-
-				print_error( "ERROR" . $id . token_name( $id ) . $text . $line );
-				$pass = false;
-			}
-
-			switch( $id ) {
-				case T_OPEN_TAG:
-					$in_php_code = true;
-					break;
-				case T_CLOSE_TAG:
-					$in_php_code = false;
-					break;
-				case T_INLINE_HTML:
-					print_error( "ERROR: Whitespace in language file outside of PHP code block (line $line)" );
-					$pass = false;
-					break;
-				case T_VARIABLE:
-					if( $set_variable && $current_var != null ) {
-						$need_end_variable = true;
-						$settingvariable = true;
-						$current_var = null;
-						break;
-					}
-					$current_var = $text;
-					break;
-				case T_STRING:
-					if( $variablearr ) {
-						$current_var .= $text;
-						if( !defined( $text ) ) {
-							print_error( "undefined constant: $current_var" );
-						}
-					} else {
-						print_error( "ERROR: T_STRING found at unexpected location (line $line)" );
-						$pass = false;
-					}
-					if ( strpos($current_var,"\n") !== false ) {
-						print_error( "PARSER - NEW LINE IN STRING: " . $id . token_name( $id ) . $text . $line );
-						$pass = false;
-						$fatal = true;
-					}					
-					$last_token2 = T_VARIABLE;
-					$expectendarr = true;
-					break;
-				case T_CONSTANT_ENCAPSED_STRING:
-					if ( $token[1][0] != '\'' ) {
-							print_error( "ERROR: Language strings should be single-quoted (line $line)" );						
-					}
-					if( $last_token == T_VARIABLE && $set_variable && $current_var != null ) {
-						if( isset( $variables[$current_var] ) ) {
-							print_error( "ERROR: duplicate language string ($current_var ) (line $line)" );
-						} else {
-							$variables[$current_var] = $text;
-						}
-						
-						if ( $base ) {
-							// english
-							//if( isset( $basevariables[$current_var] ) ) {
-							//	print_error( "WARN: english string redefined - plugin? $current_var" );
-							//}
-							$basevariables[$current_var] = true;
-						} else {
-							if( !isset( $basevariables[$current_var] ) ) {
-								print_error( "WARN: String defined in non-english file that does not exist ( $current_var )" ); 
-							//} else {
-								// missing translation
-							}
-						}
-						
-					}
-					if ( strpos($current_var,"\n") !== false ) {
-						print_error( "PARSER - NEW LINE IN STRING: " . $id . token_name( $id ) . $text . $line );
-						$pass = false;
-						$fatal = true;
-					}
-					$current_var = null;
-					$need_end_variable = true;
-					break;
-				default:
-					// if (!$in_php_code)
-					print_error( "PARSER: " . $id . token_name( $id ) . $text . $line );
-					$pass = false;
-					break;
-			}
-
-			$last_token = $id;
-			if( $last_token2 > 0 ) {
-				$last_token = $last_token2;
-			}
-		}
-		
-		if ($fatal)
-			break;
-	}
-
-	return $pass;
-}
-
-function lang_error_handler( $p_type, $p_error, $p_file, $p_line, $p_context ) {
-	print_error( "error handler thrown: " . $p_type . '<br />' . $p_error . '<br />' . $p_file . '<br />' . $p_line . '<br />' . $p_context );
-}
-
-function print_error( $p_string ) {
-	echo "<font color='red'>ERROR: ", $p_string, '</font><br />';
-}
-
-html_page_bottom();
diff --git a/admin/upgrade_unattended.php b/admin/upgrade_unattended.php
deleted file mode 100644
index 0be5995..0000000
--- a/admin/upgrade_unattended.php
+++ /dev/null
@@ -1,154 +0,0 @@
-<?php
-# MantisBT - a php based bugtracking system
-
-# MantisBT 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.
-#
-# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * @package MantisBT
- * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
- * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
- * @link http://www.mantisbt.org
- */
-
-@set_time_limit( 0 );
-
-$g_skip_open_db = true;  # don't open the database in database_api.php
-/**
- * MantisBT Core API's
- */
-require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
-$g_error_send_page_header = false; # suppress page headers in the error handler
-
-$g_failed = false;
-
-/* This script is probably meant to be executed from PHP CLI and hence should
- * not be interpreted as text/html. However saying that, we do call gpc_
- * functions that only make sense in PHP CGI mode. Given this mismatch we'll
- * just assume for now that this script is meant to be used from PHP CGI and
- * the output is meant to be text/plain. We also need to prevent Internet
- * Explorer from ignoring our MIME type and using it's own MIME sniffing.
- */
-header( 'Content-Type: text/plain' );
-header( 'X-Content-Type-Options: nosniff' );
-
-/**
- * Print the result of an upgrade step.
- * 
- * @param integer $result       GOOD or BAD.
- * @param bool    $p_hard_fail  If result is BAD, sets the global failure flag.
- * @param string  $p_message    The message describing the upgrade step.
- * @access private
- */
-function print_test_result( $p_result, $p_hard_fail = true, $p_message = '' ) {
-	global $g_failed;
-	if( BAD == $p_result ) {
-		if( $p_hard_fail ) {
-			$g_failed = true;
-			echo " - ERROR: ";
-		} else {
-			echo " - WARNING: ";
-		}
-		if( '' != $p_message ) {
-			echo $p_message;
-		}
-	}
-
-	if( GOOD == $p_result ) {
-		echo " - GOOD";
-	}
-	echo "\n";
-}
-
-$result = @db_connect( config_get_global( 'dsn', false ), config_get_global( 'hostname' ),
-	config_get_global( 'db_username' ), config_get_global( 'db_password' ),
-	config_get_global( 'database_name' ) );
-
-if( false == $result ) {
-	echo "Opening connection to database " .
-		config_get_global( 'database_name' ) .
-		" on host " . config_get_global( 'hostname' ) .
-		" with username " . config_get_global( 'db_username' ) .
-		" failed: " . db_error_msg() . "\n";
-	exit( 1 );
-}
-
-# check to see if the new installer was used
-if ( -1 == config_get( 'database_version', -1 ) ) {
-	echo "Upgrade from the current installed MantisBT version is no longer supported.  If you are using MantisBT version older than 1.0.0, then upgrade to v1.0.0 first.";
-	exit( 1 );
-}
-
-# read control variables with defaults
-$f_hostname = gpc_get( 'hostname', config_get( 'hostname', 'localhost' ) );
-$f_db_type = gpc_get( 'db_type', config_get( 'db_type', '' ) );
-$f_database_name = gpc_get( 'database_name', config_get( 'database_name', 'bugtrack' ) );
-$f_db_username = gpc_get( 'db_username', config_get( 'db_username', '' ) );
-$f_db_password = gpc_get( 'db_password', config_get( 'db_password', '' ) );
-$f_db_exists = gpc_get_bool( 'db_exists', false );
-
-# install the tables
-if ( !preg_match( '/^[a-zA-Z0-9_]+$/', $f_db_type ) ||
-     !file_exists( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'adodb' . DIRECTORY_SEPARATOR . 'drivers' . DIRECTORY_SEPARATOR . 'adodb-' . $f_db_type . '.inc.php' ) ) {
-	echo 'Invalid db type ' . htmlspecialchars( $f_db_type ) . '.';
-	exit;
-}
-
-$GLOBALS['g_db_type'] = $f_db_type; # database_api references this
-require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'schema.php' );
-$g_db = ADONewConnection( $f_db_type );
-
-echo "\nPost 1.0 schema changes\n";
-echo "Connecting to database... ";
-$t_result = @$g_db->Connect( $f_hostname, $f_db_username, $f_db_password, $f_database_name );
-
-if( false == $t_result ) {
-	echo "failed\n";
-	exit( 1 );
-}
-
-echo "OK\n";
-
-$g_db_connected = true; # fake out database access routines used by config_get
-$t_last_update = config_get( 'database_version', -1, ALL_USERS, ALL_PROJECTS );
-$lastid = count( $upgrade ) - 1;
-$i = $t_last_update + 1;
-
-while(( $i <= $lastid ) && !$g_failed ) {
-	echo 'Create Schema ( ' . $upgrade[$i][0] . ' on ' . $upgrade[$i][1][0] . ' )';
-	$dict = NewDataDictionary( $g_db );
-
-	if( $upgrade[$i][0] == 'InsertData' ) {
-		$sqlarray = call_user_func_array( $upgrade[$i][0], $upgrade[$i][1] );
-	} else {
-		$sqlarray = call_user_func_array( Array( $dict, $upgrade[$i][0] ), $upgrade[$i][1] );
-	}
-
-	$ret = $dict->ExecuteSQLArray( $sqlarray );
-	if( $ret == 2 ) {
-		print_test_result( GOOD );
-		config_set( 'database_version', $i );
-	} else {
-		print_test_result( BAD, true, $sqlarray[0] . '<br />' . $g_db->ErrorMsg() );
-	}
-
-	$i++;
-}
-
-if( false == $g_failed ) {
-	exit( 0 );
-}
-
-exit( 1 );
-
-# vim: noexpandtab tabstop=4 softtabstop=0:
diff --git a/admin/upgrade_warning.php b/admin/upgrade_warning.php
deleted file mode 100644
index 767571b..0000000
--- a/admin/upgrade_warning.php
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php
-# MantisBT - a php based bugtracking system
-
-# MantisBT 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.
-#
-# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * @package MantisBT
- * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
- * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
- * @link http://www.mantisbt.org
- */
-/**
- * MantisBT Core API's
- */
-require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
-
-access_ensure_global_level( config_get_global( 'admin_site_threshold' ) );
-
-$g_error_send_page_header = false; # suppress page headers in the error handler
-
-# @@@ upgrade list moved to the bottom of upgrade_inc.php
-
-$f_advanced = gpc_get_bool( 'advanced', false );
-
-?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
-<head>
-<title>MantisBT Administration - Check Installation </title>
-<link rel="stylesheet" type="text/css" href="admin.css" />
-</head>
-<body>
-
-<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
-	<tr class="top-bar">
-		<td class="links">
-			[ <a href="index.php">Back to Administration</a> ]
-		</td>
-		<td class="title">
-			Upgrade Installation
-		</td>
-	</tr>
-</table>
-<br /><br />
-
-<p><b>WARNING:</b> - Always backup your database data before upgrading.  For example, if you use a mysql database, From the command line you can do this with the mysqldump command.</p>
-<p>eg:</p>
-<p><tt>mysqldump -u[username] -p[password] [database_name] > [filename]</tt></p>
-<p>This will dump the contents of the specified database into the specified filename.</p>
-<p>If an error occurs you can re-create your previous database by just importing your backed up database data.  You'll need to drop and recreate your database (or remove each table).</p>
-<p><tt>mysql -u[username] -p[password] [database_name] < [filename]</tt></p>
-
-<p>Upgrades may take several minutes depending on the size of your database.</p>
-
-<div align="center">
-	<table width="80%" bgcolor="#222222" border="0" cellpadding="10" cellspacing="1">
-		<tr bgcolor="#ffffff">
-				<?php
-# check to see if the new installer was used
-if( -1 != config_get( 'database_version', -1 ) ) {
-	?>
-				<td align="center" nowrap="nowrap"><p>When you have backed up your database click the link below to continue</p>[ <a href="install.php">Upgrade Now</a> ]</td>
-				<?php
-}
-else {?>
-				<td align="center" nowrap="nowrap"><p>You aware to be running an old (pre 1.1.0) release of MantisBT. To update to this release of mantis, you must first update your installation to 1.1</td>
-				<?php
-}?>
-		</tr>
-	</table>
-</div>
-</body>
-</html>
diff --git a/core/authentication_api.php b/core/authentication_api.php
index a8cb4f6..c12ff89 100644
--- a/core/authentication_api.php
+++ b/core/authentication_api.php
@@ -222,8 +222,6 @@ function auth_cas_logout()
         }
 }
 
-
-
 /**
  * Check that there is a user logged-in and authenticated
  * If the user's account is disabled they will be logged out
@@ -354,11 +352,10 @@ function auth_attempt_login( $p_username, $p_password, $p_perm_login = false ) {
 	$t_login_method = config_get( 'login_method' );
 
 	if ( false === $t_user_id ) {
-		if ( BASIC_AUTH == $t_login_method ) {
-                        if ( in_array( $t_login_method, array( BASIC_AUTH, CAS_AUTH ) ) ) {
+                if ( in_array( $t_login_method, array( BASIC_AUTH, CAS_AUTH ) ) ) {
                         # attempt to create the user if using BASIC_AUTH or CAS_AUTH
                         # ( note: CAS_AUTH must have $g_allow_blank_email == ON )
-			$t_auto_create = true;
+	          	$t_auto_create = true;
 		} else if ( LDAP == $t_login_method && ldap_authenticate_by_username( $p_username, $p_password ) ) {
 			$t_auto_create = true;
 		} else {
-- 
1.7.5.2


From 41dceb285afae3586dc0e1a2a40915419513fde5 Mon Sep 17 00:00:00 2001
From: misilot <misilot@fit.edu>
Date: Tue, 31 May 2011 18:17:55 -0400
Subject: [PATCH 3/4] Revert "s" removed the admin files by accident

This reverts commit b77f2129a532aa06b7f1b07c754526bc58ff0f21.
---
 admin/admin.css                    |   27 +
 admin/check.php                    |  409 +++++++++++++++
 admin/copy_field.php               |  128 +++++
 admin/db_stats.php                 |   56 ++
 admin/email_queue.php              |   75 +++
 admin/index.php                    |   80 +++
 admin/install.php                  | 1015 ++++++++++++++++++++++++++++++++++++
 admin/install_functions.php        |  262 ++++++++++
 admin/install_helper_functions.php |   68 +++
 admin/move_db2disk.php             |  200 +++++++
 admin/schema.php                   |  610 ++++++++++++++++++++++
 admin/system_utils.php             |   98 ++++
 admin/test_email.php               |   77 +++
 admin/test_icons.php               |   47 ++
 admin/test_langs.php               |  363 +++++++++++++
 admin/upgrade_unattended.php       |  154 ++++++
 admin/upgrade_warning.php          |   84 +++
 core/authentication_api.php        |    7 +-
 18 files changed, 3758 insertions(+), 2 deletions(-)
 create mode 100644 admin/admin.css
 create mode 100644 admin/check.php
 create mode 100644 admin/copy_field.php
 create mode 100644 admin/db_stats.php
 create mode 100644 admin/email_queue.php
 create mode 100644 admin/index.php
 create mode 100644 admin/install.php
 create mode 100644 admin/install_functions.php
 create mode 100644 admin/install_helper_functions.php
 create mode 100644 admin/move_db2disk.php
 create mode 100644 admin/schema.php
 create mode 100644 admin/system_utils.php
 create mode 100644 admin/test_email.php
 create mode 100644 admin/test_icons.php
 create mode 100644 admin/test_langs.php
 create mode 100644 admin/upgrade_unattended.php
 create mode 100644 admin/upgrade_warning.php

diff --git a/admin/admin.css b/admin/admin.css
new file mode 100644
index 0000000..31cba82
--- /dev/null
+++ b/admin/admin.css
@@ -0,0 +1,27 @@
+body { background-color: #ffffff; font-family:Verdana, Arial; font-size: 10pt }
+
+td { font-family:Verdana, Arial; font-size: 10pt }
+
+p { font-family:Verdana, Arial; font-size: 10pt }
+
+.title    { font-family:Verdana, Arial; font-size: 12pt; color: #000000; font-weight: bold; }
+
+tr.top-bar { background-color: #98b8e8; padding: 3px; padding: 3px; color: #204888 }
+
+tr.top-bar td { border-top: 1px solid #222222; border-bottom: 1px solid #222222 }
+
+tr.top-bar td.title { text-align: right; font-size: 10pt; font-weight: bold; letter-spacing: 1.0em; }
+
+tr.top-bar td.links { text-align: left; font-size: 8pt }
+
+tr.row-1 { background-color: #d8d8d8; color: #000000; }
+
+tr.row-2 { background-color: #e8e8e8; color: #000000; }
+
+table.width100		{ width: 100%; border: solid 1px #000000; }
+
+table.width50		{ width: 50%; border: solid 1px #000000; }
+
+td.center			{ text-align: center; }
+
+.error { background-color: red; color: black; }
diff --git a/admin/check.php b/admin/check.php
new file mode 100644
index 0000000..5b26c55
--- /dev/null
+++ b/admin/check.php
@@ -0,0 +1,409 @@
+<?php
+# MantisBT - a php based bugtracking system
+
+# MantisBT 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.
+#
+# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * @package MantisBT
+ * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+ * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
+ * @link http://www.mantisbt.org
+ */
+
+error_reporting( E_ALL );
+
+$g_skip_open_db = true;  # don't open the database in database_api.php
+
+/**
+ * MantisBT Core API's
+ */
+require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
+
+require_once( 'email_api.php' );
+require_once( 'database_api.php' );
+
+$f_showall = gpc_get_int( 'showall', false );
+
+$g_failed_test = false;
+
+function print_test_result( $p_result ) {
+	global $g_failed_test;
+	switch ( $p_result ) {
+		case BAD:
+			echo '<td bgcolor="#ff0088">BAD</td>';
+			$g_failed_test = true;
+			break;
+		case GOOD:
+			echo '<td bgcolor="#00ff88">GOOD</td>';
+			break;
+		case WARN:
+			echo '<td bgcolor="#E56717">WARN</td>';
+			break;
+	}
+}
+
+function print_info_row( $p_description, $p_info = null ) {
+	if( $p_info == null ) {
+		echo '<tr><td bgcolor="#ffffff" colspan="2">' . $p_description . '</td></tr>';
+	} else {
+		echo '<tr><td bgcolor="#ffffff">' . $p_description . '</td>';
+		echo '<td bgcolor="#ffffff">' . $p_info . '</td></tr>';
+	}
+}
+
+function print_test_row( $p_description, $p_pass, $p_info = null ) {
+	global $f_showall;
+	if ( $f_showall == false && $p_pass == true ) {
+		return $p_pass;
+	}
+	echo '<tr><td bgcolor="#ffffff">' .$p_description;
+	if( $p_info != null) {
+		if( is_array( $p_info ) ) {
+			if( isset( $p_info[$p_pass] ) ) {
+				echo '<br /><i>' . $p_info[$p_pass] . '</i>';
+			}
+		} else {
+			echo '<br /><i>' . $p_info . '</i>';
+		}
+	}
+	echo '</td>';
+
+	if( $p_pass ) {
+		print_test_result( GOOD );
+	} else {
+		print_test_result( BAD );
+	}
+
+	echo '</tr>';
+
+	return $p_pass;
+}
+
+function print_test_warn_row( $p_description, $p_pass, $p_info = null ) {
+	global $f_showall;
+	if ( $f_showall == false && $p_pass == true ) {
+		return $p_pass;
+	}
+	echo '<tr><td bgcolor="#ffffff">' . $p_description;
+	if( $p_info != null) {
+		if( is_array( $p_info ) ) {
+			echo '<br /><i>' . $p_info[$p_pass] . '</i>';
+		} else {
+			echo '<br /><i>' . $p_info . '</i>';
+		}
+	}
+	echo '</td>';
+
+	if( $p_pass ) {
+		print_test_result( GOOD );
+	} else {
+		print_test_result( WARN );
+	}
+
+	echo '</tr>';
+
+	return $p_pass;
+}
+
+function test_bug_download_threshold() {
+	$t_pass = true;
+
+	$t_view_threshold = config_get_global( 'view_attachments_threshold' );
+	$t_download_threshold = config_get_global( 'download_attachments_threshold' );
+	$t_delete_threshold = config_get_global( 'delete_attachments_threshold' );
+
+	if( $t_view_threshold > $t_download_threshold ) {
+		$t_pass = false;
+	} else {
+		if( $t_download_threshold > $t_delete_threshold ) {
+			$t_pass = false;
+		}
+	}
+
+	print_test_row( 'Bug attachments download thresholds (view_attachments_threshold, ' .
+		'download_attachments_threshold, delete_attachments_threshold)', $t_pass );
+
+	return $t_pass;
+}
+
+function test_bug_attachments_allow_flags() {
+	$t_pass = true;
+
+	$t_own_view = config_get_global( 'allow_view_own_attachments' );
+	$t_own_download = config_get_global( 'allow_download_own_attachments' );
+	$t_own_delete = config_get_global( 'allow_delete_own_attachments' );
+
+	if(( $t_own_delete == ON ) && ( $t_own_download == FALSE ) ) {
+		$t_pass = false;
+	} else {
+		if(( $t_own_download == ON ) && ( $t_own_view == OFF ) ) {
+			$t_pass = false;
+		}
+	}
+
+	print_test_row( 'Bug attachments allow own flags (allow_view_own_attachments, ' .
+		'allow_download_own_attachments, allow_delete_own_attachments)', $t_pass );
+
+	return $t_pass;
+}
+
+function check_zend_optimiser_version() {
+	$t_pass = false;
+
+	ob_start();
+	phpinfo(INFO_GENERAL);
+	$t_output = ob_get_contents();
+	ob_end_clean();
+
+	$t_output = str_replace(array("&gt;", "&lt;", "&quot;", "&amp;", "&#039;", "&#160;"), array(">", "<", "\"", "&", "'", " "), $t_output);
+
+	$t_zend_optimizer_min_version = '3.3.3';
+
+	$t_info = '';
+
+	if ( preg_match( '/with Zend Optimizer\+? v([\d\.]*)/', $t_output, $t_matches ) === 1 ) {
+		if ( version_compare( $t_matches[1], $t_zend_optimizer_min_version, '>=' ) ) {
+			$t_pass = true;
+		} else {
+			$t_info = 'Fail - Installed Version: ' . $t_matches[1] . '. Zend Optimizer should be version be version ' . $t_zend_optimizer_min_version . ' or greater! Some old versions cause the view issues page not to display completely. The latest version of Zend Optimizer can be found at www.zend.com';
+		}
+	} else {
+		$t_pass = true;
+		$t_info = 'Zend Optimizer not detected.';
+	}
+
+	print_test_row( 'Checking Zend Optimizer version (if installed)...', $t_pass, $t_info );
+
+	return $t_pass;
+}
+
+function test_database_utf8() {
+	if ( !db_is_mysql() ) {
+		return;
+	}
+
+	// table collation/character set check
+	$result = db_query_bound( 'SHOW TABLE STATUS' );
+	while( $row = db_fetch_array( $result ) ) {
+		if( $row['Comment'] !== 'VIEW' ) {
+			print_test_row( 'Checking Table Collation is utf8 for ' . $row['Name'] . '....', substr( $row['Collation'], 0, 5 ) === 'utf8_', $row['Collation'] );
+		}
+	}
+
+	foreach( db_get_table_list() as $t_table ) {
+		if( db_table_exists( $t_table ) ) {
+			$result = db_query_bound( 'SHOW FULL FIELDS FROM ' . $t_table );
+			while( $row = db_fetch_array( $result ) ) {
+				if ( $row['Collation'] === null ) {
+					continue;
+				}
+				print_test_row( 'Checking Non-null Column Collation in ' . $t_table . ' is utf8 for ' . $row['Field'] . '....', substr( $row['Collation'], 0, 5 ) === 'utf8_', $row['Collation'] . ' ( ' . $row['Type'] . ')' );
+			}
+		}
+	}
+}
+
+
+
+	html_page_top( 'MantisBT Administration - Check Installation' );
+
+?>
+<table class="width75" align="center" cellspacing="1">
+<tr>
+<td class="form-title" width="30%" colspan="2"><?php echo 'Checking your installation' ?></td>
+</tr>
+
+<?php 
+
+	require_once( 'obsolete.php' );
+
+print_test_row( 'MantisBT requires at least <b>PHP ' . PHP_MIN_VERSION . '</b>. You are running <b>PHP ' . phpversion(), $result = version_compare( phpversion(), PHP_MIN_VERSION, '>=' ) );
+
+if ( !print_test_row( 'Checking Config File Exists', file_exists( $g_absolute_path . 'config_inc.php' ), array( false => 'Please use install.php to perform initial installation <a href="install.php">Click here</a>' ) ) ) {
+	die;
+}
+
+print_test_row( 'Opening connection to database [' . config_get_global( 'database_name' ) . '] on host [' . config_get_global( 'hostname' ) . '] with username [' . config_get_global( 'db_username' ) . ']', @db_connect( config_get_global( 'dsn', false ), config_get_global( 'hostname' ), config_get_global( 'db_username' ), config_get_global( 'db_password' ), config_get_global( 'database_name' ) ) != false );
+if( !db_is_connected() ) {
+	print_info_row( 'Database is not connected - Can not continue checks' );
+}
+
+if( isset( $ADODB_vers ) ) {
+	# ADOConnection::Version() is broken as it treats v5.1 the same as v5.10
+	# Therefore we must extract the correct version ourselves
+	# Upstream bug report: http://phplens.com/lens/lensforum/msgs.php?id=18320
+	if( preg_match( '/^[Vv]([0-9\.]+)/', $ADODB_vers, $t_matches ) == 1 ) {
+		$t_adodb_version_check_ok = version_compare( $t_matches[1], '5.10', '>=' );
+	}
+}
+print_test_warn_row( 'Checking adodb version...', $t_adodb_version_check_ok, $ADODB_vers );
+
+print_test_row('Checking using bundled adodb with some drivers...', !(db_is_pgsql() || db_is_mssql() || db_is_db2()) || strstr($ADODB_vers, 'MantisBT Version') !== false );
+$t_serverinfo = $g_db->ServerInfo();
+	
+print_info_row( 'Database Type (adodb)', $g_db->databaseType );
+print_info_row( 'Database Provider (adodb)', $g_db->dataProvider );
+print_info_row( 'Database Server Description (adodb)', $t_serverinfo['description'] );
+print_info_row( 'Database Server Description (version)', $t_serverinfo['version'] );
+
+print_test_row( 'Checking to see if your absolute_path config option has a trailing slash: "' . config_get_global( 'absolute_path' ) . '"', ( "\\" == substr( config_get_global( 'absolute_path' ), -1, 1 ) ) || ( "/" == substr( config_get_global( 'absolute_path' ), -1, 1 ) ) );
+
+// Windows-only checks
+if( is_windows_server() ) {
+	print_test_row( 'validate_email (if ON) requires php 5.3 on windows...',
+		OFF == config_get_global( 'validate_email' ) || ON == config_get_global( 'validate_email' ) && version_compare( phpversion(), '5.3.0', '>=' ) );
+	print_test_row( 'check_mx_record (if ON) requires php 5.3 on windows...',
+		OFF == config_get_global( 'check_mx_record' ) || ON == config_get_global( 'check_mx_record' ) && version_compare( phpversion(), '5.3.0', '>=' ) );
+}
+
+$t_vars = array(
+	'magic_quotes_gpc',
+	'include_path',
+);
+
+while( list( $t_foo, $t_var ) = each( $t_vars ) ) {
+	print_info_row( $t_var, ini_get( $t_var ) );
+}
+
+if ( db_is_mssql() ) {
+	if ( print_test_row( 'check mssql textsize in php.ini...', ini_get( 'mssql.textsize' ) != 4096, ini_get( 'mssql.textsize' ) ) ) {
+		print_test_warn_row( 'check mssql textsize in php.ini...', ini_get( 'mssql.textsize' ) == 2147483647, ini_get( 'mssql.textsize' ) );
+	}
+	if ( print_test_row( 'check mssql textsize in php.ini...', ini_get( 'mssql.textlimit' ) != 4096 , ini_get( 'mssql.textlimit' ) ) ) {
+		print_test_warn_row( 'check mssql textsize in php.ini...', ini_get( 'mssql.textsize' ) == 2147483647, ini_get( 'mssql.textsize' ) );
+	}
+}
+print_test_row( 'check variables_order includes GPCS', stristr( ini_get( 'variables_order' ), 'G' ) && stristr( ini_get( 'variables_order' ), 'P' ) && stristr( ini_get( 'variables_order' ), 'C' ) && stristr( ini_get( 'variables_order' ), 'S' ), ini_get( 'variables_order' ) );
+
+
+test_bug_download_threshold();
+test_bug_attachments_allow_flags();
+
+print_test_row( 'check mail configuration: send_reset_password = ON requires allow_blank_email = OFF',
+	( ( OFF == config_get_global( 'send_reset_password' ) ) || ( OFF == config_get_global( 'allow_blank_email' ) ) ) );
+print_test_row( 'check mail configuration: send_reset_password = ON requires enable_email_notification = ON',
+	( OFF == config_get_global( 'send_reset_password' ) ) || ( ON == config_get_global( 'enable_email_notification' ) ) );
+print_test_row( 'check mail configuration: allow_signup = ON requires enable_email_notification = ON',
+	( OFF == config_get_global( 'allow_signup' ) ) || ( ON == config_get_global( 'enable_email_notification' ) ) );
+print_test_row( 'check mail configuration: allow_signup = ON requires send_reset_password = ON',
+	( OFF == config_get_global( 'allow_signup' ) ) || ( ON == config_get_global( 'send_reset_password' ) ) );
+print_test_row( 'check language configuration: fallback_language is not \'auto\'',
+	'auto' <> config_get_global( 'fallback_language' ) );
+print_test_row( 'check configuration: allow_anonymous_login = ON requires anonymous_account to be set',
+	( OFF == config_get_global( 'allow_anonymous_login' ) ) || ( strlen( config_get_global( 'anonymous_account') ) > 0 ) );
+
+$t_anon_user = false;
+
+print_test_row( 'check configuration: anonymous_account is a valid username if set',
+	( (strlen( config_get_global( 'anonymous_account') ) > 0 ) ? ( ($t_anon_user = user_get_id_by_name( config_get_global( 'anonymous_account') ) ) !== false ) : TRUE ) );
+print_test_row( 'check configuration: anonymous_account should not be an administrator',
+	( $t_anon_user ? ( !user_is_administrator( $t_anon_user ) ) : TRUE ) );
+print_test_row( '$g_bug_link_tag is not empty ("' . config_get_global( 'bug_link_tag' ) . '")',
+	'' <> config_get_global( 'bug_link_tag' ) );
+print_test_row( '$g_bugnote_link_tag is not empty ("' . config_get_global( 'bugnote_link_tag' ) . '")',
+	'' <> config_get_global( 'bugnote_link_tag' ) );
+print_test_row( 'filters: dhtml_filters = ON requires use_javascript = ON',
+	( OFF == config_get_global( 'dhtml_filters' ) ) || ( ON == config_get_global( 'use_javascript' ) ) );
+print_test_row( 'Phpmailer sendmail configuration requires escapeshellcmd. Please use a different phpmailer method if this is blocked.',
+	( PHPMAILER_METHOD_SENDMAIL != config_get( 'phpMailer_method' ) || ( PHPMAILER_METHOD_SENDMAIL == config_get( 'phpMailer_method' ) ) && function_exists( 'escapeshellcmd' ) ) );
+print_test_row( 'Phpmailer sendmail configuration requires escapeshellarg. Please use a different phpmailer method if this is blocked.',
+	( PHPMAILER_METHOD_SENDMAIL != config_get( 'phpMailer_method' ) || ( PHPMAILER_METHOD_SENDMAIL == config_get( 'phpMailer_method' ) ) && function_exists( 'escapeshellarg' ) ) );
+
+check_zend_optimiser_version();
+
+if( plugin_is_installed( 'MantisGraph' ) ) {
+	plugin_push_current( 'MantisGraph' );
+
+	print_test_row( 'checking gd is enabled, and version 2...', get_gd_version() == 2 );
+	if ( plugin_config_get( 'eczlibrary', OFF ) == OFF ) {
+		$t_jpgraph_path = config_get( 'absolute_path' ) . 'library' . DIRECTORY_SEPARATOR . 'jpgraph' . DIRECTORY_SEPARATOR;
+
+		if( !file_exists( $t_jpgraph_path . 'jpgraph.php') ) {
+			print_test_row( 'checking we can find jpgraph class files...', false );
+		} else {
+			require_once( $t_jpgraph_path . 'jpgraph.php' );
+			print_test_row( 'Checking Jpgraph version (if installed)...', version_compare(JPG_VERSION, '2.3.0') ? true : false, JPG_VERSION );
+		}
+
+		print_test_row( 'check configuration: jpgraph (if used) requires php bundled gd for antialiasing support',
+			( plugin_config_get( 'jpgraph_antialias', OFF ) == OFF || function_exists('imageantialias') ) );
+	}
+	plugin_pop_current();
+}
+
+print_test_row( 'Checking if ctype is enabled in php (required for rss feeds)....', extension_loaded('ctype') );
+
+print_test_row( 'Checking for mysql is at least version 4.1...', !(db_is_mysql() && version_compare( $t_serverinfo['version'], '4.1.0', '<' ) ) );
+print_test_row( 'Checking for broken mysql version ( bug 10250)...', !(db_is_mysql() && $t_serverinfo['version'] == '4.1.21') );
+
+if ( !is_blank ( config_get_global( 'default_timezone' ) ) ) {
+	if ( print_test_row( 'Checking if a timezone is set in config.inc.php....', !is_blank ( config_get_global( 'default_timezone' ) ), config_get_global( 'default_timezone' ) ) ) {
+		print_test_row( 'Checking if timezone is valid from config.inc.php....', in_array( config_get_global( 'default_timezone' ), timezone_identifiers_list() ), config_get_global( 'default_timezone' ) );
+	}
+} else {
+	if( print_test_row( 'Checking if timezone is set in php.ini....', ini_get( 'date.timezone' ) !== '' ) ) {
+		print_test_row( 'Checking if timezone is valid in php.ini....', in_array( ini_get( 'date.timezone' ), timezone_identifiers_list() ), ini_get( 'date.timezone' ) );
+	}
+}
+
+test_database_utf8();
+
+print_test_row( 'Checking Register Globals is set to off', ! ini_get_bool( 'register_globals' ) );
+
+print_test_row( 'Checking CRYPT_FULL_SALT is NOT logon method', ! ( CRYPT_FULL_SALT == config_get_global( 'login_method' ) ) );
+
+print_test_warn_row( 'Warn if passwords are stored in PLAIN text', ! ( PLAIN == config_get_global( 'login_method' ) ) );
+print_test_warn_row( 'Warn if CRYPT is used (not MD5) for passwords', ! ( CRYPT == config_get_global( 'login_method' ) ) );
+
+if ( config_get_global( 'allow_file_upload' ) ) {
+	print_test_row( 'Checking that fileuploads are allowed in php (enabled in mantis config)', ini_get_bool( 'file_uploads' ) );
+	
+	print_info_row( 'PHP variable "upload_max_filesize"', ini_get_number( 'upload_max_filesize' ) );
+	print_info_row( 'PHP variable "post_max_size"', ini_get_number( 'post_max_size' ) );
+	print_info_row( 'MantisBT variable "max_file_size"', config_get_global( 'max_file_size' ) );
+
+	print_test_row( 'Checking MantisBT upload file size is less than php', ( config_get_global( 'max_file_size' ) <= ini_get_number( 'post_max_size' ) ) && ( config_get_global( 'max_file_size' ) <= ini_get_number( 'upload_max_filesize' ) ) );
+
+	if( DATABASE == config_get_global( 'file_upload_method' ) ) {
+		print_info_row( 'There may also be settings in your web server and database that prevent you from  uploading files or limit the maximum file size.  See the documentation for those packages if you need more information.');
+		if( 500 < min( ini_get_number( 'upload_max_filesize' ), ini_get_number( 'post_max_size' ), config_get_global( 'max_file_size' ) ) ) {
+			print_info_row( '<span class="error">Your current settings will most likely need adjustments to the PHP max_execution_time or memory_limit settings, the MySQL max_allowed_packet setting, or equivalent.' );
+		}
+	}
+	
+	print_info_row( 'There may also be settings in your web server that prevent you from  uploading files or limit the maximum file size.  See the documentation for those packages if you need more information.');
+}
+?>
+</table>
+<?php
+	if ( $g_failed_test ) {
+?>
+	 <table width="100%" bgcolor="#222222" border="0" cellpadding="20" cellspacing="1">
+	<tr>
+		<td bgcolor="#f4f4f4">Some Tests Failed. Please correct failed tests before using MantisBT.</td>
+	</tr>
+	</table>
+<?php
+	} else {
+?>
+	 <table width="100%" bgcolor="#222222" border="0" cellpadding="20" cellspacing="1">
+	<tr>
+		<td bgcolor="#f4f4f4">All Tests Passed. If you would like to view passed tests click <a href="check.php?showall=1">here</a>.</td>
+	</tr>
+	</table>
+<?php	
+	}
+?>
+</body>
+</html>
diff --git a/admin/copy_field.php b/admin/copy_field.php
new file mode 100644
index 0000000..a45381a
--- /dev/null
+++ b/admin/copy_field.php
@@ -0,0 +1,128 @@
+<?php
+# MantisBT - a php based bugtracking system
+
+# MantisBT 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.
+#
+# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
+# This upgrade moves attachments from the database to the disk
+
+/**
+ * @package MantisBT
+ * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+ * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
+ * @link http://www.mantisbt.org
+ */
+/**
+ * MantisBT Core API's
+ */
+require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
+
+access_ensure_global_level( config_get_global( 'admin_site_threshold' ) );
+
+$f_source_field_id = gpc_get_int( 'source_id' );
+$f_dest_field = gpc_get( 'dest_id' );
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+<title> MantisBT Administration - Copy Custom Fields to Built-in </title>
+<link rel="stylesheet" type="text/css" href="admin.css" />
+</head>
+<body>
+
+<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
+	<tr class="top-bar">
+		<td class="links">
+			[ <a href="system_utils.php">Back to System Utilities</a> ]
+			[ <a href="copy_field.php?source_id=<?php echo $f_source_field_id?>&amp;dest_id=<?php echo $f_dest_field?>">Refresh view</a> ]
+		</td>
+		<td class="title">
+			MantisBT Administration - Copy Custom Fields to Built-in
+		</td>
+	</tr>
+</table>
+<br /><br />
+
+<?php
+# checks on validity
+$t_valid_fields = array(
+	'fixed_in_version',
+);
+if( !in_array( $f_dest_field, $t_valid_fields ) ) {
+	echo '<p>Invalid destination field (' . $f_dest_field . ') specified.</p>';
+	echo '</body></html>';
+	exit;
+}
+
+# @@@ check that source and destination are compatible
+
+$t_string_table = db_get_table( 'mantis_custom_field_string_table' );
+$t_bug_table = db_get_table( 'mantis_bug_table' );
+$query = 'SELECT * FROM ' . $t_string_table . ' WHERE field_id = ' . db_param() . ' and value <> ' . db_param();
+
+$result = @db_query_bound( $query, Array( $f_source_field_id, '' ) );
+if( FALSE == $result ) {
+	echo '<p>No fields need to be updated.</p>';
+}
+else {
+
+	$count = db_num_rows( $result );
+	echo '<p>Found ' . $count . ' fields to be updated.</p>';
+	$t_failures = 0;
+
+	if( $count > 0 ) {
+		echo '<table width="80%" bgcolor="#222222" border="0" cellpadding="10" cellspacing="1">';
+
+		# Headings
+		echo '<tr bgcolor="#ffffff"><th width="10%">Bug Id</th><th width="20%">Field Value</th><th width="70%">Status</th></tr>';
+	}
+
+	for( $i = 0;$i < $count;$i++ ) {
+		$row = db_fetch_array( $result );
+		extract( $row, EXTR_PREFIX_ALL, 'v' );
+
+		# trace bug id back to project
+		$t_project_id = bug_get_field( $v_bug_id, 'project_id' );
+		$t_cust_value = $v_value;
+		printf("\n<tr %s><td><a href=\"../view.php?id=%d\">%07d</a></td><td>%s</td><td>",
+			helper_alternate_class(), $v_bug_id, $v_bug_id, $v_value);
+
+		# validate field contents
+		switch( $f_dest_field ) {
+			case 'fixed_in_version':
+				$t_valid = ( version_get_id( $t_cust_value, $t_project_id ) == FALSE ) ? FALSE : TRUE;
+				break;
+			default:
+				$t_valid = FALSE;
+		}
+		if( $t_valid ) {
+
+			# value was valid, update value
+			if( !bug_set_field( $v_bug_id, $f_dest_field, $t_cust_value ) ) {
+				echo 'database update failed';
+				$t_failures++;
+			} else {
+				echo 'applied';
+			}
+		} else {
+			echo 'field value was not valid or previously defined';
+			$t_failures++;
+		}
+		echo '</td></tr>';
+	}
+
+	echo '</table><br />' . $count . ' fields processed, ' . $t_failures . ' failures';
+}
+echo '<p> Completed...<p>';
+?>
+</body>
+</html>
diff --git a/admin/db_stats.php b/admin/db_stats.php
new file mode 100644
index 0000000..c50efff
--- /dev/null
+++ b/admin/db_stats.php
@@ -0,0 +1,56 @@
+<?php
+# MantisBT - a php based bugtracking system
+
+# MantisBT 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.
+#
+# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * @package MantisBT
+ * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+ * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
+ * @link http://www.mantisbt.org
+ */
+/**
+ * MantisBT Core API's
+ */
+require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
+
+access_ensure_global_level( config_get_global( 'admin_site_threshold' ) );
+
+# --------------------
+function helper_table_row_count( $p_table ) {
+	$t_table = $p_table;
+	$query = "SELECT COUNT(*) FROM $t_table";
+	$result = db_query_bound( $query );
+	$t_users = db_result( $result );
+
+	return $t_users;
+}
+
+# --------------------
+function print_table_stats( $p_table_name ) {
+	$t_count = helper_table_row_count( $p_table_name );
+	echo "$p_table_name = $t_count records<br />";
+}
+
+echo '<html><head><title>MantisBT Database Statistics</title></head><body>';
+
+echo '<h1>MantisBT Database Statistics</h1>';
+
+foreach( db_get_table_list() as $t_table ) {
+	if( db_table_exists( $t_table ) ) {
+		print_table_stats( $t_table );
+	}
+}
+
+echo '</body></html>';
diff --git a/admin/email_queue.php b/admin/email_queue.php
new file mode 100644
index 0000000..6527b57
--- /dev/null
+++ b/admin/email_queue.php
@@ -0,0 +1,75 @@
+<?php
+# MantisBT - a php based bugtracking system
+
+# Mantis 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.
+#
+# Mantis 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * @package MantisBT
+ * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+ * @copyright Copyright (C) 2002 - 2011  Mantis Team   - mantisbt-dev@lists.sourceforge.net
+ * @link http://www.mantisbt.org
+ */
+/**
+ * Mantis Core API's
+ */
+require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
+
+access_ensure_global_level( config_get_global( 'admin_site_threshold' ) );
+
+$f_to = gpc_get( 'send', null );
+
+if ( $f_to !== null ) {
+	if ( $f_to == 'all' ) {
+		echo "Sending emails...<br />";
+		email_send_all();
+		echo "Done";
+	} else if ( $f_to == 'sendordelall' ) {
+		echo "Sending or deleting emails...<br />";
+		email_send_all(true);
+		echo "Done";
+		
+	} else {
+		$t_email_data = email_queue_get( (int) $f_to );
+
+		// check if email was found.  This can fail if another request picks up the email first and sends it.
+		echo 'Sending email...<br />';
+		if( $t_email_data !== false ) {
+			if( !email_send( $t_email_data ) ) {
+				echo 'Email Not Sent - Deleting from queue<br />';
+				email_queue_delete( $t_email_data->email_id );
+			} else {
+				echo 'Email Sent<br />';
+			}
+		} else {
+			echo 'Email not found in queue<br />';
+		}
+	}
+}
+
+$t_ids = email_queue_get_ids();
+
+if( count( $t_ids ) > 0 ) {
+
+	echo '<table><tr><th>' . lang_get('id') . '</th><th>' . lang_get('email') . '</th><th>' . lang_get('timestamp') . '</th><th>Send Or Delete</th></tr>';
+	foreach( $t_ids as $t_id ) {
+		$row = email_queue_get( $t_id );
+
+		echo '<tr><td>' . $row->email_id . '</td><td>' . $row->email . '</td><td>' . $row->submitted . '</td><td>' , html_button( 'email_queue.php', 'Send Or Delete', array( 'send' => $row->email_id ) ) , '</td></tr>';
+	}
+	echo '</table>';
+} else {
+}
+
+html_button( 'email_queue.php', 'Send All', array( 'send' => 'all') );
+html_button( 'email_queue.php', 'Send Or Delete All', array( 'send' => 'sendordelall') );
diff --git a/admin/index.php b/admin/index.php
new file mode 100644
index 0000000..36ec3f0
--- /dev/null
+++ b/admin/index.php
@@ -0,0 +1,80 @@
+<?php
+# MantisBT - a php based bugtracking system
+
+# MantisBT 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.
+#
+# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * @package MantisBT
+ * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+ * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
+ * @link http://www.mantisbt.org
+ */
+/**
+ * MantisBT Core API's
+ */
+require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
+require_once( 'schema.php' );
+
+access_ensure_global_level( config_get_global( 'admin_site_threshold' ) );
+
+html_page_top( 'MantisBT Administration' );
+
+function print_info_row( $p_description, $p_value ) {
+	echo '<tr ' . helper_alternate_class() . '>';
+	echo '<td class="category">' . $p_description . '</td>';
+	echo '<td>' . $p_value . '</td>';
+	echo '</tr>';
+}
+
+?>
+<br />
+
+<div align="center">
+		<p>[ <a href="check.php">Check your installation</a> ]</p>
+	<?php if ( count($upgrade) - 1 != config_get( 'database_version' ) ) { ?>
+		<p>[ <a href="upgrade_warning.php"><b>Upgrade your installation</b></a> ]</p>
+	<?php } ?>
+		<p>[ <a href="system_utils.php">System Utilities</a> ]</p>
+		<p>[ <a href="test_icons.php">Test Icons</a> ]</p>
+		<p>[ <a href="test_langs.php">Test Langs</a> ]</p>
+		<p>[ <a href="test_email.php">Test Email</a> ]</p>
+		<p>[ <a href="email_queue.php">Email Queue</a> ]</p>
+</div>
+
+<table class="width75" align="center" cellspacing="1">
+<tr>
+<td class="form-title" width="30%" colspan="2"><?php echo lang_get( 'install_information' ) ?></td>
+</tr>
+<?php 
+	print_info_row( lang_get( 'mantis_version' ), MANTIS_VERSION, ( $t_version_suffix ? " $t_version_suffix" : '' ) );
+	print_info_row( 'php_version', phpversion());
+?>
+<tr>
+<td class="form-title" width="30%" colspan="2"><?php echo lang_get( 'database_information' ) ?></td>
+</tr>
+<?php 
+	print_info_row( lang_get( 'schema_version' ), config_get( 'database_version' ) );
+	print_info_row( 'adodb_version', $g_db->Version() );
+?>
+<tr>
+<td class="form-title" width="30%" colspan="2"><?php echo lang_get( 'path_information' ) ?></td>
+</tr>
+<?php 
+	print_info_row( lang_get( 'site_path' ), config_get( 'absolute_path' ) );
+	print_info_row( lang_get( 'core_path' ), config_get( 'core_path' ) );
+	print_info_row( lang_get( 'plugin_path' ), config_get( 'plugin_path' ) );
+?>
+</table>
+<?php
+	html_page_bottom();
diff --git a/admin/install.php b/admin/install.php
new file mode 100644
index 0000000..5b58843
--- /dev/null
+++ b/admin/install.php
@@ -0,0 +1,1015 @@
+<?php
+# MantisBT - a php based bugtracking system
+
+# MantisBT 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.
+#
+# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * @package MantisBT
+ * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+ * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
+ * @link http://www.mantisbt.org
+ */
+
+error_reporting( E_ALL );
+
+/** @todo put this somewhere */
+@set_time_limit( 0 );
+$g_skip_open_db = true;  # don't open the database in database_api.php
+define( 'MANTIS_INSTALLER', true );
+define( 'PLUGINS_DISABLED', true );
+@require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
+@require_once( 'install_functions.php' );
+@require_once( 'install_helper_functions.php' );
+$g_error_send_page_header = false; # bypass page headers in error handler
+
+$g_failed = false;
+$g_database_upgrade = false;
+
+# -------
+# print test result
+function print_test_result( $p_result, $p_hard_fail = true, $p_message = '' ) {
+	global $g_failed;
+	echo '<td ';
+	if( BAD == $p_result ) {
+		if( $p_hard_fail ) {
+			$g_failed = true;
+			echo 'bgcolor="red">BAD';
+		} else {
+			echo 'bgcolor="pink">POSSIBLE PROBLEM';
+		}
+		if( '' != $p_message ) {
+			echo '<br />' . $p_message;
+		}
+	}
+
+	if( GOOD == $p_result ) {
+		echo 'bgcolor="green">GOOD';
+	}
+	echo '</td>';
+}
+
+# -------
+# print test header and result
+function print_test( $p_test_description, $p_result, $p_hard_fail = true, $p_message = '' ) {
+
+	echo "\n<tr><td bgcolor=\"#ffffff\">$p_test_description</td>";
+	print_test_result( $p_result, $p_hard_fail, $p_message );
+	echo "</tr>\n";
+}
+
+# --------
+# create an SQLArray to insert data
+function InsertData( $p_table, $p_data ) {
+	$query = "INSERT INTO " . $p_table . $p_data;
+	return Array( $query );
+}
+
+# install_state
+#   0 = no checks done
+#   1 = server ok, get database information
+#   2 = check the database information
+#   3 = install the database
+#   4 = get additional config file information
+#   5 = write the config file
+#	6 = post install checks
+#	7 = done, link to login or db updater
+$t_install_state = gpc_get_int( 'install', 0 );
+?>
+<html>
+<head>
+<title> MantisBT Administration - Installation  </title>
+<link rel="stylesheet" type="text/css" href="admin.css" />
+</head>
+<body>
+<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
+	<tr class="top-bar">
+		<td class="links">
+			[ <a href="index.php">Back to Administration</a> ]
+		</td>
+		<td class="title">
+		<?php
+switch( $t_install_state ) {
+	case 6:
+		echo "Post Installation Checks";
+		break;
+	case 5:
+		echo "Install Configuration File";
+		break;
+	case 4:
+		echo "Additional Configuration Information";
+		break;
+	case 3:
+		echo "Install Database";
+		break;
+	case 2:
+		echo "Check and Install Database";
+		break;
+	case 1:
+		echo "Database Parameters";
+		break;
+	case 0:
+	default:
+		echo "Pre-Installation Check";
+		break;
+}
+?>
+		</td>
+	</tr>
+</table>
+<br /><br />
+
+<form method='POST'>
+<?php
+if( 0 == $t_install_state ) {
+	?>
+<table width="100%" bgcolor="#222222" border="0" cellpadding="10" cellspacing="1">
+<tr>
+	<td bgcolor="#e8e8e8" colspan="2">
+		<span class="title">Checking Installation...</span>
+	</td>
+</tr>
+<?php
+}
+
+$t_config_filename = $g_absolute_path . 'config_inc.php';
+$t_config_exists = file_exists( $t_config_filename );
+$f_hostname = null;
+$f_db_type = null;
+$f_database_name = null;
+$f_db_username = null;
+$f_db_password = null;
+if( $t_config_exists ) {
+	if( 0 == $t_install_state ) {
+		print_test( "Config File Exists - Upgrade", true );
+	}
+
+	# config already exists - probably an upgrade
+
+	$f_dsn = config_get( 'dsn', '' );
+	$f_hostname = config_get( 'hostname', '' );
+	$f_db_type = config_get( 'db_type', '' );
+	$f_database_name = config_get( 'database_name', '' );
+	$f_db_username = config_get( 'db_username', '' );
+	$f_db_password = config_get( 'db_password', '' );
+
+	if( 0 == $t_install_state ) {
+		print_test( 'Setting Database Type', '' !== $f_db_type, true, 'database type is blank?' );
+		print_test( 'Checking Database connection settings exist', ( $f_dsn !== '' || ( $f_database_name !== '' && $f_db_username !== '' && $f_hostname !== '' ) ), true, 'database connection settings do not exist?' );
+		print_test( 'Checking PHP support for database type', db_check_database_support( $f_db_type ), true, 'database is not supported by PHP. Check that it has been compiled into your server.' );
+	}
+
+	$g_db = ADONewConnection( $f_db_type );
+	$t_result = @$g_db->Connect( $f_hostname, $f_db_username, $f_db_password, $f_database_name );
+	if( $g_db->IsConnected() ) {
+		$g_db_connected = true;
+	}
+	$t_cur_version = config_get( 'database_version', -1 );
+	if( $t_cur_version > 1 ) {
+		$g_database_upgrade = true;
+		$f_db_exists = true;
+	} else {
+		if( 0 == $t_install_state ) {
+			print_test( 'Config File Exists but Database does not', false, false, 'Bad config_inc.php?' );
+		}
+	}
+} else {
+	# read control variables with defaults
+	$f_hostname = gpc_get( 'hostname', config_get( 'hostname', 'localhost' ) );
+	$f_db_type = gpc_get( 'db_type', config_get( 'db_type', '' ) );
+	$f_database_name = gpc_get( 'database_name', config_get( 'database_name', 'bugtrack' ) );
+	$f_db_username = gpc_get( 'db_username', config_get( 'db_username', '' ) );
+	$f_db_password = gpc_get( 'db_password', config_get( 'db_password', '' ) );
+	if( CONFIGURED_PASSWORD == $f_db_password ) {
+		$f_db_password = config_get( 'db_password' );
+	}
+}
+$f_admin_username = gpc_get( 'admin_username', '' );
+$f_admin_password = gpc_get( 'admin_password', '' );
+$f_log_queries = gpc_get_bool( 'log_queries', false );
+$f_db_exists = gpc_get_bool( 'db_exists', false );
+
+$f_db_schema = '';
+if( $f_db_type == 'db2' ) {
+
+	# If schema name is supplied, then separate it from database name.
+	if( strpos( $f_database_name, '/' ) != false ) {
+		$f_db2AS400 = $f_database_name;
+		list( $f_database_name, $f_db_schema ) = explode( '/', $f_db2AS400, 2 );
+	}
+}
+
+if( 0 == $t_install_state ) {
+	?>
+
+<!-- Check PHP Version -->
+<?php print_test( ' Checking PHP version (your version is ' . phpversion() . ')', check_php_version( phpversion() ), true, 'Upgrade to a more recent version of PHP' );?>
+
+<!-- Check Safe Mode -->
+<?php
+print_test( 'Checking if safe mode is enabled for install script',
+	! ini_get ( 'SAFE_MODE' ),
+	true,
+	'Disable safe_mode in php.ini before proceeding' ) ?>
+
+</table>
+<?php
+	if( false == $g_failed ) {
+		$t_install_state++;
+	}
+} # end install_state == 0
+
+# got database information, check and install
+if( 2 == $t_install_state ) {
+	?>
+
+<table width="100%" border="0" cellpadding="10" cellspacing="1">
+<!-- Setting config variables -->
+<?php print_test( 'Setting Database Hostname', '' !== $f_hostname, true, 'host name is blank' )?>
+
+<!-- Setting config variables -->
+<?php print_test( 'Setting Database Type', '' !== $f_db_type, true, 'database type is blank?' )?>
+
+<!-- Checking DB support-->
+<?php print_test( 'Checking PHP support for database type', db_check_database_support( $f_db_type ), true, 'database is not supported by PHP. Check that it has been compiled into your server.' )?>
+
+<?php print_test( 'Setting Database Username', '' !== $f_db_username, true, 'database username is blank' )?>
+<?php print_test( 'Setting Database Password', '' !== $f_db_password, false, 'database password is blank' )?>
+<?php print_test( 'Setting Database Name', '' !== $f_database_name, true, 'database name is blank' )?>
+<?php
+	if( $f_db_type == 'db2' ) {
+		print_test( 'Setting Database Schema', !is_blank( $f_db_schema ), true, 'must have a schema name for AS400 in the form of DBNAME/SCHEMA' );
+	}
+	?>
+<tr>
+	<td bgcolor="#ffffff">
+		Setting Admin Username
+	</td>
+	<?php
+		if( '' !== $f_admin_username ) {
+		print_test_result( GOOD );
+	} else {
+		print_test_result( BAD, false, 'admin user name is blank, using database user instead' );
+		$f_admin_username = $f_db_username;
+	}
+	?>
+</tr>
+<tr>
+	<td bgcolor="#ffffff">
+		Setting Admin Password
+	</td>
+	<?php
+		if( '' !== $f_admin_password ) {
+		print_test_result( GOOD );
+	} else {
+		if( '' != $f_db_password ) {
+			print_test_result( BAD, false, 'admin user password is blank, using database user password instead' );
+			$f_admin_password = $f_db_password;
+		} else {
+			print_test_result( GOOD );
+		}
+	}
+	?>
+</tr>
+
+<!-- connect to db -->
+<tr>
+	<td bgcolor="#ffffff">
+		Attempting to connect to database as admin
+	</td>
+	<?php
+		$t_db_open = false;
+	$g_db = ADONewConnection( $f_db_type );
+	$t_result = @$g_db->Connect( $f_hostname, $f_admin_username, $f_admin_password );
+
+	if( $t_result ) {
+
+		# check if db exists for the admin
+		$t_result = @$g_db->Connect( $f_hostname, $f_admin_username, $f_admin_password, $f_database_name );
+		if( $t_result ) {
+			$t_db_open = true;
+			$f_db_exists = true;
+		}
+		if( $f_db_type == 'db2' ) {
+			$result = &$g_db->execute( 'set schema ' . $f_db_schema );
+			if( $result === false ) {
+				print_test_result( BAD, true, 'set schema failed: ' . $g_db->errorMsg() );
+			}
+		} else {
+			print_test_result( GOOD );
+		}
+	} else {
+		print_test_result( BAD, true, 'Does administrative user have access to the database? ( ' . db_error_msg() . ' )' );
+	}
+	?>
+</tr>
+<?php
+	if( $f_db_exists ) {
+		?>
+<tr>
+	<td bgcolor="#ffffff">
+		Attempting to connect to database as user
+	</td>
+	<?php
+		$g_db = ADONewConnection( $f_db_type );
+		$t_result = @$g_db->Connect( $f_hostname, $f_db_username, $f_db_password, $f_database_name );
+
+		if( $t_result == true ) {
+			$t_db_open = true;
+			if( $f_db_type == 'db2' ) {
+				$result = &$g_db->execute( 'set schema ' . $f_db_schema );
+				if( $result === false ) {
+					print_test_result( BAD, true, 'set schema failed: ' . $g_db->errorMsg() );
+				}
+			} else {
+				print_test_result( GOOD );
+			}
+		} else {
+			print_test_result( BAD, false, 'Database user doesn\'t have access to the database ( ' . db_error_msg() . ' )' );
+		}
+		?>
+</tr>
+
+<?php
+	}
+	if( $t_db_open ) {
+		?>
+<!-- display database version -->
+<tr>
+	<td bgcolor="#ffffff">
+		Checking Database Server Version
+		<?php
+		# due to a bug in ADODB, this call prompts warnings, hence the @
+		# the check only works on mysql if the database is open
+		$t_version_info = @$g_db->ServerInfo();
+		echo '<br /> Running ' . $f_db_type . ' version ' . $t_version_info['description'];
+		?>
+	</td>
+	<?php
+		$t_warning = '';
+		$t_error = '';
+		switch( $f_db_type ) {
+			case 'mysql':
+			case 'mysqli':
+				if( version_compare( $t_version_info['version'], '4.1.0', '<' ) ) {
+					$t_error = 'MySQL 4.1.0 or later is required for installation.';
+				}
+				break;
+			case 'pgsql':
+			case 'mssql':
+			case 'db2':
+			default:
+				break;
+		}
+
+		print_test_result(( '' == $t_error ) && ( '' == $t_warning ), ( '' != $t_error ), $t_error . ' ' . $t_warning );
+		?>
+</tr>
+<?php
+	}
+	if( false == $g_failed ) {
+		$t_install_state++;
+	} else {
+		$t_install_state--; # a check failed, redisplay the questions
+	}
+} # end 2 == $t_install_state
+
+# system checks have passed, get the database information
+if( 1 == $t_install_state ) {
+	?>
+
+<table width="100%" border="0" cellpadding="10" cellspacing="1">
+<tr>
+	<td bgcolor="#e8e8e8" colspan="2">
+		<span class="title"><?php echo $g_database_upgrade ? 'Upgrade Options' : 'Installation Options'?></span>
+	</td>
+</tr>
+
+<?php if( !$g_database_upgrade ) {?>
+<tr>
+	<td>
+		Type of Database
+	</td>
+	<td>
+		<select name="db_type">
+		<?php
+			if( $f_db_type == 'mysql' ) {
+			echo '<option value="mysql" selected="selected">MySQL (default)</option>';
+		} else {
+			echo '<option value="mysql">MySQL (default)</option>';
+		}
+
+		if( $f_db_type == 'mysqli' ) {
+			echo '<option value="mysqli" selected="selected">MySQLi</option>';
+		} else {
+			echo '<option value="mysqli">MySQLi</option>';
+		}
+
+		if( $f_db_type == 'mssql' ) {
+			echo '<option value="mssql" selected="selected">Microsoft SQL Server</option>';
+		} else {
+			echo '<option value="mssql">Microsoft SQL Server</option>';
+		}
+
+		if( $f_db_type == 'pgsql' ) {
+			echo '<option value="pgsql" selected="selected">PostgreSQL</option>';
+		} else {
+			echo '<option value="pgsql">PostgreSQL</option>';
+		}
+
+		if( $f_db_type == 'oci8' ) {
+			echo '<option value="oci8" selected="selected">Oracle</option>';
+		} else {
+			echo '<option value="oci8">Oracle</option>';
+		}
+
+		if( $f_db_type == 'db2' ) {
+			echo '<option value="db2" selected="selected">IBM DB2</option>';
+		} else {
+			echo '<option value="db2">IBM DB2</option>';
+		}
+		?>
+		</select>
+	</td>
+</tr>
+<?php
+}
+
+if( !$g_database_upgrade ) {?>
+<tr>
+	<td>
+		Hostname (for Database Server)
+	</td>
+	<td>
+		<input name="hostname" type="textbox" value="<?php echo $f_hostname?>"></input>
+	</td>
+</tr>
+<?php
+}
+
+if( !$g_database_upgrade ) {?>
+<tr>
+	<td>
+		Username (for Database)
+	</td>
+	<td>
+		<input name="db_username" type="textbox" value="<?php echo $f_db_username?>"></input>
+	</td>
+</tr>
+<?php
+}
+
+if( !$g_database_upgrade ) {?>
+<tr>
+	<td>
+		Password (for Database)
+	</td>
+	<td>
+		<input name="db_password" type="password" value="<?php echo( !is_blank( $f_db_password ) ? CONFIGURED_PASSWORD : "" )?>"></input>
+	</td>
+</tr>
+<?php
+}
+
+if( !$g_database_upgrade ) {?>
+<tr>
+	<td>
+		Database name (for Database)
+	</td>
+	<td>
+		<input name="database_name" type="textbox" value="<?php echo $f_database_name?>"></input>
+	</td>
+</tr>
+<?php
+}?>
+
+<tr>
+	<td>
+		Admin Username (to <?php echo( !$g_database_upgrade ) ? 'create Database' : 'update Database'?> if required)
+	</td>
+	<td>
+		<input name="admin_username" type="textbox" value="<?php echo $f_admin_username?>"></input>
+	</td>
+</tr>
+
+<tr>
+	<td>
+		Admin Password (to <?php echo( !$g_database_upgrade ) ? 'create Database' : 'update Database'?> if required)
+	</td>
+	<td>
+		<input name="admin_password" type="password" value="<?php echo $f_admin_password?>"></input>
+	</td>
+</tr>
+
+<tr>
+	<td>
+		Print SQL Queries instead of Writing to the Database
+	</td>
+	<td>
+		<input name="log_queries" type="checkbox" value="1" <?php echo( $f_log_queries ? 'checked="checked"' : '' )?>></input>
+	</td>
+</tr>
+
+<tr>
+	<td>
+		Attempt Installation
+	</td>
+	<td>
+		<input name="go" type="submit" value="Install/Upgrade Database"></input>
+	</td>
+</tr>
+<input name="install" type="hidden" value="2"></input>
+
+</table>
+<?php
+}  # end install_state == 1
+
+# all checks have passed, install the database
+if( 3 == $t_install_state ) {
+	?>
+<table width="100%" border="0" cellpadding="10" cellspacing="1">
+<tr>
+	<td bgcolor="#e8e8e8" colspan="2">
+		<span class="title">Installing Database</span>
+	</td>
+</tr>
+<?php if( !$f_log_queries ) {?>
+<tr>
+	<td bgcolor="#ffffff">
+		Create database if it does not exist
+	</td>
+	<?php
+		$t_result = @$g_db->Connect( $f_hostname, $f_admin_username, $f_admin_password, $f_database_name );
+
+		if( $f_db_type == 'db2' ) {
+			$rs = $g_db->Execute( "select * from SYSIBM.SCHEMATA WHERE SCHEMA_NAME = '" . $f_db_schema . "' AND SCHEMA_OWNER = '" . $f_db_username . "'" );
+			if( $rs === false ) {
+				echo "<br />false";
+			}
+
+			if( $rs->EOF ) {
+				$t_result = false;
+				echo $g_db->errorMsg();
+			} else {
+				$t_result = &$g_db->execute( 'set schema ' . $f_db_schema );
+			}
+		}
+
+		$t_db_open = false;
+
+		if( $t_result == true ) {
+			print_test_result( GOOD );
+			$t_db_open = true;
+		} else {
+			// create db
+			$g_db = ADONewConnection( $f_db_type );
+			$t_result = $g_db->Connect( $f_hostname, $f_admin_username, $f_admin_password );
+
+			$dict = NewDataDictionary( $g_db );
+
+			if( $f_db_type == 'db2' ) {
+				$rs = &$g_db->Execute( "CREATE SCHEMA " . $f_db_schema );
+
+				if( !$rs ) {
+					$t_result = false;
+					print_test_result( BAD, true, 'Does administrative user have access to create the database? ( ' . db_error_msg() . ' )' );
+					$t_install_state--; # db creation failed, allow user to re-enter user/password info
+				} else {
+					print_test_result( GOOD );
+					$t_db_open = true;
+				}
+			} else {
+				$sqlarray = $dict->CreateDatabase( $f_database_name, Array( 'mysql' => 'DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci' ) );
+				$ret = $dict->ExecuteSQLArray( $sqlarray );
+				if( $ret == 2 ) {
+					print_test_result( GOOD );
+					$t_db_open = true;
+				} else {
+					$t_error = db_error_msg();
+					if( strstr( $t_error, 'atabase exists' ) ) {
+						print_test_result( BAD, false, 'Database already exists? ( ' . db_error_msg() . ' )' );
+					} else {
+						print_test_result( BAD, true, 'Does administrative user have access to create the database? ( ' . db_error_msg() . ' )' );
+						$t_install_state--; # db creation failed, allow user to re-enter user/password info
+					}
+				}
+			}
+		}
+		?>
+</tr>
+<?php
+	$g_db->Close();
+?>
+<tr>
+	<td bgcolor="#ffffff">
+		Attempting to connect to database as user
+	</td>
+	<?php
+		$g_db = ADONewConnection( $f_db_type );
+		$t_result = @$g_db->Connect( $f_hostname, $f_db_username, $f_db_password, $f_database_name );
+
+		if( $f_db_type == 'db2' ) {
+			$result = &$g_db->execute( 'set schema ' . $f_db_schema );
+			if( $result === false ) {
+				echo $g_db->errorMsg();
+			}
+		}
+
+		if( $t_result == true ) {
+			print_test_result( GOOD );
+		} else {
+			print_test_result( BAD, false, 'Database user doesn\'t have access to the database ( ' . db_error_msg() . ' )' );
+		}
+		$g_db->Close();
+		?>
+</tr>
+<?php
+	}
+
+	# install the tables
+	if( false == $g_failed ) {
+		$g_db_connected = false;
+
+		# fake out database access routines used by config_get
+		$GLOBALS['g_db_type'] = $f_db_type;
+
+		# database_api references this
+		require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'schema.php' );
+		$g_db = ADONewConnection( $f_db_type );
+		$t_result = @$g_db->Connect( $f_hostname, $f_admin_username, $f_admin_password, $f_database_name );
+		if( !$f_log_queries ) {
+			$g_db_connected = true;
+
+			# fake out database access routines used by config_get
+		}
+		$t_last_update = config_get( 'database_version', -1, ALL_USERS, ALL_PROJECTS );
+		$lastid = count( $upgrade ) - 1;
+		$i = $t_last_update + 1;
+		if( $f_log_queries ) {
+			echo '<tr><td bgcolor="#ffffff" col_span="2"> Database Creation Suppressed, SQL Queries follow <pre>';
+		}
+
+		# Make sure we do the upgrades using UTF-8 if needed
+		if ( $f_db_type === 'mysql' || $f_db_type === 'mysqli' ) {
+			$g_db->execute( 'SET NAMES UTF8' );
+		}
+
+		if( $f_db_type == 'db2' ) {
+			$result = &$g_db->execute( 'set schema ' . $f_db_schema );
+			if( $result === false ) {
+				echo $g_db->errorMsg();
+			}
+		}
+
+		while(( $i <= $lastid ) && !$g_failed ) {
+			if( !$f_log_queries ) {
+				echo '<tr><td bgcolor="#ffffff">';
+			}
+
+			$dict = NewDataDictionary( $g_db );
+			$t_sql = true;
+			$t_target = $upgrade[$i][1][0];
+			if( $upgrade[$i][0] == 'InsertData' ) {
+				$sqlarray = call_user_func_array( $upgrade[$i][0], $upgrade[$i][1] );
+			}
+			else if( $upgrade[$i][0] == 'UpdateSQL' ) {
+				$sqlarray = array(
+					$upgrade[$i][1],
+				);
+				$t_target = $upgrade[$i][1];
+			} else if( $upgrade[$i][0] == 'UpdateFunction' ) {
+				$sqlarray = array(
+					$upgrade[$i][1],					
+				);
+				if( isset( $upgrade[$i][2] ) ) {
+					$sqlarray[] = $upgrade[$i][2];
+				}
+				$t_sql = false;
+				$t_target = $upgrade[$i][1];
+			} else {
+				/* 0: function to call, 1: function params, 2: function to evaluate before calling upgrade, if false, skip upgrade. */
+				if( isset( $upgrade[$i][2] ) ) {
+					if( call_user_func_array( $upgrade[$i][2][0], $upgrade[$i][2][1] ) ) {
+						$sqlarray = call_user_func_array( Array( $dict, $upgrade[$i][0] ), $upgrade[$i][1] );
+					} else {
+						$sqlarray = array();
+					}
+				} else {
+					$sqlarray = call_user_func_array( Array( $dict, $upgrade[$i][0] ), $upgrade[$i][1] );
+				}
+			}
+			if( $f_log_queries ) {
+				if( $t_sql ) {
+					foreach( $sqlarray as $sql ) {
+						echo htmlentities( $sql ) . ";\r\n\r\n";
+					}
+				}
+			} else {
+				echo 'Schema ' . $upgrade[$i][0] . ' ( ' . $t_target . ' )</td>';
+				if( $t_sql ) {
+					$ret = $dict->ExecuteSQLArray( $sqlarray );
+				} else {
+					if( isset( $sqlarray[1] ) ) {
+						$ret = call_user_func( 'install_' . $sqlarray[0], $sqlarray[1] );
+					} else {
+						$ret = call_user_func( 'install_' . $sqlarray[0] );
+					}
+				}
+				if( $ret == 2 ) {
+					print_test_result( GOOD );
+					config_set( 'database_version', $i );
+				} else {
+					$all_sql = '';
+					foreach ( $sqlarray as $single_sql )
+						$all_sql .= $single_sql . '<br />';
+					print_test_result( BAD, true, $all_sql  . $g_db->ErrorMsg() );
+				}
+				echo '</tr>';
+			}
+			$i++;
+		}
+		if( $f_log_queries ) {
+			# add a query to set the database version
+			echo 'INSERT INTO mantis_config_table ( value, type, access_reqd, config_id, project_id, user_id ) VALUES (\'' . $lastid . '\', 1, 90, \'database_version\', 0, 0 );' . "\r\n";
+			echo '</pre></br /><p style="color:red">Your database has not been created yet. Please create the database, then install the tables and data using the information above before proceeding.</td></tr>';
+		}
+	}
+	if( false == $g_failed ) {
+		$t_install_state++;
+	} else {
+		$t_install_state--;
+	}
+
+	?>
+</table>
+<?php
+}  # end install_state == 3
+
+# database installed, get any additional information
+if( 4 == $t_install_state ) {
+
+	/** @todo to be written */
+	// must post data gathered to preserve it
+	?>
+		<input name="hostname" type="hidden" value="<?php echo $f_hostname?>"></input>
+		<input name="db_type" type="hidden" value="<?php echo $f_db_type?>"></input>
+		<input name="database_name" type="hidden" value="<?php echo $f_database_name?>"></input>
+		<input name="db_username" type="hidden" value="<?php echo $f_db_username?>"></input>
+		<input name="db_password" type="hidden" value="<?php echo $f_db_password?>"></input>
+		<input name="admin_username" type="hidden" value="<?php echo $f_admin_username?>"></input>
+		<input name="admin_password" type="hidden" value="<?php echo $f_admin_password?>"></input>
+		<input name="log_queries" type="hidden" value="<?php echo( $f_log_queries ? 1 : 0 )?>"></input>
+		<input name="db_exists" type="hidden" value="<?php echo( $f_db_exists ? 1 : 0 )?>"></input>
+<?php
+	# must post <input name="install" type="hidden" value="5"></input>
+	# rather than the following line
+	$t_install_state++;
+}  # end install_state == 4
+
+# all checks have passed, install the database
+if( 5 == $t_install_state ) {
+	$t_config_filename = $g_absolute_path . 'config_inc.php';
+	$t_config_exists = file_exists( $t_config_filename );
+	?>
+<table width="100%" border="0" cellpadding="10" cellspacing="1">
+<tr>
+	<td bgcolor="#e8e8e8" colspan="2">
+		<span class="title">Write Configuration File(s)</span>
+	</td>
+</tr>
+
+<tr>
+	<td bgcolor="#ffffff">
+		<?php
+			if( !$t_config_exists ) {
+		echo 'Creating Configuration File (config_inc.php)<br />';
+		echo '<font color="red">(if this file is not created, create it manually with the contents below)</font>';
+	} else {
+		echo 'Updating Configuration File (config_inc.php)<br />';
+	}
+	?>
+	</td>
+	<?php
+		$t_config = '<?php' . "\r\n";
+	$t_config .= "\t\$g_hostname = '$f_hostname';\r\n";
+	$t_config .= "\t\$g_db_type = '$f_db_type';\r\n";
+	$t_config .= "\t\$g_database_name = '$f_database_name';\r\n";
+	$t_config .= "\t\$g_db_username = '$f_db_username';\r\n";
+	$t_config .= "\t\$g_db_password = '$f_db_password';\r\n";
+
+	if( $f_db_type == 'db2' ) {
+		$t_config .= "\t\$g_db_schema = '$f_db_schema';\r\n";
+	}
+
+	$t_config .= '?>' . "\r\n";
+	$t_write_failed = true;
+
+	if( !$t_config_exists ) {
+		if( $fd = @fopen( $t_config_filename, 'w' ) ) {
+			fwrite( $fd, $t_config );
+			fclose( $fd );
+		}
+
+		if( file_exists( $t_config_filename ) ) {
+			print_test_result( GOOD );
+			$t_write_failed = false;
+		} else {
+			print_test_result( BAD, false, 'cannot write ' . $t_config_filename );
+		}
+	} else {
+		# already exists, see if the information is the same
+		if ( ( $f_hostname != config_get( 'hostname', '' ) ) ||
+			( $f_db_type != config_get( 'db_type', '' ) ) ||
+			( $f_database_name != config_get( 'database_name', '') ) ||
+			( $f_db_schema != config_get( 'db_schema', '') ) ||
+			( $f_db_username != config_get( 'db_username', '' ) ) ||
+			( $f_db_password != config_get( 'db_password', '' ) ) ) {
+			print_test_result( BAD, false, 'file ' . $g_absolute_path . 'config_inc.php' . ' already exists and has different settings' );
+		} else {
+			print_test_result( GOOD, false );
+			$t_write_failed = false;
+		}
+	}
+	?>
+</tr>
+<?php
+	if( true == $t_write_failed ) {
+		echo '<tr><table width="50%" border="0" cellpadding="10" cellspacing="1" align="center">';
+		echo '<tr><td>Please add the following lines to ' . $g_absolute_path . 'config_inc.php before continuing to the database upgrade check:</td></tr>';
+		echo '<tr><td><pre>' . htmlentities( $t_config ) . '</pre></td></tr></table></tr>';
+	}
+	?>
+
+</table>
+
+<?php
+	if( false == $g_failed ) {
+		$t_install_state++;
+	}
+}
+
+# end install_state == 5
+
+if( 6 == $t_install_state ) {
+
+	# post install checks
+	?>
+<table width="100%" bgcolor="#222222" border="0" cellpadding="10" cellspacing="1">
+<tr>
+	<td bgcolor="#e8e8e8" colspan="2">
+		<span class="title">Checking Installation...</span>
+	</td>
+</tr>
+
+<!-- Checking register_globals are off -->
+<?php print_test( 'Checking for register_globals are off for mantis', !ini_get_bool( 'register_globals' ), false, 'change php.ini to disable register_globals setting' )?>
+
+<tr>
+	<td bgcolor="#ffffff">
+		Attempting to connect to database as user
+	</td>
+	<?php
+		$g_db = ADONewConnection( $f_db_type );
+	$t_result = @$g_db->Connect( $f_hostname, $f_db_username, $f_db_password, $f_database_name );
+
+	if( $t_result == true ) {
+		print_test_result( GOOD );
+	} else {
+		print_test_result( BAD, false, 'Database user doesn\'t have access to the database ( ' . db_error_msg() . ' )' );
+	}
+
+	if( $f_db_type == 'db2' ) {
+		$result = &$g_db->execute( 'set schema ' . $f_db_schema );
+		if( $result === false ) {
+			echo $g_db->errorMsg();
+		}
+	}
+	?>
+</tr>
+<tr>
+	<td bgcolor="#ffffff">
+		checking ability to SELECT records
+	</td>
+	<?php
+		$t_mantis_config_table = db_get_table( 'mantis_config_table' );
+	$t_query = "SELECT COUNT(*) FROM $t_mantis_config_table";
+	$t_result = @$g_db->Execute( $t_query );
+
+	if( $t_result != false ) {
+		print_test_result( GOOD );
+	} else {
+		print_test_result( BAD, true, 'Database user doesn\'t have SELECT access to the database ( ' . db_error_msg() . ' )' );
+	}
+	?>
+</tr>
+<tr>
+	<td bgcolor="#ffffff">
+		checking ability to INSERT records
+	</td>
+	<?php
+		$t_query = "INSERT INTO $t_mantis_config_table ( value, type, access_reqd, config_id, project_id, user_id ) VALUES ('test', 1, 90, 'database_test', 20, 0 )";
+	$t_result = @$g_db->Execute( $t_query );
+
+	if( $t_result != false ) {
+		print_test_result( GOOD );
+	} else {
+		print_test_result( BAD, true, 'Database user doesn\'t have INSERT access to the database ( ' . db_error_msg() . ' )' );
+	}
+	?>
+</tr>
+<tr>
+	<td bgcolor="#ffffff">
+		checking ability to UPDATE records
+	</td>
+	<?php
+		$t_query = "UPDATE $t_mantis_config_table SET value='test_update' WHERE config_id='database_test'";
+	$t_result = @$g_db->Execute( $t_query );
+
+	if( $t_result != false ) {
+		print_test_result( GOOD );
+	} else {
+		print_test_result( BAD, true, 'Database user doesn\'t have UPDATE access to the database ( ' . db_error_msg() . ' )' );
+	}
+	?>
+</tr>
+<tr>
+	<td bgcolor="#ffffff">
+		checking ability to DELETE records
+	</td>
+	<?php
+		$t_query = "DELETE FROM $t_mantis_config_table WHERE config_id='database_test'";
+	$t_result = @$g_db->Execute( $t_query );
+
+	if( $t_result != false ) {
+		print_test_result( GOOD );
+	} else {
+		print_test_result( BAD, true, 'Database user doesn\'t have DELETE access to the database ( ' . db_error_msg() . ' )' );
+	}
+	?>
+</tr>
+</table>
+<?php
+	if( false == $g_failed ) {
+		$t_install_state++;
+	}
+}
+
+# end install_state == 6
+
+if( 7 == $t_install_state ) {
+	# cleanup and launch upgrade
+	?>
+<p>Install was successful.</p>
+<?php if( $f_db_exists ) {?>
+<p><a href="../login_page.php">Continue</a> to log into Mantis</p>
+<?php
+	} else {?>
+<p>Please log in as the administrator and <a href="../manage_proj_create_page.php">create</a> your first project.
+
+<?php
+	}
+}
+
+# end install_state == 7
+
+if( $g_failed ) {
+	?>
+<table width="100%" bgcolor="#222222" border="0" cellpadding="10" cellspacing="1">
+<tr>
+	<td bgcolor="#e8e8e8" colspan="2">
+		<span class="title">Checks Failed...</span>
+	</td>
+</tr>
+<tr>
+	<td bgcolor="#ffffff">Please correct failed checks</td>
+	<td bgcolor="#ffffff">
+		<input name="install" type="hidden" value="<?php echo $t_install_state?>"></input>
+		<input name="hostname" type="hidden" value="<?php echo $f_hostname?>"></input>
+		<input name="db_type" type="hidden" value="<?php echo $f_db_type?>"></input>
+		<input name="database_name" type="hidden" value="<?php echo $f_database_name?>"></input>
+		<input name="db_username" type="hidden" value="<?php echo $f_db_username?>"></input>
+		<input name="db_password" type="hidden" value="<?php echo $f_db_password?>"></input>
+		<input name="admin_username" type="hidden" value="<?php echo $f_admin_username?>"></input>
+		<input name="admin_password" type="hidden" value="<?php echo $f_admin_password?>"></input>
+		<input name="log_queries" type="hidden" value="<?php echo( $f_log_queries ? 1 : 0 )?>"></input>
+		<input name="retry" type="submit" value="Retry"></input>
+		<input name="db_exists" type="hidden" value="<?php echo( $f_db_exists ? 1 : 0 )?>"></input>
+	</td>
+</tr>
+</table>
+<?php
+}
+?>
+</form>
+</body>
+</html>
diff --git a/admin/install_functions.php b/admin/install_functions.php
new file mode 100644
index 0000000..7556322
--- /dev/null
+++ b/admin/install_functions.php
@@ -0,0 +1,262 @@
+<?php
+# MantisBT - a php based bugtracking system
+
+# MantisBT 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.
+#
+# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Update functions for the installation schema's 'UpdateFunction' option.
+ * All functions must be name install_<function_name> and referenced as just <function_name>.
+ * @package MantisBT
+ * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+ * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
+ * @link http://www.mantisbt.org
+ */
+
+/**
+ * Migrate the legacy category data to the new category_id-based schema.
+ */
+function install_category_migrate() {
+	global $g_db_log_queries;
+	
+	$t_bug_table = db_get_table( 'mantis_bug_table' );
+	$t_category_table = db_get_table( 'mantis_category_table' );
+	$t_project_category_table = db_get_table( 'mantis_project_category_table' );
+
+	// disable query logging (even if it's enabled in config for this)
+	if ( $g_db_log_queries !== 0 ) {
+		$t_log_queries = $g_db_log_queries;
+		$g_db_log_queries = 0;
+	} else {
+		$t_log_queries = null;
+	}
+
+	$query = "SELECT project_id, category, user_id FROM $t_project_category_table ORDER BY project_id, category";
+	$t_category_result = db_query_bound( $query );
+
+	$query = "SELECT project_id, category FROM $t_bug_table ORDER BY project_id, category";
+	$t_bug_result = db_query_bound( $query );
+
+	$t_data = Array();
+
+	# Find categories specified by project
+	while( $row = db_fetch_array( $t_category_result ) ) {
+		$t_project_id = $row['project_id'];
+		$t_name = $row['category'];
+		$t_data[$t_project_id][$t_name] = $row['user_id'];
+	}
+
+	# Find orphaned categories from bugs
+	while( $row = db_fetch_array( $t_bug_result ) ) {
+		$t_project_id = $row['project_id'];
+		$t_name = $row['category'];
+
+		if ( !isset( $t_data[$t_project_id][$t_name] ) ) {
+			$t_data[$t_project_id][$t_name] = 0;
+		}
+	}
+
+	# In every project, go through all the categories found, and create them and update the bug
+	foreach( $t_data as $t_project_id => $t_categories ) {
+		$t_inserted = array();
+		foreach( $t_categories as $t_name => $t_user_id ) {
+			$t_lower_name = utf8_strtolower( trim( $t_name ) );
+			if ( !isset( $t_inserted[$t_lower_name] ) ) {
+				$query = "INSERT INTO $t_category_table ( name, project_id, user_id ) VALUES ( " .
+					db_param() . ', ' . db_param() . ', ' . db_param() . ' )';
+				db_query_bound( $query, array( $t_name, $t_project_id, $t_user_id ) );
+				$t_category_id = db_insert_id( $t_category_table );
+				$t_inserted[$t_lower_name] = $t_category_id;
+			} else {
+				$t_category_id = $t_inserted[$t_lower_name];
+			}
+
+			$query = "UPDATE $t_bug_table SET category_id=" . db_param() . '
+						WHERE project_id=' . db_param() . ' AND category=' . db_param();
+			db_query_bound( $query, array( $t_category_id, $t_project_id, $t_name ) );
+		}
+	}
+
+	// re-enabled query logging if we disabled it
+	if ( $t_log_queries !== null ) {
+		$g_db_log_queries = $t_log_queries;
+	}
+
+	# return 2 because that's what ADOdb/DataDict does when things happen properly
+	return 2;
+}
+
+function install_date_migrate( $p_data) {
+	// $p_data[0] = tablename, [1] id column, [2] = old column, [3] = new column
+	global $g_db_log_queries;
+	
+	// disable query logging (even if it's enabled in config for this)
+	if ( $g_db_log_queries !== 0 ) {
+		$t_log_queries = $g_db_log_queries;
+		$g_db_log_queries = 0;
+	} else {
+		$t_log_queries = null;
+	}
+
+	$t_table = db_get_table( $p_data[0] );
+	$t_id_column = $p_data[1];
+
+	if ( is_array( $p_data[2] ) ) {
+		$t_old_column = implode( ',', $p_data[2] );
+		$t_date_array = true;
+		$t_cnt_fields = sizeof( $p_data[2] );
+		$t_pairs = array();
+		foreach( $p_data[3] as $var ) {
+			array_push( $t_pairs, "$var=" . db_param() ) ;
+		}		
+		$t_new_column = implode( ',', $t_pairs );
+		$query = "SELECT $t_id_column, $t_old_column FROM $t_table";
+
+		$t_first_column = true;
+
+		# In order to handle large databases where we may timeout during the upgrade, we don't
+		# start form the beginning everytime.  Here we will only pickup rows where at least one
+		# of the datetime fields wasn't upgraded yet and upgrade them all.
+		foreach ( $p_data[3] as $t_new_column_name ) {
+			if ( $t_first_column ) {
+				$t_first_column = false;
+				$query .= ' WHERE ';
+			} else {
+				$query .= ' OR ';
+			}
+
+			$query .= "$t_new_column_name = 1";
+		}
+	} else {
+		$t_old_column = $p_data[2];
+		$t_new_column = $p_data[3] . "=" . db_param();
+		$t_date_array = false;
+
+		# The check for timestamp being = 1 is to make sure the field wasn't upgraded
+		# already in a previous run - see bug #12601 for more details.
+		$t_new_column_name = $p_data[3];
+		$query = "SELECT $t_id_column, $t_old_column FROM $t_table WHERE $t_new_column_name = 1";
+	}
+	
+	$t_result = db_query_bound( $query );
+
+	while( $row = db_fetch_array( $t_result ) ) {
+		$t_id = (int)$row[$t_id_column];
+
+		if( $t_date_array ) {
+			for( $i=0; $i < $t_cnt_fields; $i++ ) {
+				$t_old_value = $row[$p_data[2][$i]];
+
+				$t_new_value[$i] = db_unixtimestamp($t_old_value);
+				if ($t_new_value[$i] < 100000 ) {
+					$t_new_value[$i] = 1;
+				}
+			}
+			$t_values = $t_new_value;
+			$t_values[] = $t_id;
+		} else {
+			$t_old_value = $row[$t_old_column];		
+
+			$t_new_value = db_unixtimestamp($t_old_value);
+			if ($t_new_value < 100000 ) {
+				$t_new_value = 1;
+			}
+			$t_values = array( $t_new_value, $t_id);
+		}
+		
+		$query = "UPDATE $t_table SET $t_new_column
+					WHERE $t_id_column=" . db_param();
+		db_query_bound( $query, $t_values );
+	}
+
+	// re-enabled query logging if we disabled it
+	if ( $t_log_queries !== null ) {
+		$g_db_log_queries = $t_log_queries;
+	}
+
+	# return 2 because that's what ADOdb/DataDict does when things happen properly
+	return 2;	
+
+}
+
+/**
+ * Once upon a time multi-select custom field types (checkbox and multiselect)
+ * were stored in the database in the format of "option1|option2|option3" where
+ * they should have been stored in a format of "|option1|option2|option3|".
+ * Additionally, radio custom field types were being stored in the database
+ * with an unnecessary vertical pipe prefix and suffix when there is only ever
+ * one possible value that can be assigned to a radio field.
+ */
+function install_correct_multiselect_custom_fields_db_format() {
+	global $g_db_log_queries;
+
+	# Disable query logging due to possibility of mass spam.
+	if ( $g_db_log_queries !== 0 ) {
+		$t_log_queries = $g_db_log_queries;
+		$g_db_log_queries = 0;
+	} else {
+		$t_log_queries = null;
+	}
+
+	$t_value_table = db_get_table( 'mantis_custom_field_string_table' );
+	$t_field_table = db_get_table( 'mantis_custom_field_table' );
+
+	# Ensure multilist and checkbox custom field values have a vertical pipe |
+	# as a prefix and suffix.
+	$t_query = "SELECT v.field_id, v.bug_id, v.value from $t_value_table v
+		LEFT JOIN $t_field_table c
+		ON v.field_id = c.id
+		WHERE (c.type = " . CUSTOM_FIELD_TYPE_MULTILIST . " OR c.type = " . CUSTOM_FIELD_TYPE_CHECKBOX . ")
+			AND v.value != ''
+			AND v.value NOT LIKE '|%|'";
+	$t_result = db_query_bound( $t_query );
+
+	while( $t_row = db_fetch_array( $t_result ) ) {
+		$c_field_id = (int)$t_row['field_id'];
+		$c_bug_id = (int)$t_row['bug_id'];
+		$c_value = '|' . rtrim( ltrim( $t_row['value'], '|' ), '|' ) . '|';
+		$t_update_query = "UPDATE $t_value_table
+			SET value = '$c_value'
+			WHERE field_id = $c_field_id
+				AND bug_id = $c_bug_id";
+		$t_update_result = db_query_bound( $t_update_query );
+	}
+
+	# Remove vertical pipe | prefix and suffix from radio custom field values.
+	$t_query = "SELECT v.field_id, v.bug_id, v.value from $t_value_table v
+		LEFT JOIN $t_field_table c
+		ON v.field_id = c.id
+		WHERE c.type = " . CUSTOM_FIELD_TYPE_RADIO . "
+			AND v.value != ''
+			AND v.value LIKE '|%|'";
+	$t_result = db_query_bound( $t_query );
+
+	while( $t_row = db_fetch_array( $t_result ) ) {
+		$c_field_id = (int)$t_row['field_id'];
+		$c_bug_id = (int)$t_row['bug_id'];
+		$c_value = rtrim( ltrim( $t_row['value'], '|' ), '|' );
+		$t_update_query = "UPDATE $t_value_table
+			SET value = '$c_value'
+			WHERE field_id = $c_field_id
+				AND bug_id = $c_bug_id";
+		$t_update_result = db_query_bound( $t_update_query );
+	}
+
+	# Re-enable query logging if we disabled it.
+	if ( $t_log_queries !== null ) {
+		$g_db_log_queries = $t_log_queries;
+	}
+
+	# Return 2 because that's what ADOdb/DataDict does when things happen properly
+	return 2;
+}
diff --git a/admin/install_helper_functions.php b/admin/install_helper_functions.php
new file mode 100644
index 0000000..fc6fe68
--- /dev/null
+++ b/admin/install_helper_functions.php
@@ -0,0 +1,68 @@
+<?php
+# MantisBT - a php based bugtracking system
+
+# MantisBT 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.
+#
+# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * @package MantisBT
+ * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+ * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
+ * @link http://www.mantisbt.org
+ */
+
+function check_php_version( $p_version ) {
+	if( $p_version == PHP_MIN_VERSION ) {
+		return true;
+	} else {
+		if( function_exists( 'version_compare' ) ) {
+			if( version_compare( phpversion(), PHP_MIN_VERSION, '>=' ) ) {
+				return true;
+			} else {
+				return false;
+			}
+		} else {
+			return false;
+		}
+	}
+}
+
+/**
+ * legacy pre-1.2 date function  used by schema.php
+ * return a DB compatible date, representing a unixtime(0) + 1 second. Internally considered a NULL date
+ * @return string Formatted Date for DB insertion e.g. 1970-01-01 00:00:00 ready for database insertion
+ */
+function db_null_date() {
+	global $g_db;
+
+	return $g_db->BindTimestamp( $g_db->UserTimeStamp( 1, 'Y-m-d H:i:s', true ) );
+}
+
+/**
+ * legacy pre-1.2 date function  used by install_functions.php
+ * generate a integer unixtimestamp of a date
+ * @param $p_date Date
+ * @param bool $p_gmt whether to use GMT or current timezone (default false)
+ * @return int unix timestamp of a date
+ * @todo review date handling
+ */
+function db_unixtimestamp( $p_date = null, $p_gmt = false ) {
+	global $g_db;
+
+	if( null !== $p_date ) {
+		$p_timestamp = $g_db->UnixTimeStamp( $p_date, $p_gmt );
+	} else {
+		$p_timestamp = time();
+	}
+	return $p_timestamp;
+}
\ No newline at end of file
diff --git a/admin/move_db2disk.php b/admin/move_db2disk.php
new file mode 100644
index 0000000..dd18207
--- /dev/null
+++ b/admin/move_db2disk.php
@@ -0,0 +1,200 @@
+<?php
+# MantisBT - a php based bugtracking system
+
+# MantisBT 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.
+#
+# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This upgrade moves attachments from the database to the disk
+ * @package MantisBT
+ * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+ * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
+ * @link http://www.mantisbt.org
+ */
+/**
+ * MantisBT Core API's
+ */
+require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
+
+access_ensure_global_level( config_get_global( 'admin_site_threshold' ) );
+
+// Move type should be attachment or project.
+$f_move_type = gpc_get( 'doc' );
+
+function get_prefix( $file_path ) {
+	if( substr( $file_path, 0, 1 ) == '/' ) {
+
+		# Unix absolute
+		return '';
+	}
+	if( substr( $file_path, 0, 1 ) == '\\' ) {
+
+		# Windows absolute
+		return '';
+	}
+	if( substr( $file_path, 1, 2 ) == ':\\' ) {
+
+		# Windows absolute
+		return '';
+	}
+	return dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR;
+}
+
+# ------ move file attachments to issues from database to disk
+# select non-empty data fields
+# match with the project to get the file path
+# store the file in the correct folder
+#
+# Assumptions: only supports storage in local file system (not FTP)
+#              file paths are set up and working
+#
+# Re-running this is safe because the data
+# is not removed from the database until it is successfully copied.
+#
+function upgrade_move_att2disk( $p_source ) {
+
+	# $p_source is the string "attachment" or "project"
+	if( $p_source == 'attachment' ) {
+		$t_file_table = db_get_table( 'mantis_bug_file_table' );
+		$t_bug_label = "Bug";
+	}
+	if( $p_source == 'project' ) {
+		$t_file_table = db_get_table( 'mantis_project_file_table' );
+		$t_bug_label = "Project";
+	}
+
+	# check that the source was valid
+	if( !isset( $t_file_table ) ) {
+		echo 'Failure: Internal Error: File source not set';
+		return;
+	}
+
+	# check that the destination is set up properly
+	$t_upload_method = config_get_global( 'file_upload_method' );
+	if( $t_upload_method <> DISK ) {
+		echo 'Failure: Upload Method is not DISK';
+		return;
+	}
+
+	$query = 'SELECT * FROM ' . $t_file_table . ' WHERE content <> \'\'';
+
+	$result = @db_query_bound( $query );
+
+	if( false == $result ) {
+		echo '<p>No attachments need to be moved.</p>';
+		return;
+	}
+
+	$count = db_num_rows( $result );
+	echo '<p>Found ' . $count . ' attachments to be moved.</p>';
+	$t_failures = 0;
+
+	if( $count > 0 ) {
+		echo '<table width="80%" bgcolor="#222222" border="0" cellpadding="10" cellspacing="1">';
+
+		# Headings
+		echo '<tr bgcolor="#ffffff"><th width="10%">' . $t_bug_label . '</th><th width="20%">Attachment</th><th width="70%">Status</th></tr>';
+	}
+
+	for( $i = 0;$i < $count;$i++ ) {
+		$t_row = db_fetch_array( $result );
+
+		// trace bug id back to project to determine the proper file path
+		if( $p_source == 'attachment' ) {
+			$t_project_id = bug_get_field( $t_row['bug_id'], 'project_id' );
+			$t_bug_id = $t_row['bug_id'];
+		} else {
+			$t_project_id = (int) $t_row['project_id'];
+			$t_bug_id = $t_project_id;
+		}
+
+		$t_file_path = project_get_field( $t_project_id, 'file_path' );
+		$prefix = get_prefix( $t_file_path );
+		$t_real_file_path = $prefix . $t_file_path;
+		$c_filename = file_clean_name( $t_row['filename'] );
+
+		printf( "\n<tr %s><td>%8d</td><td>%s</td><td>", helper_alternate_class(), $t_bug_id, $t_row['filename'] );
+
+		if( is_blank( $t_real_file_path ) || !file_exists( $t_real_file_path ) || !is_dir( $t_real_file_path ) || !is_writable( $t_real_file_path ) ) {
+			echo 'Destination ' . $t_real_file_path . ' not writable';
+			$t_failures++;
+		} else {
+			$t_file_name = $t_real_file_path . $c_filename;
+
+			// write file to disk store after adjusting the path
+			if( file_put_contents( $t_file_name, $t_row['content'] ) ) {
+				// successful, update database
+				/** @todo do we want to check the size of data transfer matches here? */
+				$c_new_file_name = $t_file_path . $c_filename;
+				$query2 = "UPDATE $t_file_table SET diskfile = " . db_param() . ",
+						folder = " . db_param() . ", content = '' WHERE id = " . db_param();
+				$update = @db_query_bound( $query2, Array( $c_new_file_name, $t_file_path, $t_row['id'] ) );
+				if( !$update ) {
+					echo 'database update failed';
+					$t_failures++;
+				} else {
+					echo 'moved to ' . $t_file_name;
+				}
+			} else {
+				echo 'copy to ' . $t_file_name . ' failed';
+				$t_failures++;
+			}
+		}
+
+		echo '</td></tr>';
+	}
+
+	echo '</table><br />' . $count . ' attachments processed, ' . $t_failures . ' failures';
+}
+
+# ---------------------
+# main code
+#
+if( $f_move_type == 'attachment' ) {
+	$t_type = 'Attachments';
+} else {
+	if( $f_move_type == 'project' ) {
+		$t_type = 'Project Files';
+	} else {
+		echo "<p>Invalid value '$f_move_type' for parameter 'doc'.</p>";
+		exit;
+	}
+}
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+<title>MantisBT Administration - Move <?php echo $t_type?> to Disk</title>
+<link rel="stylesheet" type="text/css" href="admin.css" />
+</head>
+<body>
+
+<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
+	<tr class="top-bar">
+		<td class="links">
+			[ <a href="system_utils.php">Back to System Utilities</a> ]
+			[ <a href="move_db2disk.php">Refresh view</a> ]
+		</td>
+		<td class="title">
+			Move <?php echo $t_type?> to Disk
+		</td>
+	</tr>
+</table>
+<br /><br />
+
+<?php
+	upgrade_move_att2disk( $f_move_type );
+echo '<p>Completed...</p>';
+?>
+</body>
+</html>
diff --git a/admin/schema.php b/admin/schema.php
new file mode 100644
index 0000000..d2b6940
--- /dev/null
+++ b/admin/schema.php
@@ -0,0 +1,610 @@
+<?php
+# MantisBT - a php based bugtracking system
+
+# MantisBT 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.
+#
+# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
+
+# Each entry below defines the schema. The upgrade array consists of
+#  two elements
+# The first is the function to generate SQL statements (see adodb schema doc for more details)
+#  e.g., CreateTableSQL, DropTableSQL, ChangeTableSQL, RenameTableSQL, RenameColumnSQL,
+#  DropTableSQL, ChangeTableSQL, RenameTableSQL, RenameColumnSQL, AlterColumnSQL, DropColumnSQL
+#  A local function "InsertData" has been provided to add data to the db
+# The second parameter is an array of the parameters to be passed to the function.
+
+# An update identifier is inferred from the ordering of this table. ONLY ADD NEW CHANGES TO THE
+#  END OF THE TABLE!!!
+
+if ( !function_exists( 'db_null_date' ) ) {
+	function db_null_date() {
+		return 0;
+	}
+}
+
+
+function installer_db_now() {
+        global $g_db;
+ 
+       return $g_db->BindTimeStamp( time() );
+}
+
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table( 'mantis_config_table' ),"
+			  config_id C(64) NOTNULL PRIMARY,
+			  project_id I DEFAULT '0' PRIMARY,
+			  user_id I DEFAULT '0' PRIMARY,
+			  access_reqd I DEFAULT '0',
+			  type I DEFAULT '90',
+			  value XL NOTNULL",
+Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_config',db_get_table( 'mantis_config_table' ),'config_id'));
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_bug_file_table'),"
+  id			 I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
+  bug_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
+  title 		C(250) NOTNULL DEFAULT \" '' \",
+  description 		C(250) NOTNULL DEFAULT \" '' \",
+  diskfile 		C(250) NOTNULL DEFAULT \" '' \",
+  filename 		C(250) NOTNULL DEFAULT \" '' \",
+  folder 		C(250) NOTNULL DEFAULT \" '' \",
+  filesize 		 I NOTNULL DEFAULT '0',
+  file_type 		C(250) NOTNULL DEFAULT \" '' \",
+  date_added 		T NOTNULL DEFAULT '" . db_null_date() . "',
+  content 		B NOTNULL
+  ",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_bug_file_bug_id',db_get_table('mantis_bug_file_table'),'bug_id'));
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_bug_history_table'),"
+  id 			 I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
+  user_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
+  bug_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
+  date_modified 	T NOTNULL DEFAULT '" . db_null_date() . "',
+  field_name 		C(32) NOTNULL DEFAULT \" '' \",
+  old_value 		C(128) NOTNULL DEFAULT \" '' \",
+  new_value 		C(128) NOTNULL DEFAULT \" '' \",
+  type 			I2 NOTNULL DEFAULT '0'
+  ",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_bug_history_bug_id',db_get_table('mantis_bug_history_table'),'bug_id'));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_history_user_id',db_get_table('mantis_bug_history_table'),'user_id'));
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_bug_monitor_table'),"
+  user_id 		 I  UNSIGNED NOTNULL PRIMARY DEFAULT '0',
+  bug_id 		 I  UNSIGNED NOTNULL PRIMARY DEFAULT '0'
+",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_bug_relationship_table'),"
+  id 			 I  UNSIGNED NOTNULL AUTOINCREMENT PRIMARY,
+  source_bug_id		 I  UNSIGNED NOTNULL DEFAULT '0',
+  destination_bug_id 	 I  UNSIGNED NOTNULL DEFAULT '0',
+  relationship_type 	I2 NOTNULL DEFAULT '0'
+",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_relationship_source',db_get_table('mantis_bug_relationship_table'),'source_bug_id'));
+/* 10 */
+$upgrade[] = Array('CreateIndexSQL',Array('idx_relationship_destination',db_get_table('mantis_bug_relationship_table'),'destination_bug_id'));
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_bug_table'),"
+  id 			 I  UNSIGNED PRIMARY NOTNULL AUTOINCREMENT,
+  project_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
+  reporter_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
+  handler_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
+  duplicate_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
+  priority 		I2 NOTNULL DEFAULT '30',
+  severity 		I2 NOTNULL DEFAULT '50',
+  reproducibility 	I2 NOTNULL DEFAULT '10',
+  status 		I2 NOTNULL DEFAULT '10',
+  resolution 		I2 NOTNULL DEFAULT '10',
+  projection 		I2 NOTNULL DEFAULT '10',
+  category 		C(64) NOTNULL DEFAULT \" '' \",
+  date_submitted 	T NOTNULL DEFAULT '" . db_null_date() . "',
+  last_updated 		T NOTNULL DEFAULT '" . db_null_date() . "',
+  eta 			I2 NOTNULL DEFAULT '10',
+  bug_text_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
+  os 			C(32) NOTNULL DEFAULT \" '' \",
+  os_build 		C(32) NOTNULL DEFAULT \" '' \",
+  platform 		C(32) NOTNULL DEFAULT \" '' \",
+  version 		C(64) NOTNULL DEFAULT \" '' \",
+  fixed_in_version 	C(64) NOTNULL DEFAULT \" '' \",
+  build 		C(32) NOTNULL DEFAULT \" '' \",
+  profile_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
+  view_state 		I2 NOTNULL DEFAULT '10',
+  summary 		C(128) NOTNULL DEFAULT \" '' \",
+  sponsorship_total 	 I  NOTNULL DEFAULT '0',
+  sticky		L  NOTNULL DEFAULT  \"'0'\"
+",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_bug_sponsorship_total',db_get_table('mantis_bug_table'),'sponsorship_total'));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_bug_fixed_in_version',db_get_table('mantis_bug_table'),'fixed_in_version'));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_bug_status',db_get_table('mantis_bug_table'),'status'));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_project',db_get_table('mantis_bug_table'),'project_id'));
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_bug_text_table'),"
+  id 			 I  PRIMARY UNSIGNED NOTNULL AUTOINCREMENT,
+  description 		XL NOTNULL,
+  steps_to_reproduce 	XL NOTNULL,
+  additional_information XL NOTNULL
+",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_bugnote_table'),"
+  id 			 I  UNSIGNED PRIMARY NOTNULL AUTOINCREMENT,
+  bug_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
+  reporter_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
+  bugnote_text_id 	 I  UNSIGNED NOTNULL DEFAULT '0',
+  view_state 		I2 NOTNULL DEFAULT '10',
+  date_submitted 	T NOTNULL DEFAULT '" . db_null_date() . "',
+  last_modified 	T NOTNULL DEFAULT '" . db_null_date() . "',
+  note_type 		 I  DEFAULT '0',
+  note_attr 		C(250) DEFAULT \" '' \"
+",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_bug',db_get_table('mantis_bugnote_table'),'bug_id'));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_last_mod',db_get_table('mantis_bugnote_table'),'last_modified'));
+/* 20 */
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_bugnote_text_table'),"
+  id 			 I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
+  note 			XL NOTNULL
+",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_custom_field_project_table'),"
+  field_id 		 I  NOTNULL PRIMARY DEFAULT '0',
+  project_id 		 I  UNSIGNED PRIMARY NOTNULL DEFAULT '0',
+  sequence 		I2 NOTNULL DEFAULT '0'
+",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_custom_field_string_table'),"
+  field_id 		 I  NOTNULL PRIMARY DEFAULT '0',
+  bug_id 		 I  NOTNULL PRIMARY DEFAULT '0',
+  value 		C(255) NOTNULL DEFAULT \" '' \"
+",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_custom_field_bug',db_get_table('mantis_custom_field_string_table'),'bug_id'));
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_custom_field_table'),"
+  id 			 I  NOTNULL PRIMARY AUTOINCREMENT,
+  name 			C(64) NOTNULL DEFAULT \" '' \",
+  type 			I2 NOTNULL DEFAULT '0',
+  possible_values 	C(255) NOTNULL DEFAULT \" '' \",
+  default_value 	C(255) NOTNULL DEFAULT \" '' \",
+  valid_regexp 		C(255) NOTNULL DEFAULT \" '' \",
+  access_level_r 	I2 NOTNULL DEFAULT '0',
+  access_level_rw 	I2 NOTNULL DEFAULT '0',
+  length_min 		 I  NOTNULL DEFAULT '0',
+  length_max 		 I  NOTNULL DEFAULT '0',
+  advanced 		L NOTNULL DEFAULT \" '0' \",
+  require_report 	L NOTNULL DEFAULT \" '0' \",
+  require_update 	L NOTNULL DEFAULT \" '0' \",
+  display_report 	L NOTNULL DEFAULT \" '0' \",
+  display_update 	L NOTNULL DEFAULT \" '1' \",
+  require_resolved 	L NOTNULL DEFAULT \" '0' \",
+  display_resolved 	L NOTNULL DEFAULT \" '0' \",
+  display_closed 	L NOTNULL DEFAULT \" '0' \",
+  require_closed 	L NOTNULL DEFAULT \" '0' \"
+",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_custom_field_name',db_get_table('mantis_custom_field_table'),'name'));
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_filters_table'),"
+  id 			 I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
+  user_id 		 I  NOTNULL DEFAULT '0',
+  project_id 		 I  NOTNULL DEFAULT '0',
+  is_public 		L DEFAULT NULL,
+  name 			C(64) NOTNULL DEFAULT \" '' \",
+  filter_string 	XL NOTNULL
+",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_news_table'),"
+  id 			 I  UNSIGNED PRIMARY NOTNULL AUTOINCREMENT,
+  project_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
+  poster_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
+  date_posted 		T NOTNULL DEFAULT '" . db_null_date() . "',
+  last_modified 	T NOTNULL DEFAULT '" . db_null_date() . "',
+  view_state 		I2 NOTNULL DEFAULT '10',
+  announcement 		L NOTNULL DEFAULT \" '0' \",
+  headline 		C(64) NOTNULL DEFAULT \" '' \",
+  body 			XL NOTNULL
+",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_project_category_table'),"
+  project_id 		 I  UNSIGNED NOTNULL PRIMARY DEFAULT '0',
+  category 		C(64) NOTNULL PRIMARY DEFAULT \" '' \",
+  user_id 		 I  UNSIGNED NOTNULL DEFAULT '0'
+",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_project_file_table'),"
+  id 			 I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
+  project_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
+  title 		C(250) NOTNULL DEFAULT \" '' \",
+  description 		C(250) NOTNULL DEFAULT \" '' \",
+  diskfile 		C(250) NOTNULL DEFAULT \" '' \",
+  filename 		C(250) NOTNULL DEFAULT \" '' \",
+  folder 		C(250) NOTNULL DEFAULT \" '' \",
+  filesize 		 I NOTNULL DEFAULT '0',
+  file_type 		C(250) NOTNULL DEFAULT \" '' \",
+  date_added 		T NOTNULL DEFAULT '" . db_null_date() . "',
+  content 		B NOTNULL
+",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+/* 30 */
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_project_hierarchy_table'),"
+			  child_id I UNSIGNED NOTNULL,
+			  parent_id I UNSIGNED NOTNULL",
+Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_project_table'),"
+  id 			 I  UNSIGNED PRIMARY NOTNULL AUTOINCREMENT,
+  name 			C(128) NOTNULL DEFAULT \" '' \",
+  status 		I2 NOTNULL DEFAULT '10',
+  enabled 		L NOTNULL DEFAULT \" '1' \",
+  view_state 		I2 NOTNULL DEFAULT '10',
+  access_min 		I2 NOTNULL DEFAULT '10',
+  file_path 		C(250) NOTNULL DEFAULT \" '' \",
+  description 		XL NOTNULL
+",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_project_id',db_get_table('mantis_project_table'),'id'));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_project_name',db_get_table('mantis_project_table'),'name',Array('UNIQUE')));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_project_view',db_get_table('mantis_project_table'),'view_state'));
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_project_user_list_table'),"
+  project_id 		 I  UNSIGNED PRIMARY NOTNULL DEFAULT '0',
+  user_id 		 I  UNSIGNED PRIMARY NOTNULL DEFAULT '0',
+  access_level 		I2 NOTNULL DEFAULT '10'
+",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array( 'CreateIndexSQL',Array('idx_project_user',db_get_table('mantis_project_user_list_table'),'user_id'));
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_project_version_table'),"
+  id 			 I  NOTNULL PRIMARY AUTOINCREMENT,
+  project_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
+  version 		C(64) NOTNULL DEFAULT \" '' \",
+  date_order 		T NOTNULL DEFAULT '" . db_null_date() . "',
+  description 		XL NOTNULL,
+  released 		L NOTNULL DEFAULT \" '1' \"
+",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_project_version',db_get_table('mantis_project_version_table'),'project_id,version',Array('UNIQUE')));
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_sponsorship_table'),"
+  id 			 I  NOTNULL PRIMARY AUTOINCREMENT,
+  bug_id 		 I  NOTNULL DEFAULT '0',
+  user_id 		 I  NOTNULL DEFAULT '0',
+  amount 		 I  NOTNULL DEFAULT '0',
+  logo 			C(128) NOTNULL DEFAULT \" '' \",
+  url 			C(128) NOTNULL DEFAULT \" '' \",
+  paid 			L NOTNULL DEFAULT \" '0' \",
+  date_submitted 	T NOTNULL DEFAULT '" . db_null_date() . "',
+  last_updated 		T NOTNULL DEFAULT '" . db_null_date() . "'
+",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+/* 40 */
+$upgrade[] = Array('CreateIndexSQL',Array('idx_sponsorship_bug_id',db_get_table('mantis_sponsorship_table'),'bug_id'));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_sponsorship_user_id',db_get_table('mantis_sponsorship_table'),'user_id'));
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_tokens_table'),"
+			  id I NOTNULL PRIMARY AUTOINCREMENT,
+			  owner I NOTNULL,
+			  type I NOTNULL,
+			  timestamp T NOTNULL,
+			  expiry T,
+			  value XL NOTNULL",
+Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_user_pref_table'),"
+  id 			 I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
+  user_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
+  project_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
+  default_profile 	 I  UNSIGNED NOTNULL DEFAULT '0',
+  default_project 	 I  UNSIGNED NOTNULL DEFAULT '0',
+  advanced_report 	L NOTNULL DEFAULT \" '0' \",
+  advanced_view 	L NOTNULL DEFAULT \" '0' \",
+  advanced_update 	L NOTNULL DEFAULT \" '0' \",
+  refresh_delay 	 I  NOTNULL DEFAULT '0',
+  redirect_delay 	L NOTNULL DEFAULT \" '0' \",
+  bugnote_order 	C(4) NOTNULL DEFAULT 'ASC',
+  email_on_new 		L NOTNULL DEFAULT \" '0' \",
+  email_on_assigned 	L NOTNULL DEFAULT \" '0' \",
+  email_on_feedback 	L NOTNULL DEFAULT \" '0' \",
+  email_on_resolved	L NOTNULL DEFAULT \" '0' \",
+  email_on_closed 	L NOTNULL DEFAULT \" '0' \",
+  email_on_reopened 	L NOTNULL DEFAULT \" '0' \",
+  email_on_bugnote 	L NOTNULL DEFAULT \" '0' \",
+  email_on_status 	L NOTNULL DEFAULT \" '0' \",
+  email_on_priority 	L NOTNULL DEFAULT \" '0' \",
+  email_on_priority_min_severity 	I2 NOTNULL DEFAULT '10',
+  email_on_status_min_severity 	I2 NOTNULL DEFAULT '10',
+  email_on_bugnote_min_severity 	I2 NOTNULL DEFAULT '10',
+  email_on_reopened_min_severity 	I2 NOTNULL DEFAULT '10',
+  email_on_closed_min_severity 	I2 NOTNULL DEFAULT '10',
+  email_on_resolved_min_severity 	I2 NOTNULL DEFAULT '10',
+  email_on_feedback_min_severity	I2 NOTNULL DEFAULT '10',
+  email_on_assigned_min_severity 	I2 NOTNULL DEFAULT '10',
+  email_on_new_min_severity 	I2 NOTNULL DEFAULT '10',
+  email_bugnote_limit 	I2 NOTNULL DEFAULT '0',
+  language 		C(32) NOTNULL DEFAULT 'english'
+",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_user_print_pref_table'),"
+  user_id 		 I  UNSIGNED NOTNULL PRIMARY DEFAULT '0',
+  print_pref 		C(27) NOTNULL DEFAULT \" '' \"
+",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_user_profile_table'),"
+  id 			 I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
+  user_id 		 I  UNSIGNED NOTNULL DEFAULT '0',
+  platform 		C(32) NOTNULL DEFAULT \" '' \",
+  os 			C(32) NOTNULL DEFAULT \" '' \",
+  os_build 		C(32) NOTNULL DEFAULT \" '' \",
+  description 		XL NOTNULL
+",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_user_table'),"
+  id 			 I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
+  username 		C(32) NOTNULL DEFAULT \" '' \",
+  realname 		C(64) NOTNULL DEFAULT \" '' \",
+  email 		C(64) NOTNULL DEFAULT \" '' \",
+  password 		C(32) NOTNULL DEFAULT \" '' \",
+  date_created 		T NOTNULL DEFAULT '" . db_null_date() . "',
+  last_visit 		T NOTNULL DEFAULT '" . db_null_date() . "',
+  enabled		L NOTNULL DEFAULT \" '1' \",
+  protected 		L NOTNULL DEFAULT \" '0' \",
+  access_level 		I2 NOTNULL DEFAULT '10',
+  login_count 		 I  NOTNULL DEFAULT '0',
+  lost_password_request_count 	I2 NOTNULL DEFAULT '0',
+  failed_login_count 	I2 NOTNULL DEFAULT '0',
+  cookie_string 	C(64) NOTNULL DEFAULT \" '' \"
+",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_user_cookie_string',db_get_table('mantis_user_table'),'cookie_string',Array('UNIQUE')));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_user_username',db_get_table('mantis_user_table'),'username',Array('UNIQUE')));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_enable',db_get_table('mantis_user_table'),'enabled'));
+/* 50 */
+$upgrade[] = Array('CreateIndexSQL',Array('idx_access',db_get_table('mantis_user_table'),'access_level'));
+$upgrade[] = Array('InsertData', Array( db_get_table('mantis_user_table'),
+    "(username, realname, email, password, date_created, last_visit, enabled, protected, access_level, login_count, lost_password_request_count, failed_login_count, cookie_string) VALUES
+        ('administrator', '', 'root@localhost', '63a9f0ea7bb98050796b649e85481845', '" . installer_db_now() . "', '" . installer_db_now() . "', '1', '0', 90, 3, 0, 0, '" .
+             md5( mt_rand( 0, mt_getrandmax() ) + mt_rand( 0, mt_getrandmax() ) ) . md5( time() ) . "')" ) );
+$upgrade[] = Array('AlterColumnSQL', Array( db_get_table( 'mantis_bug_history_table' ), "old_value C(255) NOTNULL" ) );
+$upgrade[] = Array('AlterColumnSQL', Array( db_get_table( 'mantis_bug_history_table' ), "new_value C(255) NOTNULL" ) );
+
+$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_email_table'),"
+  email_id 		I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
+  email		 	C(64) NOTNULL DEFAULT \" '' \",
+  subject		C(250) NOTNULL DEFAULT \" '' \",
+  submitted 	T NOTNULL DEFAULT '" . db_null_date() . "',
+  metadata 		XL NOTNULL,
+  body 			XL NOTNULL
+  ",Array('mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS')));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_email_id',db_get_table('mantis_email_table'),'email_id'));
+$upgrade[] = Array('AddColumnSQL',Array(db_get_table('mantis_bug_table'), "target_version C(64) NOTNULL DEFAULT \" '' \""));
+$upgrade[] = Array('AddColumnSQL',Array(db_get_table('mantis_bugnote_table'), "time_tracking I UNSIGNED NOTNULL DEFAULT \" 0 \""));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_diskfile',db_get_table('mantis_bug_file_table'),'diskfile'));
+$upgrade[] = Array('AlterColumnSQL', Array( db_get_table( 'mantis_user_print_pref_table' ), "print_pref C(64) NOTNULL" ) );
+/* 60 */
+$upgrade[] = Array('AlterColumnSQL', Array( db_get_table( 'mantis_bug_history_table' ), "field_name C(64) NOTNULL" ) );
+
+# Release marker: 1.1.0a4
+
+$upgrade[] = Array('CreateTableSQL', Array( db_get_table( 'mantis_tag_table' ), "
+	id				I		UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
+	user_id			I		UNSIGNED NOTNULL DEFAULT '0',
+	name			C(100)	NOTNULL PRIMARY DEFAULT \" '' \",
+	description		XL		NOTNULL,
+	date_created	T		NOTNULL DEFAULT '" . db_null_date() . "',
+	date_updated	T		NOTNULL DEFAULT '" . db_null_date() . "'
+	", Array( 'mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS' ) ) );
+$upgrade[] = Array('CreateTableSQL', Array( db_get_table( 'mantis_bug_tag_table' ), "
+	bug_id			I	UNSIGNED NOTNULL PRIMARY DEFAULT '0',
+	tag_id			I	UNSIGNED NOTNULL PRIMARY DEFAULT '0',
+	user_id			I	UNSIGNED NOTNULL DEFAULT '0',
+	date_attached	T	NOTNULL DEFAULT '" . db_null_date() . "'
+	", Array( 'mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS' ) ) );
+
+$upgrade[] = Array('CreateIndexSQL', Array( 'idx_typeowner', db_get_table( 'mantis_tokens_table' ), 'type, owner' ) );
+
+# Release marker: 1.2.0-SVN
+
+$upgrade[] = Array('CreateTableSQL', Array( db_get_table( 'mantis_plugin_table' ), "
+	basename		C(40)	NOTNULL PRIMARY,
+	enabled			L		NOTNULL DEFAULT \" '0' \"
+	", Array( 'mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS' ) ) );
+
+$upgrade[] = Array('AlterColumnSQL', Array( db_get_table( 'mantis_user_pref_table' ), "redirect_delay 	I NOTNULL DEFAULT 0" ) );
+
+/* apparently mysql now has a STRICT mode, where setting a DEFAULT value on a blob/text is now an error, instead of being silently ignored */
+if ( isset( $f_db_type ) && ( $f_db_type == 'mysql' || $f_db_type == 'mysqli' ) ) {
+	$upgrade[] = Array('AlterColumnSQL', Array( db_get_table( 'mantis_custom_field_table' ), "possible_values X NOTNULL" ) );
+} else {
+	$upgrade[] = Array('AlterColumnSQL', Array( db_get_table( 'mantis_custom_field_table' ), "possible_values X NOTNULL DEFAULT \" '' \"" ) );
+}
+
+$upgrade[] = Array( 'CreateTableSQL', Array( db_get_table( 'mantis_category_table' ), "
+	id				I		UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
+	project_id		I		UNSIGNED NOTNULL DEFAULT '0',
+	user_id			I		UNSIGNED NOTNULL DEFAULT '0',
+	name			C(128)	NOTNULL DEFAULT \" '' \",
+	status			I		UNSIGNED NOTNULL DEFAULT '0'
+	", Array( 'mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS' ) ) );
+$upgrade[] = Array( 'CreateIndexSQL', Array( 'idx_category_project_name', db_get_table( 'mantis_category_table' ), 'project_id, name', array( 'UNIQUE' ) ) );
+$upgrade[] = Array( 'InsertData', Array( db_get_table( 'mantis_category_table' ), "
+	( project_id, user_id, name, status ) VALUES
+	( '0', '0', 'General', '0' ) " ) );
+/* 70 */
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "category_id I UNSIGNED NOTNULL DEFAULT '1'" ) );
+$upgrade[] = Array( 'UpdateFunction', "category_migrate" );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "category" ) );
+$upgrade[] = Array( 'DropTableSQL', Array( db_get_table( 'mantis_project_category_table' ) ) );
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_project_table' ), "category_id I UNSIGNED NOTNULL DEFAULT '1'" ) );
+// remove unnecessary indexes
+$upgrade[] = Array('CreateIndexSQL',Array('idx_project_id',db_get_table('mantis_project_table'),'id', array('DROP')), Array( 'db_index_exists', Array( db_get_table('mantis_project_table'), 'idx_project_id')));
+$upgrade[] = Array('CreateIndexSQL',Array('idx_config',db_get_table( 'mantis_config_table' ),'config_id', array('DROP')), Array( 'db_index_exists', Array( db_get_table('mantis_config_table'), 'idx_config')));
+
+$upgrade[] = Array( 'InsertData', Array( db_get_table( 'mantis_plugin_table' ), "
+	( basename, enabled ) VALUES
+	( 'MantisCoreFormatting', '1' )" ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_project_table' ), "inherit_global I UNSIGNED NOTNULL DEFAULT '0'" ) );
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_project_hierarchy_table' ), "inherit_parent I UNSIGNED NOTNULL DEFAULT '0'" ) );
+/* 80 */
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_plugin_table' ), "
+	protected		L		NOTNULL DEFAULT \" '0' \",
+	priority		I		UNSIGNED NOTNULL DEFAULT '3'
+	" ) );
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_project_version_table' ), "
+	obsolete		L		NOTNULL DEFAULT \" '0' \"" ) );
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "
+    due_date        T       NOTNULL DEFAULT '" . db_null_date() . "' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_custom_field_table' ), "
+  filter_by 		L 		NOTNULL DEFAULT \" '1' \"" ) );
+$upgrade[] = Array( 'CreateTableSQL', Array( db_get_table( 'mantis_bug_revision_table' ), "
+	id			I		UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
+	bug_id		I		UNSIGNED NOTNULL,
+	bugnote_id	I		UNSIGNED NOTNULL DEFAULT '0',
+	user_id		I		UNSIGNED NOTNULL,
+	timestamp	T		NOTNULL DEFAULT '" . db_null_date() . "',
+	type		I		UNSIGNED NOTNULL,
+	value		XL		NOTNULL
+	", Array( 'mysql' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8', 'pgsql' => 'WITHOUT OIDS' ) ) );
+$upgrade[] = Array( 'CreateIndexSQL', Array( 'idx_bug_rev_id_time', db_get_table( 'mantis_bug_revision_table' ), 'bug_id, timestamp' ) );
+$upgrade[] = Array( 'CreateIndexSQL', Array( 'idx_bug_rev_type', db_get_table( 'mantis_bug_revision_table' ), 'type' ) );
+
+#date conversion
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "
+	date_submitted_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "
+	due_date_int        			I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "
+	last_updated_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+/* 90 */
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_bug_table', 'id', array( 'date_submitted', 'due_date', 'last_updated' ), array( 'date_submitted_int', 'due_date_int', 'last_updated_int' ) ) );
+
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "date_submitted" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "date_submitted_int", "date_submitted", "date_submitted_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "due_date" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "due_date_int", "due_date", "due_date_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "last_updated" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bug_table' ), "last_updated_int", "last_updated", "last_updated_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array('CreateIndexSQL',Array('idx_last_mod',db_get_table( 'mantis_bugnote_table' ),'last_modified', array('DROP')), Array( 'db_index_exists', Array( db_get_table('mantis_bugnote_table'), 'idx_last_mod')));
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bugnote_table' ), "
+	last_modified_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bugnote_table' ), "
+	date_submitted_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+/* 100 */
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_bugnote_table', 'id', array( 'last_modified', 'date_submitted' ), array( 'last_modified_int', 'date_submitted_int' ) ) );
+
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bugnote_table' ), "last_modified" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bugnote_table' ), "last_modified_int", "last_modified", "last_modified_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array('CreateIndexSQL',Array('idx_last_mod',db_get_table('mantis_bugnote_table'),'last_modified'));
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bugnote_table' ), "date_submitted" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bugnote_table' ), "date_submitted_int", "date_submitted", "date_submitted_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+	
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_file_table' ), "
+	date_added_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_bug_file_table', 'id', 'date_added', 'date_added_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_file_table' ), "date_added" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bug_file_table' ), "date_added_int", "date_added", "date_added_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+/* 110 */
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_project_file_table' ), "
+	date_added_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_project_file_table', 'id', 'date_added', 'date_added_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_project_file_table' ), "date_added" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_project_file_table' ), "date_added_int", "date_added", "date_added_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_history_table' ), "
+	date_modified_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_bug_history_table', 'id', 'date_modified', 'date_modified_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_history_table' ), "date_modified" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bug_history_table' ), "date_modified_int", "date_modified", "date_modified_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_user_table' ), "
+	last_visit_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_user_table' ), "
+	date_created_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+/* 120 */
+
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_user_table', 'id', array( 'last_visit', 'date_created' ), array( 'last_visit_int', 'date_created_int' ) ) );
+
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_user_table' ), "date_created" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_user_table' ), "date_created_int", "date_created", "date_created_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_user_table' ), "last_visit" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_user_table' ), "last_visit_int", "last_visit", "last_visit_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_email_table' ), "
+	submitted_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_email_table', 'email_id', 'submitted', 'submitted_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_email_table' ), "submitted" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_email_table' ), "submitted_int", "submitted", "submitted_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_tag_table' ), "
+	date_created_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+/* 130 */
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_tag_table' ), "
+	date_updated_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_tag_table', 'id', array( 'date_created', 'date_updated' ), array( 'date_created_int', 'date_updated_int' ) ) );
+
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_tag_table' ), "date_created" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_tag_table' ), "date_created_int", "date_created", "date_created_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_tag_table' ), "date_updated" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_tag_table' ), "date_updated_int", "date_updated", "date_updated_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_tag_table' ), "
+	date_attached_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_bug_tag_table', 'bug_id', 'date_attached', 'date_attached_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_tag_table' ), "date_attached" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bug_tag_table' ), "date_attached_int", "date_attached", "date_attached_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+/* 140 */
+
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_tokens_table' ), "
+	timestamp_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_tokens_table' ), "
+	expiry_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_tokens_table', 'id', array( 'timestamp', 'expiry' ), array( 'timestamp_int', 'expiry_int' ) ) );
+
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_tokens_table' ), "timestamp" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_tokens_table' ), "timestamp_int", "timestamp", "timestamp_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_tokens_table' ), "expiry" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_tokens_table' ), "expiry_int", "expiry", "expiry_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_news_table' ), "
+	last_modified_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_news_table' ), "
+	date_posted_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_news_table', 'id', array( 'date_posted', 'last_modified' ), array( 'date_posted_int', 'last_modified_int' ) ) );
+/* 150 */
+
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_news_table' ), "last_modified" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_news_table' ), "last_modified_int", "last_modified", "last_modified_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_news_table' ), "date_posted" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_news_table' ), "date_posted_int", "date_posted", "date_posted_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array('CreateIndexSQL',Array('idx_bug_rev_id_time',db_get_table( 'mantis_bug_revision_table' ),'bug_id, timestamp', array('DROP')), Array( 'db_index_exists', Array( db_get_table('mantis_bug_revision_table'), 'idx_bug_rev_id_time')));
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_revision_table' ), "
+	timestamp_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_bug_revision_table', 'id', 'timestamp', 'timestamp_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_revision_table' ), "timestamp" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_bug_revision_table' ), "timestamp_int", "timestamp", "timestamp_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'CreateIndexSQL', Array( 'idx_bug_rev_id_time', db_get_table( 'mantis_bug_revision_table' ), 'bug_id, timestamp' ) );
+/* 160 */
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_user_pref_table' ), "
+	 timezone C(32) NOTNULL DEFAULT '' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_project_version_table' ), "
+	date_order_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_project_version_table', 'id', 'date_order', 'date_order_int' ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_project_version_table' ), "date_order" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_project_version_table' ), "date_order_int", "date_order", "date_order_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_sponsorship_table' ), "
+	date_submitted_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_sponsorship_table' ), "
+	last_updated_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'UpdateFunction', "date_migrate", array( 'mantis_sponsorship_table', 'id', array( 'date_submitted', 'last_updated' ), array( 'date_submitted_int', 'last_updated_int' ) ) );
+
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_sponsorship_table' ), "last_updated" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_sponsorship_table' ), "last_updated_int", "last_updated", "last_updated_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+
+/* 170 */
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_sponsorship_table' ), "date_submitted" ) );
+$upgrade[] = Array( 'RenameColumnSQL', Array( db_get_table( 'mantis_sponsorship_table' ), "date_submitted_int", "date_submitted", "date_submitted_int		I  UNSIGNED     NOTNULL DEFAULT '1' " ) );
+
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_project_file_table' ), "
+	user_id			I		UNSIGNED NOTNULL DEFAULT '0' " ) );
+$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_bug_file_table' ), "
+	user_id		I  			UNSIGNED NOTNULL DEFAULT '0' " ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_custom_field_table'), "advanced" ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_user_pref_table'), "advanced_report" ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_user_pref_table'), "advanced_view" ) );
+$upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_user_pref_table'), "advanced_update" ) );
+$upgrade[] = Array( 'CreateIndexSQL', Array( 'idx_project_hierarchy_child_id', db_get_table( 'mantis_project_hierarchy_table' ), 'child_id' ) );
+$upgrade[] = Array( 'CreateIndexSQL', Array( 'idx_project_hierarchy_parent_id', db_get_table( 'mantis_project_hierarchy_table' ), 'parent_id' ) );
+
+/* 180 */
+$upgrade[] = Array( 'CreateIndexSQL', Array( 'idx_tag_name', db_get_table( 'mantis_tag_table' ), 'name' ) );
+$upgrade[] = Array( 'CreateIndexSQL', Array( 'idx_bug_tag_tag_id', db_get_table( 'mantis_bug_tag_table' ), 'tag_id' ) );
+$upgrade[] = Array( 'CreateIndexSQL', Array( 'idx_email_id', db_get_table( 'mantis_email_table' ), 'email_id', array( 'DROP' ) ), Array( 'db_index_exists', Array( db_get_table( 'mantis_email_table' ), 'idx_email_id') ) );
+$upgrade[] = Array( 'UpdateFunction', 'correct_multiselect_custom_fields_db_format' );
diff --git a/admin/system_utils.php b/admin/system_utils.php
new file mode 100644
index 0000000..d86d77e
--- /dev/null
+++ b/admin/system_utils.php
@@ -0,0 +1,98 @@
+<?php
+# MantisBT - a php based bugtracking system
+
+# MantisBT 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.
+#
+# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * @todo FIXME: Looks like "From", "to", and "Copy" need i18n. Possibly more in this file.
+ * @package MantisBT
+ * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+ * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
+ * @link http://www.mantisbt.org
+ */
+/**
+ * MantisBT Core API's
+ */
+require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
+
+access_ensure_global_level( config_get_global( 'admin_site_threshold' ) );
+
+html_page_top( 'MantisBT Administration - System Utilities' );
+
+?>
+<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
+	<tr class="top-bar">
+		<td class="links">
+			[ <a href="index.php">Back to MantisBT Administration</a> ]
+		</td>
+		<td class="title">
+			System Utilities
+		</td>
+	</tr>
+</table>
+<br /><br />
+
+<table width="80%" bgcolor="#222222" border="0" cellpadding="10" cellspacing="1">
+	<tr><td bgcolor=\"#e8e8e8\" colspan=\"2\"><span class=\"title\">Upgrade Utilities</span></td></tr>
+
+	<!-- # Headings -->
+	<tr bgcolor="#ffffff"><th width="70%">Description</th><th width="30%">Execute</th></tr>
+
+	<!-- each row links to an upgrade
+		move database bug attachments to disk -->
+	<tr bgcolor="#ffffff"><td>Move attachments stored in database schema to disk files.</td><td><center>
+	<?php html_button( 'move_db2disk.php', 'Move Attachments to Disk', array( 'doc' => 'attachment' ) );?>
+	</center></td></tr>
+
+	<!-- move database project files to disk -->
+	<tr bgcolor="#ffffff"><td>Move project files stored in database schema to disk.</td><td><center>
+	<?php html_button( 'move_db2disk.php', 'Move Project Files to Disk', array( 'doc' => 'project' ) );?>
+	</center></td></tr>
+
+	<!-- move custom field content to standard field -->
+	<tr bgcolor="#ffffff"><td>Copy Custom Field to Standard Field.</td><td><center>
+	<form method="post" action="copy_field.php">
+		From
+		<SELECT name="source_id">
+			<?php
+				$t_custom_ids = custom_field_get_ids();
+foreach( $t_custom_ids as $t_id ) {
+	printf( "<OPTION VALUE=\"%d\">%s", $t_id, custom_field_get_field( $t_id, 'name' ) );
+}
+?>
+		</SELECT> to
+		<SELECT name="dest_id">
+			<?php
+/** @todo should be expanded and configurable */
+// list matches exact field name from database
+$t_dest_ids = array(
+	'fixed_in_version',
+);
+foreach( $t_dest_ids as $t_id ) {
+	printf( "<OPTION VALUE=\"%s\">%s", $t_id, $t_id );
+}
+?>
+		</SELECT>
+	<input type="submit" class="button" value="Copy" />
+	</form>
+	</center></td></tr>
+
+	<!-- Database Statistics -->
+	<tr bgcolor="#ffffff"><td>Show database statistics.</td><td><center>
+	<?php html_button( 'db_stats.php', 'Display', array() );?>
+	</center></td></tr>
+
+</table>
+<?php
+	html_page_bottom();
diff --git a/admin/test_email.php b/admin/test_email.php
new file mode 100644
index 0000000..4c8c041
--- /dev/null
+++ b/admin/test_email.php
@@ -0,0 +1,77 @@
+<?php
+# MantisBT - a php based bugtracking system
+
+# MantisBT 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.
+#
+# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * @package MantisBT
+ * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+ * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
+ * @link http://www.mantisbt.org
+ */
+/**
+ * MantisBT Core API's
+ */
+require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
+
+access_ensure_global_level( config_get_global( 'admin_site_threshold' ) );
+
+$f_mail_test = gpc_get_bool( 'mail_test' );
+
+html_page_top();
+
+?>
+
+<a name="email" id="email" />
+<table width="100%" bgcolor="#222222" border="0" cellpadding="20" cellspacing="1">
+<tr>
+	<td bgcolor="#f4f4f4">
+		<span class="title">Testing Email</span>
+		<p>You can test the ability for MantisBT to send email notifications with this form.  Just click "Send Mail".  If the page takes a very long time to reappear or results in an error then you will need to investigate your php/mail server settings (see PHPMailer related settings in your config_inc.php, if they don't exist, copy from config_defaults_inc.php).  Note that errors can also appear in the server error log.  More help can be found at the <a href="http://www.php.net/manual/en/ref.mail.php">PHP website</a> if you are using the mail() PHPMailer sending mode.</p>
+		<?php
+		if( $f_mail_test ) {
+			echo '<b><font color="#ff0000">Testing Mail</font></b> - ';
+
+			# @@@ thraxisp - workaround to ensure a language is set without authenticating
+			#  will disappear when this is properly localized
+			lang_push( 'english' );
+
+			$t_email_data = new EmailData;
+			$t_email_data->email = config_get_global( 'administrator_email' );
+			$t_email_data->subject = 'Testing PHP mail() function';
+			$t_email_data->body = 'Your PHP mail settings appear to be correctly set.';
+			$t_email_data->metadata['priority'] = config_get( 'mail_priority' );
+			$t_email_data->metadata['charset'] = 'utf-8';
+			$result = email_send( $t_email_data );
+
+			# $result = email_send( config_get_global( 'administrator_email' ), 'Testing PHP mail() function',	'Your PHP mail settings appear to be correctly set.');
+
+			if( !$result ) {
+				echo ' PROBLEMS SENDING MAIL TO: ' . config_get_global( 'administrator_email' ) . '. Please check your php/mail server settings.<br />';
+			} else {
+				echo ' mail() send successful.<br />';
+			}
+		}
+?>
+		<form method="post" action="<?php echo $_SERVER['SCRIPT_NAME']?>#email">
+		Email Address: <?php echo config_get_global( 'administrator_email' );?><br />
+		<input type="submit" value="Send Mail" name="mail_test" />
+		</form>
+	</td>
+</tr>
+</table>
+
+<?php
+
+html_page_bottom();
diff --git a/admin/test_icons.php b/admin/test_icons.php
new file mode 100644
index 0000000..b289051
--- /dev/null
+++ b/admin/test_icons.php
@@ -0,0 +1,47 @@
+<?php
+# MantisBT - a php based bugtracking system
+
+# MantisBT 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.
+#
+# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * @package MantisBT
+ * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+ * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
+ * @link http://www.mantisbt.org
+ */
+/**
+ * MantisBT Core API's
+ */
+require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
+
+access_ensure_global_level( config_get_global( 'admin_site_threshold' ) );
+
+html_page_top();
+
+foreach( $g_file_type_icons as $t_ext => $t_filename ) {
+	$t_file_path = dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'fileicons' . DIRECTORY_SEPARATOR . $t_filename;
+
+	echo "Testing icon for extension '$t_ext'... $t_file_path ... ";
+	flush();
+
+	if( file_exists( $t_file_path ) ) {
+		echo 'OK';
+	} else {
+		echo '<font color="red">NOT FOUND</font>';
+	}
+
+	echo '<br />';
+}
+
+html_page_bottom();
diff --git a/admin/test_langs.php b/admin/test_langs.php
new file mode 100644
index 0000000..9e137dd
--- /dev/null
+++ b/admin/test_langs.php
@@ -0,0 +1,363 @@
+<?php
+# MantisBT - a php based bugtracking system
+
+# MantisBT 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.
+#
+# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * @package MantisBT
+ * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+ * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
+ * @link http://www.mantisbt.org
+ */
+
+define( 'PLUGINS_DISABLED', true ); 
+$g_skip_lang_load = true;
+
+/**
+ * MantisBT Core API's
+ */
+require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
+
+access_ensure_global_level( config_get_global( 'admin_site_threshold' ) );
+
+if( function_exists( 'xdebug_disable' ) ) {
+	xdebug_disable();
+}
+
+if( !defined( 'T_ML_COMMENT' ) ) {
+	define( 'T_ML_COMMENT', T_COMMENT );
+}
+else {
+	define( 'T_DOC_COMMENT', T_ML_COMMENT );
+}
+
+if (!checkfile( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR, 'strings_english.txt', true)) {
+	print_error( "FAILED: Language file 'strings_english.txt' failed." );
+	die;
+}
+
+unset( $g_skip_lang_load ) ;
+lang_push( 'english' );
+
+set_time_limit( 0 );
+
+html_page_top();
+
+// check core language files
+if( function_exists( 'opendir' ) && function_exists( 'readdir' ) ) {
+	$t_lang_files = Array();
+	if( $t_handle = opendir( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'lang' ) ) {
+		while( false !== ( $t_file = readdir( $t_handle ) ) ) {
+			if ($t_file == 'strings_english.txt' ) {
+				echo "Testing english language file '$t_file' (phase 1)...<br />";
+				flush();
+				checkfile( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR, $t_file );
+			}
+			if( $t_file[0] != '.' && $t_file != 'langreadme.txt' && !is_dir( $t_file ) ) {
+				$t_lang_files[] = $t_file;
+			}
+		}
+		closedir( $t_handle );
+	}
+}
+else {
+	$t_lang_files = Array();
+	foreach( $g_language_choices_arr as $t_lang ) {
+		if( $t_lang == 'auto' ) {
+			continue;
+		}
+		$t_lang_files[] = $t_lang;
+	}
+}
+
+if( count( $t_lang_files ) > 0 ) {
+	echo 'Retrieved ', count( $t_lang_files ), ' languages<br />';
+
+	foreach( $t_lang_files as $t_file ) {
+		echo "Testing language file '$t_file' (phase 1)...<br />";
+		flush();
+
+		checkfile( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR, $t_file );
+	}
+}
+
+// attempt to find plugin language files
+echo "Trying to find+check plugin language files...<br />";
+if( function_exists( 'opendir' ) && function_exists( 'readdir' ) ) {
+	checklangdir ( config_get( 'plugin_path' ) );
+} else {
+	echo 'php opendir/readdir are disabled - skipping<br />';
+}
+
+function checklangdir( $p_path, $p_subpath = '' ) {
+	$p_path = $p_path . DIRECTORY_SEPARATOR . $p_subpath . DIRECTORY_SEPARATOR;
+	if( $handle = opendir( $p_path ) ) {
+		while( false !== ( $file = readdir( $handle ) ) ) {
+			if ( $file[0] == '.' )
+				continue;
+			if ( $p_subpath == '' ) {
+				echo "Checking language files for plugin $file:<br />";
+
+				if (file_exists( $p_path . DIRECTORY_SEPARATOR . $p_subpath . DIRECTORY_SEPARATOR . $file . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . 'strings_english.txt' ) ) {
+					echo "Testing english language for plugin '$file' (phase 1)...<br />";
+					flush();
+					checkfile( $p_path . DIRECTORY_SEPARATOR . $p_subpath . DIRECTORY_SEPARATOR . $file . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR,  'strings_english.txt' );			
+				}
+			}
+
+			if( !is_dir( $p_path . DIRECTORY_SEPARATOR . $file ) && $p_subpath == 'lang' ) {
+				checkfile( $p_path, $file );
+			} else {
+				if ( is_dir( $p_path . DIRECTORY_SEPARATOR . $file ) )
+					checklangdir( $p_path, $file);
+			}
+		}
+		closedir( $handle );
+	}
+}
+
+
+function checkfile( $p_path, $p_file, $p_quiet = false ) {
+		if( !$p_quiet) {
+			echo "Testing language file '$p_file' (phase 1)...<br />";
+			flush();
+		}
+
+		$file = $p_path . $p_file;
+
+		set_error_handler( 'lang_error_handler' );
+		$result = checktoken( $file, ($p_file == 'strings_english.txt' ? true : false) );
+		restore_error_handler();
+
+		if( !$result ) {
+			print_error( "FAILED: Language file '$p_file' failed at phase 1." );
+			if( $p_quiet ) {
+				return false;
+			}
+		}
+
+		if( !$p_quiet ) {
+			echo "Testing language file '$p_file' (phase 2)...<br />";
+			flush();
+		} else {
+			return true;
+		}
+
+		set_error_handler( 'lang_error_handler' );
+		ob_start();
+		$result = eval( "require_once( '$file' );" );
+		$data = ob_get_contents();
+		ob_end_clean();
+		restore_error_handler();
+
+		if( $result === false ) {
+			print_error( "FAILED: Language file '$p_file' failed at eval" );
+			if( $p_quiet ) {
+				return false;
+			}
+		}
+
+		if( !empty( $data ) ) {
+			print_error( "FAILED: Language file '$p_file' failed at require_once (data output: " . var_export( $data, true ) . ")" );
+			if( $p_quiet ) {
+				return false;
+			}
+		}
+		return true;
+}
+
+$basevariables = Array();
+
+function checktoken( $file, $base = false ) {
+	$in_php_code = false;
+	$variables = Array();
+	global $basevariables;	
+	$current_var = null;
+	$last_token = 0;
+	$set_variable = false;
+	$variablearr = false;
+	$twopartstring = false;
+	$need_end_variable = false;
+	$source = file_get_contents( $file );
+	$tokens = @token_get_all( $source );
+	$expectendarr = false;
+	$settingvariable = false;
+	$pass = true;
+	$fatal = false;
+	foreach( $tokens as $token ) {
+		$last_token2 = 0;
+		if( is_string( $token ) ) {
+			switch( $token ) {
+				case '=':
+					if( $last_token != T_VARIABLE ) {
+						print_error( "ERROR: = sign without variable" );
+						$pass = false;
+					}
+					$set_variable = true;
+					break;
+				case '[':
+					if( $last_token != T_VARIABLE ) {
+						$pass = false;
+					}
+					$variablearr = true;
+					break;
+				case ']':
+					if( !$expectendarr ) {
+						$pass = false;
+					}
+					$expectendarr = false;
+					break;
+				case ';':
+					if( !$need_end_variable ) {
+						print_error( "ERROR: function seperator found at unexpected location (line $line)" );
+						$pass = false;
+					}
+					$need_end_variable = false;
+					break;
+				case '.':
+					if( $last_token == T_CONSTANT_ENCAPSED_STRING ) {
+						$twopartstring = true;
+					} else {
+						print_error( "ERROR: string concat found at unexpected location (line $line)" );
+						$pass = false;
+					}
+					break;
+				default:
+					print_error( "UNKNOWN TOKEN" . $token );
+					$pass = false;
+					break;
+			}
+		} else {
+			// token array
+			list( $id, $text, $line ) = $token;
+
+			if( $id == T_WHITESPACE || $id == T_COMMENT || $id == T_DOC_COMMENT || $id == T_ML_COMMENT ) {
+				continue;
+			}
+			if( $need_end_variable ) {
+				if( $twopartstring && $id == T_CONSTANT_ENCAPSED_STRING ) {
+					$twopartstring = false;
+					continue;
+				}
+				if( $settingvariable && $id == T_STRING ) {
+					$last_token = T_VARIABLE;
+					$expectendarr = true;
+					continue;
+				}
+
+				print_error( "ERROR" . $id . token_name( $id ) . $text . $line );
+				$pass = false;
+			}
+
+			switch( $id ) {
+				case T_OPEN_TAG:
+					$in_php_code = true;
+					break;
+				case T_CLOSE_TAG:
+					$in_php_code = false;
+					break;
+				case T_INLINE_HTML:
+					print_error( "ERROR: Whitespace in language file outside of PHP code block (line $line)" );
+					$pass = false;
+					break;
+				case T_VARIABLE:
+					if( $set_variable && $current_var != null ) {
+						$need_end_variable = true;
+						$settingvariable = true;
+						$current_var = null;
+						break;
+					}
+					$current_var = $text;
+					break;
+				case T_STRING:
+					if( $variablearr ) {
+						$current_var .= $text;
+						if( !defined( $text ) ) {
+							print_error( "undefined constant: $current_var" );
+						}
+					} else {
+						print_error( "ERROR: T_STRING found at unexpected location (line $line)" );
+						$pass = false;
+					}
+					if ( strpos($current_var,"\n") !== false ) {
+						print_error( "PARSER - NEW LINE IN STRING: " . $id . token_name( $id ) . $text . $line );
+						$pass = false;
+						$fatal = true;
+					}					
+					$last_token2 = T_VARIABLE;
+					$expectendarr = true;
+					break;
+				case T_CONSTANT_ENCAPSED_STRING:
+					if ( $token[1][0] != '\'' ) {
+							print_error( "ERROR: Language strings should be single-quoted (line $line)" );						
+					}
+					if( $last_token == T_VARIABLE && $set_variable && $current_var != null ) {
+						if( isset( $variables[$current_var] ) ) {
+							print_error( "ERROR: duplicate language string ($current_var ) (line $line)" );
+						} else {
+							$variables[$current_var] = $text;
+						}
+						
+						if ( $base ) {
+							// english
+							//if( isset( $basevariables[$current_var] ) ) {
+							//	print_error( "WARN: english string redefined - plugin? $current_var" );
+							//}
+							$basevariables[$current_var] = true;
+						} else {
+							if( !isset( $basevariables[$current_var] ) ) {
+								print_error( "WARN: String defined in non-english file that does not exist ( $current_var )" ); 
+							//} else {
+								// missing translation
+							}
+						}
+						
+					}
+					if ( strpos($current_var,"\n") !== false ) {
+						print_error( "PARSER - NEW LINE IN STRING: " . $id . token_name( $id ) . $text . $line );
+						$pass = false;
+						$fatal = true;
+					}
+					$current_var = null;
+					$need_end_variable = true;
+					break;
+				default:
+					// if (!$in_php_code)
+					print_error( "PARSER: " . $id . token_name( $id ) . $text . $line );
+					$pass = false;
+					break;
+			}
+
+			$last_token = $id;
+			if( $last_token2 > 0 ) {
+				$last_token = $last_token2;
+			}
+		}
+		
+		if ($fatal)
+			break;
+	}
+
+	return $pass;
+}
+
+function lang_error_handler( $p_type, $p_error, $p_file, $p_line, $p_context ) {
+	print_error( "error handler thrown: " . $p_type . '<br />' . $p_error . '<br />' . $p_file . '<br />' . $p_line . '<br />' . $p_context );
+}
+
+function print_error( $p_string ) {
+	echo "<font color='red'>ERROR: ", $p_string, '</font><br />';
+}
+
+html_page_bottom();
diff --git a/admin/upgrade_unattended.php b/admin/upgrade_unattended.php
new file mode 100644
index 0000000..0be5995
--- /dev/null
+++ b/admin/upgrade_unattended.php
@@ -0,0 +1,154 @@
+<?php
+# MantisBT - a php based bugtracking system
+
+# MantisBT 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.
+#
+# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * @package MantisBT
+ * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+ * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
+ * @link http://www.mantisbt.org
+ */
+
+@set_time_limit( 0 );
+
+$g_skip_open_db = true;  # don't open the database in database_api.php
+/**
+ * MantisBT Core API's
+ */
+require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
+$g_error_send_page_header = false; # suppress page headers in the error handler
+
+$g_failed = false;
+
+/* This script is probably meant to be executed from PHP CLI and hence should
+ * not be interpreted as text/html. However saying that, we do call gpc_
+ * functions that only make sense in PHP CGI mode. Given this mismatch we'll
+ * just assume for now that this script is meant to be used from PHP CGI and
+ * the output is meant to be text/plain. We also need to prevent Internet
+ * Explorer from ignoring our MIME type and using it's own MIME sniffing.
+ */
+header( 'Content-Type: text/plain' );
+header( 'X-Content-Type-Options: nosniff' );
+
+/**
+ * Print the result of an upgrade step.
+ * 
+ * @param integer $result       GOOD or BAD.
+ * @param bool    $p_hard_fail  If result is BAD, sets the global failure flag.
+ * @param string  $p_message    The message describing the upgrade step.
+ * @access private
+ */
+function print_test_result( $p_result, $p_hard_fail = true, $p_message = '' ) {
+	global $g_failed;
+	if( BAD == $p_result ) {
+		if( $p_hard_fail ) {
+			$g_failed = true;
+			echo " - ERROR: ";
+		} else {
+			echo " - WARNING: ";
+		}
+		if( '' != $p_message ) {
+			echo $p_message;
+		}
+	}
+
+	if( GOOD == $p_result ) {
+		echo " - GOOD";
+	}
+	echo "\n";
+}
+
+$result = @db_connect( config_get_global( 'dsn', false ), config_get_global( 'hostname' ),
+	config_get_global( 'db_username' ), config_get_global( 'db_password' ),
+	config_get_global( 'database_name' ) );
+
+if( false == $result ) {
+	echo "Opening connection to database " .
+		config_get_global( 'database_name' ) .
+		" on host " . config_get_global( 'hostname' ) .
+		" with username " . config_get_global( 'db_username' ) .
+		" failed: " . db_error_msg() . "\n";
+	exit( 1 );
+}
+
+# check to see if the new installer was used
+if ( -1 == config_get( 'database_version', -1 ) ) {
+	echo "Upgrade from the current installed MantisBT version is no longer supported.  If you are using MantisBT version older than 1.0.0, then upgrade to v1.0.0 first.";
+	exit( 1 );
+}
+
+# read control variables with defaults
+$f_hostname = gpc_get( 'hostname', config_get( 'hostname', 'localhost' ) );
+$f_db_type = gpc_get( 'db_type', config_get( 'db_type', '' ) );
+$f_database_name = gpc_get( 'database_name', config_get( 'database_name', 'bugtrack' ) );
+$f_db_username = gpc_get( 'db_username', config_get( 'db_username', '' ) );
+$f_db_password = gpc_get( 'db_password', config_get( 'db_password', '' ) );
+$f_db_exists = gpc_get_bool( 'db_exists', false );
+
+# install the tables
+if ( !preg_match( '/^[a-zA-Z0-9_]+$/', $f_db_type ) ||
+     !file_exists( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'adodb' . DIRECTORY_SEPARATOR . 'drivers' . DIRECTORY_SEPARATOR . 'adodb-' . $f_db_type . '.inc.php' ) ) {
+	echo 'Invalid db type ' . htmlspecialchars( $f_db_type ) . '.';
+	exit;
+}
+
+$GLOBALS['g_db_type'] = $f_db_type; # database_api references this
+require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'schema.php' );
+$g_db = ADONewConnection( $f_db_type );
+
+echo "\nPost 1.0 schema changes\n";
+echo "Connecting to database... ";
+$t_result = @$g_db->Connect( $f_hostname, $f_db_username, $f_db_password, $f_database_name );
+
+if( false == $t_result ) {
+	echo "failed\n";
+	exit( 1 );
+}
+
+echo "OK\n";
+
+$g_db_connected = true; # fake out database access routines used by config_get
+$t_last_update = config_get( 'database_version', -1, ALL_USERS, ALL_PROJECTS );
+$lastid = count( $upgrade ) - 1;
+$i = $t_last_update + 1;
+
+while(( $i <= $lastid ) && !$g_failed ) {
+	echo 'Create Schema ( ' . $upgrade[$i][0] . ' on ' . $upgrade[$i][1][0] . ' )';
+	$dict = NewDataDictionary( $g_db );
+
+	if( $upgrade[$i][0] == 'InsertData' ) {
+		$sqlarray = call_user_func_array( $upgrade[$i][0], $upgrade[$i][1] );
+	} else {
+		$sqlarray = call_user_func_array( Array( $dict, $upgrade[$i][0] ), $upgrade[$i][1] );
+	}
+
+	$ret = $dict->ExecuteSQLArray( $sqlarray );
+	if( $ret == 2 ) {
+		print_test_result( GOOD );
+		config_set( 'database_version', $i );
+	} else {
+		print_test_result( BAD, true, $sqlarray[0] . '<br />' . $g_db->ErrorMsg() );
+	}
+
+	$i++;
+}
+
+if( false == $g_failed ) {
+	exit( 0 );
+}
+
+exit( 1 );
+
+# vim: noexpandtab tabstop=4 softtabstop=0:
diff --git a/admin/upgrade_warning.php b/admin/upgrade_warning.php
new file mode 100644
index 0000000..767571b
--- /dev/null
+++ b/admin/upgrade_warning.php
@@ -0,0 +1,84 @@
+<?php
+# MantisBT - a php based bugtracking system
+
+# MantisBT 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.
+#
+# MantisBT 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 MantisBT.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * @package MantisBT
+ * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+ * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
+ * @link http://www.mantisbt.org
+ */
+/**
+ * MantisBT Core API's
+ */
+require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
+
+access_ensure_global_level( config_get_global( 'admin_site_threshold' ) );
+
+$g_error_send_page_header = false; # suppress page headers in the error handler
+
+# @@@ upgrade list moved to the bottom of upgrade_inc.php
+
+$f_advanced = gpc_get_bool( 'advanced', false );
+
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+<title>MantisBT Administration - Check Installation </title>
+<link rel="stylesheet" type="text/css" href="admin.css" />
+</head>
+<body>
+
+<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
+	<tr class="top-bar">
+		<td class="links">
+			[ <a href="index.php">Back to Administration</a> ]
+		</td>
+		<td class="title">
+			Upgrade Installation
+		</td>
+	</tr>
+</table>
+<br /><br />
+
+<p><b>WARNING:</b> - Always backup your database data before upgrading.  For example, if you use a mysql database, From the command line you can do this with the mysqldump command.</p>
+<p>eg:</p>
+<p><tt>mysqldump -u[username] -p[password] [database_name] > [filename]</tt></p>
+<p>This will dump the contents of the specified database into the specified filename.</p>
+<p>If an error occurs you can re-create your previous database by just importing your backed up database data.  You'll need to drop and recreate your database (or remove each table).</p>
+<p><tt>mysql -u[username] -p[password] [database_name] < [filename]</tt></p>
+
+<p>Upgrades may take several minutes depending on the size of your database.</p>
+
+<div align="center">
+	<table width="80%" bgcolor="#222222" border="0" cellpadding="10" cellspacing="1">
+		<tr bgcolor="#ffffff">
+				<?php
+# check to see if the new installer was used
+if( -1 != config_get( 'database_version', -1 ) ) {
+	?>
+				<td align="center" nowrap="nowrap"><p>When you have backed up your database click the link below to continue</p>[ <a href="install.php">Upgrade Now</a> ]</td>
+				<?php
+}
+else {?>
+				<td align="center" nowrap="nowrap"><p>You aware to be running an old (pre 1.1.0) release of MantisBT. To update to this release of mantis, you must first update your installation to 1.1</td>
+				<?php
+}?>
+		</tr>
+	</table>
+</div>
+</body>
+</html>
diff --git a/core/authentication_api.php b/core/authentication_api.php
index c12ff89..a8cb4f6 100644
--- a/core/authentication_api.php
+++ b/core/authentication_api.php
@@ -222,6 +222,8 @@ function auth_cas_logout()
         }
 }
 
+
+
 /**
  * Check that there is a user logged-in and authenticated
  * If the user's account is disabled they will be logged out
@@ -352,10 +354,11 @@ function auth_attempt_login( $p_username, $p_password, $p_perm_login = false ) {
 	$t_login_method = config_get( 'login_method' );
 
 	if ( false === $t_user_id ) {
-                if ( in_array( $t_login_method, array( BASIC_AUTH, CAS_AUTH ) ) ) {
+		if ( BASIC_AUTH == $t_login_method ) {
+                        if ( in_array( $t_login_method, array( BASIC_AUTH, CAS_AUTH ) ) ) {
                         # attempt to create the user if using BASIC_AUTH or CAS_AUTH
                         # ( note: CAS_AUTH must have $g_allow_blank_email == ON )
-	          	$t_auto_create = true;
+			$t_auto_create = true;
 		} else if ( LDAP == $t_login_method && ldap_authenticate_by_username( $p_username, $p_password ) ) {
 			$t_auto_create = true;
 		} else {
-- 
1.7.5.2


From b99284735fd0241430ebb4d083203c42dc3dc041 Mon Sep 17 00:00:00 2001
From: Tom Misilo <misilot@fit.edu>
Date: Tue, 31 May 2011 18:21:58 -0400
Subject: [PATCH 4/4] Removed the BASIC_AUTH == $t_login_method that I forgot
 to before Signed-off-by: misilot <misilot@fit.edu>

---
 core/authentication_api.php |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/core/authentication_api.php b/core/authentication_api.php
index a8cb4f6..7eb5f2a 100644
--- a/core/authentication_api.php
+++ b/core/authentication_api.php
@@ -354,8 +354,7 @@ function auth_attempt_login( $p_username, $p_password, $p_perm_login = false ) {
 	$t_login_method = config_get( 'login_method' );
 
 	if ( false === $t_user_id ) {
-		if ( BASIC_AUTH == $t_login_method ) {
-                        if ( in_array( $t_login_method, array( BASIC_AUTH, CAS_AUTH ) ) ) {
+                if ( in_array( $t_login_method, array( BASIC_AUTH, CAS_AUTH ) ) ) {
                         # attempt to create the user if using BASIC_AUTH or CAS_AUTH
                         # ( note: CAS_AUTH must have $g_allow_blank_email == ON )
 			$t_auto_create = true;
-- 
1.7.5.2

