IPB UPGRADE 1.x -> 2.0! | > Script written by Matt Mecham | > Date started: 21st April 2004 | > Interesting fact: Radiohead rock (Rain down, Rain down, come on rain down. On me. From a great height) +-------------------------------------------------------------------------- */ /** * Upgrade wrapper * * Set-up and load module to run * * @package InvisionPowerBoard * @author Matt Mecham * @version 2.1 */ /** * Script type * */ define( 'IPB_THIS_SCRIPT', 'upgrade' ); define( 'IPB_LOAD_SQL' , 'admin_queries' ); require_once( '../init.php' ); //----------------------------------------------- // USER CONFIGURABLE ELEMENTS //----------------------------------------------- define( 'THIS_PATH' , './' ); define( 'UPGRADE_DIR', 'upgrade' ); $INFO = array(); //-------------------------------- // Require our global functions //-------------------------------- require ROOT_PATH . "conf_global.php"; require ROOT_PATH . "sources/ipsclass.php"; require KERNEL_PATH . "class_converge.php"; require THIS_PATH . "core/functions.php"; require THIS_PATH . "core/template.php"; # Initiate super-class $ipsclass = new ipsclass(); $ipsclass->vars = $INFO; //-------------------------------- // The clocks a' tickin' //-------------------------------- $Debug = new Debug; $Debug->startTimer(); //-------------------------------- // Load the DB driver and such //-------------------------------- $ipsclass->init_db_connection(); //-------------------------------- // Set up our vars //-------------------------------- $ipsclass->parse_incoming(); //-------------------------------- // Set converge //-------------------------------- $ipsclass->converge = new class_converge( $ipsclass->DB ); //-------------------------------- // Initialize the FUNC //-------------------------------- $ipsclass->initiate_ipsclass(); //-------------------------------- // Set up our vars //-------------------------------- $ipsclass->core = new core_functions(); $ipsclass->core->ipsclass =& $ipsclass; $ipsclass->template = new template(); $ipsclass->template->ipsclass =& $ipsclass; $ipsclass->base_url = 'upgrade.php?'; $ipsclass->next_step = intval($ipsclass->input['step']) + 1; //-------------------------------- // OG //-------------------------------- $runme = new upgrade_legacy(); $runme->ipsclass =& $ipsclass; $runme->autorun(); /** * main core class * */ class upgrade_legacy { var $ipsclass; function autorun() { //-------------------------------- // GET QUERIES FILE (1.2 or 1.3)? // If we have subs table, it's 1.3 //-------------------------------- if ( ! $this->ipsclass->input['version'] ) { if ( $this->_check_for_two() ) { $this->ipsclass->input['version'] = '200'; print "You appear to be running IPB 2.0.0 already and no upgrade is required."; exit(); } else if ( $this->ipsclass->DB->field_exists( 'sub_id', 'subscriptions' ) ) { $this->ipsclass->input['version'] = '103'; } else if ( $this->ipsclass->DB->field_exists( 'perm_id', 'forum_perms' ) ) { $this->ipsclass->input['version'] = '102'; } else { $this->ipsclass->input['version'] = '101'; } } switch( $this->ipsclass->input['version'] ) { case '103': define( 'UPGRADE_FROM', '1.3' ); require_once( THIS_PATH.'pre_20000/10003_'.strtolower($this->ipsclass->vars['sql_driver']).'_queries.php' ); break; case '102': define( 'UPGRADE_FROM', '1.2' ); require_once( THIS_PATH.'pre_20000/10002_'.strtolower($this->ipsclass->vars['sql_driver']).'_queries.php' ); break; case '101': define( 'UPGRADE_FROM', '1.1' ); require_once( THIS_PATH.'pre_20000/10001_'.strtolower($this->ipsclass->vars['sql_driver']).'_queries.php' ); break; } $this->ipsclass->sql = new upgrade_sql(); $this->ipsclass->sql->ipsclass =& $this->ipsclass; //-------------------------------- // Quitting on this step? //-------------------------------- if ( $this->ipsclass->input['dieafterstep'] ) { if ( $this->ipsclass->input['step'] - 1 == $this->ipsclass->input['dieafterstep'] ) { $this->ipsclass->template->content .= "
You have chosen to stop before step {$this->ipsclass->input['step']}
The upgrade script has been been stopped as requested...
"; $this->ipsclass->template->output(); exit(); } } //-------------------------------- // What in gods name are we doing? //-------------------------------- switch ($this->ipsclass->input['act']) { case 'work': if ( intval( $this->ipsclass->input['step'] ) ) { $func_to_run = 'step_'.$this->ipsclass->input['step']; } $this->$func_to_run(); break; default: $this->show_intro(); break; } } /*-------------------------------------------------------------------------*/ // STEP 25: COMPLETED - YAY!! /*-------------------------------------------------------------------------*/ function step_25() { //----------------------------------------- // Tidy up old skins //----------------------------------------- $this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'skin_sets' ) ); $this->ipsclass->DB->simple_exec(); $skins = array(); while( $r = $this->ipsclass->DB->fetch_row() ) { $skins[] = $r['set_skin_set_id']; } if ( count( $skins ) ) { $this->ipsclass->DB->simple_exec_query( array( 'delete' => 'skin_templates', 'where' => 'set_id NOT IN('.implode( ',', $skins ).')' ) ); $this->ipsclass->DB->simple_exec_query( array( 'delete' => 'skin_macro' , 'where' => 'macro_set NOT IN('.implode( ',', $skins ).')' ) ); } $this->ipsclass->DB->do_update( 'members', array( 'skin' => '' ) ); //----------------------------------------- // Convert major rows //----------------------------------------- $major_pain_in_the_ass[] = array( 'global_board_header' , 'skin_global', 'BoardHeader' ); $major_pain_in_the_ass[] = array( 'catheader_expanded' , 'skin_boards', 'CatHeader_Expanded' ); $major_pain_in_the_ass[] = array( 'pagetop' , 'skin_boards', 'PageTop' ); $major_pain_in_the_ass[] = array( 'forumrow' , 'skin_boards', 'ForumRow' ); $major_pain_in_the_ass[] = array( 'pagetop' , 'skin_forum' , 'PageTop' ); $major_pain_in_the_ass[] = array( 'tableend' , 'skin_forum' , 'TableEnd' ); $major_pain_in_the_ass[] = array( 'render_forum_row' , 'skin_forum' , 'RenderRow' ); $major_pain_in_the_ass[] = array( 'topic_page_top_new_mode', 'skin_topic' , 'PageTop' ); $major_pain_in_the_ass[] = array( 'tablefooter' , 'skin_topic' , 'TableFooter' ); $major_pain_in_the_ass[] = array( 'renderrow' , 'skin_topic' , 'RenderRow' ); foreach( $major_pain_in_the_ass as $relief => $preperation_h ) { $this->ipsclass->DB->do_update( 'skin_templates', array( 'func_name' => $preperation_h[0] ), "group_name='{$preperation_h[1]}' and func_name='{$preperation_h[2]}'" ); } //----------------------------------------- // Update 'portal' skin //----------------------------------------- $this->ipsclass->DB->do_update( 'skin_templates', array( 'group_name' => 'skin_portal' ), "group_name='skin_csite'" ); //----------------------------------------- // Drop old tables //----------------------------------------- $this->ipsclass->DB->sql_drop_table( 'templates' ); $this->ipsclass->DB->sql_drop_table( 'macro_name' ); $this->ipsclass->DB->sql_drop_table( 'skins' ); $this->ipsclass->DB->sql_drop_table( 'css' ); $this->ipsclass->template->content .= "
Your upgrade is almost complete!
The upgrade script has been run successfully and you're now running IPB 2.0.0

