Пример #1
0
function phorum_pm_format($messages)
{
    $PHORUM = $GLOBALS["PHORUM"];
    include_once "./include/format_functions.php";
    // Reformat message so it looks like a forum message (so we can run it
    // through phorum_format_messages) and do some PM specific formatting.
    foreach ($messages as $id => $message) {
        // The formatting code expects a message id.
        $messages[$id]["message_id"] = $id;
        // Read URLs need a folder id, so we only create that URL if
        // one's available.
        if (isset($message['pm_folder_id'])) {
            $folder_id = $message['pm_folder_id'] ? $message['pm_folder_id'] : $message['special_folder'];
            $messages[$id]["URL"]["READ"] = phorum_get_url(PHORUM_PM_URL, "page=read", "folder_id={$folder_id}", "pm_id={$id}");
        }
        // The datestamp is only available for already posted messages.
        if (isset($message['datestamp'])) {
            $messages[$id]["raw_date"] = $message["datestamp"];
            $messages[$id]["date"] = phorum_date($PHORUM["short_date_time"], $message["datestamp"]);
        }
        if (isset($message['meta']) && !is_array($message['meta'])) {
            $messages[$id]['meta'] = unserialize($message['meta']);
        }
        $messages[$id]["body"] = isset($message["message"]) ? $message["message"] : "";
        $messages[$id]["email"] = "";
        $messages[$id]["URL"]["PROFILE"] = phorum_get_url(PHORUM_PROFILE_URL, $message["user_id"]);
        $messages[$id]["recipient_count"] = 0;
        $messages[$id]["receive_count"] = 0;
        if (isset($message["recipients"]) && is_array($message["recipients"])) {
            $receive_count = 0;
            foreach ($message["recipients"] as $rcpt_id => $rcpt) {
                if (!empty($rcpt["read_flag"])) {
                    $receive_count++;
                }
                if (!isset($rcpt["display_name"])) {
                    $messages[$id]["recipients"][$rcpt_id]["display_name"] = $PHORUM["DATA"]["LANG"]["AnonymousUser"];
                } else {
                    $messages[$id]["recipients"][$rcpt_id]["display_name"] = empty($PHORUM["custom_display_name"]) ? htmlspecialchars($rcpt["display_name"], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]) : $rcpt["display_name"];
                    $messages[$id]["recipients"][$rcpt_id]["URL"]["PROFILE"] = phorum_get_url(PHORUM_PROFILE_URL, $rcpt_id);
                }
            }
            $messages[$id]["recipient_count"] = count($message["recipients"]);
            $messages[$id]["receive_count"] = $receive_count;
        }
    }
    // Run the messages through the standard formatting code.
    $messages = phorum_format_messages($messages);
    // Reformat message back to a private message.
    foreach ($messages as $id => $message) {
        $messages[$id]["message"] = $message["body"];
        unset($messages[$id]["body"]);
    }
    return $messages;
}
Пример #2
0
        foreach($_POST["delete"] as $file_id){

            phorum_db_file_delete($file_id);

        }                

    }

    $files = phorum_db_get_user_file_list($PHORUM["user"]["user_id"]);

    $total_size=0;

    foreach($files as $key => $file) {
        $files[$key]["filesize"] = phorum_filesize($file["filesize"]);
        $files[$key]["dateadded"]=phorum_date($PHORUM["short_date"], $file["add_datetime"]);

        $files[$key]["url"]=phorum_get_url(PHORUM_FILE_URL, "file=$key");

        $total_size+=$file["filesize"];
    } 

    $template = "cc_files";

    if($PHORUM["max_file_size"]){
        $PHORUM["DATA"]["FILE_SIZE_LIMIT"]=$PHORUM["DATA"]["LANG"]["FileSizeLimits"] . ' ' . phorum_filesize($PHORUM["max_file_size"]*1024);
    }

    if($PHORUM["file_types"]){
        $PHORUM["DATA"]["FILE_TYPE_LIMIT"]=$PHORUM["DATA"]["LANG"]["FileTypeLimits"];
    }
Пример #3
0
// reading all subscriptions to messages
$subscr_array = phorum_db_get_message_subscriptions($PHORUM['user']['user_id'], $subdays); 

