Upgrade Script #4 | > Script written by Matt Mecham | > Date started: 23rd October 2002 | +-------------------------------------------------------------------------- */ //----------------------------------------------- // 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 'index': do_index(); break; case 'insert': do_insert(); break; case 'templates': do_templates(); break; case 'cleanup': do_cleanup(); break; default: do_intro(); break; } function do_cleanup() { global $std, $template, $root, $DB; // Insert new CSS $DB->query("INSERT INTO ibf_css (css_name, css_text, css_comments) VALUES ('Invision Style Sheet (NEW)', 'form { display:inline }\r\nTABLE, TR, TD { font-family: Verdana, Tahoma, Arial; font-size: 8.5pt; color: #000000 }\r\na:link, a:visited, a:active { text-decoration: underline; color: #000000 }\r\na:hover { color: #465584 }\r\n.hlight { background-color: #DFE6EF }\r\n.dlight { background-color: #EEF2F7 }\r\n.mainbg { background-color: #FFFFFF }\r\n.mainfoot { background-color: #BCD0ED }\r\n.forum1 { background-color: #DFE6EF }\r\n.forum2 { background-color: #E4EAF2 }\r\n.post1 { background-color: #F5F9FD }\r\n.post2 { background-color: #EEF2F7 }\r\n.posthead { background-color: #E4EAF2 }\r\n\r\n.postbak { background-color: #D2D2D0 }\r\n.title { background-color: #C4DCF7 }\r\n.row1 { background-color: #EEF2F7 }\r\n.row2 { background-color: #F5F9FD }\r\n.postsep { background-color: #C7D2E0; height: 1px }\r\n\r\n.signature { font-size: 7.5pt; color: #333399 }\r\n.postdetails { font-size: 7.5pt }\r\n.postcolor, #postcolor { font-size: 9pt; line-height: 160% }\r\n.membertitle { font-size: 10px; line-height: 150%; color: #000000 }\r\n.normalname { font-size: 12px; font-weight: bold; color: #000033; padding-bottom: 2px }\r\n.normalname a:link, .normalname a:visited, .normalname a:active { text-decoration: underline; color: #000033; padding-bottom: 2px }\r\n.unreg { font-size: 11px; font-weight: bold; color: #990000 }\r\n.highlight { color: #FF0000 }\r\n.highlight a:link, .highlight a:visited, .highlight a:active { text-decoration: underline; color: #FF0000 }\r\n.highlight a:hover { text-decoration: underline }\r\n.desc { font-size: 8.0pt; color: #434951 }\r\n.copyright { font-family: Verdana, Tahoma, Arial; font-size: 7.5pt; line-height: 12px }\r\n.category { font-weight: bold; line-height: 150%; color: #4C77B6; background-color: #C2CFDF }\r\n.category a:link, #category a:visited, #category a:active { text-decoration: none; color: #4C77B6 }\r\n.postfoot {\r\n\r\n font-weight:bold;\r\n\r\n color:#3A4F6C;\r\n\r\n height: 24px;\r\n\r\n background-color: #D1DCEB;\r\n\r\n}\r\n.titlefoot { font-weight: bold; color: #3A4F6C; height: 24px; background-color: #BCD0ED }\r\n.titlemedium {\r\n\r\n font-weight:bold;\r\n color:#3A4F6C;\r\n\r\n height: 30px;\r\n\r\n background-color: #9FBCE3;\r\n \r\n background-image: url(style_images/<#IMG_DIR#>/tile_sub.gif);\r\n\r\n}\r\n.titlemedium a:link, .titlefoot a:link, .titlemedium a:visited, .titlefoot a:visited, .titlemedium a:active, .titlefoot a:active { text-decoration: underline; color: #3A4F6C }\r\n.titlemedium a:hover, .subtitle a:hover, .titlefoot a:hover { text-decoration: underline; color: #000000 }\r\n.maintitle {\r\n\r\n color:#FFFFFF;\r\n\r\n font-size: 9.5pt;\r\n \r\n height: 26px;\r\n \r\n background-image: url(style_images/<#IMG_DIR#>/tile_back.gif);\r\n\r\n}\r\n.edit { font-size: 9px }\r\n.fancyborder { border: 1px dashed #999999 }\r\n.solidborder { border: 1px solid #999999 }\r\n.maintitle a:link, .maintitle a:visited, .maintitle a:active { text-decoration: none; color: #FFFFFF }\r\n.maintitle a:hover { text-decoration: underline }\r\n.nav { font-weight: bold; color: #000000; font-size: 8.5pt }\r\n.pagetitle { color: #4C77B6; font-size: 18px; font-weight: bold; letter-spacing: -1px; line-height: 120% }\r\n.useroptions { background-color: #598CC3; height: 25px; font-weight: bold; color: #FFFFFF }\r\n.useroptions a:link, .useroptions a:visited,.useroptions a:active { text-decoration: none; color: #FFFFFF }\r\n.bottomborder { border-bottom: 1px dashed #D2D2D0 }\r\n.linkthru { color: #000000; font-size:8.5pt }\r\n.linkthru a:link, .linkthru a:active { text-decoration: underline; color: #000000 }\r\n.linkthru a:visited { text-decoration: underline; color: #000000 }\r\n.linkthru a:hover { text-decoration: underline; color: #465584 }\r\n#QUOTE { font-family: Verdana, Arial; font-size: 8pt; color: #333333; background-color: #FAFCFE; border: 1px solid Black; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px }\r\n#CODE { font-family: Verdana, Arial; font-size: 8pt; color: #333333; background-color: #FAFCFE; border: 1px solid Black; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px }\r\n.codebuttons { font-size: 8.5pt; font-family: verdana, helvetica, sans-serif; vertical-align: middle }\r\n.forminput { font-size: 9pt; font-family: verdana, helvetica, sans-serif; vertical-align: middle }\r\n.textinput { font-size: 9pt; font-family: verdana, helvetica, sans-serif; vertical-align: middle }\r\n.input { font-size: 9pt; font-family: verdana, helvetica, sans-serif; vertical-align: middle }\r\n', NULL)"); $new_css_id = $DB->get_insert_id(); // Get old skin details $DB->query("SELECT * FROM ibf_skins WHERE default_set=1"); $old_skin = $DB->fetch_row(); // First off, change all old skin sets to hidden $DB->query("UPDATE ibf_skins SET hidden=1, default_set=0"); // Change upload perms.. $DB->query("UPDATE ibf_forums SET upload_perms=''"); // Get a new ID for the new skin set $barney = array( 'sname' => "IBF Skin Set (NEW)", 'set_id' => 1, 'tmpl_id' => $old_skin['tmpl_id'], 'img_dir' => 1, 'css_id' => $new_css_id, 'hidden' => 0, 'default_set'=> 1, 'macro_id' => 1, ); $DB->query("SELECT MAX(sid) as new_id FROM ibf_skins"); $row = $DB->fetch_row(); $barney['sid'] = $row['new_id'] + 1; $db_string = $DB->compile_db_insert_string( $barney ); $DB->query("INSERT INTO ibf_skins (".$db_string['FIELD_NAMES'].") VALUES(".$db_string['FIELD_VALUES'].")"); // Change member skins to default $DB->query("UPDATE ibf_members SET skin=NULL"); $template->print_top('Upgrade Complete'); $template->contents .= " • Upgrade from v1.0.X to v1.1
The upgrade was successful!

