tasairis wrote:It'd sure help if you posted code...
I'm sorry, but the code was posted in that pastebin link. Here's the code for any debuggers out there:
Code: Select all
<?
/*
Coburn's Domain 2 to SMF Conversionator
+-------- Made by Weremuffin. --------+
*/
## Edit these variables for maximum conversion
$db_server = 'localhost'; ## DB Server
$db_user = 'removedusername'; ## DB Username
$db_pass = 'removedpassword'; ## DB Password
$cd_db_name = 'coburndomain2'; ## This where the Coburn's Domain data is located.
$smf_db_name = 'smf'; ## This is where the SMF forum is located.
$smf_forum_prefix = 'smf_'; ## This is the prefix used by your SMF installation.
$smf_desig_forumid = '2'; ## This is where the posts get sent to.
## Infact, If you didn't edit them it probably wouldn't even work..
## Um, Yeah. Don't edit below. Maybe.
## If somethings buggy, DM or Email me.
$mysqli_cd = new mysqli($db_server, $db_user, $db_pass, $cd_db_name);
$cd_error = mysqli_connect_errno();
$mysqli_smf = new mysqli($db_server, $db_user, $db_pass, $smf_db_name);
$smf_error = mysqli_connect_errno();
?>
<html>
<head>
<style>
span{ font-weight:bold; }
span.success{ color:#34BA34; }
span.failure{ color:#FF0000; }
</style>
</head>
<body>
<?
if($cd_error == 0) echo"CD Database Connection: <span class='success'>Success</span><br>";
else{
echo"CD Database Connection: <span class='failure'>Failure</span><br>";
echo"Error #$cd_error. Please check settings and try again.<br>";
}
if($smf_error == 0) echo"SMF Database Connection: <span class='success'>Success</span><br><br>";
else{
echo"SMF Database Connection: <span class='failure'>Failure</span><br>";
echo"Error #$smf_error. Please check settings and try again.<br>";
}
if($cd_error == 0 && $smf_error == 0){
$threads = $mysqli_cd->query("select * from forum_threads");
$iter = 1;
while($t = $threads->fetch_object()){
$firstpost = $mysqli_cd->query("select posttitle from forum_posts where postid='$t->firstpostid'")->fetch_object();
$origforum = $mysqli_cd->query("select name,catid from forumsubcats where id='$t->forumid'")->fetch_object();
$origcat = $mysqli_cd->query("select catname from forumcategories where catid='$origforum->catid'")->fetch_object()->catname;
echo "Converting thread: $firstpost->posttitle<br>";
$topicid = $mysqli_smf->query("select ID_TOPIC from ".$smf_forum_prefix."topics order by ID_TOPIC desc limit 1")->fetch_object()->ID_TOPIC+1;
$rand1 = mt_rand(1,1000).mt_rand(1,1000);
$rand2 = mt_rand(1,1000).mt_rand(1,1000);
$mysqli_smf->query("insert into ".$smf_forum_prefix."topics
(
ID_BOARD,
ID_MEMBER_STARTED,
ID_MEMBER_UPDATED,
ID_FIRST_MSG,
ID_LAST_MSG,
locked,
isSticky,
numViews,
ID_POLL
)
values(
'$smf_desig_forumid',
'0','0',
'$rand1','$rand2',
'1','0',
'$t->views','0'
)
");
if(eregi('duplicate key',$mysqli_smf->error)){
echo"Critical Error. Script has ended.<br>Please restore the tables 'topics' and 'messages' from a backup and try again.";
exit;
}
$posts = $mysqli_cd->query("select * from forum_posts where threadid='$t->threadid'");
while($p = $posts->fetch_object()){
$poster = $mysqli_cd->query("select username from members where userid='$p->userid'")->fetch_object()->username;
echo "Converting post by: $poster<br>";
if($p->postid == $t->firstpostid){
if($t->issticky == 1) $stick = '[sticky] ';
else $stick = '';
$newtitle = $stick.$firstpost->posttitle;
}
else $newtitle = "Re: $firstpost->posttitle";
$origforumnote = "\n\n------------------------------\nOriginal Forum: $origcat - $origforum->name";
$smfpost = $p->post.$origforumnote;
$stmt = $mysqli_smf->stmt_init();
$stmt->prepare("insert into ".$smf_forum_prefix."messages
values(
null,
'$topicid',
'$smf_desig_forumid',
'$p->posttime',
'0',
'',
?,
?,
'',
'$p->posterip',
'1', '0', '',
?,
'xx'
)
");
$stmt->bind_param("sss",$newtitle,$poster,$smfpost);
$stmt->execute();
$stmt->close();
$postid = $mysqli_smf->insert_id;
$mysqli_smf->query("update ".$smf_forum_prefix."messages set ID_MSG_MODIFIED='$postid' where ID_MSG='$postid'");
if($p->postid == $t->firstpostid) $mysqli_smf->query("update ".$smf_forum_prefix."topics set ID_FIRST_MSG='$postid' where ID_TOPIC='$topicid'");
$origforumnote = '';
}
$last_postid = $postid;
$mysqli_smf->query("update ".$smf_forum_prefix."topics set ID_LAST_MSG='$last_postid' where ID_TOPIC='$topicid'");
echo"<br>";
// if($iter == 2) exit;
// else $iter++;
}
}
?>
</body>
</html>