// reading all forums
$forum_ids = $subscr_array['forum_ids'];
unset($subscr_array['forum_ids']);
$forums_arr = phorum_db_get_forums($forum_ids,-1,$PHORUM['vroot']);
$subscr_array_final = array();
foreach($subscr_array as $dummy => $data) {
    if ($data['forum_id'] == 0) {
        $data['forum'] = $PHORUM['DATA']['LANG']['Announcement'];
    } else {
        $data['forum'] = $forums_arr[$data['forum_id']]['name'];
    } 

    $data['datestamp'] = phorum_date($PHORUM["short_date"], $data["modifystamp"]);
    $data['readurl'] = phorum_get_url(PHORUM_FOREIGN_READ_URL, $data["forum_id"], $data["thread"]);

    if(!empty($data["user_id"])) {
        $data["profile_url"] = phorum_get_url(PHORUM_PROFILE_URL, $data["user_id"]);
        // we don't normally put HTML in this code, but this makes it easier on template builders
        $data["linked_author"] = "<a href=\"".$data["profile_url"]."\">".htmlspecialchars($data["author"])."</a>";
    } elseif(!empty($data["email"])) {
        $data["email_url"] = phorum_html_encode("mailto:$data[email]");
        // we don't normally put HTML in this code, but this makes it easier on template builders
        $data["linked_author"] = "<a href=\"".$data["email_url"]."\">".htmlspecialchars($data["author"])."</a>";
    } else {
        $data["linked_author"] = htmlspecialchars($data["author"]);
    }

    $data["subject"]=htmlspecialchars($data["subject"]);
Пример #4
0
foreach ($forums as $forum) {
    if ($forum["folder_flag"]) {
        $forum["URL"]["LIST"] = phorum_get_url(PHORUM_INDEX_URL, $forum["forum_id"]);
    } else {
        if ($PHORUM["hide_forums"] && !phorum_api_user_check_access(PHORUM_USER_ALLOW_READ, $forum["forum_id"])) {
            continue;
        }
        $forum["url"] = phorum_get_url(PHORUM_LIST_URL, $forum["forum_id"]);
        // if there is only one forum in Phorum, redirect to it.
        if ($parent_id == 0 && count($forums) < 2) {
            phorum_redirect_by_url($forum['url']);
            exit;
        }
        if ($forum["message_count"] > 0) {
            $forum["raw_last_post"] = $forum["last_post_time"];
            $forum["last_post"] = phorum_date($PHORUM["long_date_time"], $forum["last_post_time"]);
        } else {
            $forum["last_post"] = "&nbsp;";
        }
        $forum["URL"]["LIST"] = phorum_get_url(PHORUM_LIST_URL, $forum["forum_id"]);
        if ($PHORUM["DATA"]["LOGGEDIN"]) {
            $forum["URL"]["MARK_READ"] = phorum_get_url(PHORUM_INDEX_URL, $forum["forum_id"], "markread", $PHORUM['forum_id']);
        }
        if (isset($PHORUM['use_rss']) && $PHORUM['use_rss']) {
            $forum["URL"]["FEED"] = phorum_get_url(PHORUM_FEED_URL, $forum["forum_id"], "type=" . $PHORUM["default_feed"]);
        }
        $forum["raw_message_count"] = $forum["message_count"];
        $forum["message_count"] = number_format($forum["message_count"], 0, $PHORUM["dec_sep"], $PHORUM["thous_sep"]);
        $forum["raw_thread_count"] = $forum["thread_count"];
        $forum["thread_count"] = number_format($forum["thread_count"], 0, $PHORUM["dec_sep"], $PHORUM["thous_sep"]);
        if ($PHORUM["DATA"]["LOGGEDIN"]) {
Пример #5
0
function phorum_feed_make_js($messages, $forums, $feed_url, $feed_title, $feed_description)
{
    $PHORUM = $GLOBALS["PHORUM"];
    // build PHP array to later be turned into a JS object
    $feed["title"] = $feed_title;
    $feed["description"] = $feed_description;
    $feed["modified"] = phorum_date($PHORUM['short_date'], time());
    // Lookup the plain text usernames for the authenticated authors.
    $users = $messages['users'];
    unset($messages['users']);
    unset($users[0]);
    $users = phorum_api_user_get_display_name($users, '', PHORUM_FLAG_PLAINTEXT);
    foreach ($messages as $message) {
        $author = isset($users[$message['user_id']]) && $users[$message['user_id']] != '' ? $users[$message['user_id']] : $message['author'];
        $item = array("title" => strip_tags($message["subject"]), "author" => $author, "category" => $forums[$message["forum_id"]]["name"], "created" => phorum_date($PHORUM['short_date'], $message["datestamp"]), "modified" => phorum_date($PHORUM['short_date'], $message["modifystamp"]), "url" => phorum_get_url(PHORUM_FOREIGN_READ_URL, $message["forum_id"], $message["thread"], $message["message_id"]), "description" => $message["body"]);
        if ($message["thread_count"]) {
            $replies = $message["thread_count"] - 1;
            $item["replies"] = $replies;
        }
        $feed["items"][] = $item;
    }
    // this is where we convert the array into js
    $buffer = phorum_array_to_javascript("phorum_feed", $feed);
    return $buffer;
}
Пример #6
0
 $frm = new PhorumInputForm("", "post", "Update");
 $frm->hidden("module", "users");
 $frm->hidden("section", "main");
 $frm->hidden("referrer", $referrer);
 $frm->hidden("user_id", $_REQUEST["user_id"]);
 $frm->addbreak("Edit User");
 $frm->addrow("User Name", htmlspecialchars($user["username"]) . "&nbsp;&nbsp;<a href=\"#forums\">Edit Forum Permissions</a>&nbsp;&nbsp;<a href=\"#groups\">Edit Groups</a>");
 $frm->addrow("Real Name", $frm->text_box("real_name", $user["real_name"], 50));
 $frm->addrow("Email", $frm->text_box("email", $user["email"], 50));
 $frm->addrow("Password (Enter to change)", $frm->text_box("password1", ""));
 $frm->addrow("Password (Confirmation)", $frm->text_box("password2", ""));
 $frm->addrow("Signature", $frm->textarea("signature", $user["signature"]));
 $frm->addrow("Active", $frm->select_tag("active", array("No", "Yes"), $user["active"]));
 $frm->addrow("Forum posts", $user["posts"]);
 $frm->addrow("Registration Date", phorum_date($PHORUM['short_date_time'], $user['date_added']));
 $row = $frm->addrow("Date last active", phorum_date($PHORUM['short_date_time'], $user['date_last_active']));
 $frm->addrow("Administrator", $frm->select_tag("admin", array("No", "Yes"), $user["admin"]));
 $frm->addhelp($row, "Date last active", "This shows the date, when the user was last seen in the forum. Check your setting on \"Track user usage\" in the \"General Settings\". As long as this setting is not enabled, the activity will not be tracked.");
 $cf_header_shown = 0;
 foreach ($PHORUM["PROFILE_FIELDS"] as $key => $item) {
     if ($key === 'num_rows' || !empty($item['deleted'])) {
         continue;
     }
     if (!empty($item['show_in_admin'])) {
         if (!$cf_header_shown) {
             $frm->addbreak('Custom Profile Fields');
             $cf_header_shown = 1;
         }
         $itemval = "[EMPTY]";
         if (isset($user[$item['name']]) && trim($user[$item['name']]) != '') {
             $itemval = trim($user[$item['name']]);
Пример #7
0
/**
 * Formats an epoch timestamp to a relative time phrase
 *
 * @param ts - The epoch timestamp to format
 * @return phrase - The formatted phrase
 */
function phorum_relative_date($time)
{
    $PHORUM = $GLOBALS["PHORUM"];
    $today = strtotime(phorum_date('%Y-%m-%d', time()));
    $reldays = ($time - $today) / 86400;
    if ($reldays >= 0 && $reldays < 1) {
        return $PHORUM["DATA"]["LANG"]["relative_today"];
    } else {
        if ($reldays >= 1 && $reldays < 2) {
            return $PHORUM["DATA"]["LANG"]["relative_tomorrow"];
        } else {
            if ($reldays >= -1 && $reldays < 0) {
                return $PHORUM["DATA"]["LANG"]["relative_yesterday"];
            }
        }
    }
    if (abs($reldays) < 30) {
        // less than a month
        $reldays = floor($reldays);
        if ($reldays == 1) {
            $return = $PHORUM["DATA"]["LANG"]["relative_one_day"];
        } else {
            $return = abs($reldays) . " " . $PHORUM["DATA"]["LANG"]["relative_days"];
        }
        $return .= " " . $PHORUM["DATA"]["LANG"]["relative_ago"];
        return $return;
    } elseif (abs($reldays) < 60) {
        // weeks ago
        $relweeks = floor(abs($reldays / 7));
        $return = $relweeks . " " . $PHORUM["DATA"]["LANG"]["relative_weeks"];
        $return .= " " . $PHORUM["DATA"]["LANG"]["relative_ago"];
        return $return;
    } elseif (abs($reldays) < 365) {
        // months ago
        $relmonths = floor(abs($reldays / 30));
        $return = $relmonths . " " . $PHORUM["DATA"]["LANG"]["relative_months"];
        $return .= " " . $PHORUM["DATA"]["LANG"]["relative_ago"];
        return $return;
    } else {
        // years ago
        $relyears = floor(abs($reldays / 365));
        if ($relyears == 1) {
            $return = $PHORUM["DATA"]["LANG"]["relative_one_year"];
        } else {
            $return = $relyears . " " . $PHORUM["DATA"]["LANG"]["relative_years"];
        }
        $return .= " " . $PHORUM["DATA"]["LANG"]["relative_ago"];
        return $return;
    }
}
Пример #8
0
/**
 * Generates an edit message based on a message array
 */
function phorum_htmlpurifier_generate_editmessage($row)
{
    $PHORUM = $GLOBALS['PHORUM'];
    $editmessage = '';
    if (isset($row['meta']['edit_count']) && $row['meta']['edit_count'] > 0) {
        $editmessage = str_replace("%count%", $row['meta']['edit_count'], $PHORUM["DATA"]["LANG"]["EditedMessage"]);
        $editmessage = str_replace("%lastedit%", phorum_date($PHORUM["short_date_time"], $row['meta']['edit_date']), $editmessage);
        $editmessage = str_replace("%lastuser%", $row['meta']['edit_username'], $editmessage);
        $editmessage = "\n\n\n\n{$editmessage}";
    }
    return $editmessage;
}
Пример #9
0
// as the display name.
if ($user["real_name"] == $user["display_name"]) {
    unset($user["real_name"]);
}
$PHORUM["DATA"]["PROFILE"] = $user;
$PHORUM["DATA"]["PROFILE"]["forum_id"] = $PHORUM["forum_id"];
$PHORUM["DATA"]["PROFILE"]["raw_date_added"] = $PHORUM["DATA"]["PROFILE"]["date_added"];
$PHORUM["DATA"]["PROFILE"]["date_added"] = phorum_date($PHORUM['short_date_time'], $PHORUM["DATA"]["PROFILE"]["date_added"]);
if (empty($PHORUM['hide_email_addr']) && !$user['hide_email'] || !empty($PHORUM["user"]["admin"]) || phorum_api_user_check_access(PHORUM_USER_ALLOW_MODERATE_MESSAGES) && PHORUM_MOD_EMAIL_VIEW || phorum_api_user_check_access(PHORUM_USER_ALLOW_MODERATE_USERS) && PHORUM_MOD_EMAIL_VIEW) {
    $PHORUM["DATA"]["PROFILE"]["email"] = phorum_html_encode($user["email"]);
} else {
    $PHORUM["DATA"]["PROFILE"]["email"] = $PHORUM["DATA"]["LANG"]["Hidden"];
}
if ($PHORUM["track_user_activity"] && (!empty($PHORUM["user"]["admin"]) || phorum_api_user_check_access(PHORUM_USER_ALLOW_MODERATE_MESSAGES) || phorum_api_user_check_access(PHORUM_USER_ALLOW_MODERATE_USERS) || !$user["hide_activity"])) {
    $PHORUM["DATA"]["PROFILE"]["raw_date_last_active"] = $PHORUM["DATA"]["PROFILE"]["date_last_active"];
    $PHORUM["DATA"]["PROFILE"]["date_last_active"] = phorum_date($PHORUM['short_date_time'], $PHORUM["DATA"]["PROFILE"]["date_last_active"]);
} else {
    unset($PHORUM["DATA"]["PROFILE"]["date_last_active"]);
}
$PHORUM["DATA"]["PROFILE"]["posts"] = number_format($PHORUM["DATA"]["PROFILE"]["posts"], 0, "", $PHORUM["thous_sep"]);
$PHORUM["DATA"]["PROFILE"]["URL"]["PM"] = phorum_get_url(PHORUM_PM_URL, "page=send", "to_id=" . urlencode($user["user_id"]));
$PHORUM["DATA"]["PROFILE"]["URL"]["ADD_BUDDY"] = phorum_get_url(PHORUM_PM_URL, "page=buddies", "action=addbuddy", "addbuddy_id=" . urlencode($user["user_id"]));
$PHORUM["DATA"]["PROFILE"]["is_buddy"] = phorum_db_pm_is_buddy($user["user_id"]);
// unset($PHORUM["DATA"]["PROFILE"]["signature"]);
$PHORUM["DATA"]["PROFILE"]["URL"]["SEARCH"] = phorum_get_url(PHORUM_SEARCH_URL, "author=" . urlencode($PHORUM["DATA"]["PROFILE"]["user_id"]), "match_type=USER_ID", "match_dates=0", "match_threads=0");
$PHORUM["DATA"]["PROFILE"]["username"] = htmlspecialchars($PHORUM["DATA"]["PROFILE"]["username"], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]);
if (isset($PHORUM["DATA"]["PROFILE"]["real_name"])) {
    $PHORUM["DATA"]["PROFILE"]["real_name"] = htmlspecialchars($PHORUM["DATA"]["PROFILE"]["real_name"], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]);
}
if (empty($PHORUM["custom_display_name"])) {
    $PHORUM["DATA"]["PROFILE"]["display_name"] = htmlspecialchars($PHORUM["DATA"]["PROFILE"]["display_name"], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]);
Пример #10
0
                phorum_cache_remove('user',$user_id);
            }

            // Run the message through the default message formatting.
            list($message) = phorum_pm_format(array($message));

            // Setup data for recipients.
            foreach ($message["recipients"] as $rcpt_id => $rcpt) {
                $message["recipients"][$rcpt_id]["username"] = htmlspecialchars($rcpt["username"]);
                $message["recipients"][$rcpt_id]["to_profile_url"] = phorum_get_url(PHORUM_PROFILE_URL, $rcpt_id);
            }
            $message["recipient_count"] = count($message["recipients"]);

            // Setup URL's and format date.
            $message["from_profile_url"]=phorum_get_url(PHORUM_PROFILE_URL, $message["from_user_id"]);
            $message["date"]=phorum_date($PHORUM["short_date"], $message["datestamp"]);

            $PHORUM["DATA"]["MESSAGE"] = $message;
            $PHORUM["DATA"]["PMLOCATION"] = $PHORUM["DATA"]["LANG"]["PMRead"];

            // re-init folder list to account for change in read flags
            $pm_folders = phorum_db_pm_getfolders(NULL, true);

            // Set folder id to the right folder for this message.
            $folder_id = $message["pm_folder_id"];
            if ($folder_id == 0) {
                $folder_id = $message["special_folder"];
            }

            $template = "pm_read";
Пример #11
0
            $frm->addrow("User Name", htmlspecialchars($user["username"])."&nbsp;&nbsp;<a href=\"#forums\">Edit Forum Permissions</a>&nbsp;&nbsp;<a href=\"#groups\">Edit Groups</a>");

            $frm->addrow("Email", $frm->text_box("email", $user["email"], 50));
            $frm->addrow("Password (Enter to change)", $frm->text_box("password1",""));
            $frm->addrow("Password (Confirmation)", $frm->text_box("password2",""));


            $frm->addrow("Signature", $frm->textarea("signature", htmlspecialchars($user["signature"])));

            $frm->addrow("Active", $frm->select_tag("active", array("No", "Yes"), $user["active"]));

            $frm->addrow("Administrator", $frm->select_tag("admin", array("No", "Yes"), $user["admin"]));

            $frm->addrow("Registration Date", phorum_date("%m/%d/%Y %I:%M%p",$user['date_added']));

            $row=$frm->addrow("Date last active", phorum_date("%m/%d/%Y %I:%M%p",$user['date_last_active']));

            $frm->addhelp($row, "Date last active", "This shows the date, when the user was last seen in the forum. Check your setting on \"Track user usage\" in the \"General Settings\". As long as this setting is not enabled, the activity will not be tracked.");


            $frm->show();

            echo "<br /><hr class=\"PhorumAdminHR\" /><br /><a name=\"forums\"></a>";

            $frm = new PhorumInputForm ("", "post", "Update");

            $frm->hidden("user_id", $_REQUEST["user_id"]);

            $frm->hidden("module", "users");

            $frm->hidden("section", "forums");
Пример #12
0
$diffs = array_reverse($edit_tracks);
// push an empty diff for the current status
array_push($diffs, array());
$prev_body = -1;
$prev_subject = -1;
foreach ($diffs as $diff_info) {
    if (!isset($diff_info["user_id"])) {
        $this_version["username"] = empty($PHORUM['custom_display_name']) ? htmlspecialchars($message["author"], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]) : $message["author"];
        $this_version["user_id"] = $message["user_id"];
        $this_version["date"] = phorum_date($PHORUM["long_date_time"], $message["datestamp"]);
        $this_version["original"] = true;
    } else {
        $edit_user = phorum_api_user_get($diff_info['user_id']);
        $this_version["username"] = empty($PHORUM['custom_display_name']) ? htmlspecialchars($edit_user["display_name"], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]) : $edit_user["display_name"];
        $this_version["user_id"] = $diff_info["user_id"];
        $this_version["date"] = phorum_date($PHORUM["long_date_time"], $diff_info["time"]);
        $this_version["original"] = false;
    }
    // only happens in first loop
    if ($prev_body == -1) {
        $prev_body = $message["body"];
    }
    // body diffs
    if (isset($diff_info['diff_body']) && !empty($diff_info['diff_body'])) {
        $colored_body = phorum_unpatch_color($prev_body, $diff_info['diff_body']);
        $prev_body = phorum_unpatch($prev_body, $diff_info['diff_body']);
        $colored_body = htmlspecialchars($colored_body, ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]);
        $colored_body = str_replace(array("[phorum addition]", "[phorum removal]", "[/phorum addition]", "[/phorum removal]"), array("<span class=\"addition\">", "<span class=\"removal\">", "</span>", "</span>"), $colored_body);
        $colored_body = nl2br($colored_body);
        $this_version["colored_body"] = $colored_body;
    } elseif (!isset($diff_info['diff_body'])) {
Пример #13
0
                $title = $strings["LOGLEVELS"][$loginfo["loglevel"]];
                $cat = $strings["CATEGORIES"][$loginfo["category"]];
                // Find detailed info.
                $details = NULL;
                if ($loginfo["details"] !== NULL) {
                    $details = $loginfo["details"];
                }
                // Adding whitespace if the message contains ridiculously long words,
                // so the interface layout won't be wrecked.
                $message = $loginfo["message"];
                while (preg_match('/(\\S{40})\\S/', $message, $m)) {
                    $message = str_replace($m[1], $m[1] . " ", $message);
                }
                // If the event log is linked to a forum message, the generate
                // the URL that points to that message.
                $message_url = NULL;
                if ($loginfo["message_id"] !== NULL && $loginfo["message_id"] > 0) {
                    $message_url = phorum_get_url(PHORUM_FOREIGN_READ_URL, $loginfo["forum_id"], $loginfo["thread_id"], $loginfo["message_id"]);
                }
                if (!isset($PHORUM['short_time'])) {
                    $f = str_replace($PHORUM['short_date'], '', $PHORUM['short_date_time']);
                    $f = preg_replace('/^\\s+|\\s+$/', '', $f);
                    $PHORUM['short_time'] = $f;
                }
                print "==========================\n" . "Log level: {$title}\n" . "Date: " . phorum_date($PHORUM['short_date'], $loginfo["datestamp"]) . "\n" . "Time: " . phorum_date($PHORUM['short_time'], $loginfo["datestamp"]) . "\n" . "Source: " . $loginfo["source"] . "\n" . "Category: " . $cat . "\n" . "Message: " . $message . "\n" . "User info: " . ($loginfo["user_id"] ? "User ID = " . $loginfo["user_id"] . ($loginfo["username"] !== NULL ? ', username = '******'') : "Anonymous user") . ", " . "User IP address = " . $loginfo["ip"] . ($loginfo["hostname"] !== NULL ? ", hostname = " . $loginfo["hostname"] : "") . "\n" . ($message_url !== NULL ? "Related message: Forum = " . $loginfo["forum"] . ", Message ID = " . $loginfo["message_id"] . ", URL = " . $message_url . "\n" : "") . ($details !== NULL ? "Additional details:\n" . $details : "") . "\n\n";
            }
        }
    }
}
ob_end_flush();
exit;
Пример #14
0
// Also, remove the attachments that are not visible from the preview data.
$attach_count = 0;
if (isset($previewmessage["attachments"])) {
    foreach ($previewmessage["attachments"] as $id => $attachment) {
        if ($attachment["keep"]) {
            $attach_count++;
        } else {
            unset($previewmessage["attachments"][$id]);
        }
    }
}
if ($attach_count) {
    // Disable clicking on attachments in the preview (to prevent the
    // browser from jumping to a viewing page, which might break the
    // editing flow). This is not done in the previous loop where the
    // URL is set, so the formatting code for things like embedded
    // attachments can be used.
    foreach ($previewmessage["attachments"] as $nr => $data) {
        $previewmessage["attachments"][$nr]["url"] = $previewmessage["attachments"][$nr]["download_url"] = PREVIEW_NO_ATTACHMENT_CLICK;
    }
} else {
    unset($previewmessage["attachments"]);
}
// Fill the datestamp for new postings.
if ($mode != "edit") {
    $previewmessage["datestamp"] = time();
}
// Format datestamp.
$previewmessage["raw_datestamp"] = $previewmessage["datestamp"];
$previewmessage["datestamp"] = phorum_date($PHORUM["short_date_time"], $previewmessage["datestamp"]);
$PHORUM["DATA"]["PREVIEW"] = $previewmessage;
Пример #15
0
/**
 * Check the Spam Hurdles data for a posted form.
 *
 * When a form is posted, then this function has to be called to
 * check the data that was posted.
 *
 * @param string $form_id
 *     An identifier for the current form. This must be the same form id
 *     as the one that was used when calling {@link spamhurdles_api_init()}.
 *
 * @return array
 *     An array, containing two elements.
 *     The first element is the result status of the spam hurdle check.
 *     This is one of SPAMHURDLES_OK, SPAMHURDLES_WARNING or SPAMHURDLES_FATAL.
 *     The second element is the error message or NULL if there was no error.
 */
