/** * 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() { $lang = $GLOBALS["PHORUM"]["DATA"]["LANG"]["mod_editor_tools"]; // Initialize the tool data array. $GLOBALS["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($GLOBALS["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($GLOBALS["PHORUM"]["hooks"]["editor_tool_plugin"])) { phorum_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; }
} 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"]); } if (isset($PHORUM["hooks"]["profile"])) { $PHORUM["DATA"]["PROFILE"] = phorum_hook("profile", $PHORUM["DATA"]["PROFILE"]); } $PHORUM["DATA"]["HEADING"] = $PHORUM["DATA"]["LANG"]["UserProfile"]; $PHORUM["DATA"]["DESCRIPTION"] = ""; $PHORUM['DATA']['HTML_DESCRIPTION'] = ''; // fill the breadcrumbs-info. $PHORUM['DATA']['BREADCRUMBS'][] = array('URL' => '', 'TEXT' => strip_tags($PHORUM["DATA"]["HEADING"]), 'TYPE' => 'profile'); // set all our URL's phorum_build_common_urls(); phorum_output($template);
$base = strtolower(phorum_get_url(PHORUM_BASE_URL)); $len = strlen($base); if (strtolower(substr($_SERVER["HTTP_REFERER"],0,$len)) == $base) { $redir = htmlspecialchars($_SERVER["HTTP_REFERER"]); } } if (! isset($redir)) { $redir = phorum_get_url(PHORUM_LIST_URL); } // Setup template data. $PHORUM["DATA"]["LOGIN"]["redir"] = $redir; $PHORUM["DATA"]["URL"]["REGISTER"] = phorum_get_url( PHORUM_REGISTER_URL ); $PHORUM["DATA"]["URL"]["ACTION"] = phorum_get_url( PHORUM_LOGIN_ACTION_URL ); $PHORUM["DATA"]["LOGIN"]["forum_id"] = ( int )$PHORUM["forum_id"]; $PHORUM["DATA"]["LOGIN"]["username"] = htmlspecialchars( $username ); $PHORUM["DATA"]["ERROR"] = htmlspecialchars( $error ); $PHORUM["DATA"]["OKMSG"] = htmlspecialchars( $okmsg ); // Set the field to set the focus to after loading. $PHORUM["DATA"]["FOCUS_TO_ID"] = empty($username) ? "username" : "password"; // Display the page. include phorum_get_template( "header" ); phorum_hook( "after_header" ); include phorum_get_template( $template ); phorum_hook( "before_footer" ); include phorum_get_template( "footer" ); ?>
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']]); } $frm->addrow($item['name'], $itemval); } } phorum_hook("admin_users_form", $frm, $user); $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"); $frm->hidden("referrer", $referrer); $row = $frm->addbreak("Edit Forum Permissions"); $frm->addhelp($row, "Forum Permissions", "These are permissions set exclusively for this user. You need to grant all permisssions you want the user to have for a forum here. No permissions from groups or a forum's properties will be used once the user has specific permissions for a forum."); $forums = phorum_db_get_forums(); $forumpaths = phorum_get_forum_info(1); $perm_frm = $frm->checkbox("new_forum_permissions[" . PHORUM_USER_ALLOW_READ . "]", 1, "Read") . " " . $frm->checkbox("new_forum_permissions[" . PHORUM_USER_ALLOW_REPLY . "]", 1, "Reply") . " " . $frm->checkbox("new_forum_permissions[" . PHORUM_USER_ALLOW_NEW_TOPIC . "]", 1, "Create New Topics") . " " . $frm->checkbox("new_forum_permissions[" . PHORUM_USER_ALLOW_EDIT . "]", 1, "Edit Their Posts") . "<br />" . $frm->checkbox("new_forum_permissions[" . PHORUM_USER_ALLOW_ATTACH . "]", 1, "Attach Files") . "<br />" . $frm->checkbox("new_forum_permissions[" . PHORUM_USER_ALLOW_MODERATE_MESSAGES . "]", 1, "Moderate Messages") . " " . $frm->checkbox("new_forum_permissions[" . PHORUM_USER_ALLOW_MODERATE_USERS . "]", 1, "Moderate Users") . " "; $arr[] = "Add A Forum..."; foreach ($forumpaths as $forum_id => $forumname) { if (!isset($user["forum_permissions"][$forum_id]) && $forums[$forum_id]['folder_flag'] == 0) {
} // Handle the delete action, unless a module already handled it. if (!$delete_handled) { // Delete the message from the database. phorum_db_delete_message($msgthd_id, PHORUM_DELETE_MESSAGE); // Delete the message attachments from the database. $files = phorum_db_get_message_file_list($msgthd_id); foreach ($files as $file_id => $data) { if (phorum_api_file_check_delete_access($file_id)) { phorum_api_file_delete($file_id); } } } // Run a hook for performing custom actions after cleanup. if (isset($PHORUM["hooks"]["delete"])) { phorum_hook("delete", array($msgthd_id)); } } } } $PHORUM['DATA']['PREPOST'] = array(); if ($gotforums) { $foruminfo = phorum_db_get_forums($mod_forums, NULL, $PHORUM['vroot']); } else { $foruminfo = array(); } foreach ($mod_forums as $forum => $rest) { $checkvar = 1; // Get the threads $rows = array(); // get the thread set started
($mode == 'post' || $mode == 'reply')) { if (empty($message["author"])) { $error = $PHORUM["DATA"]["LANG"]["ErrAuthor"]; } elseif ((!defined('PHORUM_ENFORCE_UNREGISTERED_NAMES') || (defined('PHORUM_ENFORCE_UNREGISTERED_NAMES') && PHORUM_ENFORCE_UNREGISTERED_NAMES == true)) && phorum_user_check_username($message["author"])) { $error = $PHORUM["DATA"]["LANG"]["ErrRegisterdName"]; } elseif (!empty($message["email"]) && phorum_user_check_email($message["email"])) { $error = $PHORUM["DATA"]["LANG"]["ErrRegisterdEmail"]; } } // A hook entry for checking the data from a module. if (! $error) { list($message, $error) = phorum_hook("check_post", array($message, $error)); } // Data integrity checks for all messages. if (! $error) { if (empty($message["subject"])) { $error = $PHORUM["DATA"]["LANG"]["ErrSubject"]; } elseif (empty($message["body"])) { $error = $PHORUM["DATA"]["LANG"]["ErrBody"]; } elseif (!empty($message["email"]) && !phorum_valid_email($message["email"])) { $error = $PHORUM["DATA"]["LANG"]["ErrEmail"]; } elseif (strlen($message["body"]) > 64000) { $error = $PHORUM["DATA"]["LANG"]["ErrBodyTooLarge"]; }
* Miscellaneous * * [when] * In the <filename>script.php</filename> when called from the command * prompt or a script file. * * [input] * Any array of arguments. (Optional) * * [output] * Same as input. * */ if ($callhook == 'external') { $module = array_shift($modules); // The first argument in $callargs is set to the name of the // called module. This module name is not really needed, but it // in there for backward compatibility (in older code, all "external" // hooks were called and the external hook implementation had to check // the module name to see if it had to be run or not). array_unshift($callargs, $module); $callargs = array_values($callargs); // reindex (0, 1, 2, ...) array keys. // Call the external hook. phorum_hook("external", $callargs); } elseif ($callhook == 'scheduled') { phorum_hook('scheduled'); } else { echo $GLOBALS["PHORUM"]["DATA"]["LANG"]["ScriptUsage"]; exit(1); }
* { * // 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_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,
/** * function for sending email to users, gets addresses-array and data-array */ function phorum_email_user($addresses, $data) { $PHORUM = $GLOBALS['PHORUM']; require_once './include/api/mail.php'; // If we have no from_address in the message data, then generate // from_address ourselves, based on the system_email_* settings. if (!isset($data['from_address']) || trim($data['from_address']) == '') { $from_name = trim($PHORUM['system_email_from_name']); if ($from_name != '') { // Handle (Quoted-Printable) encoding of the from name. // Mail headers cannot contain 8-bit data as per RFC821. $from_name = phorum_api_mail_encode_header($from_name); $prefix = $from_name . ' <'; $postfix = '>'; } else { $prefix = $postfix = ''; } $data['from_address'] = $prefix . $PHORUM['system_email_from_address'] . $postfix; } /* * [hook] * email_user_start * * [description] * This hook is put at the very beginning of * <literal>phorum_email_user()</literal> and is therefore called for * <emphasis>every</emphasis> email that is sent from Phorum. It is put * before every replacement done in that function so that all data which * is sent to that function can be replaced/changed at will. * * [category] * Moderation * * [when] * In the file <filename>email_functions.php</filename> at the start of * <literal>phorum_email_user()</literal>, before any modification of * data. * * [input] * An array containing: * <ul> * <li>An array of addresses.</li> * <li>An array containing the message data.</li> * </ul> * * [output] * Same as input. * * [example] * <hookcode> * function phorum_mod_foo_email_user_start (list($addresses, $data)) * { * global $PHORUM; * * // Add our disclaimer to the end of every email message. * $data["mailmessage"] = $PHORUM["mod_foo"]["email_disclaimer"]; * * return array($addresses, $data); * } * </hookcode> */ if (isset($PHORUM["hooks"]["email_user_start"])) { list($addresses, $data) = phorum_hook("email_user_start", array($addresses, $data)); } // Clear some variables that are meant for use by the email_user_start hook. unset($data['mailmessagetpl']); unset($data['mailsubjecttpl']); unset($data['language']); // Extract message body and subject. $mailmessage = $data['mailmessage']; unset($data['mailmessage']); $mailsubject = $data['mailsubject']; unset($data['mailsubject']); // Replace template variables. if (is_array($data) && count($data)) { foreach (array_keys($data) as $key) { if ($data[$key] === NULL || is_array($data[$key])) { continue; } $mailmessage = str_replace("%{$key}%", $data[$key], $mailmessage); $mailsubject = str_replace("%{$key}%", $data[$key], $mailsubject); } } $num_addresses = count($addresses); $from_address = $data['from_address']; # Try to find a useful hostname to use in the Message-ID. $host = ""; if (isset($_SERVER["HTTP_HOST"])) { $host = $_SERVER["HTTP_HOST"]; } else { if (function_exists("posix_uname")) { $sysinfo = @posix_uname(); if (!empty($sysinfo["nodename"])) { $host .= $sysinfo["nodename"]; } if (!empty($sysinfo["domainname"])) { $host .= $sysinfo["domainname"]; } } else { if (function_exists("php_uname")) { $host = @php_uname("n"); } else { if (($envhost = getenv("HOSTNAME")) !== false) { $host = $envhost; } } } } if (empty($host)) { $host = "webserver"; } // Compose an RFC compatible Message-ID header. if (isset($data["msgid"])) { $messageid = "<{$data['msgid']}@{$host}>"; } else { $l = localtime(time()); $l[4]++; $l[5] += 1900; $stamp = sprintf("%d%02d%02d%02d%02d", $l[5], $l[4], $l[3], $l[2], $l[1]); $rand = substr(md5(microtime()), 0, 14); $messageid = "<{$stamp}.{$rand}@{$host}>"; } $messageid_header = "\nMessage-ID: {$messageid}"; // Handle (Quoted-Printable) encoding of the Subject: header. // Mail headers can not contain 8-bit data as per RFC821. $mailsubject = phorum_api_mail_encode_header($mailsubject); /* * [hook] * send_mail * * [description] * This hook can be used for implementing an alternative mail sending * system. The hook should return true if Phorum should still send the * mails. If you do not want to have Phorum send the mails also, return * false.<sbr/> * <sbr/> * The SMTP module is a good example of using this hook to replace * Phorum's default mail sending system. * * [category] * Moderation * * [when] * In the file <filename>email_functions.php</filename> in * <literal>phorum_email_user()</literal>, right before email is sent * using <phpfunc>mail</phpfunc>. * * [input] * Array with mail data (read-only) containing: * <ul> * <li><literal>addresses</literal>, an array of e-mail addresses</li> * <li><literal>from</literal>, the sender address</li> * <li><literal>subject</literal>, the mail subject</li> * <li><literal>body</literal>, the mail body</li> * <li><literal>bcc</literal>, whether to use Bcc for mailing multiple * recipients</li> * </ul> * * [output] * true or false - see description. * */ $send_messages = 1; if (isset($PHORUM["hooks"]["send_mail"])) { $hook_data = array('addresses' => $addresses, 'from' => $from_address, 'subject' => $mailsubject, 'body' => $mailmessage, 'bcc' => $PHORUM['use_bcc'], 'messageid' => $messageid); $send_messages = phorum_hook("send_mail", $hook_data); } if ($send_messages != 0 && $num_addresses > 0) { $phorum_major_version = substr(PHORUM, 0, strpos(PHORUM, '.')); $mailer = "Phorum" . $phorum_major_version; $mailheader = "Content-Type: text/plain; charset={$PHORUM["DATA"]["CHARSET"]}\nContent-Transfer-Encoding: {$PHORUM["DATA"]["MAILENCODING"]}\nX-Mailer: {$mailer}{$messageid_header}\n"; // adding custom headers if defined if (!empty($data['custom_headers'])) { $mailheader .= $data['custom_headers'] . "\n"; } if (isset($PHORUM['use_bcc']) && $PHORUM['use_bcc'] && $num_addresses > 3) { mail(" ", $mailsubject, $mailmessage, $mailheader . "From: {$from_address}\nBCC: " . implode(",", $addresses)); } else { foreach ($addresses as $address) { mail($address, $mailsubject, $mailmessage, $mailheader . "From: {$from_address}"); } } } return $num_addresses; }
/** * This function is used for purging stale files from the Phorum system. * * @param boolean $do_purge * If this parameter is set to a false value (the default), then no * actual purging will take place. The function will only return an * array of stale files. If the parameter is set to a true value, * then the stale files will be purged for real. * * @return array * An array of stale Phorum files, indexed by file_id. Every item in * this array is an array on its own, containing the fields: * - file_id: the file id of the stale file * - filename: the name of the stale file * - filesize: the size of the file in bytes * - add_datetime: the time (epoch) at which the file was added * - reason: the reason why it's a stale file * This array will be returned, regardless of the $do_purge parameter. */ function phorum_api_file_purge_stale($do_purge) { $stale_files = phorum_db_list_stale_files(); /** * [hook] * file_purge_stale * * [description] * This hook can be used to feed the file storage API function * phorum_api_file_purge_stale() extra stale files. This can be * useful for modules that handle their own files, using a * custom link type. * * [category] * File storage * * [when] * Right after Phorum created its own list of stale files. * * [input] * An array containing stale files, indexed by file_id. Each item * in this array is an array on its own, containing the following * fields: * <ul> * <li>file_id: * the file id of the stale file</li> * <li>filename: * the name of the stale file</li> * <li>filesize: * the size of the file in bytes</li> * <li>add_datetime: * the time (epoch) at which the file was added</li> * <li>reason: * the reason why it's a stale file</li> * </ul> * * [output] * The same array as the one that was used for the hook call * argument, possibly extended with extra files that are * considered to be stale. */ if (isset($GLOBALS['PHORUM']['hooks']['file_purge_stale'])) { $stale_files = phorum_hook('file_purge_stale', $stale_files); } // Delete the files if requested. if ($do_purge) { foreach ($stale_files as $file) { phorum_api_file_delete($file); } } return $stale_files; }
// will return messages with the same thread id in // other forums as well (those are the move notifications). if ($delmode == PHORUM_DELETE_TREE) { $forum_id = $PHORUM["forum_id"]; $PHORUM["forum_id"] = 0; $moved = phorum_db_get_messages($msg["message_id"]); $PHORUM["forum_id"] = $forum_id; foreach ($moved as $id => $data) { if (!empty($data["moved"])) { phorum_db_delete_message($id, PHORUM_DELETE_MESSAGE); } } } } // Run a hook for performing custom actions after cleanup. phorum_hook("delete", $delids); // Keep track of deleted messages ids for counting the deleted // messages at the end. We can't simply add the number of messages // in the message array, because there might be overlap between // messages and threads here. foreach ($delids as $id) { $delete_messages[$id] = 1; } } $delete_count = count($delete_messages); phorum_admin_okmsg("Deleted {$delete_count} message(s) from the database."); } // If a filterdesc field is in the post data, then query the database // based on this filterdesc. The results will be shown later on, // below the filter form. if (isset($_POST["filterdesc"])) {
* [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_hook("admin_general", $frm); $frm->show(); ?>
* $pm_message = preg_replace( * "/%message_subject%/", * $dbmessage["subject"], * $PHORUM["DATA"]["LANG"]["mod_foo"]["MessageEditedBody"] * ); * phorum_db_pm_send( * $PHORUM["DATA"]["LANG"]["mod_foo"]["MessageEditedSubject"], * $pm_message, * $dbmessage["user_id"] * ); * } * } * </hookcode> */ if (isset($PHORUM["hooks"]["after_edit"])) { phorum_hook("after_edit", $dbmessage); } // remove the message from the cache if caching is enabled // no need to clear the thread-index as the message has only been changed if ($PHORUM['cache_messages']) { phorum_cache_remove('message', $message["message_id"]); phorum_db_update_forum(array('forum_id' => $PHORUM['forum_id'], 'cache_version' => $PHORUM['cache_version'] + 1)); } // Update children to the same sort setting. if (!$message["parent_id"] && $origmessage["sort"] != $dbmessage["sort"]) { $messages = phorum_db_get_messages($message["thread"], 0); unset($messages["users"]); foreach ($messages as $message_id => $msg) { if ($msg["sort"] != $dbmessage["sort"] || $msg["forum_id"] != $dbmessage["forum_id"]) { $msg["sort"] = $dbmessage["sort"]; phorum_db_update_message($message_id, $msg);
/** * Formats forum messages. * * @param array $data * An array containing an array of messages to be formatted. * * @param array $author_specs * By default, the formatting function will create author info * data out of the fields "user_id", "author" and "email". * This will create $data["URL"]["PROFILE"] if needed (either pointing * to a user profile for registered users or the email address of * anonymous users that left an email address in the forum) and will * do formatting on the $data["author"] field. * * By providing extra $author_specs, this formatting can be done on * more author fields. This argument should be an array, containing * arrays with five fields: the field that contains a user_id, * the field for the name of the author and the field for the email * address (can be NULL if none available), the name of the field * to store the author name in and the name of the URL field to store * the profile/email link in. For the default author field like * describe above, this array would be: * * array("user_id", "author", "email", "author", "PROFILE"); * * @return data - The formatted messages. */ function phorum_format_messages($data, $author_specs = NULL) { $PHORUM = $GLOBALS["PHORUM"]; // Prepare author specs. if ($author_specs === NULL) { $author_specs = array(); } $author_specs[] = array("user_id", "author", "email", "author", "PROFILE"); // Prepare the bad-words replacement code. $bad_word_check = false; $banlists = NULL; if (!empty($PHORUM['cache_banlists']) && !empty($PHORUM['banlist_version'])) { $cache_key = $PHORUM['forum_id']; $banlists = phorum_cache_get('banlist', $cache_key, $PHORUM['banlist_version']); } // not found or no caching enabled if ($banlists === NULL) { $banlists = phorum_db_get_banlists(); if (!empty($PHORUM['cache_banlists']) && !empty($PHORUM['banlist_version'])) { phorum_cache_put('banlist', $cache_key, $banlists, 7200, $PHORUM['banlist_version']); } } if (isset($banlists[PHORUM_BAD_WORDS]) && is_array($banlists[PHORUM_BAD_WORDS])) { $replace_vals = array(); $replace_words = array(); foreach ($banlists[PHORUM_BAD_WORDS] as $item) { $replace_words[] = "/\\b" . preg_quote($item['string'], '/') . "(ing|ed|s|er|es)*\\b/i"; $replace_vals[] = PHORUM_BADWORD_REPLACE; $bad_word_check = true; } } // A special <br> tag to keep track of breaks that are added by phorum. $phorum_br = '<phorum break>'; // prepare url-templates used later on $profile_url_template = phorum_get_url(PHORUM_PROFILE_URL, '%spec_data%'); // Apply Phorum's formatting rules to all messages. foreach ($data as $key => $message) { // Normally, the message_id must be set, since we should be handling // message data. It might not be set however, because sometimes // the message formatting is called using some fake message data // for formatting something else than a message. if (!isset($message['message_id'])) { $data[$key]['message_id'] = $message['message_id'] = $key; } // Work on the message body ======================== if (isset($message["body"])) { $body = $message["body"]; // Convert legacy <> urls into bare urls. $body = preg_replace("/<((http|https|ftp):\\/\\/[a-z0-9;\\/\\?:@=\\&\$\\-_\\.\\+!*'\\(\\),~%]+?)>/i", "\$1", $body); // Escape special HTML characters. $escaped_body = htmlspecialchars($body, ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]); 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 Phorum did vs the user. $body = str_replace("\n", "{$phorum_br}\n", $body); // Run bad word replacement code. if ($bad_word_check) { $body = preg_replace($replace_words, $replace_vals, $body); } $data[$key]["body"] = $body; } // Work on the other fields ======================== // Run bad word replacement code on subject and author. if ($bad_word_check) { if (isset($message["subject"])) { $data[$key]["subject"] = preg_replace($replace_words, $replace_vals, $data[$key]["subject"]); } if (isset($message["author"])) { $data[$key]["author"] = preg_replace($replace_words, $replace_vals, $data[$key]["author"]); } } // Escape special HTML characters in fields. if (isset($message["email"])) { $data[$key]["email"] = htmlspecialchars($data[$key]["email"], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]); } if (isset($message["subject"])) { $data[$key]["subject"] = htmlspecialchars($data[$key]["subject"], 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]] == '') { $data[$key][$spec[3]] = $PHORUM["DATA"]["LANG"]["AnonymousUser"]; } elseif (!empty($message[$spec[0]])) { $url = str_replace('%spec_data%', $message[$spec[0]], $profile_url_template); $data[$key]["URL"][$spec[4]] = $url; $data[$key][$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)) { $data[$key][$spec[3]] = htmlspecialchars($message[$spec[1]], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]); $email_url = phorum_html_encode("mailto:" . $message[$spec[2]]); $data[$key]["URL"]["PROFILE"] = $email_url; } else { $data[$key][$spec[3]] = htmlspecialchars($message[$spec[1]], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]); } } } // A hook for module writers to apply custom message formatting. if (isset($PHORUM["hooks"]["format"])) { $data = phorum_hook("format", $data); } // A hook for module writers for doing post formatting fixups. if (isset($PHORUM["hooks"]["format_fixup"])) { $data = phorum_hook("format_fixup", $data); } // Clean up after the mods are done. foreach ($data as $key => $message) { // Clean up line breaks inside pre and xmp tags. These tags // take care of showing newlines as breaks themselves. if (isset($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. $data[$key]["body"] = str_replace($phorum_br, "<br />", $message["body"]); } } return $data; }
* * [category] * Moderation * * [when] * In <filename>moderation.php</filename>, right after a thread has * been split by a moderator. * * [input] * The id of the newly created thread * * [output] * None * */ phorum_hook('after_split', $_POST['message']); break; default: if (!isset($PHORUM['DATA']['OKMSG'])) { $PHORUM['DATA']['OKMSG'] = ""; } $PHORUM['DATA']["URL"]["REDIRECT"] = $PHORUM["DATA"]["URL"]["LIST"]; } // remove the affected messages from the cache if caching is enabled. if ($PHORUM['cache_messages']) { foreach ($invalidate_message_cache as $message) { phorum_cache_remove('message', $message["message_id"]); phorum_db_update_forum(array('forum_id' => $PHORUM['forum_id'], 'cache_version' => $PHORUM['cache_version'] + 1)); } } if (!isset($PHORUM['DATA']['BACKMSG'])) {
if ($filter != "all") { if ($filter != $status) { continue; } } $disabled = false; $statustext = ""; // moderators can't edit other moderators if ($status == PHORUM_USER_GROUP_MODERATOR) { $disabled = true; $statustext = $PHORUM["DATA"]["LANG"]["PermGroupModerator"]; } $PHORUM["DATA"]["USERS"][$userid] = array("userid" => $userid, "name" => htmlspecialchars($users[$userid]["username"], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]), "display_name" => empty($PHORUM["custom_display_name"]) ? htmlspecialchars($users[$userid]["display_name"], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]) : $users[$userid]["display_name"], "status" => $status, "statustext" => $statustext, "disabled" => $disabled, "flag" => $status < PHORUM_USER_GROUP_APPROVED, "url" => phorum_get_url(PHORUM_PROFILE_URL, $userid)); } if (isset($PHORUM["hooks"]["user_list"])) { $PHORUM["DATA"]["USERS"] = phorum_hook("user_list", $PHORUM["DATA"]["USERS"]); } // if the option to build a dropdown list is enabled, build the list of members that could be added if ($PHORUM["enable_dropdown_userlist"]) { $userlist = phorum_api_user_list(PHORUM_GET_ACTIVE); $PHORUM["DATA"]["NEWMEMBERS"] = array(); foreach ($userlist as $userid => $userinfo) { if (!in_array($userid, $usersingroup)) { $userinfo["username"] = htmlspecialchars($userinfo["username"], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]); $userinfo["display_name"] = htmlspecialchars($userinfo["display_name"], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]); $PHORUM["DATA"]["NEWMEMBERS"][] = $userinfo; } } } } else { $PHORUM["DATA"]["GROUPS"] = array();
if (empty($_POST["explanation"])) { $_POST["explanation"] = "<" . $PHORUM["DATA"]["LANG"]["None"] . ">"; } $mail_users = phorum_api_user_list_moderators($PHORUM['forum_id'], $PHORUM['email_ignore_admin'], TRUE); if (count($mail_users)) { $mail_data = array("mailmessage" => $PHORUM["DATA"]["LANG"]['ReportPostEmailBody'], "mailsubject" => $PHORUM["DATA"]["LANG"]['ReportPostEmailSubject'], "forumname" => $PHORUM["DATA"]["NAME"], "reportedby" => $PHORUM["user"]["display_name"], "author" => $message["author"], "subject" => $message["subject"], "body" => wordwrap($message["body"], 72), "ip" => $message["ip"], "raw_date" => $message["datestamp"], "date" => phorum_date($PHORUM["short_date_time"], $message["datestamp"]), "explanation" => wordwrap($_POST["explanation"], 72), "url" => phorum_get_url(PHORUM_READ_URL, $message["thread"], $message_id), "delete_url" => phorum_get_url(PHORUM_MODERATION_URL, PHORUM_DELETE_MESSAGE, $message_id), "hide_url" => phorum_get_url(PHORUM_MODERATION_URL, PHORUM_HIDE_POST, $message_id), "edit_url" => phorum_get_url(PHORUM_POSTING_URL, 'moderation', $message_id), "reporter_url" => phorum_get_url(PHORUM_PROFILE_URL, $PHORUM["user"]["user_id"]), "message" => $message); if (isset($_POST[PHORUM_SESSION_LONG_TERM])) { // strip any auth info from the created urls $mail_data["url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["url"]); $mail_data["delete_url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["delete_url"]); $mail_data["hide_url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["hide_url"]); $mail_data["edit_url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["edit_url"]); $mail_data["reporter_url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["reporter_url"]); } if (isset($PHORUM["hooks"]["report"])) { $mail_data = phorum_hook("report", $mail_data); } 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"];
/** * A common function which is used to save the userdata from the post-data. * @param panel - The panel for which to save data. * @return array - An array containing $error and $okmsg. */ function phorum_controlcenter_user_save($panel) { $PHORUM = $GLOBALS['PHORUM']; $error = ""; $okmsg = ""; // Setup the default userdata fields that can be changed // from the control panel interface. $userdata = array('signature' => NULL, 'hide_email' => NULL, 'hide_activity' => NULL, 'password' => NULL, 'password_temp' => NULL, 'tz_offset' => NULL, 'is_dst' => NULL, 'user_language' => NULL, 'threaded_list' => NULL, 'threaded_read' => NULL, 'email_notify' => NULL, 'show_signature' => NULL, 'pm_email_notify' => NULL, 'email' => NULL, 'email_temp' => NULL, 'user_template' => NULL, 'moderation_email' => NULL, 'real_name' => NULL); // Add custom profile fields as acceptable fields. foreach ($PHORUM["PROFILE_FIELDS"] as $id => $field) { if ($id === "num_fields" || !empty($field['deleted'])) { continue; } $userdata[$field["name"]] = NULL; } // Update userdata with $_POST information. foreach ($_POST as $key => $val) { if (array_key_exists($key, $userdata)) { $userdata[$key] = $val; } } // Remove unused profile fields. foreach ($userdata as $key => $val) { if (is_null($val)) { unset($userdata[$key]); } } // Set static userdata. $userdata["user_id"] = $PHORUM["user"]["user_id"]; /** * [hook] * cc_save_user * * [description] * This hook works the same way as the <hook>before_register</hook> * hook, so you can also use it for changing and checking the user data * that will be saved in the database. There's one difference. If you * want to check a custom field, you'll also need to check the panel * which you are on, because this hook is called from multiple panels. * The panel that you are on will be stored in the * <literal>panel</literal> field of the user data.<sbr/> * <sbr/> * The example hook belows demonstrates code which could be used if you * have added a custom field to the template for the option * <literal>Edit My Profile</literal> in the control panel. * * [category] * Control center * * [when] * In <filename>control.php</filename>, right before data for a user is * saved in the control panel. * * [input] * An array containing the user data to save. * <ul> * <li>error: * modules can fill this field with an error message to show.</li> * </ul> * * [output] * The same array as the one that was used for the hook call * argument, possibly with the "error" field updated in it. * * [example] * <hookcode> * function phorum_mod_foo_cc_save_user ($data) * { * // Only check data for the panel "user". * if ($data['panel'] != "user") return $data; * * $myfield = trim($data['your_custom_field']); * if (empty($myfield)) { * $data['error'] = 'You need to fill in my custom field'; * } * * return $data; * } * </hookcode> */ if (isset($PHORUM["hooks"]["cc_save_user"])) { $userdata = phorum_hook("cc_save_user", $userdata); } // Set $error, in case the cc_save_user hook did set an error. if (isset($userdata['error'])) { $error = $userdata['error']; unset($userdata['error']); // Try to update the userdata in the database. } elseif (!phorum_api_user_save($userdata)) { // Updating the user failed. $error = $PHORUM["DATA"]["LANG"]["ErrUserAddUpdate"]; } else { // Updating the user was successful. $okmsg = $PHORUM["DATA"]["LANG"]["ProfileUpdatedOk"]; // Let the userdata be reloaded. phorum_api_user_set_active_user(PHORUM_FORUM_SESSION, $userdata["user_id"]); // If a new password was set, then reset all session id(s), so // other computers or browser will lose any active session that // they are running. if (isset($userdata["password"]) && $userdata["password"] != '') { phorum_api_user_session_create(PHORUM_FORUM_SESSION, PHORUM_SESSID_RESET_ALL); } // Copy data from the updated user back into the user template data. $formatted = phorum_api_user_format(array($GLOBALS['PHORUM']['user'])); foreach ($formatted[0] as $key => $val) { $GLOBALS['PHORUM']['DATA']['USER'][$key] = $val; } // Copy data from the updated user back into the template data. // Leave PANEL and forum_id alone (these are injected into the // userdata in the template from this script). foreach ($GLOBALS["PHORUM"]["DATA"]["PROFILE"] as $key => $val) { if ($key == "PANEL" || $key == "forum_id") { continue; } if (isset($GLOBALS["PHORUM"]["user"][$key])) { $GLOBALS["PHORUM"]["DATA"]["PROFILE"][$key] = $GLOBALS["PHORUM"]["user"][$key]; } else { $GLOBALS["PHORUM"]["DATA"]["PROFILE"][$key] = ""; } } } return array($error, $okmsg); }
* // remove the post count increment for the user in select forums * if (in_array($message["forum_id"], $PHORUM["mod_foo"]["forums_to_ignore"])) { * phorum_api_user_save ( * array ( * "user_id" => $PHORUM["user"]["user_id"], * "posts" => $PHORUM["user"]["posts"] * ) * ); * } * * return $message; * } * </hookcode> */ if (isset($PHORUM["hooks"]["after_post"])) { $message = phorum_hook("after_post", $message); } // Posting is completed. Take the user back to the forum. if ($PHORUM["redirect_after_post"] == "read") { // Messsage that are not approved are only visible for moderators. $not_viewable = $message["status"] != PHORUM_STATUS_APPROVED && !$PHORUM["DATA"]["MODERATOR"]; // Thread reply message: jump to the last message in the thread // or to the thread starter in case the new message is not viewable. if (isset($top_parent)) { if ($not_viewable) { $redir_url = phorum_get_url(PHORUM_READ_URL, $message["thread"]); } else { $readlen = $PHORUM["read_length"]; $pages = ceil(($top_parent["thread_count"] + 1) / $readlen); if ($pages > 1) { $redir_url = phorum_get_url(PHORUM_READ_URL, $message["thread"], $message["message_id"], "page={$pages}");
* $PHORUM["mod_foo"]["login_failures"][$_SERVER["REMOTE_ADDR"]]["timestamp"] = $curr_time; * // Otherwise, reset the count. * } else { * $PHORUM["mod_foo"]["login_failures"][$_SERVER["REMOTE_ADDR"]]["login_failure_count"] = 1; * $PHORUM["mod_foo"]["login_failures"][$_SERVER["REMOTE_ADDR"]]["timestamp"] = $curr_time; * } else { * // Log the timestamp and IP address of a login failure * $PHORUM["mod_foo"]["login_failures"][$_SERVER["REMOTE_ADDR"]]["login_failure_count"] = 1; * $PHORUM["mod_foo"]["login_failures"][$_SERVER["REMOTE_ADDR"]]["timestamp"] = $curr_time; * } * phorum_db_update_settings(array("mod_foo" => $PHORUM["mod_foo"])); * } * </hookcode> */ if (isset($PHORUM["hooks"]["failed_login"])) { phorum_hook("failed_login", array("username" => $_POST["username"], "password" => $_POST["password"], "location" => "forum")); } } } } elseif ($PHORUM["use_cookies"] > PHORUM_NO_COOKIES) { setcookie("phorum_tmp_cookie", "this will be destroyed once logged in", 0, $PHORUM["session_path"], $PHORUM["session_domain"]); } // Determine to what URL the user must be redirected after login. if (!empty($PHORUM["args"]["redir"])) { $redir = htmlspecialchars(urldecode($PHORUM["args"]["redir"]), ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]); } elseif (!empty($_REQUEST["redir"])) { $redir = htmlspecialchars($_REQUEST["redir"], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]); } elseif (!empty($_SERVER["HTTP_REFERER"])) { $base = strtolower(phorum_get_url(PHORUM_BASE_URL)); $len = strlen($base); if (strtolower(substr($_SERVER["HTTP_REFERER"], 0, $len)) == $base) {
/** * Save the groups and group permissions for a user. * * @param integer $user_id * The user_id of the user for which to store the group permissions. * * @param array $groups * An array of groups and their permissions. The keys in this array are * group ids. The values are either group permission values or arrays * containing at least the key "user_status" (which has the group * permission as its value) in them. The group permission value must be * one of the PHORUM_USER_GROUP_* constants. */ function phorum_api_user_save_groups($user_id, $groups) { if (!empty($GLOBALS["PHORUM"]['cache_users'])) { phorum_cache_remove('user', $user_id); } $dbgroups = array(); foreach ($groups as $id => $perm) { if (is_array($perm) && isset($perm['user_status'])) { $perm = $perm['user_status']; } if ($perm != PHORUM_USER_GROUP_SUSPENDED && $perm != PHORUM_USER_GROUP_UNAPPROVED && $perm != PHORUM_USER_GROUP_APPROVED && $perm != PHORUM_USER_GROUP_MODERATOR) { trigger_error('phorum_api_user_save_groups(): Illegal group permission for ' . 'group id ' . htmlspecialchars($id) . ': ' . htmlspecialchars($perm), E_USER_ERROR); return NULL; } $dbgroups[$id] = $perm; } /** * [hook] * user_save_groups * * [description] * This hook can be used to handle the groups data that is going to be * stored in the database for a user. Modules can do some last * minute change on the data or keep some external system in sync * with the Phorum user data. * * [category] * User data handling * * [when] * Just before the groups for a user are stored in the database. * * [input] * An array containing user_id and groups-data as another array. * * [output] * 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_user_save_groups($data) * { * list($user_id,$groups) = $data; * foreach($groups as $group_id => $group_permission) { * // do something with the groups permissions * } * * return array($user_id,$groups); * } * </hookcode> */ if (isset($GLOBALS['PHORUM']['hooks']['user_save_groups'])) { list($user_id, $dbgroups) = phorum_hook('user_save_groups', array($user_id, $dbgroups)); } return phorum_db_user_save_groups($user_id, $dbgroups); }
/** * A common function which is used to save the userdata from the post-data. * @param panel - The panel for which to save data. * @return array - An array containing $error and $okmsg. */ function phorum_controlcenter_user_save($panel) { $PHORUM = $GLOBALS['PHORUM']; $error = ""; $okmsg = ""; // Setup the default userdata fields that may be changed // from the control panel interface. $userdata = array( 'signature' => NULL, 'hide_email' => NULL, 'hide_activity' => NULL, 'password' => NULL, 'tz_offset' => NULL, 'is_dst' => NULL, 'user_language' => NULL, 'threaded_list' => NULL, 'threaded_read' => NULL, 'email_notify' => NULL, 'show_signature' => NULL, 'pm_email_notify' => NULL, 'email' => NULL, 'email_temp' => NULL, 'user_template' => NULL, 'moderation_email'=> NULL, ); // Add custom profile fields as acceptable fields. foreach ($PHORUM["PROFILE_FIELDS"] as $field) { $userdata[$field["name"]] = NULL; } // Update userdata with $_POST information. foreach ($_POST as $key => $val) { if (array_key_exists($key, $userdata)) { $userdata[$key] = $val; } } // Remove unused profile fields. foreach ($userdata as $key => $val) { if (is_null($val)) { unset($userdata[$key]); } } // Set static userdata. $userdata["user_id"] = $PHORUM["user"]["user_id"]; $userdata["fk_campsite_user_id"] = $PHORUM["user"]["fk_campsite_user_id"]; // Run a hook, so module writers can update and check the userdata. $userdata = phorum_hook("cc_save_user", $userdata); // Set $error, in case the before_register hook did set an error. if (isset($userdata['error'])) { $error=$userdata['error']; unset($userdata['error']); // Try to update the userdata in the database. } elseif (!phorum_user_save($userdata)) { // Updating the user failed. $error = $PHORUM["DATA"]["LANG"]["ErrUserAddUpdate"]; } else { // Sync the campsite user require_once('../../admin-files/localizer/Localizer.php'); require_once('../../classes/User.php'); $campsiteUser = new User($userdata["fk_campsite_user_id"]); if ($campsiteUser->exists()) { if (array_key_exists('password', $userdata)) { $campsiteUser->setPassword($userdata["password"]); } elseif (array_key_exists('email', $userdata)) { $campsiteUser->setProperty('EMail', $userdata["email"]); } } // Updating the user was successful. $okmsg = $PHORUM["DATA"]["LANG"]["ProfileUpdatedOk"]; // Let the userdata be reloaded. phorum_user_set_current_user($userdata["user_id"]); // If a new password was set, let's create a new session. if (isset($userdata["password"]) && !empty($userdata["password"])) { phorum_user_create_session(); } // Copy data from the updated user back into the template data. // Leave PANEL and forum_id alone (these are injected into the // userdata in the template from this script). foreach ($GLOBALS["PHORUM"]["DATA"]["PROFILE"] as $key => $val) { if ($key == "PANEL" || $key == "forum_id") continue; if (isset($GLOBALS["PHORUM"]["user"][$key])) { $GLOBALS["PHORUM"]["DATA"]["PROFILE"][$key] = $GLOBALS["PHORUM"]["user"][$key]; } else { $GLOBALS["PHORUM"]["DATA"]["PROFILE"][$key] = ""; } } } return array($error, $okmsg); }
/** * function for sending email to users, gets addresses-array and data-array */ function phorum_email_user($addresses, $data) { $PHORUM = $GLOBALS['PHORUM']; $mailmessage = $data['mailmessage']; unset($data['mailmessage']); $mailsubject = $data['mailsubject']; unset($data['mailsubject']); if(is_array($data) && count($data)) { foreach(array_keys($data) as $key){ $mailmessage = str_replace("%$key%", $data[$key], $mailmessage); $mailsubject = str_replace("%$key%", $data[$key], $mailsubject); } } $num_addresses = count($addresses); $from_address = "\"".$PHORUM['system_email_from_name']."\" <".$PHORUM['system_email_from_address'].">"; $hook_data = array( 'addresses' => $addresses, 'from' => $from_address, 'subject' => $mailsubject, 'body' => $mailmessage, 'bcc' => $PHORUM['use_bcc'] ); $send_messages = phorum_hook("send_mail", $hook_data); if(isset($data["msgid"])){ $msgid="\nMessage-ID: {$data['msgid']}"; } else { $msgid=""; } if($send_messages != 0 && $num_addresses > 0){ $phorum_major_version = substr(PHORUM, 0, strpos(PHORUM, '.')); $mailer = "Phorum" . $phorum_major_version; $mailheader ="Content-Type: text/plain; charset={$PHORUM["DATA"]["CHARSET"]}\nContent-Transfer-Encoding: {$PHORUM["DATA"]["MAILENCODING"]}\nX-Mailer: $mailer$msgid\n"; if(isset($PHORUM['use_bcc']) && $PHORUM['use_bcc'] && $num_addresses > 3){ mail(" ", $mailsubject, $mailmessage, $mailheader."From: $from_address\nBCC: " . implode(",", $addresses)); } else { foreach($addresses as $address){ mail($address, $mailsubject, $mailmessage, $mailheader."From: $from_address"); } } } return $num_addresses; }
} elseif ($PHORUM["show_new_on_index"] == 2) { $forum["new_message_check"] = $new_checks[$forum["forum_id"]]; } } } $forums_shown = true; if ($forum["folder_flag"]) { $PHORUM["DATA"]["FOLDERS"][] = $forum; } else { $PHORUM["DATA"]["FORUMS"][] = $forum; } } if (!$forums_shown) { // we did not show any forums here, show an error-message // set all our URL's phorum_build_common_urls(); unset($PHORUM["DATA"]["URL"]["TOP"]); $PHORUM["DATA"]["OKMSG"] = $PHORUM["DATA"]["LANG"]["NoForums"]; phorum_output("message"); } else { if (isset($PHORUM["hooks"]["index"])) { $PHORUM["DATA"]["FORUMS"] = phorum_hook("index", $PHORUM["DATA"]["FORUMS"]); } // set all our URL's phorum_build_common_urls(); // should we show the top-link? if ($PHORUM['forum_id'] == 0 || $PHORUM['vroot'] == $PHORUM['forum_id']) { unset($PHORUM["DATA"]["URL"]["INDEX"]); } phorum_output("index_classic"); }
} } if ($vroot == $forum_id) { $vroot = 1; } else { $foreign_vroot = $vroot; $vroot = 0; } } else { $frm->hidden("module", "newfolder"); $title = "Add A Folder"; $folders = $folder_data; $vroot = 0; $active = 1; $template = $PHORUM["default_forum_options"]["template"]; } $frm->hidden("folder_flag", "1"); $frm->addbreak($title); $frm->addrow("Folder Title", $frm->text_box("name", $name, 30)); $frm->addrow("Folder Description", $frm->textarea("description", $description, $cols = 60, $rows = 10, "style=\"width: 100%;\""), "top"); $frm->addrow("Folder", $frm->select_tag("parent_id", $folders, $parent_id)); $frm->addrow("Visible", $frm->select_tag("active", array("No", "Yes"), $active)); $frm->addbreak("Display Settings"); $frm->addrow("Template", $frm->select_tag("template", phorum_get_template_info(), $template)); $frm->addrow("Language", $frm->select_tag("language", phorum_get_language_info(), $language)); $frm->addrow("Virtual Root for descending forums/folders", $frm->checkbox("vroot", "1", "enabled", $vroot ? 1 : 0)); if ($foreign_vroot > 0) { $frm->addrow("This folder is in the Virtual Root of:", $folders[$foreign_vroot]); } phorum_hook("admin_editfolder_form", $frm, $forum_settings); $frm->show();
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; }
$file["name"], $file["size"], $file["data"], 0, PHORUM_LINK_EDITOR ); // Create new attachment information. $new_attachment = array( "file_id" => $file_id, "name" => $file["name"], "size" => $file["size"], "keep" => true, "linked" => false, ); // Run the after_attach hook. list($message, $new_attachment) = phorum_hook("after_attach", array($message, $new_attachment)); // Add the attachment to the message. $message['attachments'][] = $new_attachment; $attach_totalsize += $new_attachment["size"]; $attach_count++; $attached++; } // Show a generic error message if nothing was attached and // no specific message was set. if (! $error_flag && ! $attached) { $PHORUM["DATA"]["ERROR"] = $PHORUM["DATA"]["LANG"]["AttachmentsMissing"]; $error_flag = true; }
// This program is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY, without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // // // // You should have received a copy of the Phorum License // // along with this program. // //////////////////////////////////////////////////////////////////////////////// if (!defined("PHORUM")) { return; } $previewmessage = $message; // Add the message author's signature to the message body. if (isset($message["user_id"]) && !empty($message["user_id"])) { $user = phorum_api_user_get($message["user_id"]); if (isset($PHORUM["hooks"]["read_user_info"])) { $user_info = phorum_hook("read_user_info", array($user["user_id"] => $user)); $user = array_shift($user_info); } if ($user && $message["show_signature"]) { $previewmessage["body"] .= "\n\n" . $user["signature"]; } } // Add the list of attachments. if ($attach_count) { define('PREVIEW_NO_ATTACHMENT_CLICK', "javascript:alert('" . $PHORUM["DATA"]["LANG"]["PreviewNoClickAttach"] . "')"); // Create the URL and formatted size for attachment files. foreach ($previewmessage["attachments"] as $nr => $data) { $previewmessage["attachments"][$nr]["url"] = phorum_get_url(PHORUM_FILE_URL, "file={$data['file_id']}", "filename=" . urlencode($data['name'])); $previewmessage["attachments"][$nr]["download_url"] = phorum_get_url(PHORUM_FILE_URL, "file={$data['file_id']}", "filename=" . urlencode($data['name']), "download=1"); $previewmessage["attachments"][$nr]["size"] = phorum_filesize($data["size"]); $previewmessage["attachments"][$nr]["name"] = htmlspecialchars($data['name'], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]);
$messages[$key]["subject"] = $row["subject"] . " ({$row['viewcount']} {$PHORUM['DATA']['LANG']['Views']})"; } } $messages[$key]["URL"]["NEXT"] = $PHORUM["DATA"]["URL"]["NEWERTHREAD"]; if (empty($last_key)) { $messages[$key]["URL"]["PREV"] = $PHORUM["DATA"]["URL"]["OLDERTHREAD"]; } else { $messages[$key]["URL"]["PREV"] = str_replace(array('%thread_id%', '%message_id%'), array($row["thread"], $last_key), $read_url_template_both); $messages[$last_key]["URL"]["NEXT"] = str_replace(array('%thread_id%', '%message_id%'), array($row["thread"], $row["message_id"]), $read_url_template_both); } $last_key = $key; } } // run read mods if (isset($PHORUM["hooks"]["read"])) { $messages = phorum_hook("read", $messages); } // increment viewcount if enabled if ($PHORUM['count_views'] && (!isset($PHORUM['status']) || $PHORUM["status"] != PHORUM_MASTER_STATUS_READ_ONLY)) { // increment viewcount per thread if enabled $inc_thread_id = NULL; if (!empty($PHORUM['count_views_per_thread'])) { $inc_thread_id = $thread; } phorum_db_increment_viewcount($message_id, $inc_thread_id); } // format messages $messages = phorum_format_messages($messages); // set up the data // this is the message that is the first in the thread $PHORUM["DATA"]["TOPIC"] = $messages[$thread];
* * [description] * This hook is called whenever the feed has been sent to the client * (regardless of the cache setting). This can be used to add internal * server side tracking code. * * [category] * Feed * * [when] * Feed sent to the client * * [input] * None * * [output] * None * * [example] * <hookcode> * function phorum_mod_foo_feed_after () * { * # E.g. do server side tracking * @file_get_contents('your tracking service'); * } * </hookcode> */ phorum_hook('feed_sent'); // Exit here explicitly for not giving back control to portable and // embedded Phorum setups. exit(0);