echo "Reading maximum message-id from messages-table... {$CONVERT['lbr']}"; flush(); $CONVERT['max_id'] = phorum_db_get_max_messageid(); $offsets[$forumid] = $CONVERT['max_id']; if ($forumdata['allow_uploads'] == 'Y' && file_exists($CONVERT['attachmentdir'] . "/" . $forumdata['table_name'])) { $CONVERT['attachments'] = phorum_convert_getAttachments($forumdata['table_name']); echo "Reading attachments for forum " . $forumdata['name'] . "...{$CONVERT['lbr']}"; flush(); } echo "Writing postings for forum " . $forumdata['name'] . "...{$CONVERT['lbr']}"; flush(); $count = 1; $total = 0; $res = phorum_convert_selectMessages($forumdata, $oldlink); while ($newmessage = phorum_convert_getNextMessage($res, $forumdata['table_name'])) { if (phorum_db_post_message($newmessage, true)) { phorum_update_thread_info($newmessage['thread']); echo "+"; flush(); if ($count == 50) { $total += $count; echo " {$total} from \"{$forumdata['name']}\""; if ($CONVERT['lbr'] == "\n") { // lets just go back on this line if we are on the console echo "\r"; } else { echo $CONVERT['lbr']; } flush(); $count = 0; }
"thread" => 0, "parent_id" => 0, "author" => 'Phorum Installer', "subject" => 'Test Message', "email" => '', "ip" => '127.0.0.1', "user_id" => 0, "moderator_post" => 0, "closed" => 0, "status" => PHORUM_STATUS_APPROVED, "sort" => PHORUM_SORT_DEFAULT, "msgid" => '', "body" => "This is a test message. You can delete it after install using the admin.\n\nPhorum 5 Team" ); phorum_db_post_message($test_message); include_once ("./include/thread_info.php"); phorum_update_thread_info($test_message["thread"]); phorum_db_update_forum_stats(true); } $frm = new PhorumInputForm ("", "post", "Continue ->"); $frm->addbreak("Creating tables...."); $frm->addmessage($message); $frm->hidden("step", "6"); $frm->hidden("module", "install"); $frm->show();
* global $PHORUM; * * // Add the disclaimer to the new message body * $message["body"] .= "\n".$PHORUM["DATA"]["LANG"]["mod_foo"]["Disclaimer"]; * * return $message; * } * </hookcode> */ if (isset($PHORUM["hooks"]["before_post"])) { $message = phorum_hook("before_post", $message); } // Keep a copy of the message we have got now. $message_copy = $message; // Store the message in the database. $success = phorum_db_post_message($message); if ($success) { // Handle linking and deleting of attachments to synchronize // the message attachments with the working copy list // of attachments. foreach ($message_copy["attachments"] as $info) { if ($info["keep"]) { phorum_db_file_link($info["file_id"], $message["message_id"], PHORUM_LINK_MESSAGE); } else { if (phorum_api_file_check_delete_access($info["file_id"])) { phorum_api_file_delete($info["file_id"]); } } } // Retrieve the message again to have it in the correct // format (otherwise it's a bit messed up in the
$msg['thread'] = $target['thread']; // the thread we merge with $msg['forum_id'] = $target['forum_id']; // the forum_id of the new thread $msg['sort'] = $target['sort']; // the sort type of the new thread if ($msg['message_id'] == $msg['thread']) { $msg['parent_id'] = $target['thread']; } elseif (isset($msgid_translation[$msg['parent_id']])) { $msg['parent_id'] = $msgid_translation[$msg['parent_id']]; } else { $msg['parent_id'] = $msg['thread']; } unset($msg['message_id']); unset($msg['modifystamp']); phorum_db_post_message($msg, true); // Link attached files to the new message id. $linked_files = phorum_db_get_message_file_list($oldid); foreach ($linked_files as $linked_file) { phorum_db_file_link($linked_file["file_id"], $msg["message_id"], PHORUM_LINK_MESSAGE); } // save the new message-id for later use $msgid_translation[$oldid] = $msg['message_id']; } // deleting messages which are now doubled phorum_db_delete_message($_POST['thread'], PHORUM_DELETE_TREE); // update message count / stats phorum_db_update_forum_stats(true); // change forum_id for the following calls to update the right forum $PHORUM["forum_id"] = $target['forum_id']; // update message count / stats
/** * Create a message. * * @param int $p_forumId * The forum ID that this message belongs to. * * @param string $p_subject * The subject of the message. * * @param string $p_body * The body of the message * * @param int $p_threadId * Set this to zero if it is the first message in the thread * * @param int $p_parentId * The message you are replying to. * * @param string $p_author * Human readable string for the name of the author. * * @param string $p_email * Author's email. * * @param int $p_userId * User ID that is stored in the phorum_users table. * * @return boolean */ public function create($p_forumId, $p_subject ='', $p_body = '', $p_threadId = 0, $p_parentId = 0, $p_author = '', $p_email = '', $p_userId = 0) { global $PHORUM; global $g_ado_db; if (!is_numeric($p_forumId)) { return null; } // Fetch the settings and pretend they were returned to // us instead of setting a global variable. phorum_db_load_settings(); $settings = $PHORUM['SETTINGS']; // Required Input $message['forum_id'] = $p_forumId; // Optional input $message['body'] = $p_body; $message['subject'] = $p_subject; $message['thread'] = $p_threadId; $message['parent_id'] = $p_parentId; $message['author'] = $p_author; $message['email'] = $p_email; $message['user_id'] = $p_userId; // Defaults $message['sort'] = PHORUM_SORT_DEFAULT; $message['closed'] = 0; // ??? Whats that suffix for? // $suffix = preg_replace("/[^a-z0-9]/i", "", $PHORUM["name"]); // $message['msgid'] = md5(uniqid(rand())) . ".$suffix"; $message['msgid'] = md5(uniqid(rand())); $message['moderator_post'] = '0'; $message['datestamp'] = time(); // Fetch the forum object - // we need it for the config values. $forumObj = new Phorum_forum($p_forumId); if (!$forumObj->exists()) { return false; } // Set message workflow based on forum config. if ($forumObj->isModerated()) { $message['status'] = PHORUM_STATUS_HOLD; } else { $message['status'] = PHORUM_STATUS_APPROVED; } // Set user IP. $user_ip = $_SERVER["REMOTE_ADDR"]; if ($settings["dns_lookup"]) { $resolved = @gethostbyaddr($_SERVER["REMOTE_ADDR"]); if (!empty($resolved)) { $user_ip = $resolved; } } $message["ip"] = $user_ip; $lockTables = array($PHORUM['message_table'], $PHORUM['search_table'], $PHORUM['subscribers_table']); $this->lockTables($lockTables); phorum_db_post_message($message); $this->mod_emailcomments($message); // Update the thread count. $sql = "SELECT COUNT(*) as thread_count FROM ".$PHORUM['message_table'] ." WHERE forum_id=".$p_forumId ." AND thread=".$message['thread'] ." AND status > 0"; $threadCount = $g_ado_db->GetOne($sql); $sql = "UPDATE ".$PHORUM['message_table'] ." SET thread_count=".$threadCount; $g_ado_db->Execute($sql); // Retrieve the message again because the database sets // some values. $message = phorum_db_get_message($message["message_id"], "message_id", true); $this->m_data = $message; // Set the thread depth $this->__initThreadDepth(); // Set the thread order. $this->__initThreadOrder(); $this->__updateThreadInfo(); if (isset($PHORUM['user']['user_id'])) { // Mark own message read. phorum_db_newflag_add_read(array(0=>array( "id" => $message["message_id"], "forum" => $message["forum_id"], ))); // Update the number of messages the user has posted. phorum_db_user_addpost(); } // Actions for messages which are approved. if ($message["status"] > 0) { // Update forum statistics, // ??? Note: phorum_db_update_forum_stats requires global parameter-passing. $PHORUM['forum_id'] = $p_forumId; phorum_db_update_forum_stats(false, 1, $message["datestamp"]); // Mail subscribed users. //phorum_email_notice($message); } // Mail moderators. if ($forumObj->emailModeratorsEnabled()) { //phorum_email_moderators($message); } $this->unlockTables(); return true; } // fn create
} if ($tcount) { $batch = time(); print "\nPosting {$tcount} threads to the database:\n\n"; $count = 0; while ($tcount) { $f = $forum_ids[$count % count($forum_ids)]; print "."; $count++; $treemsgs = array(); $parent = 0; $thread = 0; for ($i = 0; $i < $mcount; $i++) { $u = $user_ids[$i % count($user_ids)]; $msg = array("parent_id" => $parent, "thread" => $thread, "forum_id" => $f, "subject" => "Message {$i} of stress batch thread {$batch} / {$count}", "body" => "I am just a test message, created by the Phorum\n" . "stress testing software. I have no value at all.\n", "user_id" => $u, "author" => $users[$u]["username"], "ip" => "127.0.0.1", "status" => PHORUM_STATUS_APPROVED, "msgid" => "<stressbatch_{$batch}_{$count}_{$i}@localhost>", "moderator_post" => 0, "sort" => PHORUM_SORT_DEFAULT, "closed" => 0); phorum_db_post_message($msg); $thread = $msg["thread"]; $treemsgs[] = $msg["message_id"]; $parent = $treemsgs[array_rand($treemsgs)]; } phorum_update_thread_info($thread); $tcount--; } print "\n"; foreach ($forum_ids as $id) { $PHORUM["forum_id"] = $id; phorum_db_update_forum_stats(true); } } if ($ncount) { print "\nSetting {$ncount} newflags for " . count($users) . " users:\n\n";