Forum Upload Permission Changes
Note, due to the way that the upload permissions are handled in v1.1, the upload permissions for all forums have been removed. You will need to log into your Admin CP and set up the permissions using the new system.

Skin Set Changes
The skin, templates and macros are handled completely differently in this new version. Unfortunately v1.0.X skins are not compatible with this new version. All old skin sets have been set to 'hidden' and all members have been moved onto the new default skin.

The new skin set will use the directory 'style_images/1/' as the image directory. Ensure that all the images in there have been updated from the download zip. If the directory does not exist, create it and upload the contents of the folder 'style_images/1/' from the zip file.

PLEASE REMOVE THIS UPGRADE SCRIPT AS SOON AS POSSIBLE
"; $template->output(); } //+--------------------------------------- function do_templates() { global $std, $template, $root, $DB; //----------------------------------- // Lets open the style file //----------------------------------- $style_file = $root.'install_templates.txt'; if ( ! file_exists($style_file) ) { install_error("Could not locate '$style_file'.

Check to ensure that this file exists in the same location as this script.

You may need to enter a value for the root path in this installer script, to do this, simply open up this script in a text editor and enter a value in \$root - remember to add a trailing slash. NT users will need to use double backslashes"); } if ( $fh = fopen( $style_file, 'r' ) ) { $data = fread($fh, filesize($style_file) ); fclose($fh); } else { install_error("Could open '$style_file'"); } if (strlen($data) < 100) { install_error("Err 1:'$style_file' is incomplete, please re-upload a fresh copy over the existing copy on the server'"); } // Chop up the data file. $template_rows = explode( "||~&~||", $data ); $crows = count($template_rows); if ( $crows < 100 ) { install_error("Err2: (Found $crows rows) '$style_file' is incomplete, please re-upload a fresh copy over the existing copy on the server'"); } //----------------------------------- // Lets populate the database! //----------------------------------- foreach( $template_rows as $q ) { $DB->error = ""; $q = trim($q); //print $q; if (strlen($q) < 5) { continue; } $DB->query("INSERT INTO ibf_skin_templates (set_id, group_name, section_content, func_name, func_data, updated, can_remove) VALUES $q"); if ( $DB->error != "" ) { install_error( "mySQL Error: ".$DB->error ); } } //--------------------------------------- $template->print_top('Step 5 Complete'); $template->contents .= " • Upgrade from v1.0.X to v1.1
The new templates been inserted

