Attempting to connect to phpBB database [ {$phpbb2Database} @ {$phpbb2Host} ] ... \n"; flush(); $phpbbConnection = mysql_connect($phpbb2Host, $phpbb2Username, $phpbb2Password, TRUE); if(!mysql_select_db($phpbb2Database, $phpbbConnection)) { goError("Error! Could not connect to phpBB database. Please go back to the previous page and check your settings"); } $e107Connection = mysql_connect($mySQLserver, $mySQLuser, $mySQLpassword, TRUE); if(!mysql_select_db($mySQLdefaultdb, $e107Connection)) { goError("Error! Could not connect to e107 database."); } echo "Successfully connected to phpBB and e107 databases ... "; $phpbb_res = mysql_query("SELECT * FROM {$phpbb2Prefix}users", $phpbbConnection); if(!$phpbb_res) { goError("Error! Unable to access ".$phpbb2Prefix."users table."); } require_once('import_mapper.php'); //------------------------------------------------------ // Convert users //------------------------------------------------------ while($user = mysql_fetch_array($phpbb_res)) { $userArray = convertUsers(); // if($user['user_level'] != 1 && $user['user_id'] != -1) // Convert any user other than ID=1 (which will be E107 main admin) if($user['user_id'] > 1) { $query = createQuery($userArray, $user, $mySQLprefix."user"); echo (mysql_query($query, $e107Connection) ? "Successfully inserted user: ".$user['user_id'].": ".$user['username'] : "Unable to insert user: ".$user['user_id'].": ".$user['username']." ".mysql_errno() . ": " . mysql_error())." "; flush(); } } //----------------------------------------------------------- // ### get phpbb categories and insert them as forum parents //----------------------------------------------------------- mysql_query("TRUNCATE TABLE {$mySQLprefix}forum", $e107Connection); $phpbb_res = mysql_query("SELECT * FROM {$phpbb2Prefix}categories", $phpbbConnection); if(!$phpbb_res) { goError("Error! Unable to access ".$phpbb2Prefix."categories table."); } $catcount = 500; while($parent = mysql_fetch_array($phpbb_res)) { $parentArray = convertParents($catcount); $query = createQuery($parentArray, $parent, $mySQLprefix."forum"); echo (mysql_query($query, $e107Connection) ? "Successfully inserted parent: ".$parent['cat_id'].": ".$parent['cat_title'] : "Unable to insert parent: ".$parent['cat_id'].": ".$parent['cat_title']." ".mysql_errno() . ": " . mysql_error())." "; flush(); $phpbb_res2 = mysql_query("SELECT * FROM {$phpbb2Prefix}forums WHERE cat_id = ".$parent['cat_id'], $phpbbConnection); if($phpbb_res2) { while($forum = mysql_fetch_array($phpbb_res2)) { $forumArray = convertForums($catcount); $query = createQuery($forumArray, $forum, $mySQLprefix."forum"); echo (mysql_query($query, $e107Connection) ? "Successfully inserted forum: ".$parent['cat_id'].": ".$parent['cat_title'] : "Unable to insert forum: ".$parent['cat_id'].": ".$parent['cat_title']." ".mysql_errno() . ": " . mysql_error())." "; flush(); } } else { echo "Didn't find any forums for parent '".$parent['cat_title']."' "; } $catcount ++; } //------------------------------------------------------ // Read in forum topics //------------------------------------------------------ mysql_query("TRUNCATE TABLE {$mySQLprefix}forum_t", $e107Connection); mysql_query("TRUNCATE TABLE {$mySQLprefix}polls", $e107Connection); $query = "SELECT * FROM {$phpbb2Prefix}topics LEFT JOIN {$phpbb2Prefix}posts_text ON ({$phpbb2Prefix}topics.topic_title = {$phpbb2Prefix}posts_text.post_subject) LEFT JOIN {$phpbb2Prefix}posts ON ({$phpbb2Prefix}posts.post_id = {$phpbb2Prefix}posts_text.post_id) ORDER BY topic_time ASC"; $phpbb_res = mysql_query($query, $phpbbConnection); if(!$phpbb_res) { goError("Error! Unable to access ".$phpbb2Prefix."topics table."); } while($topic = mysql_fetch_array($phpbb_res)) { //echo " "; print_r($topic); echo ""; if($topic['topic_vote']) { // poll attached to this topic ... $topic['topic_title'] = "[poll] ".$topic['topic_title']; $query = "SELECT * FROM {$phpbb2Prefix}vote_desc WHERE topic_id=".$topic['topic_id']; $phpbb_res3 = mysql_query($query, $phpbbConnection); $pollQ = mysql_fetch_array($phpbb_res3); $query = "SELECT * FROM {$phpbb2Prefix}vote_results WHERE vote_id=".$pollQ['vote_id']; $phpbb_res3 = mysql_query($query, $phpbbConnection); $options = ""; $votes = ""; while($pollO = mysql_fetch_array($phpbb_res3)) { $options .= $pollO['vote_option_text'].chr(1); $votes .= $pollO['vote_result'].chr(1); } extract($pollQ); $vote_text = $tp->toDB($vote_text); // McFly added 25/5/06 $options = $tp->toDB($options); // McFly added 25/5/06 $query = "INSERT INTO ".$mySQLprefix."polls VALUES ('0', {$vote_start}, {$vote_start}, 0, 0, '{$vote_text}', '{$options}', '{$votes}', '', 2, 0, 0, 0, 255, 0)"; echo (mysql_query($query, $e107Connection) ? "Poll successfully inserted" : "Unable to insert poll ({$query})")." "; } if($topic['topic_poster'] == 2) { $topic['topic_poster'] = 1; } if($topic['topic_poster'] == -1) { $poster = ($topic['post_username'] ? $topic['post_username'] : "Anonymous"); $topic['topic_poster'] = "0.".$poster; // McFly moved, edited 25/5/06 } $topicArray = convertTopics(); // McFly edited 25/5/06 $query = createQuery($topicArray, $topic, $mySQLprefix."forum_t"); if(!mysql_query($query, $e107Connection)) { echo "Unable to insert topic: ".$topic['topic_id']." "; flush(); } else { echo "Successfully inserted topic: ".$topic['topic_id']." "; flush(); $parent_id = mysql_insert_id(); $topic_id = $topic['topic_id']; //echo "PARENT: $parent_id, TOPIC: $topic_id "; $query = "SELECT * FROM {$phpbb2Prefix}posts LEFT JOIN {$phpbb2Prefix}posts_text ON ({$phpbb2Prefix}posts.post_id = {$phpbb2Prefix}posts_text.post_id) WHERE topic_id='{$topic_id}' AND post_subject = '' ORDER BY post_time DESC"; $phpbb_res2 = mysql_query($query, $phpbbConnection); if(!$phpbb_res2) { goError("Error! Unable to access ".$phpbb2Prefix."posts / ".$phpbb2Prefix."posts_text table."); } while($post = mysql_fetch_array($phpbb_res2)) { if($post['poster_id'] == 2) { $post['poster_id'] = 1; } if($post['poster_id'] == -1) { $poster = ($post['post_username'] ? $post['post_username'] : "Anonymous"); $post['poster_id'] = "0.".$poster; // McFly moved, edited 25/5/06 } $postArray = convertForumPosts($parent_id, $poster); $query = createQuery($postArray, $post, $mySQLprefix."forum_t",$mapdata); echo (mysql_query($query, $e107Connection) ? "Successfully inserted thread: ".$post['post_id'] : "Unable to insert thread: ".$parent['cat_id'].": ".$parent['cat_title']." ".mysql_errno() . ": " . mysql_error())." "; flush(); } } } //------------------------------------------------------ // Consider polls here later //------------------------------------------------------ echo " |