function spamhurdles_api_check_form($form_id)
{
    global $PHORUM;
    $error = $PHORUM['DATA']['LANG']['mod_spamhurdles']['PostingRejected'];
    $status = SPAMHURDLES_FATAL;
    // Retrieve the spam hurdles data from the form.
    $data = spamhurdles_api_get_formdata($form_id);
    // Check if we were able to retrieve spam hurdles data from the form.
    if ($data === NULL) {
        spamhurdles_log("Spam Hurdles blocked post, form id \"{$form_id}\"", "The posting form was posted without or with invalid " . "Spam Hurdles data.");
        return array($status, $error);
    }
    // Check if the id in the form data is the same as the
    // id that we expect to see.
    if ($data['id'] != $form_id) {
        spamhurdles_log("Spam Hurdles blocked post, form id \"{$form_id}\"", "The posting form was posted with an invalid Spam Hurdles " . "form id.<br/>" . "<br/>" . "Posted form id = {$data['id']}<br/>" . "Expected form id =  {$form_id}");
        return array($status, $error);
    }
    // Check if the TTL on the data didn't expire.
    if ($data['ttl'] < time()) {
        // Only for 5.2. In 5.3 this was moved to formatting API functions.
        if (file_exists('./include/format_functions.php')) {
            require_once './include/format_functions.php';
        }
        spamhurdles_log("Spam Hurdles blocked post, form id \"{$form_id}\"", "The posting form was posted with valid Spam Hurdles data, " . "but the data expired at " . phorum_date($PHORUM["short_date_time"], $data['ttl']));
        return array($status, $error);
    }
    // Let the spam hurdles check the data. If one sees a problem, then
    // it can set the $data['error'] and $data['status'] elements. It can
    // also add log messages to the $data['log'] array.
    $data['error'] = NULL;
    $data['status'] = SPAMHURDLES_OK;
    $data['log'] = array();
    $data = spamhurdles_hurdle_call('check_form', $data, $data['hurdles']);
    $status = $data['status'];
    if ($status !== SPAMHURDLES_OK) {
        spamhurdles_log("Spam Hurdles blocked post, form id \"{$form_id}\"", "Block type: " . ($status === SPAMHURDLES_FATAL ? 'fatal' : 'warning') . "\n" . "Block error: \"" . $data['error'] . "\"" . (empty($data['log']) ? '' : "\n\nInfo: " . implode(' ', $data['log'])));
    }
    return array($data['status'], $data['error']);
}
Пример #16
0
 $message_url = NULL;
 if ($loginfo["message_id"] !== NULL && $loginfo["message_id"] > 0) {
     $message_url = phorum_get_url(PHORUM_FOREIGN_READ_URL, $loginfo["forum_id"], $loginfo["thread_id"], $loginfo["message_id"]);
 }
 if (!isset($PHORUM['short_time'])) {
     $f = str_replace($PHORUM['short_date'], '', $PHORUM['short_date_time']);
     $f = preg_replace('/^\\s+|\\s+$/', '', $f);
     $PHORUM['short_time'] = $f;
 }
 print '
   <tr>
     <td valign="middle" style="white-space:nowrap">
       <img alt="' . $title . '" title="' . $title . '" src="' . $icon . '"/>
     </td>
     <td valign="left" style="white-space:nowrap; font-size: 10px">' . phorum_date($PHORUM['short_date'], $loginfo["datestamp"]) . '</td>
     <td valign="left" style="white-space:nowrap; font-size: 10px">' . phorum_date($PHORUM['short_time'], $loginfo["datestamp"]) . '</td>
     <td valign="middle" style="white-space:nowrap; font-size: 10px">
       <a title="Extend filter using this source" href="' . $filter_base . '&source=' . urlencode($loginfo["source"]) . '">' . htmlspecialchars($loginfo["source"]) . '</a>
     </td>
     <td valign="middle" style="font-size: 10px">
       <a title="Extend filter using this category" href="' . $filter_base . '&show_category[' . urlencode($loginfo["category"]) . ']=1">' . $cat . '</a>
     </td>
     <td valign="middle" style="font-size: 12px">' . htmlspecialchars($message) . '</td>
     <td valign="middle">
       <a href="#" onclick="return toggle_detail_visibility(' . $loginfo["log_id"] . ')"><small>details</small></a>
     </td>
   </tr>
   <tr>
     <td style="border-bottom: 1px solid #888"></td>
     <td colspan="6" style="border-bottom: 1px solid #888">
       <div style="display:none;overflow:auto;border:1px solid #aaa; padding:10px; margin-bottom: 10px" id="detail_' . $loginfo["log_id"] . '">
