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 "Вы, кажется, уже имеете IPB 2.0.x — обновление не требуется."; 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 .= "
Вы выбрали остановку перед шагом: {$this->ipsclass->input['step']}
Скрипт обновления был остановлен по запросу...
"; $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 .= "
Ваше обновление почти завершено!
Скрипт обновления успешно сделал свою работу и вы сейчас имеете IPB 2.0.0

Сейчас, пожалуйста, посетите основную систему обновления для обновления до последней версии

Все ваши текущие стили перемещены в 2.0. Для использования этих стилей вам первое, что необходимо сделать: Этим вы завершите импортирование ваших старых стилей. Вы должны будете отредактировать, чтобы добавить в вашем новом IPB 2.0.0 секции и переименования некоторых процедур.

"; $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 = "Перестройка сделана — завершение..."; $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 = "Настройки импортированы, далее перестроение и обновление..."; $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("Ошибка в файле ipb_templates.xml — невозможно выполнить этот XML файл"); } 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("Ошибка в файле ipb_templates.xml — невозможно выполнить этот XML файл"); } 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 = "Стили импортированы, далее импортирование настроек..."; $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 = "Оптимизация завершена, далее импорт новых стилей..."; $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)." запросов успешно сделано!" ); } } /*-------------------------------------------------------------------------*/ // 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 = "Оптимизация начата..."; $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)." запросов успешно сделано!" ); } } /*-------------------------------------------------------------------------*/ // 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 = "Старые таблицы удалены, далее оптимизация..."; $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)." запросов успешно сделано!" ); } } /*-------------------------------------------------------------------------*/ // 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 = "Вставка завершена, далее удаление старых таблиц..."; $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)." запросов успешно сделано!" ); } } /*-------------------------------------------------------------------------*/ // 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 = "Другие таблицы вставлены, далее конвертирование форумов..."; $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)." запросов успешно сделано!" ); } } /*-------------------------------------------------------------------------*/ // 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 = "Таблица с пользователями вставлена, далее другие таблицы..."; $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)." запросов успешно сделано!" ); } } /*-------------------------------------------------------------------------*/ // 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 = "Таблица с темами вставлена, далее вставка таблицы с пользователями..."; $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)." запросов успешно сделано!" ); } } /*-------------------------------------------------------------------------*/ // 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 = "Таблица с сообщениями вставлена, далее вставка таблицы с темами..."; $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)." запросов успешно сделано!" ); } } /*-------------------------------------------------------------------------*/ // 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 = "Мульти-модерация тем конвертирована, вставка таблиц, стадия 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 = "Личные сообщения: от $start до $end завершено...."; $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 = "Личные сообщения сконвертированы, процесс обновления мульти-модерации тем..."; $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' => strtolower($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(), 'email' => strtolower($r['email']) ), 'id='.$r['id'] ); } $found++; } if ( ! $found and ! $max['id'] ) { $msg = "Добавление системы авторизации завершено, конвертирование личных сообщений..."; $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 = "Добавление системы авторизации: от $start до $end завершено...."; $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 = "Проверка e-mail адресов: от $start до $end завершено...."; $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 = "E-mail адреса пользователей проверены, добавление системы авторизации..."; $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 = "Конвертирование пользователей: от $start до $end завершено...."; $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 = "Конвертирование пользователей завершено, проверка e-mail адресов пользователей для системы авторизации..."; $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 = "Прикрепленные файлы: от $start до $end завершено...."; $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 = "Прикрепленные файлы сконвертированы, перенос пользователей..."; $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 = "Форумы сконвертированы, далее конвертирование прикрепленных файлов..."; $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 = "Другие таблицы вставлены, далее конвертирование форумов..."; $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)." запросов успешно сделано!" ); } } /*-------------------------------------------------------------------------*/ // 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 = "Таблица пользователей вставлена, далее другие таблицы..."; $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)." запросов успешно сделано!" ); } } /*-------------------------------------------------------------------------*/ // 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 = "Таблица с темами вставлена, далее вставка таблицы с пользователями..."; $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)." запросов успешно сделано!" ); } } /*-------------------------------------------------------------------------*/ // 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 = "Таблица с сообщениями вставлена, далее вставка таблицы с темами..."; $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)." запросов успешно сделано!" ); } } /*-------------------------------------------------------------------------*/ // 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 = "Новые таблицы созданы. Вставка таблиц (часть 1, секция 1 — таблица с сообщениями)"; $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)." запросов успешно сделано!" ); } } /*-------------------------------------------------------------------------*/ // 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 = "Поднята таблица с форумами — далее создание новых таблиц...."; $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)." запросов успешно сделано!" ); } } /*-------------------------------------------------------------------------*/ // STEP 0: SHOW INTRO /*-------------------------------------------------------------------------*/ function show_intro() { //----------------------------------------- // Check for missing files //----------------------------------------- $this->ipsclass->template->content .= "
Добро пожаловать систему обновления IPB с ".UPGRADE_FROM." в 2.0.0
Этот скрипт обновления будет обновлять вашу ".UPGRADE_FROM.".x в IPB 2.0.0

Во время процесса обновления будет несколько шагов для обновления ваших SQL таблиц и конвертирования текущих данных в новую систему. Если вы имеете большой форум, рекомендуем ознакомиться с инструкцией по обновлению больших форумов > upgrade/manual_upgradekit/readme.txt.

ВНИМАНИЕ: Этот скрипт обновления будет обновлять вашу текущую базу данных и вернуться на старую версию форума уже будет невозможно!
Пожалуйста сохраните вашу базу данных и файлы (backup) перед тем, как начать обновление. Это сделает возможным быстро вернуть старый форум, если у вас возникнут серьезные ошибки при обновлении.
Мы не можем гарантировать, что процесс обновления пройдет без проблем, именно поэтому мы просим вас сделать копию ваших файлов и базы перед обновлением


Первый шаг: Копирование SQL таблиц для использования в программе конвертирования.

"; $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[] = "Невозможно найти файл '$cf'."; } } foreach ( $writeable as $cf ) { if ( ! is_writeable($cf) ) { $warnings[] = "Невозможно произвести запись в файл или папку '$cf'. Пожалуйста сделайте права (CHMOD) 0777."; } } $phpversion = phpversion(); //---------------------------------- // CHECK BASICS //---------------------------------- if ($phpversion < '4.1.0') { $warnings[] = "Вы не можете устанавливать Invision Power Board. Invision Power Board требует PHP версии 4.1.0 или выше."; } if ( ! function_exists('get_cfg_var') ) { $warnings[] = "Вы не можете устанавливать Invision Power Board. Ваш PHP не достаточен для запуска IPB."; } if ( ! function_exists('xml_parse_into_struct') ) { $warnings[] = "Вы не можете устанавливать Invision Power Board. IPB требует, чтобы XML функции в PHP были включены, пожалуйста сообщите вашему хостинг-провайдеру, чтобы включил вам XML."; } //---------------------------------- // Got error? //---------------------------------- if ( count($warnings) > 0 ) { $err_string = '·'.implode( "

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

Внимание! Найдены ошибки, требующие устранения. Без этого продолжение невозможно!

$err_string
"; } else { $this->ipsclass->template->content .= "
» ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}'>Далее...
"; } $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!
Скрипт возвратил следующую ошибку:

$msg
» ipsclass->next_step}&dieafterstep={$this->ipsclass->input['dieafterstep']}'>Все равно продолжить?
"; $this->ipsclass->template->output(); } } ?>