Upgrade Script #5 | > Script written by Matt Mecham | > Date started: 24th September 2003 on a chilly but sunny day | +-------------------------------------------------------------------------- */ //----------------------------------------------- // USER CONFIGURABLE ELEMENTS //----------------------------------------------- // Root path $root_path = "./"; //----------------------------------------------- // NO USER EDITABLE SECTIONS BELOW //----------------------------------------------- error_reporting (E_ERROR | E_WARNING | E_PARSE); set_magic_quotes_runtime(0); $template = new template; $std = new installer; $VARS = $std->parse_incoming(); //-------------------------------- // Import $INFO, now! //-------------------------------- require $root_path."conf_global.php"; //-------------------------------- // Load the DB driver and such //-------------------------------- $INFO['sql_driver'] = !$INFO['sql_driver'] ? 'mySQL' : $INFO['sql_driver']; $to_require = $root_path."sources/Drivers/".$INFO['sql_driver'].".php"; require ($to_require); $DB = new db_driver; $DB->obj['sql_database'] = $INFO['sql_database']; $DB->obj['sql_user'] = $INFO['sql_user']; $DB->obj['sql_pass'] = $INFO['sql_pass']; $DB->obj['sql_host'] = $INFO['sql_host']; $DB->obj['sql_tbl_prefix'] = $INFO['sql_tbl_prefix']; // Get a DB connection $DB->connect(); // Switch off auto_error $DB->return_die = 1; //--------------------------------------- // Sort out what to do.. //--------------------------------------- switch($VARS['a']) { case 'tables': do_tables(); break; case 'alter': do_alter(); break; case 'insert': do_insert(); break; default: do_intro(); break; } //+--------------------------------------- //+--------------------------------------- function do_insert() { global $std, $template, $root, $DB; run_sql('insert'); $template->print_top('Step 4 Complete'); $template->contents .= "
Upgrade from v1.2 to v1.3
The new data has been inserted
The upgrade is now complete and you may go to your board!

PLEASE REMOVE THIS UPGRADE SCRIPT AS SOON AS POSSIBLE
 
"; $template->output(); } //+--------------------------------------- function do_index() { global $std, $template, $root, $DB; run_sql('index'); $template->print_top('Step 3 Complete'); $template->contents .= "
Upgrade from v1.2 to v1.3
The indexes have been adjusted
You may now proceed to the next step.

Proceed to Step 4: Insert New Data >>
 
"; $template->output(); } //+--------------------------------------- function do_alter() { global $std, $template, $root, $DB; run_sql('alter'); $template->print_top('Step 2 Complete'); $template->contents .= "
Upgrade from v1.2 to v1.3
The tables have been altered
You may now proceed to the next step.

Proceed to Step 3: Insert New Data >>
 
"; $template->output(); } //+--------------------------------------- function do_tables() { global $std, $template, $root, $DB; run_sql('tables'); $template->print_top('Step 1 Complete'); $template->contents .= "
Upgrade from v1.2 to v1.3
The new tables have been created
You may now proceed to the next step.

Proceed to Step 2: Alter Existing Tables >>
 
"; $template->output(); } //+--------------------------------------- function do_intro() { global $std, $template, $root; $template->print_top('Welcome'); $template->contents .= "
Intro Welcome to IPB

Welcome to the Invision Board Upgrade Utility
Invision Power Board 1.2 -> Invision Power Board 1.3

Before you run this upgrade tool, please ensure that ALL of the source, language and skin files have been uploaded into the corresponding directories on your server as noted in the documentation included with the download package.

This script should be in the root forum directory (the same directory that index.php is in).

Once you have used this script, you can use the new 'Skin Version Control' to update your skins. "; $template->contents .= "

Proceed to Step 1: Create New Tables >>
"; $template->output(); } function install_error($msg="") { global $std, $template, $root; $template->print_top('Warning!'); $template->contents .= "
• WARNING!
The following errors must be rectified before continuing!
Please go back and try again!

$msg
"; $template->output(); } //+------------------------------------------------- // GLOBAL ROUTINES //+------------------------------------------------- function fatal_error($message="", $help="") { echo("$message

$help"); exit; } //+-------------------------------------------------------------------------- // CLASSES //+-------------------------------------------------------------------------- class template { var $contents = ""; function output() { echo $this->contents; echo "


© 2002 Invision Board (www.invisionboard.com)
"; exit(); } //-------------------------------------- function print_top($title="") { $this->contents = " Invision Power Board Set Up :: $title
Invision Power Board Installer
 

"; } } class installer { function parse_incoming() { global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_CLIENT_IP, $REQUEST_METHOD, $REMOTE_ADDR, $HTTP_PROXY_USER, $HTTP_X_FORWARDED_FOR; $return = array(); if( is_array($HTTP_GET_VARS) ) { while( list($k, $v) = each($HTTP_GET_VARS) ) { //$k = $this->clean_key($k); if( is_array($HTTP_GET_VARS[$k]) ) { while( list($k2, $v2) = each($HTTP_GET_VARS[$k]) ) { $return[$k][ $this->clean_key($k2) ] = $this->clean_value($v2); } } else { $return[$k] = $this->clean_value($v); } } } // Overwrite GET data with post data if( is_array($HTTP_POST_VARS) ) { while( list($k, $v) = each($HTTP_POST_VARS) ) { //$k = $this->clean_key($k); if ( is_array($HTTP_POST_VARS[$k]) ) { while( list($k2, $v2) = each($HTTP_POST_VARS[$k]) ) { $return[$k][ $this->clean_key($k2) ] = $this->clean_value($v2); } } else { $return[$k] = $this->clean_value($v); } } } return $return; } function clean_key($key) { if ($key == "") { return ""; } $key = preg_replace( "/\.\./" , "" , $key ); $key = preg_replace( "/\_\_(.+?)\_\_/" , "" , $key ); $key = preg_replace( "/^([\w\.\-\_]+)$/", "$1", $key ); return $key; } function clean_value($val) { if ($val == "") { return ""; } $val = preg_replace( "/&/" , "&" , $val ); $val = preg_replace( "//" , "-->" , $val ); $val = preg_replace( "/