/**
* Adds the javascript and CSS for the editor tools to the page header.
* Sets up internal datastructures for the editor tools module.
* Allows other modules to register their editor tool buttons.
*/
function phorum_mod_editor_tools_common()
{
global $PHORUM;
$lang = $PHORUM["DATA"]["LANG"]["mod_editor_tools"];
// Initialize the tool data array.
$PHORUM["MOD_EDITOR_TOOLS"] = array("DO_TOOLS" => false, "STARTED" => false, "TOOLS" => array(), "JSLIBS" => array(), "HELP_CHAPTERS" => array(), "TRANSLATIONS" => $lang);
// Add a help tool. We add it as the first tool, so we can
// shift it nicely to the right side of the page using CSS float.
if (!empty($PHORUM["mod_editor_tools"]["enable_help"])) {
editor_tools_register_tool('help', $lang['help']);
}
// Give other modules a chance to setup their plugged in
// editor tools. This is done through a standard hook call.
if (isset($PHORUM["hooks"]["editor_tool_plugin"])) {
phorum_api_hook('editor_tool_plugin');
}
// Keep track that the editor tools have been setup. From here
// on, the API calls for registering tools, javascript libraries
// help chapters and language strings are no longer allowed.
$PHORUM["MOD_EDITOR_TOOLS"]["STARTED"] = true;
}
* Same as input.
*
* [example]
* <hookcode>
* function phorum_mod_foo_hide_thread($msgthd_id)
* {
* global $PHORUM;
*
* // Log the hidden thread id
* $PHORUM["mod_foo"]["hidden_threads"][] = $msgthd_id;
* $PHORUM['DB']->update_settings(array(
* "mod_foo" => $PHORUM["mod_foo"]
* ));
*
* return $msgthd_id;
* }
* </hookcode>
*/
if (isset($PHORUM["hooks"]["hide_thread"])) {
phorum_api_hook("hide_thread", $msgthd_id);
}
// updating the thread-info
phorum_api_thread_update_metadata($old_message['thread']);
// updating the forum-stats
$PHORUM['DB']->update_forum_stats(false, "-{$num_hidden}");
$PHORUM['DATA']['OKMSG'] = "{$num_hidden} " . $PHORUM['DATA']['LANG']['MsgHiddenOk'];
if (isset($PHORUM['args']["prepost"])) {
$PHORUM['DATA']["URL"]["REDIRECT"] = phorum_api_url(PHORUM_CONTROLCENTER_URL, "panel=" . PHORUM_CC_UNAPPROVED);
} else {
$PHORUM['DATA']["URL"]["REDIRECT"] = $PHORUM["DATA"]["URL"]["LIST"];
}
开发者ID:netovs,项目名称:Core,代码行数:31,代码来源:hide_post.php
示例3: phorum_api_hook
* Allow modules to perform custom action whenever the user edits his post.
* This can be used to e.g. redirect the user immediately back to the edited
* post where he came from.
*
* [category]
* Message handling
*
* [when]
* In <filename>action_edit.php</filename> at the end of the file when
* everything has been done.
*
* [input]
* Array containing message data.
*
* [output]
* Same as input.
*
* [example]
* <hookcode>
* function phorum_mod_foo_posting_action_edit_post ($message)
* {
* global $PHORUM;
*
* // perform a custom redirect
* phorum_redirect_by_url($PHORUM["DATA"]["URL"]["REDIRECT"]);
* }
* </hookcode>
*/
if (isset($PHORUM["hooks"]["posting_action_edit_post"])) {
phorum_api_hook("posting_action_edit_post", $message);
}
function phorum_pm_quoteformat($orig_author, $orig_author_id, $message, $inreplyto = NULL)
{
global $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_api_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_api_format_strip($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;
}
开发者ID:netovs,项目名称:Core,代码行数:27,代码来源:pm.php
示例5: phorum_api_hook
* [when]
* Right before the <literal>PhorumInputForm</literal> object is shown.
*
* [input]
* The <literal>PhorumInputForm</literal> object.
*
* [output]
* Same as input.
*
* [example]
* <hookcode>
* function phorum_mod_foo_admin_general ($frm)
* {
* // Add a section for the foo settings
* $frm->addbreak( "Foo Module Settings" );
*
* // Add the option to cache the bar
* $row=$frm->addrow( "Enable Bar Caching:", $frm->select_tag( "mod_foo[enable_bar_caching]", array( "No", "Yes" ), $PHORUM["mod_foo"]["enable_bar_caching"] ) );
* $frm->addhelp($row, "Enable Bar Caching", "If you select yes for this option, then the bar will be cached." );
*
* // Return the modified PhorumInputForm
* return $frm;
*
* }
* </hookcode>
*/
$frm = phorum_api_hook("admin_general", $frm);
$frm->show();
?>
开发者ID:netovs,项目名称:Core,代码行数:29,代码来源:settings.php
示例6: phorum_api_hook
* case 'unapproved':
* $log = 'No new password generated for ' .
* 'unapproved user ' . $user['username'];
* break;
* }
*
* if ($log !== NULL) {
* log_the_password_reset($log);
* }
*
* return $user;
* }
* </hookcode>
*/
if ($hook_args && isset($PHORUM['hooks']['password_reset'])) {
phorum_api_hook("password_reset", $hook_args);
}
}
// ----------------------------------------------------------------------------
// Build template data and output the page
// ----------------------------------------------------------------------------
$redir = htmlspecialchars($redir, ENT_COMPAT, $PHORUM['DATA']['HCHARSET']);
// Fill the breadcrumbs-info.
$PHORUM['DATA']['BREADCRUMBS'][] = array('URL' => '', 'TEXT' => $PHORUM['DATA']['LANG']['LogIn'], 'TYPE' => 'login');
// Fill the page heading info.
$PHORUM['DATA']['HEADING'] = $heading;
$PHORUM['DATA']['HTML_DESCRIPTION'] = '';
$PHORUM['DATA']['DESCRIPTION'] = '';
// Setup template data.
$PHORUM['DATA']['LOGIN']['redir'] = $redir;
$PHORUM['DATA']['URL']['REGISTER'] = phorum_api_url(PHORUM_REGISTER_URL);
开发者ID:samuell,项目名称:Core,代码行数:31,代码来源:login.php
示例7: phorum_api_hook
* // Set the type of list page to use, based on a cookie.
* if (empty($_COOKIE['list_style'])) {
* $PHORUM['threaded_list'] = PHORUM_THREADED_DEFAULT;
* } elseif ($_COOKIE['list_style'] == 'threaded') {
* $PHORUM['threaded_list'] = PHORUM_THREADED_ON;
* } elseif ($_COOKIE['list_style'] == 'flat') {
* $PHORUM['threaded_list'] = PHORUM_THREADED_OFF;
* } elseif ($_COOKIE['list_style'] == 'hybrid') {
* $PHORUM['threaded_list'] = PHORUM_THREADED_HYBRID;
* }
* }
* </hookcode>
*/
$page_hook = 'page_' . phorum_page;
if (isset($PHORUM["hooks"][$page_hook])) {
phorum_api_hook($page_hook, "");
}
$formatted = phorum_api_format_users(array($PHORUM['user']));
$PHORUM['DATA']['USER'] = $formatted[0];
$PHORUM['DATA']['PHORUM_PAGE'] = phorum_page;
$PHORUM['DATA']['USERTRACK'] = $PHORUM['track_user_activity'];
$PHORUM['DATA']['VROOT'] = $PHORUM['vroot'];
$PHORUM['DATA']['POST_VARS'] .= "<input type=\"hidden\" name=\"forum_id\" value=\"{$PHORUM["forum_id"]}\" />\n";
if (!empty($PHORUM['ref_thread_id'])) {
$PHORUM['DATA']['POST_VARS'] .= "<input type=\"hidden\" name=\"ref_thread_id\" value=\"{$PHORUM["ref_thread_id"]}\" />\n";
}
if (!empty($PHORUM['ref_message_id'])) {
$PHORUM['DATA']['POST_VARS'] .= "<input type=\"hidden\" name=\"ref_message_id\" value=\"{$PHORUM["ref_message_id"]}\" />\n";
}
if (!empty($PHORUM['use_rss'])) {
if ($PHORUM["default_feed"] == "rss") {
开发者ID:netovs,项目名称:Core,代码行数:31,代码来源:common.php
示例8: phorum_shutdown
/**
* The Phorum shutdown function, which will always be called when a
* Phorum script ends.
*/
function phorum_shutdown()
{
global $PHORUM;
// Strange things happen during shutdown
// Make sure that we are in the Phorum dir.
/**
* @todo Still needed now we include files using absolute paths?
*/
$working_dir = getcwd();
chdir(PHORUM_PATH);
/*
* [hook]
* phorum_shutdown
*
* [description]
* This hook gives modules a chance to easily hook into
* PHP's <phpfunc>register_shutdown_function</phpfunc>
* functionality.<sbr/>
* <sbr/>
* Code that you put in a phorum_shutdown hook will be run after
* running a Phorum script finishes. This hook can be considered
* an expert hook. Only use it if you really need it and if you
* are aware of implementation details of PHP's shutdown
* functionality.
*
* [category]
* Page output
*
* [when]
* After running a Phorum script finishes.
*
* [input]
* No input.
*
* [output]
* No output.
*/
if (isset($PHORUM["hooks"]["shutdown"])) {
phorum_api_hook("shutdown");
}
// Shutdown the database connection.
$PHORUM['DB']->close_connection();
if ($working_dir !== FALSE) {
chdir($working_dir);
}
}
开发者ID:samuell,项目名称:Core,代码行数:50,代码来源:api.php
示例9: phorum_api_hook
* {
* // An optional name=.... argument can be used in the request.
* $name = phorum_ajax_getarg('name', 'string', 'Anonymous Person');
*
* // This will return a JSON encoded string to the client.
* phorum_ajax_return("Hello, $name");
* }
* </hookcode>
*
* For this hook implementation, a GET based URL to fire this
* Ajax call could look like
* <literal>http://example.com/ajax.php?call=sayhello,name=JohnDoe</literal>.
*/
$call_hook = 'ajax_' . $ajax_call;
if (isset($PHORUM['hooks'][$call_hook])) {
phorum_api_hook($call_hook, $PHORUM['ajax_args']);
}
// Check if the Ajax call has a core handler script.
if (file_exists("./include/ajax/call.{$ajax_call}.php")) {
include "./include/ajax/call.{$ajax_call}.php";
exit;
}
// No handler script available. Bail out.
phorum_ajax_error('Unknown call "' . $ajax_call . '" in Ajax POST request');
// ----------------------------------------------------------------------
// Utility functions that can be used by Ajax call implementations
// ----------------------------------------------------------------------
/**
* Return an Ajax error to the caller.
*
* This will send an error (500 HTTP status code) message to the client,
开发者ID:samuell,项目名称:Core,代码行数:31,代码来源:ajax.php
示例10: phorum_api_hook
*
* [when]
* Right after the javascript.php script has generated a new
* JavaScript file and right before storing that file in the cache.
* The filter hook will not be run for every request to
* javascript.php, but only in case the JavaScript code has
* to be refreshed.
*
* [input]
* The generated JavaScript code.
*
* [output]
* The filtered JavaScript code.
*/
if (isset($PHORUM['hooks']['javascript_filter'])) {
$content = phorum_api_hook('javascript_filter', $content);
}
if (!empty($PHORUM['cache_javascript'])) {
$cache_time = time();
phorum_cache_put('js', $cache_key, array($cache_time, $content), 86400);
}
// Send the JavaScript to the browser.
header("Content-Type: text/javascript");
print "/* FRESH */";
print $content;
// Exit here explicitly for not giving back control to portable and
// embedded Phorum setups.
exit(0);
}
// Find the modification time for the cache file.
$last_modified = $cache_time;
$message["thread"] = $dbmessage["thread"];
// Create Re: subject prefix.
if (substr($dbmessage["subject"], 0, 4) != "Re: ") {
$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_api_hook("quote", array($author, $dbmessage["body"], $dbmessage["user_id"]));
}
if (empty($quoted) || is_array($quoted)) {
$quoted = phorum_api_format_strip($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);
}
*
* [description]
* This hook can be used for performing actions like sending
* notifications or making log entries after making a message sticky.
*
* [category]
* Moderation
*
* [when]
* In <filename>include/moderation/make_sticky.php</filename>,
* right after a message has been made sticky by a moderator.
*
* [input]
* The id of the thread that has to be made sticky.
*
* [output]
* Same as input.
*
* [example]
* <hookcode>
* function phorum_mod_foo_make_sticky($msgthd_id)
* {
* // ... extra processing for make_sticky operations goes here ...
*
* return $msgthd_id;
* }
* </hookcode>
*/
if (isset($PHORUM["hooks"]["make_sticky"])) {
phorum_api_hook("make_sticky", $msgthd_id);
}
* Allow modules to perform custom action whenever the user cancels editing
* of his post. This can be used to e.g. redirect the user immediately back
* to the edited post where he came from.
*
* [category]
* Message handling
*
* [when]
* In <filename>action_cancel.php</filename> at the end of the file when
* everything has been done.
*
* [input]
* Array containing message data.
*
* [output]
* Same as input.
*
* [example]
* <hookcode>
* function phorum_mod_foo_posting_action_cancel_post ($message)
* {
* global $PHORUM;
*
* // perform a custom redirect
* phorum_redirect_by_url($PHORUM["DATA"]["URL"]["REDIRECT"]);
* }
* </hookcode>
*/
if (isset($PHORUM["hooks"]["posting_action_cancel_post"])) {
phorum_api_hook("posting_action_cancel_post", $message);
}
//.........这里部分代码省略.........
// Convert legacy <...> URLs into bare URLs.
$body = preg_replace("/<(\n (?:http|https|ftp):\\/\\/\n [a-z0-9;\\/\\?:@=\\&\$\\-_\\.\\+!*'\\(\\),~%]+?\n )>/xi", "\$1", $body);
// Escape special HTML characters.
$escaped_body = htmlspecialchars($body, ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]);
// When there is a charset mismatch between the database
// and the language file, then bodies might get crippled
// because of the htmlspecialchars() call. Here we try to
// correct this issue. It's not perfect, but we do what
// we can ...
if ($escaped_body == '') {
if (function_exists("iconv")) {
// We are gonna guess and see if we get lucky.
$escaped_body = iconv("ISO-8859-1", $PHORUM["DATA"]["HCHARSET"], $body);
} else {
// We let htmlspecialchars use its defaults.
$escaped_body = htmlspecialchars($body);
}
}
$body = $escaped_body;
// Replace newlines with $phorum_br temporarily.
// This way the mods know what breaks were added by
// Phorum and what breaks by the user.
$body = str_replace("\n", "{$phorum_br}\n", $body);
// Censor bad words in the body.
if ($censor_search !== NULL) {
$body = preg_replace($censor_search, $censor_replace, $body);
}
$messages[$id]['body'] = $body;
}
// -----------------------------------------------------------------
// Message subject
// -----------------------------------------------------------------
// Censor bad words in the subject.
if (isset($message['subject']) && $censor_search !== NULL) {
$messages[$id]['subject'] = preg_replace($censor_search, $censor_replace, $message['subject']);
}
// Escape special HTML characters.
if (isset($message['subject'])) {
$messages[$id]['subject'] = htmlspecialchars($messages[$id]['subject'], ENT_COMPAT, $PHORUM['DATA']['HCHARSET']);
}
// -----------------------------------------------------------------
// Message author
// -----------------------------------------------------------------
// Escape special HTML characters in the email address.
if (isset($message['email'])) {
$messages[$id]['email'] = htmlspecialchars($message['email'], ENT_COMPAT, $PHORUM['DATA']['HCHARSET']);
}
// Do author formatting for all provided author fields.
foreach ($author_specs as $spec) {
// Use "Anonymous user" as the author name if there's no author
// name available for some reason.
if (!isset($message[$spec[1]]) || $message[$spec[1]] == '') {
$messages[$id][$spec[3]] = $PHORUM["DATA"]["LANG"]["AnonymousUser"];
} elseif (!empty($message[$spec[0]])) {
$url = str_replace('%spec_data%', $message[$spec[0]], $profile_url_template);
$messages[$id]["URL"][$spec[4]] = $url;
$messages[$id][$spec[3]] = empty($PHORUM["custom_display_name"]) ? htmlspecialchars($message[$spec[1]], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]) : $message[$spec[1]];
} elseif ($spec[2] !== NULL && !empty($message[$spec[2]]) && (empty($PHORUM['hide_email_addr']) || !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)) {
$messages[$id][$spec[3]] = htmlspecialchars($message[$spec[1]], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]);
$email_url = phorum_api_format_html_encode("mailto:" . $message[$spec[2]]);
$messages[$id]["URL"]["PROFILE"] = $email_url;
} else {
$messages[$id][$spec[3]] = htmlspecialchars($message[$spec[1]], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]);
}
if ($censor_search !== NULL) {
$messages[$id][$spec[3]] = preg_replace($censor_search, $censor_replace, $messages[$id][$spec[3]]);
}
}
}
// A hook for module writers to apply custom message formatting.
if (isset($PHORUM["hooks"]["format"])) {
$messages = phorum_api_hook("format", $messages);
}
// A hook for module writers for doing post formatting fixups.
if (isset($PHORUM["hooks"]["format_fixup"])) {
$messages = phorum_api_hook("format_fixup", $messages);
}
// Clean up after the mods are done.
foreach ($messages as $id => $message) {
// Clean up line breaks inside pre and xmp tags. These tags
// take care of showing newlines as breaks themselves.
if (isset($message['body']) && $message['body'] != '') {
foreach (array('pre', 'goep', 'xmp') as $tagname) {
if (preg_match_all("/(<{$tagname}.*?>).+?(<\\/{$tagname}>)/si", $message['body'], $matches)) {
foreach ($matches[0] as $match) {
$stripped = str_replace($phorum_br, '', $match);
$message['body'] = str_replace($match, $stripped, $message['body']);
}
}
}
// Remove line break after div, quote and code tags. These
// tags have their own line break. Without this, there would
// be to many white lines.
$message['body'] = preg_replace("/\\s*(<\\/?(?:div|xmp|blockquote|pre)[^>]*>)\\s*\\Q{$phorum_br}\\E/", '$1', $message['body']);
// Normalize the Phorum line breaks that are left.
$messages[$id]['body'] = str_replace($phorum_br, "<br />", $message['body']);
}
}
return $messages;
}
* The same array as the one that was used for the hook call
* argument, possibly with some updated fields in it.
*
* [example]
* <hookcode>
* function phorum_mod_foo_index($data)
* {
* global $PHORUM;
*
* // An example to add some data to the description of
* // forums on the index page in flat view.
* if ($PHORUM['index_style'] == PHORUM_INDEX_FLAT)
* {
* foreach ($data as $id => $item)
* {
* if (!$item['folder_flag'])
* {
* $data[$id]['description'] .= '<br/>Blah foo bar baz';
* }
* }
* }
*
* return $data;
* }
* </hookcode>
*/
if (isset($PHORUM['hooks']['index'])) {
$PHORUM['DATA']['FORUMS'] = phorum_api_hook('index', $PHORUM['DATA']['FORUMS']);
}
// Display the page.
phorum_api_output('index_flat');
$thread_id = phorum_ajax_getarg('thread_id', 'int', 0);
$threads_only = phorum_ajax_getarg('threads_only', 'boolean', 0);
$format = phorum_ajax_getarg('format', 'string', 'html');
// Retrieve the recent messages.
$recent = $PHORUM['DB']->get_recent_messages($count, 0, $forum_id, $thread_id, $threads_only);
unset($recent["users"]);
// Add newflag info to the messages.
if ($PHORUM["DATA"]["LOGGEDIN"]) {
$type = $threads_only ? PHORUM_NEWFLAGS_BY_THREAD : PHORUM_NEWFLAGS_BY_MESSAGE;
$recent = phorum_api_newflags_apply_to_messages($recent, $type);
}
// Format the messages.
$recent = phorum_api_format_messages($recent);
// Apply the list hook to the messages.
if (isset($PHORUM["hooks"]["list"])) {
$recent = phorum_api_hook("list", $recent);
}
// Retrieve information about the forums for the active user.
$allowed_forums = phorum_api_user_check_access(PHORUM_USER_ALLOW_READ, PHORUM_ACCESS_LIST);
$forums = $PHORUM['DB']->get_forums($allowed_forums);
foreach ($forums as $id => $forum) {
$forums[$id]['url'] = phorum_get_url(PHORUM_LIST_URL, $forum['forum_id']);
}
// Add forum info to the messages and clean up data.
foreach ($recent as $id => $message) {
$recent[$id]['foruminfo'] = array('id' => $message['forum_id'], 'name' => $forums[$message['forum_id']]['name'], 'url' => $forums[$message['forum_id']]['url']);
// Strip fields that the caller should not see in the return data.
unset($recent[$id]['email']);
unset($recent[$id]['ip']);
unset($recent[$id]['meta']);
unset($recent[$id]['msgid']);
/**
* Write a new message to the event logging table.
*
* This function will automatically fill the log information with
* user_id, ip, hostname (if hostname resolving is enabled for the log module)
* datestamp and vroot information. Other log info can be provided throught
* the $loginfo argument.
*
* @param $loginfo - An array containing logging information. This array
* can contain the following fields:
*
* message A short log message on one line.
* details Details about the log message, which can
* span multiple lines. This could for example
* be used for providing a debug backtrace.
* source The source of the log message. This is a
* free 32 char text field, which can be used
* to specifiy what part of Phorum generated the
* log message (e.g. "mod_smileys"). If no
* source is provided, the "phorum_page"
* constant will be used instead.
* category A high level category for the message.
* Options for this field are:
* EVENTLOG_CAT_APPLICATION (default)
* EVENTLOG_CAT_DATABASE
* EVENTLOG_CAT_SECURITY
* EVENTLOG_CAT_SYSTEM
* EVENTLOG_CAT_MODULE
* loglevel This indicates the severety of the message.
* Options for this field are:
* EVENTLOG_LVL_DEBUG
* Messages that are used by programmers
* for tracking low level Phorum operation.
* EVENTLOG_LVL_INFO
* Messages that provide logging for events
* that occur during normal operation. These
* messages could be harvested for usage
* reporting and other types of reports.
* EVENTLOG_LVL_WARNING
* Warning messages do not indicate errors,
* but they do report events that are not
* considered to belong to normal operation
* (e.g. a user which enters a wrong password
* or a duplicate message being posted).
* EVENTLOG_LVL_ERROR
* Error messages indicate non urgent failures
* in Phorum operation. These should be
* relayed to administrators and/or developers
* to have them solved.
* EVENTLOG_LVL_ALERT
* Alert messages indicate errors which should
* be corrected as soon as possible (e.g. loss
* of network connectivity or a full disk).
* These should be relayed to the system
* administrator).
*
* vroot vroot for which a message is generated.
* forum_id forum_id for which a message is generated.
* thread_id thread_id for which a message is generated
* message_id message_id for which a message is generated
*
* user_id Filled automatically, but can be overridden
* ip Filled automatically, but can be overridden
* hostname Filled automatically, but can be overridden
* datestamp Filled automatically, but can be overridden
*/
function event_logging_writelog($loginfo)
{
global $PHORUM;
// Check the minimum log level. Only write to the log if the
// log level of the event is at or above the configured minimum.
$lvl = isset($loginfo["loglevel"]) ? (int) $loginfo["loglevel"] : 0;
if ($lvl < $PHORUM["mod_event_logging"]["min_log_level"]) {
return;
}
$loginfo = phorum_api_hook("event_logging_writelog", $loginfo);
// The record that we will insert in the database.
$record = array();
// Handle messages that exceed the maximum message length.
if ($loginfo["message"] !== NULL && strlen($loginfo["message"]) > 255) {
if (!isset($loginfo["details"])) {
$loginfo["details"] = '';
}
$loginfo["details"] = "Message:\n\n{$loginfo["message"]}\n\n" . $loginfo["details"];
$loginfo["message"] = substr($loginfo["message"], 0, 100) . "... (see event details for the full message)\n";
} elseif (isset($loginfo["details"])) {
$loginfo["details"] = "Message:\n\n{$loginfo["message"]}\n\n" . $loginfo["details"];
}
// Add the fields from the $loginfo argument.
foreach ($loginfo as $key => $val) {
switch ($key) {
case "datestamp":
case "user_id":
case "vroot":
case "forum_id":
case "thread_id":
case "message_id":
case "category":
case "loglevel":
settype($val, "int");
//.........这里部分代码省略.........
请发表评论