Here is my script to move my forum data from file to database.
*** IMPORTANT NOTE ***
You MUST get latest version of private.inc.t from this URL: http://cvs.prohost.org/c/index.cgi/FUDforum/rlog?f=install/forum_data/src/p rivate.inc.t
(I tested with version 1.52)
Please backup (and test your backup) before running this script.
Use at your own risk. I am NOT resiponsible to any data lost.
*** IMPORTANT NOTE ***
<?php
require("./GLOBALS.php");
fud_use("db.inc");
fud_use("fileio.inc");
fud_use("private.inc");
echo "Processing messages...<br/>";
$msg_res = q("SELECT id, foff, length, file_id, thread_id FROM ".$GLOBALS["DBHOST_TBL_PREFIX"]."msg");
while($msg = db_rowobj($msg_res)) {
$body = read_msg_body($msg->foff, $msg->length, $msg->file_id);
$file_id_preview = $length_preview = 0;
$offset = $offset_preview = -1;
$length = strlen($body);
// copy msg to db
$file_id = db_qid("INSERT INTO ".$GLOBALS["DBHOST_TBL_PREFIX"]."msg_store (data) VALUES ("._esc($body).")");
$message_threshold = q_singleval("SELECT f.message_threshold FROM ".$GLOBALS["DBHOST_TBL_PREFIX"]."forum f, ".$GLOBALS["DBHOST_TBL_PREFIX"]."thread t WHERE f.id = t.forum_id AND t.id = ".$msg->thread_id);
if ($message_threshold && $length > $message_threshold) {
$file_id_preview = db_qid("INSERT INTO ".$GLOBALS["DBHOST_TBL_PREFIX"]."msg_store (data) VALUES ("._esc(trim_html($body, $message_threshold)).")");
}
q("UPDATE ".$GLOBALS["DBHOST_TBL_PREFIX"]."msg SET file_id = ".$file_id.", foff = ".$offset.", length = ".$length.", file_id_preview = ".$file_id_preview.", offset_preview = ".$offset_preview.", length_preview = ".$length_preview." WHERE id = ".$msg->id);
}
echo "Processing private messages...<br/>";
$pmsg_res = q("SELECT id, foff, length FROM ".$GLOBALS["DBHOST_TBL_PREFIX"]."pmsg");
while($pmsg = db_rowobj($pmsg_res)) {
$pbody = read_pmsg_body($pmsg->foff, $pmsg->length);
$fid = db_qid("INSERT INTO ".$GLOBALS["DBHOST_TBL_PREFIX"]."msg_store (data) VALUES ("._esc($pbody).")");
q("UPDATE ".$GLOBALS["DBHOST_TBL_PREFIX"]."pmsg SET foff = -1, length = ".$fid." WHERE id = ".$pmsg->id);
}
echo "Done...<br/>";
?>