function _ff_migrateComments($forum, $sid, $parent) { global $verbose, $_TABLES, $_CONF, $migratedcomments; $sql = DB_query("SELECT sid,date,uid,title,comment from {$_TABLES['comments']} WHERE sid = '" . DB_escapeString($sid) . "' ORDER BY date ASC"); $num_comments = DB_numRows($sql); $i = 0; while (list($sid, $commentdate, $uid, $subject, $comment) = DB_fetchArray($sql)) { $sqlid = DB_query("SELECT id from {$_TABLES['ff_topic']} ORDER BY id desc LIMIT 1"); list($lastid) = DB_fetchArray($sqlid); $comment = prepareStringForDB($comment); $subject = prepareStringForDB($subject); $postmode = "html"; $name = DB_getITEM($_TABLES['users'], 'username', "uid=" . (int) $uid); $email = DB_getITEM($_TABLES['users'], 'email', "uid=" . (int) $uid); $website = DB_getITEM($_TABLES['users'], 'homepage', "uid=" . (int) $uid); $datetime = explode(" ", $commentdate); $date = explode("-", $datetime[0]); $time = explode(":", $datetime[1]); $year = $date[0] > 1969 ? $date[0] : "2001"; $month = $date[1]; $day = $date[2]; $hour = $time[0]; $min = $time[1]; $timestamp = mktime($hour, $min, 0, $month, $day, $year); $lastupdated = $timestamp; $migratedcomments++; DB_query("INSERT INTO {$_TABLES['ff_topic']} (forum,name,date,lastupdated, email, website, subject, comment, postmode, ip, mood, uid, pid, sticky, locked)\n VALUES (" . (int) $forum . ",'" . DB_escapeString($name) . "','{$timestamp}','{$lastupdated}','" . DB_escapeString($email) . "','" . DB_escapeString($website) . "','{$subject}','{$comment}','" . DB_escapeString($postmode) . "','',''," . (int) $uid . "," . (int) $parent . ",'0','0')"); $i++; } DB_query("UPDATE {$_TABLES['ff_topic']} SET replies = {$num_comments} WHERE id=" . (int) $parent); return $num_comments; }
function migrateComments($forum, $sid, $parent) { global $verbose, $_TABLES, $_CONF, $migratedcomments; $sql = "SELECT sid,date,uid,title,comment " . "FROM {$_TABLES['comments']} WHERE sid = '{$sid}' ORDER BY date ASC"; $result = DB_query($sql); $num_comments = DB_numRows($result); if ($verbose) { echo "Found {$num_comments} Comments to migrate for this topic"; } $i = 0; while (list($sid, $commentdate, $uid, $subject, $comment) = DB_fetchArray($result)) { $sqlid = DB_query("SELECT id FROM {$_TABLES['forum_topic']} ORDER BY id DESC LIMIT 1"); list($lastid) = DB_fetchArray($sqlid); $comment = prepareStringForDB($comment); $subject = prepareStringForDB($subject); $postmode = "HTML"; $name = DB_getItem($_TABLES['users'], 'username', "uid={$uid}"); $email = DB_getItem($_TABLES['users'], 'email', "uid={$uid}"); $website = DB_getItem($_TABLES['users'], 'homepage', "uid={$uid}"); $datetime = explode(" ", $commentdate); $date = explode("-", $datetime[0]); $time = explode(":", $datetime[1]); $year = $date[0] > 1969 ? $date[0] : "2001"; $month = $date[1]; $day = $date[2]; $hour = $time[0]; $min = $time[1]; $timestamp = mktime($hour, $min, 0, $month, $day, $year); $lastupdated = $timestamp; $migratedcomments++; DB_query("INSERT INTO {$_TABLES['forum_topic']} " . "(forum,name,date,lastupdated, email, website, subject, " . "comment, postmode, ip, mood, uid, pid, sticky, locked) " . "VALUES ('{$forum}','{$name}','{$timestamp}','{$lastupdated}','{$email}'," . "'{$website}','{$subject}','{$comment}','{$postmode}','',''," . "'{$uid}','{$parent}','0','0')"); PLG_itemSaved(DB_insertID(), 'forum'); $i++; } DB_query("UPDATE {$_TABLES['forum_topic']} SET replies = {$num_comments} WHERE id={$parent}"); return $num_comments; }