Sorry, maybe you diff with a wrong version. Here is my major change:
/* Import phpBB private messages */
q("DELETE FROM ".$DBHOST_TBL_PREFIX."pmsg");
$r = bbq("SELECT p.*, pt.privmsgs_text, u.username FROM {$bb2}privmsgs p INNER JOIN {$bb2}privmsgs_text pt ON p.privmsgs_id=pt.privmsgs_text_id INNER JOIN {$bb2}users u ON u.user_id=p.privmsgs_to_userid");
print_msg('Importing Private Messages '.db_count($r));
while ($obj = db_rowobj($r)) {
if ($obj->privmsgs_type != PRIVMSGS_READ_MAIL && $obj->privmsgs_type != PRIVMSGS_NEW_MAIL && $obj->privmsgs_type != PRIVMSGS_SENT_MAIL) {
continue;
}
list($off, $len) = write_pmsg_body(bbcode2fudcode($obj->privmsgs_text));
$pmsg_opt = ($obj->privmsgs_attach_sig ? 1 : 0) | ($obj->privmsgs_enable_smilies ? 0 : 2);
if (strncasecmp($obj->privmsgs_subject, "re:", 3) == 0) {
$pmsg_opt = $pmsg_opt | 64;
} else {
$pmsg_opt = $pmsg_opt | 32;
}
$read_stamp = $obj->privmsgs_type != PRIVMSGS_NEW_MAIL ? $obj->privmsgs_date : 0;
if ($obj->privmsgs_type == PRIVMSGS_SENT_MAIL) {
$folder = 3;
$duser_id = $obj->privmsgs_from_userid;
$pdest = $obj->privmsgs_to_userid;
} else {
$folder = 1;
$duser_id = $obj->privmsgs_to_userid;
$pdest = 0;
}
q("INSERT INTO ".$DBHOST_TBL_PREFIX."pmsg
(ouser_id, duser_id, pdest, ip_addr, post_stamp, read_stamp, fldr, subject, pmsg_opt, foff, length, to_list)
VALUES(
".(int)$obj->privmsgs_from_userid.",
".(int)$duser_id.",
".(int)$pdest.",
'".phpbb_decode_ip($obj->privmsgs_ip)."',
".(int)$obj->privmsgs_date.",
".$read_stamp.",
".$folder.",
'".addslashes($obj->privmsgs_subject)."',
".$pmsg_opt.",
".$off.",
".$len.",
'".addslashes($obj->username)."')"
);
}
unset($r);
print_msg('Finished Importing Private Messages');
/* Import phpBB file attachments (if person has applied phpbb file attachment mod) */
$ENABLED_FILE_ATTACHMENTS = 0;
if (@db_rowarr(bbq("SELECT * FROM {$bb2}attachments_desc LIMIT 1", 1))) {
$ENABLED_FILE_ATTACHMENTS = 1;
q("DELETE FROM ".$DBHOST_TBL_PREFIX."attach");
list($phpbb_storage) = db_rowarr(bbq("SELECT config_value FROM {$bb2}attachments_config WHERE config_name='upload_dir'"));
$phpbb_storage = $phpbb_storage."/";
$old_umask = umask(0111);
$r = bbq("SELECT a.physical_filename attach_filename, a.real_filename filename, b.user_id_1 user_id, b.post_id, a.download_count FROM {$bb2}attachments_desc a INNER JOIN {$bb2}attachments b on a.attach_id = b.attach_id");
print_msg('Importing File Attachments '.db_count($r));
while ($obj = db_rowobj($r)) {
if (!@file_exists($PHPBB_INSTALL_ROOT.$phpbb_storage.$obj->attach_filename)) {
print_msg("\tWARNING: file attachment ".$PHPBB_INSTALL_ROOT.$phpbb_storage.$obj->attach_filename." doesn't exist");
continue;
}
$mime = q_singleval("SELECT id FROM ".$DBHOST_TBL_PREFIX."mime WHERE fl_ext='".substr(strrchr($obj->filename, '.'), 1)."'");
$attach_id = db_qid("INSERT INTO ".$DBHOST_TBL_PREFIX."attach
(original_name, owner, message_id, dlcount, mime_type, fsize)
VALUES (
'".addslashes($obj->filename)."',
".(int)$obj->user_id.",
".(int)$obj->post_id.",
".(int)$obj->download_count.",
".(int)$mime.",
".(int)filesize($PHPBB_INSTALL_ROOT.$phpbb_storage.$obj->attach_filename).")"
);
if (!copy($PHPBB_INSTALL_ROOT.$phpbb_storage.$obj->attach_filename, $FILE_STORE.$attach_id.'.atch')) {
print_msg("Couldn't copy file attachment (".$PHPBB_INSTALL_ROOT.$phpbb_storage.$obj->attach_filename.") to (".$FILE_STORE.$attach_id.'.atch'.")");
exit;
}
q("UPDATE ".$DBHOST_TBL_PREFIX."attach SET location='".$FILE_STORE.$attach_id.'.atch'."' WHERE id=".$attach_id);
}
unset($r);
umask($old_umask);
print_msg('Finished Importing File Attachments');
}