Example #1
0
 // if it wasn't in cache, we need to make it
 // init array
 $messages = array();
 // check if this is a thread subscription
 $thread = isset($PHORUM["args"][1]) ? (int) $PHORUM["args"][1] : 0;
 if ($thread) {
     $PHORUM["args"]["replies"] = 1;
 }
 // check if we are getting replies
 $replies = empty($PHORUM["args"]["replies"]) ? false : true;
 // check the feed type
 $feed_type = empty($PHORUM["args"]["type"]) ? "rss" : $PHORUM["args"]["type"];
 // generate list of forum ids to grab data for
 $forum_ids = array_keys($forums);
 // get messages
 $messages = phorum_db_get_recent_messages(30, 0, $forum_ids, $thread, $replies ? LIST_RECENT_MESSAGES : LIST_RECENT_THREADS);
 // remove users from messages array
 $users = $messages["users"];
 unset($messages["users"]);
 // run read hooks to get everything formatted
 if (isset($PHORUM["hooks"]["read"])) {
     $messages = phorum_hook("read", $messages);
 }
 $messages = phorum_format_messages($messages);
 // set up the feed specifics based on the info we are getting
 if ($thread && $PHORUM["forum_id"]) {
     // could happen with long threads
     if (!isset($messages[$thread])) {
         $thread_start = phorum_db_get_message($thread);
     } else {
         $thread_start = $messages[$thread];
Example #2
0
            $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";
    $recent = phorum_db_get_recent_messages($ncount);
    $markread = array();
    foreach ($recent as $id => $msg) {
        $markread[] = array("id" => $id, "forum" => $msg["forum_id"]);
    }
    foreach ($users as $user_id => $stuff) {
        print ".";
        $PHORUM["user"]["user_id"] = $user_id;
        phorum_db_newflag_add_read($markread);
    }
    print "\n";
}
print "\nDone!\n\n";
exit(0);
Example #3
0
function phorum_setup_announcements()
{
    global $PHORUM;
    // This variable will be used to store the formatted announcements.
    $PHORUM['DATA']['MOD_ANNOUNCEMENTS'] = '';
    // Check if we are on a page on which the announcements have to be shown.
    if (phorum_page == 'index') {
        // Hide the announcements, unless enabled for "index".
        $hide = empty($PHORUM["mod_announcements"]["pages"]["index"]);
        // Show announcements for the root page if "home" is enabled.
        if ($PHORUM['vroot'] == $PHORUM['forum_id'] && !empty($PHORUM["mod_announcements"]["pages"]["home"])) {
            $hide = FALSE;
        }
        if ($hide) {
            return;
        }
    } else {
        if (empty($PHORUM["mod_announcements"]["pages"][phorum_page])) {
            return;
        }
    }
    // Check if we need to show announcements.
    $ann_forum_id = NULL;
    // Inside a vroot, where we have a vroot configuration for the forum
    // to use for announcements and the current forum is not that
    // announcement forum.
    if ($PHORUM['vroot'] > 0 && !empty($PHORUM["mod_announcements"]["vroot"][$PHORUM['vroot']]) && $PHORUM["forum_id"] != $PHORUM["mod_announcements"]["vroot"][$PHORUM['vroot']]) {
        $ann_forum_id = $PHORUM["mod_announcements"]["vroot"][$PHORUM['vroot']];
        // Inside the top level folder, where we have a forum that is configured
        // to be used for announcements and the current forum is not that
        // announcement forum.
    } elseif ($PHORUM['vroot'] == 0 && !empty($PHORUM["mod_announcements"]["forum_id"]) && $PHORUM["forum_id"] != $PHORUM["mod_announcements"]["forum_id"]) {
        $ann_forum_id = $PHORUM["mod_announcements"]["forum_id"];
    }
    // If no announcement forum_id is found, no announcements
    // have to be shown.
    if ($ann_forum_id === NULL) {
        return;
    }
    // Retrieve the last number of posts from the announcement forum.
    $messages = phorum_db_get_recent_messages($PHORUM["mod_announcements"]["number_to_show"], 0, $ann_forum_id, 0, true);
    unset($messages["users"]);
    // No announcements to show? Then we are done.
    if (count($messages) == 0) {
        return;
    }
    // Read the newflags information for authenticated users.
    $newinfo = NULL;
    if ($PHORUM["DATA"]["LOGGEDIN"]) {
        $newflagkey = $ann_forum_id . "-" . $PHORUM['user']['user_id'];
        if ($PHORUM['cache_newflags']) {
            $newinfo = phorum_cache_get('newflags', $newflagkey, $PHORUM['cache_version']);
        }
        if ($newinfo == NULL) {
            $newinfo = phorum_db_newflag_get_flags($ann_forum_id);
            if ($PHORUM['cache_newflags']) {
                phorum_cache_put('newflags', $newflagkey, $newinfo, 86400, $PHORUM['cache_version']);
            }
        }
    }
    require_once "./include/format_functions.php";
    // Process the announcements.
    foreach ($messages as $message) {
        // Skip this message if it's older than the number of days that was
        // configured in the settings screen.
        if (!empty($PHORUM["mod_announcements"]["days_to_show"]) && $message["datestamp"] < time() - $PHORUM["mod_announcements"]["days_to_show"] * 86400) {
            continue;
        }
        // Check if there are new messages in the thread.
        if (isset($newinfo)) {
            $new = 0;
            foreach ($message["meta"]["message_ids"] as $id) {
                if (!isset($newinfo[$id]) && $id > $newinfo['min_id']) {
                    $new = 1;
                    break;
                }
            }
            // There are new messages. Setup the template data for showing
            // a new flag.
            if ($new) {
                $message["new"] = $new ? $PHORUM["DATA"]["LANG"]["newflag"] : NULL;
                $message["URL"]["NEWPOST"] = phorum_get_url(PHORUM_FOREIGN_READ_URL, $message["forum_id"], $message["thread"], "gotonewpost");
            } elseif ($PHORUM["mod_announcements"]["only_show_unread"]) {
                continue;
            }
        }
        // Setup template data for the message.
        unset($message['body']);
        $message["lastpost"] = phorum_date($PHORUM["short_date_time"], $message["modifystamp"]);
        $message["raw_datestamp"] = $message["datestamp"];
        $message["datestamp"] = phorum_date($PHORUM["short_date_time"], $message["datestamp"]);
        $message["URL"]["READ"] = phorum_get_url(PHORUM_FOREIGN_READ_URL, $message["forum_id"], $message["message_id"]);
        $PHORUM["DATA"]["ANNOUNCEMENTS"][] = $message;
    }
    // If all announcements were skipped, then we are done.
    if (!isset($PHORUM["DATA"]["ANNOUNCEMENTS"])) {
        return;
    }
    // format / clean etc. the messages found
    $PHORUM["DATA"]["ANNOUNCEMENTS"] = phorum_format_messages($PHORUM["DATA"]["ANNOUNCEMENTS"]);
    // Build the announcements code.
    ob_start();
    include phorum_get_template("announcements::announcements");
    $PHORUM['DATA']['MOD_ANNOUNCEMENTS'] = ob_get_contents();
    ob_end_clean();
}
Example #4
0
    foreach($forums as $forum_id=>$forum){
        if($forum["folder_flag"]){
            unset($forums[$forum_id]);
        } elseif(empty($default_forum_id)) { 
            $default_forum_id = $forum_id;
        }
    }
    
    $PHORUM["threaded_list"]=false;
    $PHORUM["float_to_top"]=false;
    
    // get the thread set started
    $rows = array();
    $thread = (isset($PHORUM["args"][1])) ? (int)$PHORUM["args"][1] : 0;

    $rows = phorum_db_get_recent_messages(30, $forum_ids, $thread);
    
    unset($rows["users"]);
    
    $items = array();
    $pub_date=0;
    foreach($rows as $key => $row){
    
        if(!$PHORUM["forum_id"]){
            $row["subject"]="[".$forums[$row["forum_id"]]["name"]."] ".$row["subject"];
        }
    
        $forum_id = ($row["forum_id"]==0) ? $default_forum_id : $row["forum_id"];
    
        $items[]=array(
            "pub_date" => date("r",$row["datestamp"]),