Now visit the upgrade system to upgrade to the latest release

All of your current skins have been moved to a pre 2.0 parent. To use these skins, you'll need to first to the following: This will complete the import of your old skins. You will need to edit them to add in the new IPB 2.0.0 sections and to account for some of the renaming procedures.
"; $this->ipsclass->template->output(); } /*-------------------------------------------------------------------------*/ // STEP 24: RECACHE & REBUILD /*-------------------------------------------------------------------------*/ function step_24() { $this->ipsclass->sql->step_24(); if ( count($this->ipsclass->sql->error) ) { $this->show_error( implode( "
", $this->ipsclass->sql->error ) ); } else { $msg = "Rebuild completed - finishing up..."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ); } } /*-------------------------------------------------------------------------*/ // STEP 23: IMPORT SETTINGS /*-------------------------------------------------------------------------*/ function step_23() { global $INFO; //----------------------------------- // Get XML //----------------------------------- require_once( KERNEL_PATH.'class_xml.php' ); $xml = new class_xml(); $xml->lite_parser = 1; //----------------------------------- // Get XML file //----------------------------------- $xmlfile = ROOT_PATH.'install/installfiles/ipb_settings.xml'; $setting_content = implode( "", file($xmlfile) ); //------------------------------- // Unpack the datafile //------------------------------- $xml->xml_parse_document( $setting_content ); //------------------------------- // pArse //------------------------------- $fields = array( 'conf_title', 'conf_description', 'conf_group', 'conf_type', 'conf_key', 'conf_value', 'conf_default', 'conf_extra', 'conf_evalphp', 'conf_protected', 'conf_position', 'conf_start_group', 'conf_end_group', 'conf_help_key', 'conf_add_cache' ); if ( ! is_array( $xml->xml_array['settingexport']['settinggroup']['setting'] ) ) { show_error("Error with ipb_settings.xml - could not process XML properly"); } foreach( $xml->xml_array['settingexport']['settinggroup']['setting'] as $id => $entry ) { if ( ! $entry['conf_key']['VALUE'] ) { continue; } $newrow = array(); $entry['conf_value']['VALUE'] = ""; if ( $INFO[ $entry['conf_key']['VALUE'] ] != "" and $INFO[ $entry['conf_key']['VALUE'] ] != $entry['conf_default']['VALUE'] ) { $entry['conf_value']['VALUE'] = $INFO[ $entry['conf_key']['VALUE'] ]; } //----------------------------------- // Special considerations? //----------------------------------- if ( $entry['conf_key']['VALUE'] == 'img_ext' ) { $entry['conf_value']['VALUE'] = str_replace( '|', ',', $entry['conf_value']['VALUE'] ); } else if ( $entry['conf_key']['VALUE'] == 'photo_ext' ) { $entry['conf_value']['VALUE'] = str_replace( '|', ',', $entry['conf_value']['VALUE'] ); } else if ( $entry['conf_key']['VALUE'] == 'avatar_ext' ) { $entry['conf_value']['VALUE'] = str_replace( '|', ',', $entry['conf_value']['VALUE'] ); } //----------------------------------- // Make PHP slashes safe //----------------------------------- $entry['conf_evalphp']['VALUE'] = str_replace( '\\', '\\\\', $entry['conf_evalphp']['VALUE'] ); foreach( $fields as $f ) { $newrow[$f] = $entry[ $f ]['VALUE']; } $db_string = $this->ipsclass->DB->compile_db_insert_string($newrow); $query = "INSERT INTO ".SQL_PREFIX."conf_settings (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")"; if ( ! $this->ipsclass->DB->query($query) ) { $this->show_error($query."

".$DB->error); } } $msg = "Settings imported, recache & rebuild next..."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ); } /*-------------------------------------------------------------------------*/ // STEP 22: IMPORT SKINS & SETTINGS /*-------------------------------------------------------------------------*/ function step_22() { //----------------------------------------- // Get old skins data //----------------------------------------- $this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'skins' ) ); $outer = $this->ipsclass->DB->simple_exec(); while( $r = $this->ipsclass->DB->fetch_row( $outer ) ) { //----------------------------------------- // Get CSS //----------------------------------------- $css = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'css', 'where' => 'cssid='.$r['css_id'] ) ); //----------------------------------------- // Get Wrapper //----------------------------------------- $wrapper = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'templates', 'where' => 'tmid='.$r['tmpl_id'] ) ); //----------------------------------------- // Insert... //----------------------------------------- $this->ipsclass->DB->do_insert( 'skin_sets', array( 'set_name' => $r['sname'], 'set_image_dir' => $r['img_dir'], 'set_hidden' => 1, 'set_default' => 0, 'set_css_method' => 0, 'set_skin_set_parent' => 3, 'set_author_email' => '', 'set_author_name' => 'IPB 2.0 Import', 'set_author_url' => '', 'set_css' => stripslashes($css['css_text']), 'set_wrapper' => stripslashes($wrapper['template']), 'set_emoticon_folder' => 'default', ) ); $new_id = $this->ipsclass->DB->get_insert_id(); //----------------------------------------- // Update templates //----------------------------------------- $this->ipsclass->DB->do_update( 'skin_templates', array( 'set_id' => $new_id ), 'set_id='.$r['set_id'] ); //----------------------------------------- // Update macros //----------------------------------------- $this->ipsclass->DB->do_update( 'skin_macro', array( 'macro_set' => $new_id ), 'macro_set='.$r['set_id'] ); } //----------------------------------- // Get XML //----------------------------------- require_once( KERNEL_PATH.'class_xml.php' ); $xml = new class_xml(); $xml->lite_parser = 1; //----------------------------------- // Get XML file (TEMPLATES) //----------------------------------- $xmlfile = ROOT_PATH.'ipb_templates.xml'; $setting_content = implode( "", file($xmlfile) ); //------------------------------- // Unpack the datafile (TEMPLATES) //------------------------------- $xml->xml_parse_document( $setting_content ); //------------------------------- // (TEMPLATES) //------------------------------- if ( ! is_array( $xml->xml_array['templateexport']['templategroup']['template'] ) ) { $this->show_error("Error with ipb_templates.xml - could not process XML properly"); } foreach( $xml->xml_array['templateexport']['templategroup']['template'] as $id => $entry ) { $newrow = array(); $newrow['group_name'] = $entry[ 'group_name' ]['VALUE']; $newrow['section_content'] = $entry[ 'section_content' ]['VALUE']; $newrow['func_name'] = $entry[ 'func_name' ]['VALUE']; $newrow['func_data'] = $entry[ 'func_data' ]['VALUE']; $newrow['set_id'] = 1; $newrow['updated'] = time(); $db_string = $this->ipsclass->DB->compile_db_insert_string($newrow); $query = "INSERT INTO ".SQL_PREFIX."skin_templates (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")"; if ( ! $this->ipsclass->DB->query($query) ) { $this->show_error($query."

".$this->ipsclass->DB->error); } } //------------------------------- // GET MACRO //------------------------------- $xmlfile = ROOT_PATH.'install/installfiles/ipb_macro.xml'; $setting_content = implode( "", file($xmlfile) ); //------------------------------- // Unpack the datafile (MACRO) //------------------------------- $xml->xml_parse_document( $setting_content ); //------------------------------- // (MACRO) //------------------------------- if ( ! is_array( $xml->xml_array['macroexport']['macrogroup']['macro'] ) ) { $this->show_error("Error with ipb_macro.xml - could not process XML properly"); } foreach( $xml->xml_array['macroexport']['macrogroup']['macro'] as $id => $entry ) { $newrow = array(); $newrow['macro_value'] = $entry[ 'macro_value' ]['VALUE']; $newrow['macro_replace'] = $entry[ 'macro_replace' ]['VALUE']; $newrow['macro_set'] = 1; $db_string = $this->ipsclass->DB->compile_db_insert_string($newrow); $query = "INSERT INTO ".SQL_PREFIX."skin_macro (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")"; if ( ! $this->ipsclass->DB->query($query) ) { $this->show_error($query."

".$this->ipsclass->DB->error); } } //------------------------------- // WRAPPER / CSS //------------------------------- require_once( ROOT_PATH.'install/installfiles/components.php' ); $wrapper_record = array( 'set_wrapper' => $WRAPPER, 'set_css' => $CSS, ); $str = $this->ipsclass->DB->compile_db_update_string($wrapper_record); $query = "UPDATE ".SQL_PREFIX."skin_sets set ".$str." where set_skin_set_id=1"; if ( ! $this->ipsclass->DB->query($query) ) { $this->show_error($query."

".$this->ipsclass->DB->error); } //----------------------------------------- // Import XML //----------------------------------------- $msg = "Skins imported, importing settings..."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ); } /*-------------------------------------------------------------------------*/ // STEP 21: OPTIMIZE: Part 2 /*-------------------------------------------------------------------------*/ function step_21() { $this->ipsclass->sql->step_21(); if ( count($this->ipsclass->sql->error) ) { $this->show_error( implode( "
", $this->ipsclass->sql->error ) ); } else { $msg = "Optimization completed, new skins import next..."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ."

".intval($this->ipsclass->sql->sqlcount)." queries run successfully!" ); } } /*-------------------------------------------------------------------------*/ // STEP 20: OPTIMIZE: Part 1 /*-------------------------------------------------------------------------*/ function step_20() { $this->ipsclass->sql->step_20(); if ( count($this->ipsclass->sql->error) ) { $this->show_error( implode( "
", $this->ipsclass->sql->error ) ); } else { $msg = "Optimization started..."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ."

".intval($this->ipsclass->sql->sqlcount)." queries run successfully!" ); } } /*-------------------------------------------------------------------------*/ // STEP 19: DROP TABLES /*-------------------------------------------------------------------------*/ function step_19() { $this->ipsclass->sql->step_19(); if ( count($this->ipsclass->sql->error) ) { $this->show_error( implode( "
", $this->ipsclass->sql->error ) ); } else { $msg = "Old tables dropped, optimization next..."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ."

".intval($this->ipsclass->sql->sqlcount)." queries run successfully!" ); } } /*-------------------------------------------------------------------------*/ // STEP 18: INSERTS /*-------------------------------------------------------------------------*/ function step_18() { $this->ipsclass->sql->step_18(); if ( count($this->ipsclass->sql->error) ) { $this->show_error( implode( "
", $this->ipsclass->sql->error ) ); } else { $msg = "Inserts completed, dropping old tables next..."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ."

".intval($this->ipsclass->sql->sqlcount)." queries run successfully!" ); } } /*-------------------------------------------------------------------------*/ // STEP 17: ALTER OTHER TABLES II /*-------------------------------------------------------------------------*/ function step_17() { $this->ipsclass->sql->step_17(); if ( count($this->ipsclass->sql->error) ) { $this->show_error( implode( "
", $this->ipsclass->sql->error ) ); } else { $msg = "Other tables altered, converting forums next..."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ."

".intval($this->ipsclass->sql->sqlcount)." queries run successfully!" ); } } /*-------------------------------------------------------------------------*/ // STEP 16: ALTER MEMBERS TABLE II /*-------------------------------------------------------------------------*/ function step_16() { $this->ipsclass->sql->step_16(); if ( count($this->ipsclass->sql->error) ) { $this->show_error( implode( "
", $this->ipsclass->sql->error ) ); } else { $msg = "Members table altered, other tables next..."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ."

".intval($this->ipsclass->sql->sqlcount)." queries run successfully!" ); } } /*-------------------------------------------------------------------------*/ // STEP 15: ALTER TOPIC TABLE II /*-------------------------------------------------------------------------*/ function step_15() { $this->ipsclass->sql->step_15(); if ( count($this->ipsclass->sql->error) ) { $this->show_error( implode( "
", $this->ipsclass->sql->error ) ); } else { $msg = "Topic table altered, altering members table next..."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ."

".intval($this->ipsclass->sql->sqlcount)." queries run successfully!" ); } } /*-------------------------------------------------------------------------*/ // STEP 14: ALTER POST TABLE II /*-------------------------------------------------------------------------*/ function step_14() { $this->ipsclass->sql->step_14(); if ( count($this->ipsclass->sql->error) ) { $this->show_error( implode( "
", $this->ipsclass->sql->error ) ); } else { $msg = "Post table altered, altering topic table next..."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ."

".intval($this->ipsclass->sql->sqlcount)." queries run successfully!" ); } } /*-------------------------------------------------------------------------*/ // STEP 13: CONVERT TOPIC MULTI_MODS /*-------------------------------------------------------------------------*/ function step_13() { $f = $this->ipsclass->DB->query("SELECT * FROM ibf_forums"); $final = array(); while ( $r = $this->ipsclass->DB->fetch_row($f) ) { $mmids = preg_split( "/,/", $r['topic_mm_id'], -1, PREG_SPLIT_NO_EMPTY ); if ( is_array( $mmids ) ) { foreach( $mmids as $m ) { $final[ $m ][] = $r['id']; } } } $real_final = array(); foreach( $final as $id => $forums_ids ) { $ff = implode( ",",$forums_ids ); $this->ipsclass->DB->do_update( 'topic_mmod', array( 'mm_forums' => $ff ), 'mm_id='.$id ); } $msg = "Topic multi-moderation converted, alterting tables, stage 2..."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ); } /*-------------------------------------------------------------------------*/ // STEP 12: CONVERT PMs /*-------------------------------------------------------------------------*/ function step_12() { $start = intval($_GET['st']); $lend = 300; $end = $start + $lend; //----------------------------------------- // In steps... //----------------------------------------- $this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'messages', 'limit' => array( $start, $lend ) ) ); $o = $this->ipsclass->DB->simple_exec(); //----------------------------------------- // Do it... //----------------------------------------- if ( $this->ipsclass->DB->get_num_rows() ) { //----------------------------------------- // Got some to convert! //----------------------------------------- $this->ipsclass->next_step--; while ( $r = $this->ipsclass->DB->fetch_row($o) ) { if ( ! $r['msg_date'] ) { $r['msg_date'] = $r['read_date']; } if ( $r['vid'] != 'sent' ) { $this->ipsclass->DB->do_insert( 'message_text', array( 'msg_date' => $r['msg_date'], 'msg_post' => stripslashes($r['message']), 'msg_cc_users' => $r['cc_users'], 'msg_author_id' => $r['from_id'], 'msg_sent_to_count' => 1, 'msg_deleted_count' => 0, ) ); $msg_id = $this->ipsclass->DB->get_insert_id(); $this->ipsclass->DB->do_insert( 'message_topics', array( 'mt_msg_id' => $msg_id, 'mt_date' => $r['msg_date'], 'mt_title' => $r['title'], 'mt_from_id' => $r['from_id'], 'mt_to_id' => $r['recipient_id'], 'mt_vid_folder' => $r['vid'], 'mt_read' => $r['read_state'], 'mt_tracking' => $r['tracking'], 'mt_owner_id' => $r['recipient_id'], ) ); } else { $this->ipsclass->DB->do_insert( 'message_text', array( 'msg_date' => $r['msg_date'], 'msg_post' => stripslashes($r['message']), 'msg_cc_users' => $r['cc_users'], 'msg_author_id' => $r['from_id'], 'msg_sent_to_count' => 1, 'msg_deleted_count' => 0, ) ); $msg_id = $this->ipsclass->DB->get_insert_id(); $this->ipsclass->DB->do_insert( 'message_topics', array( 'mt_msg_id' => $msg_id, 'mt_date' => $r['msg_date'], 'mt_title' => $r['title'], 'mt_from_id' => $r['from_id'], 'mt_to_id' => $r['recipient_id'], 'mt_vid_folder' => $r['vid'], 'mt_read' => $r['read_state'], 'mt_tracking' => $r['tracking'], 'mt_owner_id' => $r['from_id'], ) ); } } $msg = "Personal messages: $start to $end completed...."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}&st={$end}", $msg ); } else { $msg = "Personal messages converted, proceeding to update topic multi-moderation..."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ); } } /*-------------------------------------------------------------------------*/ // STEP 11: CONVERGE /*-------------------------------------------------------------------------*/ function step_11() { $start = intval($_GET['st']); $lend = 300; $end = $start + $lend; //----------------------------------------- // In steps... //----------------------------------------- require_once( ROOT_PATH."ips_kernel/class_converge.php" ); $converge = new class_converge($DB); $max = 0; $this->ipsclass->DB->query("SELECT id FROM ibf_members where id > $end"); $max = $this->ipsclass->DB->fetch_row(); $o = $this->ipsclass->DB->query( $this->ipsclass->sql->sql_members_converge( $start, $end ) ); $found = 0; //----------------------------------------- // Do it... //----------------------------------------- while ( $r = $this->ipsclass->DB->fetch_row($o) ) { if ( ! $r['cid'] or ! $r['id'] ) { $r['password'] = $r['password'] ? $r['password'] : $r['legacy_password']; $salt = $converge->generate_password_salt(5); $salt = str_replace( '\\', "\\\\", $salt ); $this->ipsclass->DB->do_insert( 'members_converge', array( 'converge_id' => $r['id'], 'converge_email' => $r['email'], 'converge_joined' => $r['joined'], 'converge_pass_hash' => md5( md5($salt) . $r['password'] ), 'converge_pass_salt' => $salt ) ); $this->ipsclass->DB->do_update( 'members', array( 'member_login_key' => $converge->generate_auto_log_in_key() ), 'id='.$r['id'] ); } $found++; } if ( ! $found and ! $max['id'] ) { $msg = "Converge completed, converting personal messages..."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ); } else { $this->ipsclass->next_step--; $msg = "Converge added: $start to $end completed...."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}&st={$end}", $msg ); } } /*-------------------------------------------------------------------------*/ // STEP 10: CHECK EMAIL ADDRESSES /*-------------------------------------------------------------------------*/ function step_10() { $start = intval($_GET['st']); $lend = 300; $end = $start + $lend; //----------------------------------------- // In steps... //----------------------------------------- $o = $this->ipsclass->DB->query( $this->ipsclass->sql->sql_members_email( $lend ) ); //----------------------------------------- // Do it... //----------------------------------------- while ( $r = $this->ipsclass->DB->fetch_row($o) ) { if ( $r['count'] < 2 ) { break; } else { $dupe_emails[] = $r['email']; } } if ( count( $dupe_emails ) ) { foreach( $dupe_emails as $email ) { $first = 0; $this->ipsclass->DB->query( "SELECT id, name, email FROM ibf_members WHERE email='{$email}' ORDER BY joined ASC" ); while( $r = $this->ipsclass->DB->fetch_row() ) { // First? if ( ! $first ) { $first = 1; continue; } else { // later dupe.. $push_auth[] = $r['id']; } } } if ( count( $push_auth ) ) { $this->ipsclass->DB->do_update( 'member_extra', array( 'bio' => 'dupemail' ), 'id IN ('.implode(",", $push_auth).")" ); $this->ipsclass->DB->query( $this->ipsclass->sql->sql_members_email_update( $push_auth ) ); } $this->ipsclass->next_step--; $msg = "Members email addresses checked $start to $end completed...."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}&st={$end}", $msg ); } else { $msg = "Members email addresses checked, adding to converge..."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ); } } /*-------------------------------------------------------------------------*/ // STEP 9: CONVERT MEMBERS /*-------------------------------------------------------------------------*/ function step_9() { $start = intval($_GET['st']); $lend = 300; $end = $start + $lend; //----------------------------------------- // In steps... //----------------------------------------- $o = $this->ipsclass->DB->query( $this->ipsclass->sql->sql_members( $start, $lend ) ); //----------------------------------------- // Do it... //----------------------------------------- if ( $this->ipsclass->DB->get_num_rows() ) { //----------------------------------------- // Got some to convert! //----------------------------------------- $this->ipsclass->next_step--; while ( $r = $this->ipsclass->DB->fetch_row($o) ) { if ( $r['mextra'] ) { $this->ipsclass->DB->do_update( 'member_extra', array( 'aim_name' => $r['aim_name'], 'icq_number' => $r['icq_number'], 'website' => $r['website'], 'yahoo' => $r['yahoo'], 'interests' => $r['interests'], 'msnname' => $r['msnname'], 'vdirs' => $r['vdirs'], 'location' => $r['location'], 'signature' => $r['signature'], 'avatar_location' => $r['avatar'], 'avatar_size' => $r['avatar_size'], 'avatar_type' => preg_match( "/^upload\:/", $r['avatar'] ) ? 'upload' : ( preg_match( "#^http://#", $r['avatar'] ) ? 'url' : 'local' ) ), 'id='.$r['mextra'] ); } else { $this->ipsclass->DB->do_insert( 'member_extra', array( 'id' => $r['id'], 'aim_name' => $r['aim_name'], 'icq_number' => $r['icq_number'], 'website' => $r['website'], 'yahoo' => $r['yahoo'], 'interests' => $r['interests'], 'msnname' => $r['msnname'], 'vdirs' => $r['vdirs'], 'location' => $r['location'], 'signature' => $r['signature'], 'avatar_location' => $r['avatar'], 'avatar_size' => $r['avatar_size'], 'avatar_type' => preg_match( "/^upload\:/", $r['avatar'] ) ? 'upload' : ( preg_match( "#^http://#", $r['avatar'] ) ? 'url' : 'local' ) ) ); } } $msg = "Members adjusted $start to $end completed...."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}&st={$end}", $msg ); } else { $msg = "Members converted, making members email addresses safe for converge..."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ); } } /*-------------------------------------------------------------------------*/ // STEP 8: CONVERT ATTACHMENTS /*-------------------------------------------------------------------------*/ function step_8() { $start = intval($_GET['st']); $lend = 300; $end = $start + $lend; //----------------------------------------- // In steps... //----------------------------------------- $this->ipsclass->DB->simple_construct( array( "select" => '*', 'from' => 'posts', 'where' => "attach_file != ''", 'limit' => array( $start, $lend ) ) ); $outer = $this->ipsclass->DB->simple_exec(); //----------------------------------------- // Do it... //----------------------------------------- if ( $this->ipsclass->DB->get_num_rows() ) { //----------------------------------------- // Got some to convert! //----------------------------------------- $this->ipsclass->next_step--; while( $r = $this->ipsclass->DB->fetch_row( $outer ) ) { $image = 0; $ext = strtolower( str_replace( ".", "", substr( $r['attach_file'], strrpos( $r['attach_file'], '.' ) ) ) ); $postkey = md5( $r['post_date'].','.$r['pid'] ); if ( in_array( $ext, array( 'gif', 'jpeg', 'jpg', 'png' ) ) ) { $image = 1; } $this->ipsclass->DB->do_insert( 'attachments', array( 'attach_ext' => $ext, 'attach_file' => $r['attach_file'], 'attach_location' => $r['attach_id'], 'attach_is_image' => $image, 'attach_hits' => $r['attach_hits'], 'attach_date' => $r['post_date'], 'attach_pid' => $r['pid'], 'attach_post_key' => $postkey, 'attach_member_id' => $r['author_id'], 'attach_approved' => 1, 'attach_filesize' => @filesize( ROOT_PATH.'uploads/'.$r['attach_id'] ), ) ); $this->ipsclass->DB->do_update( 'posts', array( 'post_key' => $postkey ), 'pid='.$r['pid'] ); $this->ipsclass->DB->simple_exec_query( array( 'update' => 'topics', 'set' => 'topic_hasattach=topic_hasattach+1', 'where' => 'tid='.$r['topic_id'] ) ); } $msg = "Attachments $start to $end completed...."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}&st={$end}", $msg ); } else { $msg = "Attachments converted, converting members..."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ); } } /*-------------------------------------------------------------------------*/ // STEP 7: CONVERT FORUMS /*-------------------------------------------------------------------------*/ function step_7() { $this->ipsclass->sql->step_7(); if ( count($this->ipsclass->sql->error) ) { $this->show_error( implode( "
", $this->ipsclass->sql->error ) ); } else { $msg = "Forums converted, converting attachments next..."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ); } } /*-------------------------------------------------------------------------*/ // STEP 6: ALTER OTHER TABLES /*-------------------------------------------------------------------------*/ function step_6() { $this->ipsclass->sql->step_6(); if ( count($this->ipsclass->sql->error) ) { $this->show_error( implode( "
", $this->ipsclass->sql->error ) ); } else { $msg = "Other tables altered, converting forums next..."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ."

".intval($this->ipsclass->sql->sqlcount)." queries run successfully!" ); } } /*-------------------------------------------------------------------------*/ // STEP 5: ALTER MEMBERS TABLE /*-------------------------------------------------------------------------*/ function step_5() { $this->ipsclass->sql->step_5(); if ( count($this->ipsclass->sql->error) ) { $this->show_error( implode( "
", $this->ipsclass->sql->error ) ); } else { $msg = "Members table altered, other tables next..."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ."

".intval($this->ipsclass->sql->sqlcount)." queries run successfully!" ); } } /*-------------------------------------------------------------------------*/ // STEP 4: ALTER TOPIC TABLE /*-------------------------------------------------------------------------*/ function step_4() { $this->ipsclass->sql->step_4(); if ( count($this->ipsclass->sql->error) ) { $this->show_error( implode( "
", $this->ipsclass->sql->error ) ); } else { $msg = "Topic table altered, altering members table next..."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ."

".intval($this->ipsclass->sql->sqlcount)." queries run successfully!" ); } } /*-------------------------------------------------------------------------*/ // STEP 3: ALTER POST TABLE /*-------------------------------------------------------------------------*/ function step_3() { $this->ipsclass->sql->step_3(); if ( count($this->ipsclass->sql->error) ) { $this->show_error( implode( "
", $this->ipsclass->sql->error ) ); } else { $msg = "Post table altered, altering topic table next..."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ."

".intval($this->ipsclass->sql->sqlcount)." queries run successfully!" ); } } /*-------------------------------------------------------------------------*/ // STEP 2: ADD NEW TABLES /*-------------------------------------------------------------------------*/ function step_2() { $this->ipsclass->sql->step_2(); if ( count($this->ipsclass->sql->error) ) { $this->show_error( implode( "
", $this->ipsclass->sql->error ) ); } else { $msg = "New tables created. Altering tables (Part 1, section 1 - post table)"; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ."

".intval($this->ipsclass->sql->sqlcount)." queries run successfully!" ); } } /*-------------------------------------------------------------------------*/ // STEP 1: COPY FORUMS TABLE /*-------------------------------------------------------------------------*/ function step_1() { $this->ipsclass->sql->step_1(); if ( count($this->ipsclass->sql->error) ) { $this->show_error( implode( "
", $this->ipsclass->sql->error ) ); } else { $msg = "Forums table backed up - creating new tables next...."; $this->ipsclass->core->redirect( "{$this->ipsclass->base_url}&act=work&version={$this->ipsclass->input['version']}&step={$this->ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}", $msg ."

".intval($this->ipsclass->sql->sqlcount)." queries run successfully!" ); } } /*-------------------------------------------------------------------------*/ // STEP 0: SHOW INTRO /*-------------------------------------------------------------------------*/ function show_intro() { //----------------------------------------- // Check for missing files //----------------------------------------- $this->ipsclass->template->content .= "
Welcome to the IPB ".UPGRADE_FROM." -> 2.0.0 Upgrade System
This upgrade script will upgrade your ".UPGRADE_FROM.".x board to IPB 2.0.0

There are quite a few steps to perform to update your SQL tables and convert the current data over to the new system.

WARNING: This upgrade script WILL upgrade your current database tables AND there is NO 'downgrade' script!
PLEASE ensure that you have a very recent SQL back-up so that you can restore your working board quickly if you need to do so.
We cannot stress how important it is to ensure that you have a backup of this database before continuing


First step: Copying drastically altered SQL tables for use later in the convert program.

"; $warnings = array(); $checkfiles = array( ROOT_PATH ."ipb_templates.xml", ROOT_PATH ."install/installfiles/components.php", ROOT_PATH ."install/installfiles/ipb_macro.xml", ROOT_PATH ."install/installfiles/ipb_settings.xml", ROOT_PATH ."sources/sql", KERNEL_PATH ."class_converge.php", KERNEL_PATH ."class_xml.php", KERNEL_PATH ."class_db_".SQL_DRIVER.".php", ROOT_PATH ."conf_global.php", ); $writeable = array( ROOT_PATH."conf_global.php", ROOT_PATH."cache/", ROOT_PATH."cache/skin_cache" ); foreach ( $checkfiles as $cf ) { if ( ! file_exists($cf) ) { $warnings[] = "Cannot locate the file '$cf'."; } } foreach ( $writeable as $cf ) { if ( ! is_writeable($cf) ) { $warnings[] = "Cannot write to the file '$cf'. Please CHMOD to 0777."; } } $phpversion = phpversion(); //---------------------------------- // CHECK BASICS //---------------------------------- if ($phpversion < '4.1.0') { $warnings[] = "You cannot install Invision Power Board. Invision Power Board requires PHP Version 4.1.0 or better."; } if ( ! function_exists('get_cfg_var') ) { $warnings[] = "You cannot install Invision Power Board. Your PHP installation isn't sufficient to run IPB."; } if ( ! function_exists('xml_parse_into_struct') ) { $warnings[] = "You cannot install Invision Power Board. IPB requires that the XML functions in PHP are enabled, please ask your host to enable XML."; } //---------------------------------- // Got error? //---------------------------------- if ( count($warnings) > 0 ) { $err_string = '·'.implode( "

·", $warnings ); $this->ipsclass->template->content .= "

Warning! The following errors must be rectified before continuing!

$err_string
"; } else { $this->ipsclass->template->content .= "
» ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}'>Proceed...
"; } $this->ipsclass->template->content .= "
"; $this->ipsclass->template->output(); } /*-------------------------------------------------------------------------*/ // check for IPB 2 /*-------------------------------------------------------------------------*/ function _check_for_two() { if ( ! $this->ipsclass->DB->field_exists( 'cs_key', 'cache_store' ) ) { return 0; } $r = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'cache_store', 'where' => "cs_key='forum_cache'" ) ); if ( $r['cs_value'] ) { return 1; } else { return 0; } } /*-------------------------------------------------------------------------*/ // SHOW ERROR WITH CONTINUE /*-------------------------------------------------------------------------*/ function show_error( $msg ) { $this->ipsclass->template->content .= "
Error!
The following error has been returned:

$msg
» ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}'>Continue regardless?
"; $this->ipsclass->template->output(); } } ?>