Пример #17
0
$forum_ids = array($PHORUM["vroot"]);
foreach ($forums as $forum) {
    $forum_ids[] = $forum["forum_id"];
}
$subscr_array = phorum_api_user_list_subscriptions($PHORUM['user']['user_id'], $subdays, $forum_ids);
// storage for newflags
$PHORUM['user']['newinfo'] = array();
// go through all subscriptions
$subscr_array_final = array();
unset($subscr_array["forum_ids"]);
foreach ($subscr_array as $id => $data) {
    $data['forum'] = $forums[$data['forum_id']]['name'];
    $data['raw_datestamp'] = $data["modifystamp"];
    $data['datestamp'] = phorum_date($PHORUM["short_date_time"], $data["modifystamp"]);
    $data['raw_lastpost'] = $data['modifystamp'];
    $data['lastpost'] = phorum_date($PHORUM["short_date_time"], $data["modifystamp"]);
    $data["URL"]["READ"] = phorum_get_url(PHORUM_FOREIGN_READ_URL, $data["forum_id"], $data["thread"]);
    $data["URL"]["NEWPOST"] = phorum_get_url(PHORUM_FOREIGN_READ_URL, $data["forum_id"], $data["thread"], "gotonewpost");
    // Check if there are new messages for the current thread.
    if (!isset($PHORUM['user']['newinfo'][$data["forum_id"]])) {
        $PHORUM['user']['newinfo'][$data["forum_id"]] = null;
        if ($PHORUM['cache_newflags']) {
            $newflagkey = $data["forum_id"] . "-" . $PHORUM['user']['user_id'];
            $PHORUM['user']['newinfo'][$data["forum_id"]] = phorum_cache_get('newflags', $newflagkey, $forums[$data["forum_id"]]['cache_version']);
        }
        if ($PHORUM['user']['newinfo'][$data["forum_id"]] == null) {
            $PHORUM['user']['newinfo'][$data["forum_id"]] = phorum_db_newflag_get_flags($data["forum_id"]);
            if ($PHORUM['cache_newflags']) {
                phorum_cache_put('newflags', $newflagkey, $PHORUM['user']['newinfo'][$data["forum_id"]], 86400, $forums[$data["forum_id"]]['cache_version']);
            }
        }
Пример #18
0
                }
                phorum_email_user($mail_users, $mail_data);
                $PHORUM["DATA"]["URL"]["REDIRECT"] = phorum_get_url(PHORUM_FOREIGN_READ_URL, $message["forum_id"], $message["thread"]);
                $PHORUM["DATA"]["BACKMSG"] = $PHORUM["DATA"]["LANG"]["BackToThread"];
                $PHORUM["DATA"]["OKMSG"] = $PHORUM["DATA"]["LANG"]["ReportPostSuccess"];
                $template = "message";
                $report = true;
            }
        } else {
            $PHORUM["DATA"]["ReportPostMessage"] = $PHORUM["DATA"]["LANG"]['ReportPostNotAllowed'];
        }
    }
    // format message
    list($message) = phorum_format_messages(array($message));
    $PHORUM["DATA"]["PostSubject"] = $message["subject"];
    $PHORUM["DATA"]["PostAuthor"] = $message["author"];
    $PHORUM["DATA"]["PostBody"] = $message["body"];
    $PHORUM["DATA"]["raw_PostDate"] = $message["datestamp"];
    $PHORUM["DATA"]["PostDate"] = phorum_date($PHORUM["short_date_time"], $message["datestamp"]);
    $PHORUM["DATA"]["ReportURL"] = phorum_get_url(PHORUM_REPORT_URL, $message_id);
    // if the report was not successfully sent, keep whatever explanation they gave already
    if (isset($_POST["explanation"]) && !$report) {
        $PHORUM["DATA"]["explanation"] = $_POST["explanation"];
    } else {
        $PHORUM["DATA"]["explanation"] = "";
    }
} else {
    $PHORUM["DATA"]["ERROR"] = $PHORUM['DATA']['LANG']['MessageNotFound'];
    $template = 'message';
}
phorum_output($template);
Пример #19
0
">
              <?php 
            if ($data["user_id"]) {
                print "Posted by authenticated user \"" . htmlspecialchars($data["user_username"]) . "\" (user_id " . $data["user_id"] . ") from " . $data['ip'] . "<br/>";
            }
            print "Date and time: " . phorum_date($PHORUM['short_date_time'], $data["datestamp"]) . "<br/>";
            // Might not be available (for announcements).
            // I won't put a lot of stuff in here for handling announcements,
            // because 5.2 handles them differently than 5.1.
            if (isset($forum_info[$data["forum_id"]])) {
                print "Forum: " . $forum_info[$data["forum_id"]] . "<br/>";
            }
            if ($data["parent_id"] == 0) {
                print "Messages in this thread: {$data["thread_count"]}<br/>";
                if ($data["thread_count"] > 1) {
                    print "Thread's last post: " . phorum_date($PHORUM['short_date_time'], $data["thread_modifystamp"]) . "<br/>";
                }
            }
            ?>
              <a target="_blank" href="<?php 
            print $url;
            ?>
