function phorum_email_moderators($message)
{
    $PHORUM=$GLOBALS["PHORUM"];

    $mail_users = phorum_user_get_moderators($PHORUM['forum_id'],false,true);

    if (count($mail_users)) {
        include_once("./include/format_functions.php");
        if($message["status"] > 0) { // just notification of a new message
            $mailtext = $PHORUM["DATA"]["LANG"]['NewUnModeratedMessage'];
        } else { // posts needing approval
            $mailtext = $PHORUM["DATA"]["LANG"]['NewModeratedMessage'];
        }
        $mail_data = array(
            "mailmessage" => $mailtext,
            "mailsubject" => $PHORUM["DATA"]["LANG"]['NewModeratedSubject'],
            "forumname"   => strip_tags($PHORUM["DATA"]["NAME"]),
            "forum_id"    => $PHORUM['forum_id'],
            "message_id"  => $message['message_id'],
            "author"      => $message['author'],
            "subject"     => $message['subject'],
            "full_body"   => $message['body'],
            "plain_body"  => phorum_strip_body($message['body']),
            "approve_url" => phorum_get_url(PHORUM_PREPOST_URL),
            "read_url"    => phorum_get_url(PHORUM_READ_URL, $message['thread'], $message['message_id'])
        );
        if (isset($_POST[PHORUM_SESSION_LONG_TERM])) {
            // strip any auth info from the read url
            $mail_data["read_url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["read_url"]);
            $mail_data["approve_url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["approve_url"]);
        }
        phorum_email_user($mail_users, $mail_data);
    }
}
Exemple #2
0
function phorum_pm_quoteformat($orig_author, $orig_author_id, $message, $inreplyto = NULL)
{
    $PHORUM = $GLOBALS["PHORUM"];
    // Build the reply subject.
    if (substr($message["subject"], 0, 3) != "Re:") {
        $message["subject"] = "Re: " . $message["subject"];
    }
    // Lookup the plain text name that we have to use for the author that we reply to.
    $author = phorum_api_user_get_display_name($orig_author_id, '', PHORUM_FLAG_PLAINTEXT);
    // TODO we'll have to handle anonymous users in the PM box. Those are
    // TODO users which sent a PM to somebody, but signed out afterwards.
    // TODO Currently, there's no graceful handling for that I think
    // TODO (maybe it's handled already, but that would only be by accident).
    if (isset($PHORUM["hooks"]["quote"])) {
        $quote = phorum_hook("quote", array($author, $message["message"], $orig_author_id));
    }
    if (empty($quote) || is_array($quote)) {
        // Build a quoted version of the message body.
        $quote = phorum_strip_body($message["message"]);
        $quote = str_replace("\n", "\n> ", $quote);
        $quote = wordwrap(trim($quote), 50, "\n> ", true);
        $quote = "{$author} {$PHORUM['DATA']['LANG']['Wrote']}:\n" . str_repeat("-", 55) . "\n> {$quote}\n\n\n";
    }
    $quote = ($inreplyto != NULL ? "{$PHORUM['DATA']['LANG']['InReplyTo']} {$inreplyto}\n\n" : '') . $quote;
    $message["message"] = $quote;
    return $message;
}
Exemple #3
0
function phorum_feed_make_html($messages, $forums, $feed_url, $feed_title, $feed_description)
{
    $PHORUM = $GLOBALS["PHORUM"];
    $buffer = "<div id=\"phorum_feed\">\n";
    $buffer .= "    <div id=\"phorum_feed_title\"><a href=\"" . htmlspecialchars($feed_url, ENT_COMPAT, $PHORUM['DATA']['HCHARSET']) . "\" title=\"" . htmlspecialchars($feed_description, ENT_COMPAT, $PHORUM['DATA']['HCHARSET']) . "\">" . htmlspecialchars($feed_title, ENT_COMPAT, $PHORUM['DATA']['HCHARSET']) . "</div>\n";
    $buffer .= "    <div id=\"phorum_feed_date\">" . htmlspecialchars(phorum_date($PHORUM['long_date'], time()), ENT_COMPAT, $PHORUM['DATA']['HCHARSET']) . "</lastBuildDate>\n";
    $buffer .= "    <ul>\n";
    foreach ($messages as $message) {
        $title = strip_tags($message["subject"]);
        if (empty($PHORUM["args"]["replies"])) {
            switch ($message["thread_count"]) {
                case 1:
                    $title .= " (no " . $PHORUM["DATA"]["LANG"]["replies"] . ")";
                    break;
                case 2:
                    $title .= " (1 " . $PHORUM["DATA"]["LANG"]["reply"] . ")";
                    break;
                default:
                    $replies = $message["thread_count"] - 1;
                    $title .= " ({$replies} " . $PHORUM["DATA"]["LANG"]["replies"] . ")";
            }
        }
        $url = phorum_get_url(PHORUM_FOREIGN_READ_URL, $message["forum_id"], $message["thread"], $message["message_id"]);
        $body = phorum_strip_body($message["body"]);
        $body = substr($body, 0, 200);
        $buffer .= "        <li><a href=\"" . htmlspecialchars($url, ENT_COMPAT, $PHORUM['DATA']['HCHARSET']) . "\" title=\"" . htmlspecialchars($message["body"], ENT_COMPAT, $PHORUM['DATA']['HCHARSET']) . "\">" . htmlspecialchars($title, ENT_COMPAT, $PHORUM['DATA']['HCHARSET']) . "</a></li>\n";
    }
    $buffer .= "    </ul>\n";
    $buffer .= "</div>\n";
    return $buffer;
}
function phorum_email_moderators($message)
{
    $PHORUM = $GLOBALS["PHORUM"];
    $mail_users = phorum_api_user_list_moderators($PHORUM['forum_id'], $PHORUM['email_ignore_admin'], TRUE);
    if (count($mail_users)) {
        include_once "./include/format_functions.php";
        if ($message["status"] > 0) {
            // just notification of a new message
            $mailsubjecttpl = 'NewUnModeratedSubject';
            $mailmessagetpl = 'NewUnModeratedMessage';
            $mailsubject = $PHORUM["DATA"]["LANG"]['NewUnModeratedSubject'];
            $mailmessage = $PHORUM["DATA"]["LANG"]['NewUnModeratedMessage'];
        } else {
            // posts needing approval
            $mailsubjecttpl = 'NewModeratedSubject';
            $mailmessagetpl = 'NewModeratedMessage';
            $mailsubject = $PHORUM["DATA"]["LANG"]['NewModeratedSubject'];
            $mailmessage = $PHORUM["DATA"]["LANG"]['NewModeratedMessage'];
        }
        $mail_data = array("forumname" => strip_tags($PHORUM["DATA"]["NAME"]), "forum_id" => $PHORUM['forum_id'], "message_id" => $message['message_id'], "author" => phorum_api_user_get_display_name($message["user_id"], $message["author"], PHORUM_FLAG_PLAINTEXT), "subject" => $message['subject'], "full_body" => $message['body'], "plain_body" => phorum_strip_body($message['body']), "approve_url" => phorum_get_url(PHORUM_CONTROLCENTER_URL, "panel=messages"), "read_url" => phorum_get_url(PHORUM_READ_URL, $message['thread'], $message['message_id']), "mailmessage" => $mailmessage, "mailsubject" => $mailsubject, "mailmessagetpl" => $mailmessagetpl, "mailsubjecttpl" => $mailsubjecttpl, "language" => $PHORUM['language']);
        if (isset($_POST[PHORUM_SESSION_LONG_TERM])) {
            // strip any auth info from the read url
            $mail_data["read_url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["read_url"]);
            $mail_data["approve_url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["approve_url"]);
        }
        phorum_email_user($mail_users, $mail_data);
    }
}
Exemple #5
0
function phorum_pm_quoteformat($orig_author, $message, $inreplyto = NULL)
{
    $PHORUM = $GLOBALS["PHORUM"];

    // Build the reply subject.
    if (substr($message["subject"], 0, 3) != "Re:") {
        $message["subject"] = "Re: ".$message["subject"];
    }

    // Build a quoted version of the message body.
    $quote = phorum_strip_body($message["message"]);
    $quote = str_replace("\n", "\n> ", $quote);
    $quote = wordwrap(trim($quote), 50, "\n> ", true);
    $quote = ($inreplyto != NULL ? "{$PHORUM['DATA']['LANG']['InReplyTo']} {$inreplyto}\n" : '') .
             "$orig_author {$PHORUM['DATA']['LANG']['Wrote']}:\n" .
             str_repeat("-", 55)."\n> {$quote}\n\n\n";
    $message["message"] = $quote;

    return $message;
}
Exemple #6
0
        $dbmessage["subject"] = "Re: " . $dbmessage["subject"];
    }
    $message["subject"] = $dbmessage["subject"];
    // Add a quoted version of the body for quoted reply messages.
    if ($mode == "quote") {
        // Lookup the name that we have to use for the author, if the
        // author is a registered user. The author field could be used
        // directly, but it can contain HTML formatting code, in case
        // some module uses the custom display name functionality.
        $author = phorum_api_user_get_display_name($dbmessage["user_id"], $dbmessage['author'], PHORUM_FLAG_PLAINTEXT);
        $quoted = 0;
        if (isset($PHORUM["hooks"]["quote"])) {
            $quoted = phorum_hook("quote", array($author, $dbmessage["body"], $dbmessage["user_id"]));
        }
        if (empty($quoted) || is_array($quoted)) {
            $quoted = phorum_strip_body($dbmessage["body"]);
            $quoted = str_replace("\n", "\n> ", $quoted);
            $quoted = wordwrap(trim($quoted), 50, "\n> ", true);
            $quoted = "{$author} " . "{$PHORUM["DATA"]["LANG"]["Wrote"]}:\n" . str_repeat("-", 55) . "\n> {$quoted}\n\n\n";
        }
        $message["body"] = $quoted;
    }
}
// Set message data for editing posts.
if ($mode == "edit" || $mode == "moderation") {
    // Transfer all database fields to the form fields.
    $message = phorum_posting_merge_db2form($message, $dbmessage, ALLFIELDS);
}
// For new messages, set some default values for logged in users.
if (($mode == "post" || $mode == "reply" || $mode == "quote") && $PHORUM["DATA"]["LOGGEDIN"]) {
    if (isset($PHORUM["user"]["show_signature"]) && $PHORUM["user"]["show_signature"]) {
Exemple #7
0
     $arr['rows'] = $search_request_data['results'];
     $arr['count'] = $search_request_data['totals'];
     $raw_body = $search_request_data['raw_body'];
 }
 if (count($arr["rows"])) {
     $match_number = $start + 1;
     $forums = phorum_db_get_forums(0, NULL, $PHORUM["vroot"]);
     if (!$raw_body) {
         $arr["rows"] = phorum_format_messages($arr["rows"]);
     }
     foreach ($arr["rows"] as $key => $row) {
         $arr["rows"][$key]["number"] = $match_number;
         $arr["rows"][$key]["URL"]["READ"] = phorum_get_url(PHORUM_FOREIGN_READ_URL, $row["forum_id"], $row["thread"], $row["message_id"]);
         // strip HTML & BB Code
         if (!$raw_body) {
             $body = phorum_strip_body($arr["rows"][$key]["body"]);
             $arr["rows"][$key]["short_body"] = substr($body, 0, 400);
         }
         $arr["rows"][$key]["raw_datestamp"] = $row["datestamp"];
         $arr["rows"][$key]["datestamp"] = phorum_relative_date($row["datestamp"]);
         $forum_ids[$row["forum_id"]] = $row["forum_id"];
         $match_number++;
     }
     foreach ($arr["rows"] as $key => $row) {
         $arr["rows"][$key]["URL"]["LIST"] = phorum_get_url(PHORUM_LIST_URL, $row["forum_id"]);
         $arr["rows"][$key]["forum_name"] = $forums[$row["forum_id"]]["name"];
     }
     $PHORUM["DATA"]["RANGE_START"] = $start + 1;
     $PHORUM["DATA"]["RANGE_END"] = $start + count($arr["rows"]);
     $PHORUM["DATA"]["TOTAL"] = $arr["count"];
     $PHORUM["DATA"]["SEARCH"]["showresults"] = true;
function sphinx_search_action($arrSearch)
{
    global $PHORUM;
    // No pecl class, try php version
    if (!class_exists('SphinxClient')) {
        // loads from php include_path
        require_once 'sphinxapi.php';
    }
    // these are the index-names set in sphinx.conf - one for searching messages, the other for searching by authors only
    // both contain an additional index for the deltas - changes done after the last full reindex
    $index_name_msg = 'phorum5_msg_d phorum5_msg';
    $index_name_author = 'phorum5_author phorum5_author_d';
    // excerpts_index is just one index as that function only accepts one, it used for determining charsets / mapping tables, nothing more
    $excerpts_index = 'phorum5_msg';
    $index = $index_name_msg;
    if ($arrSearch['match_type'] == 'ALL') {
        $match_mode = SPH_MATCH_ALL;
    } elseif ($arrSearch['match_type'] == 'ANY') {
        $match_mode = SPH_MATCH_ANY;
    } elseif ($arrSearch['match_type'] == 'PHRASE') {
        $match_mode = SPH_MATCH_PHRASE;
    } elseif ($arrSearch['match_type'] == 'AUTHOR') {
        $match_mode = SPH_MATCH_PHRASE;
        $index = $index_name_author;
    } else {
        // Return search control to Phorum in case the search type isn't handled by the module.
        return $arrSearch;
    }
    if (empty($arrSearch['search']) && !empty($arrSearch['author'])) {
        $arrSearch['search'] = $arrSearch['author'];
        $index = $index_name_author;
    }
    $sphinx = new SphinxClient();
    $sphinx->SetServer($PHORUM['mod_sphinx_search']['hostname'], $PHORUM['mod_sphinx_search']['port']);
    $sphinx->SetMatchMode($match_mode);
    // set the limits for paging
    $sphinx->SetLimits($arrSearch['offset'], $arrSearch['length']);
    // set the timeframe to search
    if ($arrSearch['match_dates'] > 0) {
        $min_ts = time() - 86400 * $arrSearch['match_dates'];
        $max_ts = time();
        $sphinx->SetFilterRange('datestamp', $min_ts, $max_ts);
    }
    // Check what forums the active Phorum user can read.
    $allowed_forums = phorum_api_user_check_access(PHORUM_USER_ALLOW_READ, PHORUM_ACCESS_LIST);
    // If the user is not allowed to search any forum or the current
    // active forum, then return the emtpy search results array.
    if (empty($allowed_forums) || $PHORUM['forum_id'] > 0 && !in_array($PHORUM['forum_id'], $allowed_forums)) {
        $arrSearch['results'] = array();
        $arrSearch['totals'] = 0;
        $arrSearch['continue'] = 0;
        $arrSearch['raw_body'] = 1;
        return $arrSearch;
    }
    // Prepare forum_id restriction.
    $search_forums = array();
    foreach (explode(',', $arrSearch['match_forum']) as $forum_id) {
        if ($forum_id == 'ALL') {
            $search_forums = $allowed_forums;
            break;
        }
        if (isset($allowed_forums[$forum_id])) {
            $search_forums[] = $forum_id;
        }
    }
    $sphinx->SetFilter('forum_id', $search_forums);
    // set the sort-mode
    $sphinx->SetSortMode(SPH_SORT_ATTR_DESC, 'datestamp');
    // do the actual query
    $results = $sphinx->Query($arrSearch['search'], $index);
    $res = $sphinx->GetLastWarning();
    if ($res) {
        error_log("sphinx_search.php: WARNING: {$res}");
    }
    $res = $sphinx->GetLastError();
    if ($res) {
        error_log("sphinx_search.php: ERROR: {$res}");
    }
    // if no messages were found, then return empty handed.
    if (!isset($results['matches'])) {
        $arrSearch['results'] = array();
        $arrSearch['totals'] = 0;
        $arrSearch['continue'] = 0;
        $arrSearch['raw_body'] = 1;
        return $arrSearch;
    }
    $search_msg_ids = $results['matches'];
    // get the messages we found
    $found_messages = phorum_db_get_message(array_keys($search_msg_ids), 'message_id', true);
    // sort them in reverse order of the message_id to automagically sort them by date desc this way
    krsort($found_messages);
    reset($found_messages);
    // prepare the array for building highlighted excerpts
    $docs = array();
    foreach ($found_messages as $id => $data) {
        // remove hidden text in the output - only added by the hidden_msg module
        $data['body'] = preg_replace("/(\\[hide=([\\#a-z0-9]+?)\\](.+?)\\[\\/hide\\])/is", '', $data['body']);
        $docs[] = htmlspecialchars(phorum_strip_body($data['body']));
    }
    $words = '';
    if (!empty($results['words'])) {
        $words = implode(' ', array_keys($results['words']));
    }
    $opts = array('chunk_separator' => ' [...] ');
    // build highlighted excerpts
    $highlighted = $sphinx->BuildExcerpts($docs, $excerpts_index, $words, $opts);
    $res = $sphinx->GetLastWarning();
    if ($res) {
        error_log("sphinx_search.php: WARNING: {$res}");
    }
    $res = $sphinx->GetLastError();
    if ($res) {
        error_log("sphinx_search.php: ERROR: {$res}");
    }
    $cnt = 0;
    foreach ($found_messages as $id => $content) {
        $found_messages[$id]['short_body'] = $highlighted[$cnt];
        $cnt++;
    }
    $arrSearch['results'] = $found_messages;
    // we need the total results
    $arrSearch['totals'] = $results['total_found'];
    if ($arrSearch['totals'] > 1000) {
        $arrSearch['totals'] = 1000;
    }
    // don't run the default search
    $arrSearch['continue'] = 0;
    // tell it to leave the body alone
    $arrSearch['raw_body'] = 1;
    return $arrSearch;
}