示例#1
0
文件: js.php 项目: samuell/Core
/**
 * This function implements the JavaScript output adapter for the Feed API.
 *
 * @param array $messages
 *     An array of messages to include in the feed.
 *
 * @param array $forums
 *     An array of related forums.
 *
 * @param string $url
 *     The URL that points to the feed's target.
 *
 * @param string $title
 *     The title to use for the feed.
 *
 * @param string $description
 *     The description to use for the feed.
 *
 * @param bool $replies
 *     Whether or not this is a feed that includes reply messages.
 *     If not, then it will only contain thread starter messages.
 *
 * @return array
 *     An array containing two elements:
 *     - The generated feed data (JavaScript code)
 *     - The Content-Type header to use for the feed.
 */
function phorum_api_feed_js($messages, $forums, $url, $title, $description, $replies)
{
    global $PHORUM;
    $feed = array('title' => $title, 'description' => $description, 'modified' => phorum_api_format_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 = !empty($users[$message['user_id']]) ? $users[$message['user_id']] : $message['author'];
        // Created date.
        $fmt = $PHORUM['short_date'];
        $created = phorum_api_format_date($fmt, $message['datestamp']);
        // Updated date.
        if ($message['parent_id']) {
            if (!empty($message['meta']['edit_date'])) {
                $modified = $message['meta']['edit_date'];
            } else {
                $modified = $message['datestamp'];
            }
        } else {
            $modified = $message['modifystamp'];
        }
        $modified = phorum_api_format_date($fmt, $modified);
        $url = htmlspecialchars(phorum_api_url(PHORUM_FOREIGN_READ_URL, $message['forum_id'], $message['thread'], $message['message_id']));
        $item = array('title' => strip_tags($message['subject']), 'author' => $author, 'category' => $forums[$message['forum_id']]['name'], 'created' => $created, 'modified' => $modified, 'url' => $url, '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_feed = ' . phorum_api_json_encode($feed);
    return array($buffer, 'text/javascript');
}
示例#2
0
文件: messages.php 项目: netovs/Core
    $checkvar = 1;
    // Get the threads
    $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_api_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_api_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_api_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_api_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_api_format_date($PHORUM["short_date_time"], $row["datestamp"]);
    }
    $rows = phorum_api_format_messages($rows);
    $PHORUM['DATA']['PREPOST'] = array_merge($PHORUM['DATA']['PREPOST'], $rows);
}
if (!$numunapproved) {
    $PHORUM["DATA"]["UNAPPROVEDMESSAGE"] = $PHORUM["DATA"]["LANG"]["NoUnapprovedMessages"];
}
$template = "cc_prepost";
示例#3
0
文件: files.php 项目: netovs/Core
} elseif (!empty($_POST["delete"])) {
    foreach ($_POST["delete"] as $file_id) {
        if (phorum_api_file_check_delete_access($file_id)) {
            phorum_api_file_delete($file_id);
        }
    }
}
// ----------------------------------------------------------------------
// Display the files for the current user.
// ----------------------------------------------------------------------
$files = $PHORUM['DB']->get_user_file_list($PHORUM["user"]["user_id"]);
$total_size = 0;
foreach ($files as $key => $file) {
    $files[$key]["filesize"] = phorum_api_format_filesize($file["filesize"]);
    $files[$key]["raw_dateadded"] = $file["add_datetime"];
    $files[$key]["dateadded"] = phorum_api_format_date($PHORUM["short_date_time"], $file["add_datetime"]);
    $files[$key]["url"] = phorum_api_url(PHORUM_FILE_URL, "file={$key}", "filename=" . urlencode($file['filename']));
    $total_size += $file["filesize"];
}
$template = "cc_files";
if ($PHORUM["max_file_size"]) {
    $PHORUM["DATA"]["FILE_SIZE_LIMIT"] = $PHORUM["DATA"]["LANG"]["FileSizeLimits"] . ' ' . phorum_api_format_filesize($PHORUM["max_file_size"] * 1024);
}
if ($PHORUM["file_types"]) {
    $PHORUM["DATA"]["FILE_TYPE_LIMIT"] = $PHORUM["DATA"]["LANG"]["FileTypeLimits"];
}
if ($PHORUM["file_space_quota"]) {
    $PHORUM["DATA"]["FILE_QUOTA_LIMIT"] = $PHORUM["DATA"]["LANG"]["FileQuotaLimits"] . ' ' . phorum_api_format_filesize($PHORUM["file_space_quota"] * 1024);
}
foreach ($files as $id => $file) {
    $files[$id]['filename'] = htmlspecialchars($file['filename'], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]);
