Esempio n. 1
0
                "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();

            break;

        case 4:
Esempio n. 2
0
 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;
         }
         $count++;
Esempio n. 3
0
     $PHORUM["float_to_top"] = 0;
     $PHORUM["threaded_list"] = 0;
     $PHORUM['list_length_flat'] = 100;
     $threads_updated = 0;
     foreach ($forums as $fid => $fdata) {
         if ($fdata['folder_flag'] == 0) {
             $PHORUM['forum_id'] = $fid;
             $PHORUM['vroot'] = $fdata['vroot'];
             $offset = 0;
             while ($offset < $fdata['thread_count']) {
                 $curpage = $offset / 100;
                 $threads = phorum_db_get_thread_list($curpage);
                 $num_threads = count($threads);
                 if ($num_threads) {
                     foreach ($threads as $tid => $tdata) {
                         phorum_update_thread_info($tid);
                     }
                     $threads_updated += $num_threads;
                     // if we got less messages, we can jump out - last page hopefully
                     if ($num_threads < 100) {
                         break;
                     }
                 }
                 $offset += 100;
             }
             $forums_updated++;
         }
     }
     $PHORUM['forum_id'] = $old_forum_id;
     $okmsg .= "{$threads_updated} threads updated.<br />";
 }
Esempio n. 4
0
    return;
}
define('phorum_page', 'rebuild_thread_info');
define('PHORUM_ADMIN', 1);
chdir(dirname(__FILE__) . "/..");
require_once './common.php';
include './include/thread_info.php';
// Make sure that the output is not buffered.
phorum_ob_clean();
if (!ini_get('safe_mode')) {
    set_time_limit(0);
    ini_set("memory_limit", "128M");
}
print "\nRebuilding thread info meta data ...\n";
$count_total = phorum_db_interact(DB_RETURN_VALUE, "SELECT count(*)\n     FROM   {$PHORUM["message_table"]}\n     WHERE  parent_id = 0 AND\n            message_id = thread");
$res = phorum_db_interact(DB_RETURN_RES, "SELECT message_id, forum_id\n     FROM   {$PHORUM["message_table"]}\n     WHERE  parent_id = 0 AND\n            message_id = thread");
$size = strlen($count_total);
$count = 0;
while ($row = phorum_db_fetch_row($res, DB_RETURN_ROW)) {
    $PHORUM['forum_id'] = $row[1];
    phorum_update_thread_info($row[0]);
    $count++;
    $perc = floor($count / $count_total * 100);
    $barlen = floor(20 * ($perc / 100));
    $bar = "[";
    $bar .= str_repeat("=", $barlen);
    $bar .= str_repeat(" ", 20 - $barlen);
    $bar .= "]";
    printf("updating %{$size}d / %{$size}d  %s (%d%%)\r", $count, $count_total, $bar, $perc);
}
print "\n\n";
Esempio n. 5
0
/**
 * Delete a message or a message tree from the database.
 *
 * @param integer $message_id
 *     The message_id of the message which should be deleted.
 *
 * @param integer $mode
 *     The mode of deletion. This is one of:
 *     - PHORUM_DELETE_MESSAGE: Delete a message and reconnect
 *       its reply messages to the parent of the deleted message.
 *     - PHORUM_DELETE_TREE: Delete a message and all its reply messages.
 */