">Open this message in a new window</a><br/>
              <div class="message_prune_msginfo_body">
                <?php 
            print $strippedbody;
            ?>
              </div>
            </div>
          </td>
        </tr> <?php 
Пример #20
0
    $rows = array();
    // get the thread set started
    $rows = phorum_db_get_unapproved_list($forum, $showwaiting, $moddays);
    // loop through and read all the data in.
    foreach ($rows as $key => $row) {
        $numunapproved++;
        $rows[$key]['forumname'] = $foruminfo[$forum]['name'];
        $rows[$key]['checkvar'] = $checkvar;
        if ($checkvar) {
            $checkvar = 0;
        }
        $rows[$key]['forum_id'] = $forum;
        $rows[$key]["URL"]["READ"] = phorum_get_url(PHORUM_FOREIGN_READ_URL, $forum, $row["thread"], $row['message_id']);
        // we need to fake the forum_id here
        $PHORUM["forum_id"] = $forum;
        $rows[$key]["URL"]["APPROVE_MESSAGE"] = phorum_get_url(PHORUM_MODERATION_URL, PHORUM_APPROVE_MESSAGE, $row["message_id"], "prepost=1", "old_forum=" . $oldforum, "onlyunapproved=" . $showwaiting, "moddays=" . $moddays);
        $rows[$key]["URL"]["APPROVE_TREE"] = phorum_get_url(PHORUM_MODERATION_URL, PHORUM_APPROVE_MESSAGE_TREE, $row["message_id"], "prepost=1", "old_forum=" . $oldforum, "onlyunapproved=" . $showwaiting, "moddays=" . $moddays);
        $rows[$key]["URL"]["DELETE"] = phorum_get_url(PHORUM_MODERATION_URL, PHORUM_DELETE_TREE, $row["message_id"], "prepost=1", "old_forum=" . $oldforum, "onlyunapproved=" . $showwaiting, "moddays=" . $moddays);
        $PHORUM["forum_id"] = $oldforum;
        $rows[$key]["raw_short_datestamp"] = $row["datestamp"];
        $rows[$key]["short_datestamp"] = phorum_date($PHORUM["short_date_time"], $row["datestamp"]);
    }
    require_once "./include/format_functions.php";
    $rows = phorum_format_messages($rows);
    $PHORUM['DATA']['PREPOST'] = array_merge($PHORUM['DATA']['PREPOST'], $rows);
}
if (!$numunapproved) {
    $PHORUM["DATA"]["UNAPPROVEDMESSAGE"] = $PHORUM["DATA"]["LANG"]["NoUnapprovedMessages"];
}
$PHORUM["DATA"]["HEADING"] = $PHORUM["DATA"]["LANG"]["UnapprovedMessages"];
$template = "cc_prepost";
Пример #21
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();
}
Пример #22
0
     $row["default_reply"] = true;
 } else {
     $row["default_reply"] = false;
 }
 // should we show the signature?
 if (isset($row['body'])) {
     if (isset($row["user"]["signature"]) && isset($row['meta']['show_signature']) && $row['meta']['show_signature'] == 1) {
         $phorum_sig = trim($row["user"]["signature"]);
         if (!empty($phorum_sig)) {
             $row["body"] .= "\n\n{$phorum_sig}";
         }
     }
     // add the edited-message to a post if its edited
     if (isset($row['meta']['edit_count']) && $row['meta']['edit_count'] > 0) {
         $editmessage = str_replace("%count%", $row['meta']['edit_count'], $PHORUM["DATA"]["LANG"]["EditedMessage"]);
         $editmessage = str_replace("%lastedit%", phorum_date($PHORUM["short_date_time"], $row['meta']['edit_date']), $editmessage);
         $editmessage = str_replace("%lastuser%", $row['meta']['edit_username'], $editmessage);
         $row["body"] .= "\n\n\n\n{$editmessage}";
         if ($row['meta']['edit_count'] > 0 && ($PHORUM["track_edits"] == PHORUM_EDIT_TRACK_ON || $PHORUM["track_edits"] == PHORUM_EDIT_TRACK_MODERATOR && $PHORUM["DATA"]["MODERATOR"])) {
             $row["URL"]["CHANGES"] = str_replace('%message_id%', $row['message_id'], $changes_url_template);
         }
     }
 }
 // mask host if not a moderator
 if (empty($PHORUM["user"]["admin"]) && (empty($PHORUM["DATA"]["MODERATOR"]) || !PHORUM_MOD_IP_VIEW)) {
     if ($PHORUM["display_ip_address"]) {
         if ($row["moderator_post"]) {
             $row["ip"] = $PHORUM["DATA"]["LANG"]["Moderator"];
         } elseif (is_numeric(str_replace(".", "", $row["ip"]))) {
             $row["ip"] = substr($row["ip"], 0, strrpos($row["ip"], '.')) . '.---';
         } else {
Пример #23
0
        }

        foreach($arr["rows"] as $key => $row){
            $arr["rows"][$key]["number"] = $match_number;

            // Fake a forum_id for folders.
            if ($row["forum_id"] == 0) {
                $row["forum_id"] = $announcement_forum_id;
            }

            $arr["rows"][$key]["url"] = phorum_get_url(PHORUM_FOREIGN_READ_URL, $row["forum_id"], $row["thread"], $row["message_id"]);

            // strip HTML & BB Code
            $body = phorum_strip_body($arr["rows"][$key]["body"]);
            $arr["rows"][$key]["short_body"] = substr($body, 0, 200);
            $arr["rows"][$key]["datestamp"] = phorum_date($PHORUM["short_date"], $row["datestamp"]);
            $arr["rows"][$key]["author"] = htmlspecialchars($row["author"]);
            $arr["rows"][$key]["short_body"] = htmlspecialchars($arr["rows"][$key]["short_body"]);

            $forum_ids[$row["forum_id"]] = $row["forum_id"];

            $match_number++;
        }

        foreach($arr["rows"] as $key => $row){
            // Skip announcements "forum".
            if ($row["forum_id"] == 0) continue;

            $arr["rows"][$key]["forum_url"] = phorum_get_url(PHORUM_LIST_URL, $row["forum_id"]);

            $arr["rows"][$key]["forum_name"] = $forums[$row["forum_id"]]["name"];