You may now proceed to the next step.
"; $template->contents .= "
Proceed to Step 6: Finishing Up >>"; $template->output(); } //+--------------------------------------- function do_insert() { global $std, $template, $root, $DB; run_sql('insert'); $template->print_top('Step 4 Complete'); $template->contents .= " • Upgrade from v1.0.X to v1.1
The new data has been inserted

You may now proceed to the next step.
"; $template->contents .= "
Proceed to Step 5: Insert New Templates >>"; $template->output(); } //+--------------------------------------- function do_index() { global $std, $template, $root, $DB; run_sql('index'); $template->print_top('Step 3 Complete'); $template->contents .= " • Upgrade from v1.0.X to v1.1
The indexes have been created

You may now proceed to the next step.
"; $template->contents .= "
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.0.X to v1.1
The tables have been altered

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

You may now proceed to the next step.
"; $template->contents .= "
Proceed to Step 2: Alter Existing Tables >>"; $template->output(); } //+--------------------------------------- function do_intro() { global $std, $template, $root; $template->print_top('Welcome'); $template->contents .= " • Upgrade from v1.0.X to v1.1
Welcome to the Invision Board Upgrade Utility

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.

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

This installer will alter the database for the new format and install the skin and macro files.

Please ensure that 'install_templates.txt' is uploaded and in the same directory as this script.

Also, please ensure that all the new skin_*.php files have been uploaded into 'Skin/s1' before starting this upgrader. If you wish to keep the old skin data in that directory, please copy the directory now before proceeding. Running this installer will set all existing skins to 'hidden' and install a new default skin pack
"; $style_file = $root."install_templates.txt"; $warnings = array(); if ( ! file_exists($style_file) ) { $warnings[] = "Cannot locate the file 'install_templates.txt'. This should be uploaded into the same directory as this script!"; } if ( count($warnings) > 0 ) { $err_string = ""; $template->contents .= " • WARNING!
The following errors must be rectified before continuing!

$err_string
"; } else { $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 Upgrader :: $title

"; } } 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( "/