本文整理汇总了PHP中smiley_text函数的典型用法代码示例。如果您正苦于以下问题:PHP smiley_text函数的具体用法?PHP smiley_text怎么用?PHP smiley_text使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了smiley_text函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: remove_markup
/**
* Strip BBCodes, tags and links from text
*
* @param string $message Message text
* @return string Cleaned message text
* @access protected
*/
protected function remove_markup($message)
{
$message = smiley_text($message, true);
// display smileys as text :)
$message = $this->strip_bbcode_contents($message);
static $patterns = array();
if (empty($patterns)) {
// RegEx patterns based on Topic Text Hover Mod by RMcGirr83
$patterns = array('#<!-- [lmw] --><a class="postlink[^>]*>(.*<\\/a[^>]*>)?<!-- [lmw] -->#Usi', '#<[^>]*>(.*<[^>]*>)?#Usi', '#\\[/?[^\\[\\]]+\\]#mi', '#(http|https|ftp|mailto)(:|\\&\\#58;)\\/\\/[^\\s]+#i', '#"#', '#[ \\t]{2,}#');
}
return trim(preg_replace($patterns, ' ', $message));
}
示例2: bbcode_strip
function bbcode_strip($text)
{
static $RegEx = array();
static $bbcode_strip = 'flash';
// Save the smileys - show them as text :)
$text = smiley_text($text, true);
$text = str_replace(' ... ', '', $text);
// remove ' ... ' from shortened urls so they can be stripped too
if (empty($RegEx)) {
$RegEx = array('#<[^>]*>(.*<[^>]*>)?#Usi', '#\\[(' . $bbcode_strip . ')[^\\[\\]]+\\].*\\[/(' . $bbcode_strip . ')[^\\[\\]]+\\]#Usi', '#\\[/?[^\\[\\]]+\\]#mi', '#(http|https|ftp|mailto)(:|\\&\\#58;)\\/\\/[^\\s]+#i', '#[\\s]+#');
}
return trim(preg_replace($RegEx, ' ', $text));
}
示例3: trim_text
/**
* Trim and clean text
*
* @param string $message Message text
* @param int $length The length to trim text to
*
* @return string Trimmed message text
*/
public function trim_text($message, $length)
{
// display smileys as text :)
$message = smiley_text($message, true);
/** @var tools\tool_interface $tool Run text through trim tools to strip out bbcodes and other markup */
foreach ($this->tools as $tool) {
$message = $tool->set_text($message)->run();
}
if (utf8_strlen($message) <= $length) {
return $this->tp_nl2br($message);
}
// trim the text to the last whitespace character before the cut-off
$message = preg_replace('/\\s+?(\\S+)?$/', '', utf8_substr($message, 0, $length));
return $this->tp_nl2br($message) . '...';
}
示例4: display_user_activity
if ($config['load_user_activity']) {
display_user_activity($member);
}
// Do the relevant calculations
$memberdays = max(1, round((time() - $member['user_regdate']) / 86400));
$posts_per_day = $member['user_posts'] / $memberdays;
$percentage = $config['num_posts'] ? min(100, $member['user_posts'] / $config['num_posts'] * 100) : 0;
if ($member['user_sig']) {
$member['user_sig'] = censor_text($member['user_sig']);
if ($member['user_sig_bbcode_bitfield']) {
include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx;
$bbcode = new bbcode();
$bbcode->bbcode_second_pass($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield']);
}
$member['user_sig'] = bbcode_nl2br($member['user_sig']);
$member['user_sig'] = smiley_text($member['user_sig']);
}
$poster_avatar = get_user_avatar($member['user_avatar'], $member['user_avatar_type'], $member['user_avatar_width'], $member['user_avatar_height']);
$template->assign_vars(show_profile($member));
// Custom Profile Fields
$profile_fields = array();
if ($config['load_cpf_viewprofile']) {
include_once $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx;
$cp = new custom_profile();
$profile_fields = $cp->generate_profile_fields_template('grab', $user_id);
$profile_fields = isset($profile_fields[$user_id]) ? $cp->generate_profile_fields_template('show', false, $profile_fields[$user_id]) : array();
}
// We need to check if the module 'zebra' is accessible
$zebra_enabled = false;
if ($user->data['user_id'] != $user_id && $user->data['is_registered']) {
include_once $phpbb_root_path . 'includes/functions_module.' . $phpEx;
示例5: get_forum_func
//.........这里部分代码省略.........
foreach ($forum_rows as $id => $value) {
if (!in_array($value['parent_id'], $fids)) {
unset($forum_rows[$id]);
} else {
if ($value['left_id'] > $value['right_id']) {
unset($forum_rows[$id]);
} else {
$fids[] = $id;
}
}
}
while (empty($forum_rows[$root_forum_id]['child']) && count($forum_rows) > 1) {
$current_parent_id = -1;
$leaves_forum = array();
foreach ($forum_rows as $row) {
$row_parent_id = $row['parent_id'];
if ($row_parent_id != $current_parent_id) {
if (isset($leaves_forum[$row_parent_id])) {
$leaves_forum[$row_parent_id] = array();
} else {
if (isset($leaves_forum[$forum_rows[$row_parent_id]['parent_id']])) {
$leaves_forum[$forum_rows[$row_parent_id]['parent_id']] = array();
}
$leaves_forum[$row_parent_id][] = $row['forum_id'];
}
$current_parent_id = $row_parent_id;
} else {
if ($row_parent_id == $current_parent_id) {
if (!empty($leaves_forum[$row_parent_id])) {
$leaves_forum[$row_parent_id][] = $row['forum_id'];
}
}
}
}
foreach ($leaves_forum as $node_forum_id => $leaves) {
foreach ($leaves as $forum_id) {
$forum =& $forum_rows[$forum_id];
if (function_exists('get_unread_topics')) {
$unread_count = count(get_unread_topics(false, "AND t.forum_id = {$forum_id}"));
} else {
$unread_count = count(tt_get_unread_topics(false, "AND t.forum_id = {$forum_id}"));
}
$forum['unread_count'] += $unread_count;
if ($forum['unread_count']) {
$forum_rows[$forum['parent_id']]['unread_count'] += $forum['unread_count'];
}
$forum_type = $forum['forum_link'] ? 'link' : ($forum['forum_type'] != FORUM_POST ? 'category' : 'forum');
if ($logo_icon_name = tp_get_forum_icon($forum_id, $forum_type, $forum['forum_status'], $forum['unread_count'])) {
$logo_url = $phpbb_home . $config['tapatalkdir'] . '/forum_icons/' . $logo_icon_name;
} else {
if ($forum['forum_image']) {
if (preg_match('#^https?://#i', $forum['forum_image'])) {
$logo_url = $forum['forum_image'];
} else {
$logo_url = $phpbb_home . $forum['forum_image'];
}
} else {
$logo_url = '';
}
}
$xmlrpc_forum = array('forum_id' => new xmlrpcval($forum_id), 'forum_name' => new xmlrpcval(basic_clean($forum['forum_name']), 'base64'), 'parent_id' => new xmlrpcval($node_forum_id), 'logo_url' => new xmlrpcval($logo_url), 'url' => new xmlrpcval($forum['forum_link']));
if ($forum['unread_count']) {
$xmlrpc_forum['unread_count'] = new xmlrpcval($forum['unread_count'], 'int');
}
if ($forum['unread_count']) {
$xmlrpc_forum['new_post'] = new xmlrpcval(true, 'boolean');
}
if ($forum['forum_password']) {
$xmlrpc_forum['is_protected'] = new xmlrpcval(true, 'boolean');
}
if (!empty($forum['can_subscribe'])) {
$xmlrpc_forum['can_subscribe'] = new xmlrpcval(true, 'boolean');
} else {
$xmlrpc_forum['can_subscribe'] = new xmlrpcval(false, 'boolean');
}
if (!empty($forum['is_subscribed'])) {
$xmlrpc_forum['is_subscribed'] = new xmlrpcval(true, 'boolean');
} else {
$xmlrpc_forum['is_subscribed'] = new xmlrpcval(false, 'boolean');
}
if ($forum['forum_type'] != FORUM_POST) {
$xmlrpc_forum['sub_only'] = new xmlrpcval(true, 'boolean');
}
if ($return_description) {
$description = smiley_text($forum['forum_desc'], true);
$description = generate_text_for_display($description, $forum['forum_desc_uid'], $forum['forum_desc_bitfield'], $forum['forum_desc_options']);
$description = preg_replace('/<br *?\\/?>/i', "\n", $description);
$xmlrpc_forum['description'] = new xmlrpcval(basic_clean($description), 'base64');
}
if (isset($forum['child'])) {
$xmlrpc_forum['child'] = new xmlrpcval($forum['child'], 'array');
}
$forum_rows[$node_forum_id]['child'][] = new xmlrpcval($xmlrpc_forum, 'struct');
unset($forum_rows[$forum_id]);
}
}
}
$response = new xmlrpcval($forum_rows[$root_forum_id]['child'], 'array');
return new xmlrpcresp($response);
}
示例6: main
function main($id, $mode)
{
global $auth, $db, $user, $template, $cache;
global $config, $phpbb_root_path, $phpEx, $action;
include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx;
$forum_id = request_var('f', 0);
$start = request_var('start', 0);
$this->page_title = 'MCP_REPORTS';
switch ($action) {
case 'close':
case 'delete':
include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
$report_id_list = request_var('report_id_list', array(0));
if (!sizeof($report_id_list)) {
trigger_error('NO_REPORT_SELECTED');
}
close_report($report_id_list, $mode, $action);
break;
}
switch ($mode) {
case 'report_details':
$user->add_lang(array('posting', 'viewforum', 'viewtopic'));
$post_id = request_var('p', 0);
// closed reports are accessed by report id
$report_id = request_var('r', 0);
$sql = 'SELECT r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour
FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . ' u
WHERE ' . ($report_id ? 'r.report_id = ' . $report_id : "r.post_id = {$post_id}") . '
AND rr.reason_id = r.reason_id
AND r.user_id = u.user_id
AND r.pm_id = 0
ORDER BY report_closed ASC';
$result = $db->sql_query_limit($sql, 1);
$report = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$report) {
trigger_error('NO_REPORT');
}
if (!$report_id && $report['report_closed']) {
trigger_error('REPORT_CLOSED');
}
$post_id = $report['post_id'];
$report_id = $report['report_id'];
$post_info = get_post_data(array($post_id), 'm_report', true);
if (!sizeof($post_info)) {
trigger_error('NO_REPORT_SELECTED');
}
$post_info = $post_info[$post_id];
$reason = array('title' => $report['reason_title'], 'description' => $report['reason_description']);
if (isset($user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])])) {
$reason['description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])];
$reason['title'] = $user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])];
}
if (topic_review($post_info['topic_id'], $post_info['forum_id'], 'topic_review', 0, false)) {
$template->assign_vars(array('S_TOPIC_REVIEW' => true, 'S_BBCODE_ALLOWED' => $post_info['enable_bbcode'], 'TOPIC_TITLE' => $post_info['topic_title']));
}
$topic_tracking_info = $extensions = $attachments = array();
// Get topic tracking info
if ($config['load_db_lastread']) {
$tmp_topic_data = array($post_info['topic_id'] => $post_info);
$topic_tracking_info = get_topic_tracking($post_info['forum_id'], $post_info['topic_id'], $tmp_topic_data, array($post_info['forum_id'] => $post_info['forum_mark_time']));
unset($tmp_topic_data);
} else {
$topic_tracking_info = get_complete_topic_tracking($post_info['forum_id'], $post_info['topic_id']);
}
$post_unread = isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']] ? true : false;
// Process message, leave it uncensored
$message = $post_info['post_text'];
if ($post_info['bbcode_bitfield']) {
include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx;
$bbcode = new bbcode($post_info['bbcode_bitfield']);
$bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']);
}
$message = bbcode_nl2br($message);
$message = smiley_text($message);
if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) {
$sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . '
WHERE post_msg_id = ' . $post_id . '
AND in_message = 0
ORDER BY filetime DESC';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$attachments[] = $row;
}
$db->sql_freeresult($result);
if (sizeof($attachments)) {
$update_count = array();
parse_attachments($post_info['forum_id'], $message, $attachments, $update_count);
}
// Display not already displayed Attachments for this post, we already parsed them. ;)
if (!empty($attachments)) {
$template->assign_var('S_HAS_ATTACHMENTS', true);
foreach ($attachments as $attachment) {
$template->assign_block_vars('attachment', array('DISPLAY_ATTACHMENT' => $attachment));
}
}
}
$template->assign_vars(array('S_MCP_REPORT' => true, 'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'], 'S_POST_UNAPPROVED' => !$post_info['post_approved'], 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_USER_NOTES' => true, 'U_EDIT' => $auth->acl_get('m_edit', $post_info['forum_id']) ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '', 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_REPORTER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&u=' . $report['user_id']), 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&u=' . $post_info['user_id']), 'U_MCP_WARN_REPORTER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&mode=warn_user&u=' . $report['user_id']) : '', 'U_MCP_WARN_USER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&mode=warn_user&u=' . $post_info['user_id']) : '', 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $post_info['forum_id']), 'U_VIEW_POST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']), 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']), 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']), 'MINI_POST_IMG' => $post_unread ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']), 'RETURN_REPORTS' => sprintf($user->lang['RETURN_REPORTS'], '<a href="' . append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports' . ($post_info['post_reported'] ? '&mode=reports' : '&mode=reports_closed') . '&start=' . $start . '&f=' . $post_info['forum_id']) . '">', '</a>'), 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']), 'REPORT_DATE' => $user->format_date($report['report_time']), 'REPORT_ID' => $report_id, 'REPORT_REASON_TITLE' => $reason['title'], 'REPORT_REASON_DESCRIPTION' => $reason['description'], 'REPORT_TEXT' => $report['report_text'], 'POST_AUTHOR_FULL' => get_username_string('full', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR' => get_username_string('username', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'REPORTER_FULL' => get_username_string('full', $report['user_id'], $report['username'], $report['user_colour']), 'REPORTER_COLOUR' => get_username_string('colour', $report['user_id'], $report['username'], $report['user_colour']), 'REPORTER_NAME' => get_username_string('username', $report['user_id'], $report['username'], $report['user_colour']), 'U_VIEW_REPORTER_PROFILE' => get_username_string('profile', $report['user_id'], $report['username'], $report['user_colour']), 'POST_PREVIEW' => $message, 'POST_SUBJECT' => $post_info['post_subject'] ? $post_info['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_DATE' => $user->format_date($post_info['post_time']), 'POST_IP' => $post_info['poster_ip'], 'POST_IPADDR' => $auth->acl_get('m_info', $post_info['forum_id']) && request_var('lookup', '') ? @gethostbyaddr($post_info['poster_ip']) : '', 'POST_ID' => $post_info['post_id'], 'U_LOOKUP_IP' => $auth->acl_get('m_info', $post_info['forum_id']) ? $this->u_action . '&r=' . $report_id . '&p=' . $post_id . '&f=' . $forum_id . '&lookup=' . $post_info['poster_ip'] . '#ip' : ''));
$this->tpl_name = 'mcp_post';
//.........这里部分代码省略.........
示例7: mcp_warn_post_view
/**
* Handles warning the user when the warning is for a specific post
*/
function mcp_warn_post_view($action)
{
global $phpEx, $phpbb_root_path, $config;
global $template, $db, $user, $auth;
$post_id = request_var('p', 0);
$forum_id = request_var('f', 0);
$notify = (isset($_REQUEST['notify_user'])) ? true : false;
$warning = utf8_normalize_nfc(request_var('warning', '', true));
$sql = 'SELECT u.*, p.*
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u
WHERE post_id = $post_id
AND u.user_id = p.poster_id";
$result = $db->sql_query($sql);
$user_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$user_row)
{
trigger_error('NO_POST');
}
// There is no point issuing a warning to ignored users (ie anonymous and bots)
if ($user_row['user_type'] == USER_IGNORE)
{
trigger_error('CANNOT_WARN_ANONYMOUS');
}
// Prevent someone from warning themselves
if ($user_row['user_id'] == $user->data['user_id'])
{
trigger_error('CANNOT_WARN_SELF');
}
// Check if there is already a warning for this post to prevent multiple
// warnings for the same offence
$sql = 'SELECT post_id
FROM ' . WARNINGS_TABLE . "
WHERE post_id = $post_id";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
trigger_error('ALREADY_WARNED');
}
$user_id = $user_row['user_id'];
if (strpos($this->u_action, "&f=$forum_id&p=$post_id") === false)
{
$this->p_master->adjust_url("&f=$forum_id&p=$post_id");
$this->u_action .= "&f=$forum_id&p=$post_id";
}
if ($warning && $action == 'add_warning')
{
if (check_form_key('mcp_warn'))
{
add_warning($user_row, $warning, $notify, $post_id);
$msg = $user->lang['USER_WARNING_ADDED'];
}
else
{
$msg = $user->lang['FORM_INVALID'];
}
$redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&mode=user_notes&u=$user_id");
meta_refresh(2, $redirect);
trigger_error($user->lang['USER_WARNING_ADDED'] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
}
// OK, they didn't submit a warning so lets build the page for them to do so
// We want to make the message available here as a reminder
// Parse the message and subject
$message = censor_text($user_row['post_text']);
// Second parse bbcode here
if ($user_row['bbcode_bitfield'])
{
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
$bbcode = new bbcode($user_row['bbcode_bitfield']);
$bbcode->bbcode_second_pass($message, $user_row['bbcode_uid'], $user_row['bbcode_bitfield']);
}
$message = bbcode_nl2br($message);
$message = smiley_text($message);
// Generate the appropriate user information for the user we are looking at
if (!function_exists('get_user_avatar'))
{
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
}
//.........这里部分代码省略.........
示例8: get_context
if ($row['display_text_only'])
{
// now find context for the searched words
$row['post_text'] = get_context($row['post_text'], array_filter(explode('|', $hilit), 'strlen'), $return_chars);
$row['post_text'] = bbcode_nl2br($row['post_text']);
}
else
{
// Second parse bbcode here
if ($row['bbcode_bitfield'])
{
$bbcode->bbcode_second_pass($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield']);
}
$row['post_text'] = bbcode_nl2br($row['post_text']);
$row['post_text'] = smiley_text($row['post_text']);
if (!empty($attachments[$row['post_id']]))
{
parse_attachments($forum_id, $row['post_text'], $attachments[$row['post_id']], $update_count);
// we only display inline attachments
unset($attachments[$row['post_id']]);
}
}
if ($hilit)
{
// post highlighting
$row['post_text'] = preg_replace('#(?!<.*)(?<!\w)(' . $hilit . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">$1</span>', $row['post_text']);
$row['post_subject'] = preg_replace('#(?!<.*)(?<!\w)(' . $hilit . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">$1</span>', $row['post_subject']);
示例9: generate_text_for_display
/**
* For display of custom parsed text on user-facing pages
* Expects $text to be the value directly from the database (stored value)
*/
function generate_text_for_display($text, $uid, $bitfield, $flags, $censor_text = true)
{
static $bbcode;
global $phpbb_dispatcher;
if ($text === '') {
return '';
}
/**
* Use this event to modify the text before it is parsed
*
* @event core.modify_text_for_display_before
* @var string text The text to parse
* @var string uid The BBCode UID
* @var string bitfield The BBCode Bitfield
* @var int flags The BBCode Flags
* @var bool censor_text Whether or not to apply word censors
* @since 3.1.0-a1
*/
$vars = array('text', 'uid', 'bitfield', 'flags', 'censor_text');
extract($phpbb_dispatcher->trigger_event('core.modify_text_for_display_before', compact($vars)));
if ($censor_text) {
$text = censor_text($text);
}
// Parse bbcode if bbcode uid stored and bbcode enabled
if ($uid && $flags & OPTION_FLAG_BBCODE) {
if (!class_exists('bbcode')) {
global $phpbb_root_path, $phpEx;
include $phpbb_root_path . 'includes/bbcode.' . $phpEx;
}
if (empty($bbcode)) {
$bbcode = new bbcode($bitfield);
} else {
$bbcode->bbcode($bitfield);
}
$bbcode->bbcode_second_pass($text, $uid);
}
$text = bbcode_nl2br($text);
$text = smiley_text($text, !($flags & OPTION_FLAG_SMILIES));
/**
* Use this event to modify the text after it is parsed
*
* @event core.modify_text_for_display_after
* @var string text The text to parse
* @var string uid The BBCode UID
* @var string bitfield The BBCode Bitfield
* @var int flags The BBCode Flags
* @since 3.1.0-a1
*/
$vars = array('text', 'uid', 'bitfield', 'flags');
extract($phpbb_dispatcher->trigger_event('core.modify_text_for_display_after', compact($vars)));
return $text;
}
示例10: main
function main($id, $mode)
{
global $auth, $db, $user, $template;
global $config, $phpbb_root_path, $phpEx, $action;
include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx;
$forum_id = request_var('f', 0);
$start = request_var('start', 0);
$this->page_title = 'MCP_QUEUE';
switch ($action) {
case 'approve':
case 'disapprove':
include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
$post_id_list = request_var('post_id_list', array(0));
if (!sizeof($post_id_list)) {
trigger_error('NO_POST_SELECTED');
}
if ($action == 'approve') {
approve_post($post_id_list, $mode);
} else {
disapprove_post($post_id_list, $mode);
}
break;
}
switch ($mode) {
case 'approve_details':
$user->add_lang('posting');
$post_id = request_var('p', 0);
$topic_id = request_var('t', 0);
if ($topic_id) {
$topic_info = get_topic_data(array($topic_id), 'm_approve');
if (isset($topic_info[$topic_id]['topic_first_post_id'])) {
$post_id = (int) $topic_info[$topic_id]['topic_first_post_id'];
} else {
$topic_id = 0;
}
}
$post_info = get_post_data(array($post_id), 'm_approve');
if (!sizeof($post_info)) {
trigger_error('NO_POST_SELECTED');
}
$post_info = $post_info[$post_id];
if ($post_info['topic_first_post_id'] != $post_id && topic_review($post_info['topic_id'], $post_info['forum_id'], 'topic_review', 0, false)) {
$template->assign_vars(array('S_TOPIC_REVIEW' => true, 'TOPIC_TITLE' => $post_info['topic_title']));
}
// Set some vars
if ($post_info['user_id'] == ANONYMOUS) {
$poster = $post_info['post_username'] ? $post_info['post_username'] : $user->lang['GUEST'];
}
$poster = $post_info['user_colour'] ? '<span style="color:#' . $post_info['user_colour'] . '">' . $post_info['username'] . '</span>' : $post_info['username'];
// Process message, leave it uncensored
$message = $post_info['post_text'];
if ($post_info['bbcode_bitfield']) {
include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx;
$bbcode = new bbcode($post_info['bbcode_bitfield']);
$bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']);
}
$message = smiley_text($message);
$template->assign_vars(array('S_MCP_QUEUE' => true, 'S_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=queue&p={$post_id}&f={$forum_id}"), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'], 'S_POST_UNAPPROVED' => !$post_info['post_approved'], 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_USER_NOTES' => true, 'U_EDIT' => $auth->acl_get('m_edit', $post_info['forum_id']) ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '', 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&u=' . $post_info['user_id']), 'U_MCP_WARN_USER' => $auth->acl_getf_global('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&mode=warn_user&u=' . $post_info['user_id']) : '', 'U_VIEW_PROFILE' => $post_info['user_id'] != ANONYMOUS ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=viewprofile&u=' . $post_info['user_id']) : '', 'RETURN_QUEUE' => sprintf($user->lang['RETURN_QUEUE'], '<a href="' . append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue' . ($topic_id ? '&mode=unapproved_topics' : '&mode=unapproved_posts')) . "&start={$start}\">", '</a>'), 'REPORTED_IMG' => $user->img('icon_reported', $user->lang['POST_REPORTED']), 'UNAPPROVED_IMG' => $user->img('icon_unapproved', $user->lang['POST_UNAPPROVED']), 'EDIT_IMG' => $user->img('btn_edit', $user->lang['EDIT_POST']), 'POSTER_NAME' => $poster, 'POST_PREVIEW' => $message, 'POST_SUBJECT' => $post_info['post_subject'], 'POST_DATE' => $user->format_date($post_info['post_time']), 'POST_IP' => $post_info['poster_ip'], 'POST_IPADDR' => @gethostbyaddr($post_info['poster_ip']), 'POST_ID' => $post_info['post_id']));
$this->tpl_name = 'mcp_post';
break;
case 'unapproved_topics':
case 'unapproved_posts':
$topic_id = request_var('t', 0);
$forum_info = array();
if ($topic_id) {
$topic_info = get_topic_data(array($topic_id));
if (!sizeof($topic_info)) {
trigger_error($user->lang['TOPIC_NOT_EXIST']);
}
$topic_info = $topic_info[$topic_id];
$forum_id = $topic_info['forum_id'];
}
$forum_list_approve = get_forum_list('m_approve', false, true);
if (!$forum_id) {
$forum_list = array();
foreach ($forum_list_approve as $row) {
$forum_list[] = $row['forum_id'];
}
if (!($forum_list = implode(', ', $forum_list))) {
trigger_error('NOT_MODERATOR');
}
$sql = 'SELECT SUM(forum_topics) as sum_forum_topics
FROM ' . FORUMS_TABLE . "\n\t\t\t\t\t\tWHERE forum_id IN (0, {$forum_list})";
$result = $db->sql_query($sql);
$forum_info['forum_topics'] = (int) $db->sql_fetchfield('sum_forum_topics');
$db->sql_freeresult($result);
$global_id = $forum_list[0];
} else {
$forum_info = get_forum_data(array($forum_id), 'm_approve');
if (!sizeof($forum_info)) {
trigger_error('NOT_MODERATOR');
}
$forum_info = $forum_info[$forum_id];
$forum_list = $forum_id;
$global_id = $forum_id;
}
$forum_options = '<option value="0"' . ($forum_id == 0 ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>';
foreach ($forum_list_approve as $row) {
$forum_options .= '<option value="' . $row['forum_id'] . '"' . ($forum_id == $row['forum_id'] ? ' selected="selected"' : '') . '>' . $row['forum_name'] . '</option>';
}
//.........这里部分代码省略.........
示例11: censor_text
{
$power = $row['karma_action'] . $row['karma_power'];
}
$poster_id = $row['poster_id'];
$comment = censor_text($row['comment_text']);
// Parse bbcode
if ($row['bbcode_bitfield'])
{
$bbcode = new bbcode(base64_encode($row['bbcode_bitfield']));
$bbcode->bbcode_second_pass($comment, $row['bbcode_uid'], $row['bbcode_bitfield']);
}
$comment = bbcode_nl2br($comment);
$comment = smiley_text($comment, !$config['allow_smilies']);
if ($karmamod->user_level != 'admin' && (($karmamod->config['anonym_increase'] && $row['karma_action'] == '+') || ($karmamod->config['anonym_decrease'] && $row['karma_action'] == '-')))
{
$author_full = $user->lang['KARMA_NOTIFY_HIDDEN_SENDER'];
$author_colour = $user->lang['KARMA_NOTIFY_HIDDEN_SENDER'];
$author = $user->lang['KARMA_NOTIFY_HIDDEN_SENDER'];
$u_author = '';
}
else
{
$author_full = get_username_string('full', $poster_id, $row['username'], $row['user_colour']);
$author_colour = get_username_string('colour', $poster_id, $row['username'], $row['user_colour']);
$author = get_username_string('username', $poster_id, $row['username'], $row['user_colour']);
$u_author = get_username_string('profile', $poster_id, $row['username'], $row['user_colour']);
}
示例12: topic_review
function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id = 0, $show_quote_button = true)
{
global $_CLASS, $bbcode, $config;
// Go ahead and pull all data for this topic
$sql = 'SELECT u.username, u.user_id, p.post_id, p.post_username, p.post_subject, p.post_text, p.enable_smilies, p.bbcode_uid, p.bbcode_bitfield, p.post_time
FROM ' . FORUMS_POSTS_TABLE . ' p, ' . USERS_TABLE . " u\n\t\tWHERE p.topic_id = {$topic_id}\n\t\t\tAND p.poster_id = u.user_id\n\t\t\t" . (!$_CLASS['auth']->acl_get('m_approve', $forum_id) ? 'AND p.post_approved = 1' : '') . '
' . ($mode == 'post_review' ? " AND p.post_id > {$cur_post_id}" : '') . '
ORDER BY p.post_time DESC';
$result = $_CLASS['core_db']->query_limit($sql, $config['posts_per_page']);
if (!($row = $_CLASS['core_db']->fetch_row_assoc($result))) {
return false;
}
$bbcode_bitfield = 0;
do {
$rowset[] = $row;
$bbcode_bitfield |= $row['bbcode_bitfield'];
} while ($row = $_CLASS['core_db']->fetch_row_assoc($result));
$_CLASS['core_db']->free_result($result);
// Instantiate BBCode class
if (!isset($bbcode) && $bbcode_bitfield) {
require_once SITE_FILE_ROOT . 'includes/forums/bbcode.php';
$bbcode = new bbcode($bbcode_bitfield);
}
foreach ($rowset as $i => $row) {
$poster_id = $row['user_id'];
$poster = $row['username'];
// Handle anon users posting with usernames
if ($poster_id == ANONYMOUS && $row['post_username']) {
$poster = $row['post_username'];
$poster_rank = $_CLASS['core_user']->lang['GUEST'];
}
$post_subject = $row['post_subject'];
$message = $row['post_text'];
if ($row['bbcode_bitfield']) {
$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
}
$message = smiley_text($message, !$row['enable_smilies']);
$post_subject = censor_text($post_subject);
$message = censor_text($message);
$_CLASS['core_template']->assign_vars_array($mode . '_row', array('POSTER_NAME' => $poster, 'POST_SUBJECT' => $post_subject, 'MINI_POST_IMG' => $_CLASS['core_user']->img('icon_post', $_CLASS['core_user']->lang['POST']), 'POST_DATE' => $_CLASS['core_user']->format_date($row['post_time']), 'MESSAGE' => str_replace("\n", '<br />', $message), 'U_POST_ID' => $row['post_id'], 'U_MINI_POST' => generate_link('Forums&file=viewtopic&p=' . $row['post_id'] . '#' . $row['post_id']), 'U_MCP_DETAILS' => $_CLASS['auth']->acl_get('m_', $forum_id) ? generate_link('Forums&file=mcp&mode=post_details&p=' . $row['post_id']) : '', 'U_QUOTE' => $show_quote_button && $_CLASS['auth']->acl_get('f_quote', $forum_id) ? 'javascript:addquote(' . $row['post_id'] . ", '" . str_replace("'", "\\'", $poster) . "')" : ''));
unset($rowset[$i]);
}
if ($mode == 'topic_review') {
$_CLASS['core_template']->assign('QUOTE_IMG', $_CLASS['core_user']->img('btn_quote', $_CLASS['core_user']->lang['REPLY_WITH_QUOTE']));
}
return true;
}
示例13: announcement_post
/**
* prepares the preview announcement text
*/
function announcement_post($where_sql, $order, $gotopost)
{
global $db, $auth, $user, $template;
global $phpbb_root_path, $phpEx, $config;
if (!class_exists('bbcode')) {
include $phpbb_root_path . 'includes/bbcode.' . $phpEx;
}
$bbcode_bitfield = '';
$sql = 'SELECT *
FROM ' . POSTS_TABLE . " \n\t\t\t{$where_sql}\n\t\tORDER BY post_id {$order}";
$result = $db->sql_query_limit($sql, 1, 0);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row['post_attachment']) {
$sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('post_msg_id', $row['post_id']) . '
AND in_message = 0
ORDER BY filetime DESC, post_msg_id ASC';
$result = $db->sql_query($sql);
while ($row2 = $db->sql_fetchrow($result)) {
$attachments[$row2['post_msg_id']][] = $row2;
}
$db->sql_freeresult($result);
}
// Parse the message and subject
$message = censor_text($row['post_text']);
// Define the global bbcode bitfield, will be used to load bbcodes
$bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);
// Instantiate BBCode if need be
if ($bbcode_bitfield !== '') {
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
}
// Second parse bbcode here
//if ($row['bbcode_bitfield'])
//{
if (!function_exists('Markdown')) {
global $phpbb_root_path, $phpEx;
include $phpbb_root_path . 'includes/markdown.' . $phpEx;
}
$message = Markdown($message);
//$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
//}
//$message = bbcode_nl2br($message);
$message = smiley_text($message);
if (!empty($attachments[$row['post_id']])) {
parse_attachments($row['forum_id'], $message, $attachments[$row['post_id']], $update_count);
}
// Display not already displayed Attachments for this post, we already parsed them. ;)
if (!empty($attachments[$row['post_id']])) {
foreach ($attachments[$row['post_id']] as $attachment) {
$template->assign_block_vars('announcement_attachments', array('DISPLAY_ATTACHMENTS' => $attachment));
}
}
// Assign index specific vars
$template->assign_vars(array('S_HASATTACHMENTS' => !empty($attachments[$row['post_id']]) ? true : false, 'U_ANNOUNCEMENT_GOTOPOST' => $gotopost ? append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'p=' . $row['post_id']) . '#p' . $row['post_id'] : ''));
return $message;
}
示例14: mcp_queue
function mcp_queue($id, $mode, $url)
{
global $_CLASS, $site_file_root, $config;
$forum_id = request_var('f', 0);
$start = request_var('start', 0);
switch ($mode) {
case 'approve':
case 'disapprove':
require_once $site_file_root . 'includes/forums/functions_messenger.php';
require_once $site_file_root . 'includes/forums/functions_posting.php';
$post_id_list = request_var('post_id_list', array(0));
if (!sizeof($post_id_list)) {
trigger_error('NO_POST_SELECTED');
}
if ($mode == 'approve') {
approve_post($post_id_list);
} else {
disapprove_post($post_id_list);
}
break;
case 'approve_details':
$_CLASS['core_user']->add_lang('posting');
require_once $site_file_root . 'includes/forums/functions_posting.php';
$post_id = request_var('p', 0);
$topic_id = request_var('t', 0);
if ($topic_id) {
$topic_info = get_topic_data(array($topic_id), 'm_approve');
$post_id = (int) $topic_info[$topic_id]['topic_first_post_id'];
}
$post_info = get_post_data(array($post_id), 'm_approve');
if (!sizeof($post_info)) {
trigger_error('NO_POST_SELECTED');
}
$post_info = $post_info[$post_id];
if ($post_info['topic_first_post_id'] != $post_id && topic_review($post_info['topic_id'], $post_info['forum_id'], 'topic_review', 0, false)) {
$_CLASS['core_template']->assign_array(array('S_TOPIC_REVIEW' => true, 'TOPIC_TITLE' => $post_info['topic_title']));
}
// Set some vars
$poster = $post_info['user_colour'] ? '<span style="color:#' . $post_info['user_colour'] . '">' . $post_info['username'] . '</span>' : $post_info['username'];
// Process message, leave it uncensored
$message = $post_info['post_text'];
if ($post_info['bbcode_bitfield']) {
require_once $site_file_root . 'includes/forums/bbcode.php';
$bbcode = new bbcode($post_info['bbcode_bitfield']);
$bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']);
}
$message = smiley_text($message);
$_CLASS['core_template']->assign_array(array('S_MCP_QUEUE' => true, 'S_APPROVE_ACTION' => generate_link("Forums&file=mcp&i=queue&p={$post_id}&f={$forum_id}"), 'S_CAN_VIEWIP' => $_CLASS['auth']->acl_get('m_ip', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'], 'S_POST_UNAPPROVED' => !$post_info['post_approved'], 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_USER_WARNINGS' => $post_info['user_warnings'] ? true : false, 'U_VIEW_PROFILE' => generate_link('Members_List&mode=viewprofile&u=' . $post_info['user_id']), 'U_MCP_USERNOTES' => generate_link('Forums&file=mcp&i=notes&mode=user_notes&u=' . $post_info['user_id']), 'U_MCP_WARNINGS' => generate_link('Forums&file=mcp&i=warnings&mode=view_user&u=' . $post_info['user_id']), 'U_EDIT' => $_CLASS['auth']->acl_get('m_edit', $post_info['forum_id']) ? generate_link("Forums&file=posting&mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '', 'REPORTED_IMG' => $_CLASS['core_user']->img('icon_reported', $_CLASS['core_user']->lang['POST_REPORTED']), 'UNAPPROVED_IMG' => $_CLASS['core_user']->img('icon_unapproved', $_CLASS['core_user']->lang['POST_UNAPPROVED']), 'EDIT_IMG' => $_CLASS['core_user']->img('btn_edit', $_CLASS['core_user']->lang['EDIT_POST']), 'POSTER_NAME' => $poster, 'POST_PREVIEW' => $message, 'POST_SUBJECT' => $post_info['post_subject'], 'POST_DATE' => $_CLASS['core_user']->format_date($post_info['post_time']), 'POST_IP' => $post_info['poster_ip'], 'POST_IPADDR' => @gethostbyaddr($post_info['poster_ip']), 'POST_ID' => $post_info['post_id']));
$this->display($_CLASS['core_user']->lang['MCP_QUEUE'], 'mcp_post.html');
break;
case 'unapproved_topics':
case 'unapproved_posts':
$forum_info = array();
$forum_list_approve = get_forum_list('m_approve', false, true);
if (!$forum_id) {
$forum_list = array();
foreach ($forum_list_approve as $row) {
$forum_list[] = $row['forum_id'];
}
if (!($forum_list = implode(', ', $forum_list))) {
trigger_error('NOT_MODERATOR');
}
$sql = 'SELECT SUM(forum_topics) as sum_forum_topics
FROM ' . FORUMS_FORUMS_TABLE . "\n\t\t\t\t\t\tWHERE forum_id IN ({$forum_list})";
$result = $_CLASS['core_db']->query($sql);
$row = $_CLASS['core_db']->fetch_row_assoc($result);
$_CLASS['core_db']->free_result($result);
$forum_info['forum_topics'] = (int) $row['sum_forum_topics'];
} else {
$forum_info = get_forum_data(array($forum_id), 'm_approve');
if (!sizeof($forum_info)) {
trigger_error('NOT_MODERATOR');
}
$forum_info = $forum_info[$forum_id];
$forum_list = $forum_id;
}
$forum_options = '<option value="0"' . ($forum_id == 0 ? ' selected="selected"' : '') . '>' . $_CLASS['core_user']->lang['ALL_FORUMS'] . '</option>';
foreach ($forum_list_approve as $row) {
$forum_options .= '<option value="' . $row['forum_id'] . '"' . ($forum_id == $row['forum_id'] ? ' selected="selected"' : '') . '>' . $row['forum_name'] . '</option>';
}
mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id);
$forum_topics = $total == -1 ? $forum_info['forum_topics'] : $total;
$limit_time_sql = $sort_days ? 'AND t.topic_last_post_time >= ' . (time() - $sort_days * 86400) : '';
if ($mode == 'unapproved_posts') {
$sql = 'SELECT p.post_id
FROM ' . FORUMS_POSTS_TABLE . ' p, ' . FORUMS_TOPICS_TABLE . ' t' . ($sort_order_sql[0] == 'u' ? ', ' . USERS_TABLE . ' u' : '') . "\n\t\t\t\t\t\tWHERE p.forum_id IN ({$forum_list})\n\t\t\t\t\t\t\tAND p.post_approved = 0\n\t\t\t\t\t\t\t" . ($sort_order_sql[0] == 'u' ? 'AND u.user_id = p.poster_id' : '') . "\n\t\t\t\t\t\t\tAND t.topic_id = p.topic_id\n\t\t\t\t\t\t\tAND t.topic_first_post_id <> p.post_id\n\t\t\t\t\t\tORDER BY {$sort_order_sql}";
$result = $_CLASS['core_db']->query_limit($sql, $config['topics_per_page'], $start);
$i = 0;
$post_ids = array();
while ($row = $_CLASS['core_db']->fetch_row_assoc($result)) {
$post_ids[] = $row['post_id'];
$row_num[$row['post_id']] = $i++;
}
if (sizeof($post_ids)) {
$sql = 'SELECT f.forum_id, f.forum_name, t.topic_id, t.topic_title, p.post_id, p.post_username, p.poster_id, p.post_time, u.username
FROM ' . FORUMS_POSTS_TABLE . ' p, ' . FORUMS_FORUMS_TABLE . ' f, ' . FORUMS_TOPICS_TABLE . ' t, ' . USERS_TABLE . " u\n\t\t\t\t\t\t\tWHERE p.post_id IN (" . implode(', ', $post_ids) . ")\n\t\t\t\t\t\t\t\tAND t.topic_id = p.topic_id\n\t\t\t\t\t\t\t\tAND f.forum_id = p.forum_id\n\t\t\t\t\t\t\t\tAND u.user_id = p.poster_id";
$result = $_CLASS['core_db']->query($sql);
$post_data = $rowset = array();
while ($row = $_CLASS['core_db']->fetch_row_assoc($result)) {
$post_data[$row['post_id']] = $row;
//.........这里部分代码省略.........
示例15: save_raw_post_func
//.........这里部分代码省略.........
trigger_error('NOT_AUTHORISED');
}
$forum_id = $to_forum_id;
}
}
}
// Lock/Unlock Topic
$change_topic_status = $post_data['topic_status'];
$perm_lock_unlock = $auth->acl_get('m_lock', $forum_id) || $auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED ? true : false;
if ($post_data['topic_status'] == ITEM_LOCKED && !$topic_lock && $perm_lock_unlock) {
$change_topic_status = ITEM_UNLOCKED;
} else {
if ($post_data['topic_status'] == ITEM_UNLOCKED && $topic_lock && $perm_lock_unlock) {
$change_topic_status = ITEM_LOCKED;
}
}
if ($change_topic_status != $post_data['topic_status']) {
$sql = 'UPDATE ' . TOPICS_TABLE . "\r\r\n SET topic_status = {$change_topic_status}\r\r\n WHERE topic_id = {$topic_id}\r\r\n AND topic_moved_id = 0";
$db->sql_query($sql);
$user_lock = $auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $post_data['topic_poster'] ? 'USER_' : '';
add_log('mod', $forum_id, $topic_id, 'LOG_' . $user_lock . ($change_topic_status == ITEM_LOCKED ? 'LOCK' : 'UNLOCK'), $post_data['topic_title']);
}
// Lock/Unlock Post Edit
if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_LOCKED && !$post_lock && $auth->acl_get('m_edit', $forum_id)) {
$post_data['post_edit_locked'] = ITEM_UNLOCKED;
} else {
if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_UNLOCKED && $post_lock && $auth->acl_get('m_edit', $forum_id)) {
$post_data['post_edit_locked'] = ITEM_LOCKED;
}
}
$data = array('topic_title' => empty($post_data['topic_title']) ? $post_data['post_subject'] : $post_data['topic_title'], 'topic_first_post_id' => isset($post_data['topic_first_post_id']) ? (int) $post_data['topic_first_post_id'] : 0, 'topic_last_post_id' => isset($post_data['topic_last_post_id']) ? (int) $post_data['topic_last_post_id'] : 0, 'topic_time_limit' => (int) $post_data['topic_time_limit'], 'topic_attachment' => isset($post_data['topic_attachment']) ? (int) $post_data['topic_attachment'] : 0, 'post_id' => (int) $post_id, 'topic_id' => (int) $topic_id, 'forum_id' => (int) $forum_id, 'icon_id' => (int) $post_data['icon_id'], 'poster_id' => (int) $post_data['poster_id'], 'enable_sig' => (bool) $post_data['enable_sig'], 'enable_bbcode' => (bool) $post_data['enable_bbcode'], 'enable_smilies' => (bool) $post_data['enable_smilies'], 'enable_urls' => (bool) $post_data['enable_urls'], 'enable_indexing' => (bool) $post_data['enable_indexing'], 'message_md5' => (string) $message_md5, 'post_time' => isset($post_data['post_time']) ? (int) $post_data['post_time'] : time(), 'post_checksum' => isset($post_data['post_checksum']) ? (string) $post_data['post_checksum'] : '', 'post_edit_reason' => $post_data['post_edit_reason'], 'post_edit_user' => $mode == 'edit' ? $user->data['user_id'] : (isset($post_data['post_edit_user']) ? (int) $post_data['post_edit_user'] : 0), 'forum_parents' => $post_data['forum_parents'], 'forum_name' => $post_data['forum_name'], 'notify' => $notify, 'poster_ip' => isset($post_data['poster_ip']) ? $post_data['poster_ip'] : $user->ip, 'post_edit_locked' => (int) $post_data['post_edit_locked'], 'bbcode_bitfield' => $message_parser->bbcode_bitfield, 'bbcode_uid' => $message_parser->bbcode_uid, 'message' => $message_parser->message, 'attachment_data' => $message_parser->attachment_data, 'filename_data' => $message_parser->filename_data, 'topic_approved' => isset($post_data['topic_approved']) ? $post_data['topic_approved'] : false, 'post_approved' => isset($post_data['post_approved']) ? $post_data['post_approved'] : false);
$data['topic_replies_real'] = $post_data['topic_replies_real'];
$data['topic_replies'] = $post_data['topic_replies'];
include $phpbb_root_path . 'includes/functions_posting.' . $phpEx;
$cwd = getcwd();
chdir('../');
$redirect_url = submit_post($mode, $post_data['post_subject'], $post_data['username'], $post_data['topic_type'], $poll, $data, $update_message);
chdir($cwd);
// Check the permissions for post approval, as well as the queue trigger where users are put on approval with a post count lower than specified. Moderators are not affected.
$approved = true;
if (($config['enable_queue_trigger'] && $user->data['user_posts'] < $config['queue_trigger_posts'] || !$auth->acl_get('f_noapprove', $data['forum_id'])) && !$auth->acl_get('m_approve', $data['forum_id'])) {
$approved = false;
}
$reply_success = false;
$post_id = '';
if ($redirect_url) {
preg_match('/&p=(\\d+)/', $redirect_url, $matches);
$post_id = $matches[1];
$reply_success = true;
// get new post_content
$message = censor_text($data['message']);
$quote_wrote_string = $user->lang['WROTE'];
$message = str_replace('[/quote:' . $data['bbcode_uid'] . ']', '[/quote]', $message);
$message = preg_replace('/\\[quote(?:="(.*?)")?:' . $data['bbcode_uid'] . '\\]/ise', "'[quote]' . ('\$1' ? '\$1' . ' {$quote_wrote_string}:\n' : '\n')", $message);
$blocks = preg_split('/(\\[\\/?quote\\])/i', $message, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
$quote_level = 0;
$message = '';
foreach ($blocks as $block) {
if ($block == '[quote]') {
if ($quote_level == 0) {
$message .= $block;
}
$quote_level++;
} else {
if ($block == '[/quote]') {
if ($quote_level <= 1) {
$message .= $block;
}
if ($quote_level >= 1) {
$quote_level--;
}
} else {
if ($quote_level <= 1) {
$message .= $block;
}
}
}
}
$message = preg_replace('/\\[(youtube|video|googlevideo|gvideo):' . $data['bbcode_uid'] . '\\](.*?)\\[\\/\\1:' . $data['bbcode_uid'] . '\\]/sie', "video_bbcode_format('\$1', '\$2')", $message);
$message = preg_replace('/\\[(BBvideo)[\\d, ]+:' . $row['bbcode_uid'] . '\\](.*?)\\[\\/\\1:' . $row['bbcode_uid'] . '\\]/si', "[url=\$2]YouTube Video[/url]", $message);
$message = preg_replace('/\\[(spoil|spoiler):' . $row['bbcode_uid'] . '\\](.*?)\\[\\/\\1:' . $row['bbcode_uid'] . '\\]/si', "[spoiler]\$2[/spoiler]", $message);
$message = preg_replace('/\\[b:' . $data['bbcode_uid'] . '\\](.*?)\\[\\/b:' . $data['bbcode_uid'] . '\\]/si', '[b]$1[/b]', $message);
$message = preg_replace('/\\[i:' . $data['bbcode_uid'] . '\\](.*?)\\[\\/i:' . $data['bbcode_uid'] . '\\]/si', '[i]$1[/i]', $message);
$message = preg_replace('/\\[u:' . $data['bbcode_uid'] . '\\](.*?)\\[\\/u:' . $data['bbcode_uid'] . '\\]/si', '[u]$1[/u]', $message);
$message = preg_replace('/\\[color=#(\\w{6}):' . $data['bbcode_uid'] . '\\](.*?)\\[\\/color:' . $data['bbcode_uid'] . '\\]/si', '[color=#$1]$2[/color]', $message);
// Second parse bbcode here
if ($data['bbcode_bitfield']) {
$bbcode = new bbcode(base64_encode($data['bbcode_bitfield']));
$bbcode->bbcode_second_pass($message, $data['bbcode_uid'], $data['bbcode_bitfield']);
}
$message = bbcode_nl2br($message);
$message = smiley_text($message);
if (!empty($data['attachment_data'])) {
parse_attachments($forum_id, $message, $data['attachment_data'], $update_count);
}
$updated_post_title = html_entity_decode(strip_tags(censor_text($data['topic_title'])), ENT_QUOTES, 'UTF-8');
}
$xmlrpc_reply_topic = new xmlrpcval(array('result' => new xmlrpcval($reply_success, 'boolean'), 'state' => new xmlrpcval($approved ? 0 : 1, 'int'), 'post_title' => new xmlrpcval($updated_post_title, 'base64'), 'post_content' => new xmlrpcval(post_html_clean($message), 'base64')), 'struct');
return new xmlrpcresp($xmlrpc_reply_topic);
}