示例#4
0
文件: summary.php 项目: samuell/Core
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     //
//                                                                            //
//   You should have received a copy of the Phorum License                    //
//   along with this program.                                                 //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
if (!defined("PHORUM_CONTROL_CENTER")) {
    return;
}
$template = "cc_start";
$PHORUM['DATA']['UserPerms'] = phorum_readable_permissions();
$PHORUM['DATA']['PROFILE']['raw_date_added'] = $PHORUM['DATA']['PROFILE']['date_added'];
$PHORUM['DATA']['PROFILE']['date_added'] = phorum_api_format_date($PHORUM['short_date_time'], $PHORUM['DATA']['PROFILE']['date_added']);
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) || !$PHORUM['DATA']['PROFILE']["hide_activity"])) {
    $PHORUM["DATA"]["PROFILE"]["raw_date_last_active"] = $PHORUM["DATA"]["PROFILE"]["date_last_active"];
    $PHORUM["DATA"]["PROFILE"]["date_last_active"] = phorum_api_format_date($PHORUM['short_date_time'], $PHORUM["DATA"]["PROFILE"]["date_last_active"]);
} else {
    unset($PHORUM["DATA"]["PROFILE"]["date_last_active"]);
}
if (isset($PHORUM["hooks"]["profile"])) {
    $PHORUM["DATA"]["PROFILE"] = phorum_api_hook("profile", $PHORUM["DATA"]["PROFILE"]);
}
/* --------------------------------------------------------------- */
function phorum_readable_permissions()
{
    global $PHORUM;
    $newperms = array();
    if (isset($PHORUM["user"]["permissions"])) {
        $forums = phorum_api_forums_get(array_keys($PHORUM["user"]["permissions"]));
        foreach ($PHORUM["user"]["permissions"] as $forum => $perms) {
            if (isset($forums[$forum])) {
示例#5
0
文件: format.php 项目: netovs/Core
/**
 * Formats an epoch timestamp to a relative time phrase
 * (yesterday, 6 days ago, 4 months ago).
 *
 * @param integer ts
 *     The epoch timestamp to format
 *
 * @return phrase
 *     The formatted phrase that describes the relative time.
 */
function phorum_api_format_relative_date($time)
{
    global $PHORUM;
    $today = strtotime(phorum_api_format_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;
    }
}
示例#6
0
文件: report.php 项目: samuell/Core
                phorum_api_mail($mail_users, $mail_data);
                $PHORUM["DATA"]["URL"]["REDIRECT"] = phorum_api_url(PHORUM_FOREIGN_READ_URL, $message["forum_id"], $message["thread"], $message['message_id']);
                $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_api_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_api_format_date($PHORUM["short_date_time"], $message["datestamp"]);
    $PHORUM["DATA"]["ReportURL"] = phorum_api_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['DATA']['BREADCRUMBS'][] = array('URL' => '', 'TEXT' => $PHORUM['DATA']['LANG']['Report'], 'TYPE' => 'report');
phorum_api_output($template);
示例#7
0
文件: changes.php 项目: netovs/Core
$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_api_format_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_api_format_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_api_diff_unpatch_color($prev_body, $diff_info['diff_body']);
        $prev_body = phorum_api_diff_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'])) {
示例#8
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_api_format_date($PHORUM["short_date_time"], $data["modifystamp"]);
    $data['raw_lastpost'] = $data['modifystamp'];
    $data['lastpost'] = phorum_api_format_date($PHORUM["short_date_time"], $data["modifystamp"]);
    $data["URL"]["READ"] = phorum_api_url(PHORUM_FOREIGN_READ_URL, $data["forum_id"], $data["thread"]);
    $data["URL"]["NEWPOST"] = phorum_api_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_api_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_api_cache_put('newflags', $newflagkey, $PHORUM['user']['newinfo'][$data["forum_id"]], 86400, $forums[$data["forum_id"]]['cache_version']);
            }
        }
示例#9
0
/**
 * @deprecated Replaced by {@link phorum_api_format_date()}.
 */
function phorum_date($picture, $ts)
{
    return phorum_api_format_date($picture, $ts);
}
示例#10
0
文件: users.php 项目: netovs/Core
 $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", $frm->text_box("username", $user["username"], 50));
 $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_api_format_date($PHORUM['short_date_time'], $user['date_added']));
 $row = $frm->addrow("Date last active", phorum_api_format_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["CUSTOM_FIELDS"][PHORUM_CUSTOM_FIELD_USER] 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']]);
示例#11
0
文件: forums.php 项目: netovs/Core
/**
 * This function handles preparing forum or folder data
 * for use in the templates.
 *
 * @param array $forums
 *     An array of forum and/or folder data records to format.
 *
 * @param int $flags
 *     If the {@link PHORUM_FLAG_ADD_UNREAD_INFO} flag is set, then template
 *     data for showing new messages/threads will be added to the data records.
 *     The exact data that is added depends on the value of the
 *     $PHORUM['show_new_on_index'] setting variable.
 *
 * @param array
 *     The same as the $forums argument array, with formatting applied
 *     and template variables added.
 */
function phorum_api_format_forums($forums, $flags = 0)
{
    global $PHORUM;
    static $index_url_template;
    static $list_url_template;
    static $markread_url_template;
    static $feed_url_template;
    if (empty($feed_url_template)) {
        $index_url_template = phorum_api_url(PHORUM_INDEX_URL, '%forum_id%');
        $orig_forum_id = $PHORUM['forum_id'];
        $PHORUM['forum_id'] = '%forum_id%';
        $post_url_template = phorum_api_url(PHORUM_POSTING_URL);
        $PHORUM['forum_id'] = $orig_forum_id;
        $list_url_template = phorum_api_url(PHORUM_LIST_URL, '%forum_id%');
        $markread_url_template = phorum_api_url(PHORUM_INDEX_URL, '%forum_id%', 'markread', '%folder_id%');
        $feed_url_template = phorum_api_url(PHORUM_FEED_URL, '%forum_id%', 'type=' . $PHORUM['default_feed']);
    }
    // For tracking forums for which we have to check unread messages.
    $forums_to_check = array();
    foreach ($forums as $forum_id => $forum) {
        // Setup template data for folders.
        if ($forum['folder_flag']) {
            // A URL for the index view for this folder. We also set this
            // one up as URL->LIST, because up to Phorum 5.3 that variable
            // was in use.
            $forum['URL']['INDEX'] = $forum['URL']['LIST'] = str_replace('%forum_id%', $forum_id, $index_url_template);
        } else {
            // A URL for the message list for this forum.
            $forum['URL']['LIST'] = str_replace('%forum_id%', $forum_id, $list_url_template);
            // A "mark forum read" URL for authenticated users.
            if ($PHORUM['user']['user_id']) {
                $forum['URL']['MARK_READ'] = str_replace(array('%forum_id%', '%folder_id%'), array($forum_id, $PHORUM['forum_id']), $markread_url_template);
            }
            // A URL to post a new message.
            $forum['URL']['POST'] = str_replace('%forum_id%', $forum_id, $post_url_template);
            // A URL to the syndication feed.
            if (!empty($PHORUM['use_rss'])) {
                $forum['URL']['FEED'] = str_replace('%forum_id%', $forum_id, $feed_url_template);
            }
            // For dates, we store an unmodified version to always have
            // the original date available for modules. Not strictly
            // needed for this one, since we to not override the original
            // "last_post_time" field, but we still add it to be compliant
            // with the rest of the Phorum code.
            $forum['raw_last_post'] = $forum['last_post_time'];
            // Format the last post time, unless no messages were posted at all.
            if ($forum['message_count'] > 0) {
                $forum['last_post'] = phorum_api_format_date($PHORUM['long_date_time'], $forum['last_post_time']);
            } else {
                $forum['last_post'] = '&nbsp;';
            }
            // Some number formatting.
            $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']);
            $forums_to_check[] = $forum_id;
        }
        // Put the formatted record back in the array.
        $forums[$forum_id] = $forum;
    }
    // Add unread message information.
    if ($flags & PHORUM_FLAG_ADD_UNREAD_INFO && $PHORUM['show_new_on_index'] != PHORUM_NEWFLAGS_NOCOUNT && $PHORUM['user']['user_id'] && !empty($forums_to_check)) {
        $forums = phorum_api_newflags_apply_to_forums($forums, $PHORUM['show_new_on_index'], $forums_to_check);
    }
    return $forums;
}
示例#12
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 are on a page on which the announcements have to be shown.
    if (!empty($PHORUM["mod_announcements"]["pages"]["home"])) {
        if ($PHORUM['vroot'] != $PHORUM['forum_id'] || phorum_page != 'index') {
            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_api_cache_get('newflags', $newflagkey, $PHORUM['cache_version']);
        }
        if ($newinfo == NULL) {
            $newinfo = $PHORUM['DB']->newflag_get_flags($ann_forum_id);
            if ($PHORUM['cache_newflags']) {
                phorum_api_cache_put('newflags', $newflagkey, $newinfo, 86400, $PHORUM['cache_version']);
            }
        }
    }
    require_once PHORUM_PATH . '/include/api/format/messages.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_api_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_api_format_date($PHORUM["short_date_time"], $message["modifystamp"]);
        $message["raw_datestamp"] = $message["datestamp"];
        $message["datestamp"] = phorum_api_format_date($PHORUM["short_date_time"], $message["datestamp"]);
        $message["URL"]["READ"] = phorum_api_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_api_format_messages($PHORUM["DATA"]["ANNOUNCEMENTS"]);
    // Build the announcements code.
    ob_start();
    include phorum_api_template("announcements::announcements");
    $PHORUM['DATA']['MOD_ANNOUNCEMENTS'] = ob_get_contents();
    ob_end_clean();
}
示例#13
0
文件: read.php 项目: samuell/Core
 } else {
     $row["default_reply"] = false;
 }
 if (isset($row['body'])) {
     // Should we show the signature?
     if (isset($row['user']['signature']) && !empty($row['meta']['show_signature'])) {
         $phorum_sig = trim($row['user']['signature']);
         if (!empty($phorum_sig)) {
             $row['body'] .= "\n\n{$phorum_sig}";
         }
     }
     // Add the "edited X times by ..." message to a post
     // if it was edited.
     if (!empty($row['meta']['edit_count'])) {
         $editmessage = str_replace("%count%", $row['meta']['edit_count'], $PHORUM["DATA"]["LANG"]["EditedMessage"]);
         $editmessage = str_replace("%lastedit%", phorum_api_format_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 {
示例#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_api_format_date($PHORUM["short_date_time"], $previewmessage["datestamp"]);
$PHORUM["DATA"]["PREVIEW"] = $previewmessage;
示例#15
0
 $message_url = NULL;
 if ($loginfo["message_id"] !== NULL && $loginfo["message_id"] > 0) {
     $message_url = phorum_api_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_api_format_date($PHORUM['short_date'], $loginfo["datestamp"]) . '</td>
     <td valign="left" style="white-space:nowrap; font-size: 10px">' . phorum_api_format_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"] . '">
示例#16
0
文件: pm.php 项目: netovs/Core
function phorum_pm_format($messages)
{
    global $PHORUM;
    // Reformat message so it looks like a forum message (so we can run it
    // through phorum_api_message_format()) 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_api_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_api_format_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_api_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_api_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_api_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;
}
示例#17
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_api_format_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_api_format_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