summaryrefslogtreecommitdiff
path: root/admin/upgrade_inc.php
diff options
context:
space:
mode:
authorbitweaver.org <bitweaver@users.sourceforge.net>2006-12-27 04:36:05 +0000
committerbitweaver.org <bitweaver@users.sourceforge.net>2006-12-27 04:36:05 +0000
commitf742488610acb9c215b06e1ccdd0566e7327d185 (patch)
tree10d91525c3f8925ed24cdcf50579411c108768d8 /admin/upgrade_inc.php
parent2b98b75a10a0b64f2b7a0d3f2e136bd96b70b25d (diff)
downloadboards-f742488610acb9c215b06e1ccdd0566e7327d185.tar.gz
boards-f742488610acb9c215b06e1ccdd0566e7327d185.tar.bz2
boards-f742488610acb9c215b06e1ccdd0566e7327d185.zip
add some function to migrate phpBB - still lots to be done
Diffstat (limited to 'admin/upgrade_inc.php')
-rw-r--r--admin/upgrade_inc.php69
1 files changed, 69 insertions, 0 deletions
diff --git a/admin/upgrade_inc.php b/admin/upgrade_inc.php
index edf55c7..5d1480b 100644
--- a/admin/upgrade_inc.php
+++ b/admin/upgrade_inc.php
@@ -3,6 +3,7 @@
// Just a few phpBB migration queries for now....
/*
+-- POSTGRESQL-centric initial SQL
INSERT INTO liberty_content ( content_id, title, data, content_type_guid, format_guid, content_status_id, user_id, modifier_user_id, created, last_modified ) (SELECT nextval('liberty_content_id_seq'), forum_name, forum_desc, 'bitboard', 'bbcode', 50, 1, 1, CURRENT_TIMESTAMP::abstime::int::bigint, CURRENT_TIMESTAMP::abstime::int::bigint FROM phpbb.forums);
INSERT INTO boards (board_id, content_id) (SELECT forum_id, content_id FROM phpbb.forums INNER JOIN liberty_content ON (content_type_guid='bitboard' AND forum_name=title) );
@@ -13,4 +14,72 @@ ALTER SEQUENCE boards_board_id_seq RESTART WITH 6;
INSERT INTO boards_map (board_content_id, topic_content_id) (SELECT content_id, content_id FROM phpbb.forums INNER JOIN liberty_content ON (content_type_guid='bitboard' AND forum_name=title) );
*/
+require_once( '../../bit_setup_inc.php' );
+
+global $db;
+
+if( file_exists( PHPBB_PKG_PATH.'config.php' ) ) {
+ require_once( PHPBB_PKG_PATH.'config.php' );
+}
+
+chdir( PHPBB_PKG_PATH );
+define('IN_PHPBB', true);
+$phpbb_root_path = './';
+include($phpbb_root_path . 'extension.inc');
+include($phpbb_root_path . 'common.'.$phpEx);
+include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
+
+migrate_phpbb();
+
+function migrate_phpbb() {
+ global $gBitDb, $db;
+
+ if( $forumIds = $gBitDb->getAssoc( "SELECT `forum_id`,`content_id` FROM " . FORUMS_TABLE . " bbf INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON (lc.`content_type_guid`='bitboard' AND bbf.`forum_name`=lc.`title`) ORDER BY bbf.forum_id" ) ) {
+ foreach( $forumIds as $forumId => $contentId ) {
+ migrate_phpbb_forum( $forumId, $contentId );
+ }
+ die;
+ }
+}
+
+function migrate_phpbb_forum( $pForumId, $pForumContentId ) {
+ global $db;
+ $sql = "SELECT * FROM " . TOPICS_TABLE . " bbt
+ INNER JOIN " . POSTS_TABLE . " bbp ON(bbt.topic_first_post_id=bbp.post_id)
+ INNER JOIN " . POSTS_TEXT_TABLE . " bbpt ON(bbpt.post_id=bbp.post_id)
+ WHERE bbt.forum_id=$pForumId
+ ORDER BY bbt.topic_id LIMIT 10";
+ if ( !($result = $db->sql_query($sql)) ) {
+ message_die(GENERAL_ERROR, "Could not obtain topic/post information.", '', __LINE__, __FILE__, $sql);
+ }
+ while ( $row = $db->sql_fetchrow($result) ) {
+ $commentHash = array();
+ $commentHash['root_id'] = $pForumContentId;
+ $commentHash['anon_name'] = $row['post_username'];
+ $commentHash['title'] = $row['post_subject'];
+ $commentHash['edit'] = $row['post_text'];
+ $commentHash['format_guid'] = 'bbcode';
+ $commentHash['created'] = $row['post_time'];
+ $commentHash['last_modified'] = $row['post_edit_time'];
+ $commentHash['user_id'] = $row['poster_id'];
+ $commentHash['ip'] = decode_ip( $row['poster_ip'] );
+ vd( $commentHash );
+// migrate_phpp_topic( $row['topic_id'], $newComment->mContentId );
+ }
+ $db->sql_freeresult($result);
+}
+
+function migrate_phpbb_topic( $pTopicId, &$pRootComment ) {
+ $sql = "SELECT * FROM " . TOPICS_TABLE . " bbt
+ INNER JOIN " . POSTS_TABLE . " bbp ON(bbt.topic_first_post_id=bbp.post_id)
+ INNER JOIN " . POSTS_TEXT_TABLE . " bbpt ON(bbpt.post_id=bbp.post_id)
+ WHERE bbt.forum_id=$pForumId
+ ORDER BY bbt.topic_id LIMIT 10";
+ if ( !($result = $db->sql_query($sql)) ) {
+ message_die(GENERAL_ERROR, "Could not obtain topic/post information.", '', __LINE__, __FILE__, $sql);
+ }
+ while ( $row = $db->sql_fetchrow($result) ) {
+ }
+}
+
?>