function phorum_db_delete_message($message_id, $mode = PHORUM_DELETE_MESSAGE)
{
    $PHORUM = $GLOBALS['PHORUM'];
    settype($message_id, 'int');
    settype($mode, 'int');
    // Find the info for the message that has to be deleted.
    $msg = phorum_db_interact(DB_RETURN_ASSOC, "SELECT forum_id, message_id, thread, parent_id\n         FROM   {$PHORUM['message_table']}\n         WHERE  message_id = {$message_id}");
    if (empty($msg)) {
        trigger_error("No message found for message_id {$message_id}", E_USER_ERROR);
    }
    // Find all message_ids that have to be deleted, based on the mode.
    if ($mode == PHORUM_DELETE_TREE) {
        $mids = phorum_db_get_messagetree($message_id, $msg['forum_id']);
        $where = "message_id IN ({$mids})";
        $mids = explode(',', $mids);
    } else {
        $mids = array($message_id);
        $where = "message_id = {$message_id}";
    }
    // First, the messages are unapproved, so replies will not get posted
    // during the time that we need for deleting them. There is still a
    // race condition here, but this already makes things quite reliable.
    phorum_db_interact(DB_RETURN_RES, "UPDATE {$PHORUM['message_table']}\n         SET    status=" . PHORUM_STATUS_HOLD . "\n         WHERE  {$where}", NULL, DB_MASTERQUERY);
    $thread = $msg['thread'];
    // Change reply messages to point to the parent of the deleted message.
    if ($mode == PHORUM_DELETE_MESSAGE) {
        // The forum_id is in here for speeding up the query
        // (with the forum_id a lookup key will be used).
        phorum_db_interact(DB_RETURN_RES, "UPDATE {$PHORUM['message_table']}\n             SET    parent_id = {$msg['parent_id']}\n             WHERE  forum_id  = {$msg['forum_id']} AND\n                    parent_id = {$msg['message_id']}", NULL, DB_MASTERQUERY);
    }
    // Delete the messages.
    phorum_db_interact(DB_RETURN_RES, "DELETE FROM {$PHORUM['message_table']}\n         WHERE {$where}", NULL, DB_MASTERQUERY);
    // Delete the read flags.
    phorum_db_interact(DB_RETURN_RES, "DELETE FROM {$PHORUM['user_newflags_table']}\n         WHERE {$where}", NULL, DB_MASTERQUERY);
    // Delete the edit tracking.
    phorum_db_interact(DB_RETURN_RES, "DELETE FROM {$PHORUM['message_tracking_table']}\n         WHERE {$where}", NULL, DB_MASTERQUERY);
    // Full text searching updates.
    phorum_db_interact(DB_RETURN_RES, "DELETE FROM {$PHORUM['search_table']}\n         WHERE {$where}", NULL, DB_MASTERQUERY);
    // It kind of sucks to have this here, but it is the best way
    // to ensure that thread info gets updated if messages are deleted.
    // Leave this include down here, so it is included conditionally.
    include_once './include/thread_info.php';
    phorum_update_thread_info($thread);
    // We need to delete the subscriptions for the thread too.
    phorum_db_interact(DB_RETURN_RES, "DELETE FROM {$PHORUM['subscribers_table']}\n         WHERE forum_id > 0 AND thread = {$thread}", NULL, DB_MASTERQUERY);
    // This function will be slow with a lot of messages.
    phorum_db_update_forum_stats(TRUE);
    return $mids;
}
Esempio n. 6
0
     $PHORUM['DATA']["FORM"]["message_id"] = $msgthd_id;
     $PHORUM['DATA']["FORM"]["message_subject"] = htmlspecialchars($message["subject"], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]);
     $PHORUM['DATA']["FORM"]["mod_step"] = PHORUM_DO_THREAD_SPLIT;
     $template = "split_form";
     break;
 case PHORUM_DO_THREAD_SPLIT:
     // this is the last step of a thread split
     $PHORUM['DATA']['OKMSG'] = $PHORUM["DATA"]['LANG']['MsgSplitOk'];
     $PHORUM['DATA']["URL"]["REDIRECT"] = $PHORUM["DATA"]["URL"]["LIST"];
     settype($_POST['forum_id'], "int");
     settype($_POST['message'], "int");
     settype($_POST['thread'], "int");
     phorum_db_split_thread($_POST['message'], $_POST['forum_id']);
     // update message count / stats
     phorum_update_thread_info($_POST['thread']);
     phorum_update_thread_info($_POST['message']);
     phorum_db_update_forum_stats(true);
     /*
      * [hook]
      *     after_split
      *
      * [description]
      *     This hook can be used for performing actions on
      *     splitting threads
      *
      * [category]
      *     Moderation
      *
      * [when]
      *     In <filename>moderation.php</filename>, right after a thread has
      *     been split by a moderator.
Esempio n. 7
0
/**
 * This function deletes messages from the messages table.
 *
 * @param message $ _id the id of the message which should be deleted
 * mode the mode of deletion, PHORUM_DELETE_MESSAGE for reconnecting the children, PHORUM_DELETE_TREE for deleting the children
 */

function phorum_db_delete_message($message_id, $mode = PHORUM_DELETE_MESSAGE)
{
    $PHORUM = $GLOBALS["PHORUM"];

    $conn = phorum_db_postgresql_connect();

    settype($message_id, "int");

#    // lock the table so we don't leave orphans.
#    pg_query($conn, "LOCK TABLES {$PHORUM['message_table']} WRITE");

    $threadset = 0;
    // get the parents of the message to delete.
    $sql = "select forum_id, message_id, thread, parent_id from {$PHORUM['message_table']} where message_id = $message_id ";
    $res = pg_query($conn, $sql);
    $rec = pg_fetch_assoc($res);

    if($mode == PHORUM_DELETE_TREE){
        $mids = phorum_db_get_messagetree($message_id, $rec['forum_id']);
    }else{
        $mids = $message_id;
    }

    $thread = $rec['thread'];
    if($thread == $message_id && $mode == PHORUM_DELETE_TREE){
        $threadset = 1;
    }else{
        $threadset = 0;
    }

    if($mode == PHORUM_DELETE_MESSAGE){
        $count = 1;
        // change the children to point to their parent's parent
        // forum_id is in here for speed by using a key only
        $sql = "update {$PHORUM['message_table']} set parent_id=$rec[parent_id] where forum_id=$rec[forum_id] and parent_id=$rec[message_id]";
        pg_query($conn, $sql);
    }else{
        $count = count(explode(",", $mids));
    }

    // delete the messages
    $sql = "delete from {$PHORUM['message_table']} where message_id in ($mids)";
    pg_query($conn, $sql);

#    // clear the lock
#    pg_query($conn, "UNLOCK TABLES");

    // start ft-search stuff
    $sql="delete from {$PHORUM['search_table']} where message_id in ($mids)";
    $res = pg_query($conn, $sql);
    if ($err = pg_last_error()) phorum_db_pg_last_error("$err: $sql");
    // end ft-search stuff

    // it kind of sucks to have this here, but it is the best way
    // to ensure that it gets done if stuff is deleted.
    // leave this include here, it needs to be conditional
    include_once("./include/thread_info.php");
    phorum_update_thread_info($thread);

    // we need to delete the subscriptions for that thread too
    $sql = "DELETE FROM {$PHORUM['subscribers_table']} WHERE forum_id > 0 AND thread=$thread";
    $res = pg_query($conn, $sql);
    if ($err = pg_last_error()) phorum_db_pg_last_error("$err: $sql");

    // this function will be slow with a lot of messages.
    phorum_db_update_forum_stats(true);

    return explode(",", $mids);
}