本文整理汇总了PHP中parse_message类的典型用法代码示例。如果您正苦于以下问题:PHP parse_message类的具体用法?PHP parse_message怎么用?PHP parse_message使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了parse_message类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: viewtopic_modify_data
/**
* Show bbcodes and smilies in the quickreply
* Template data for Ajax submit
*
* @param object $event The event object
* @return null
* @access public
*/
public function viewtopic_modify_data($event)
{
$forum_id = $event['forum_id'];
$topic_data = $event['topic_data'];
$post_list = $event['post_list'];
$topic_id = $topic_data['topic_id'];
$s_quick_reply = false;
if (($this->user->data['is_registered'] || $this->config['qr_allow_for_guests']) && $this->config['allow_quick_reply'] && $topic_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY && $this->auth->acl_get('f_reply', $forum_id)) {
// Quick reply enabled forum
$s_quick_reply = $topic_data['forum_status'] == ITEM_UNLOCKED && $topic_data['topic_status'] == ITEM_UNLOCKED || $this->auth->acl_get('m_edit', $forum_id) ? true : false;
}
if (!$this->user->data['is_registered'] && $s_quick_reply) {
add_form_key('posting');
$s_attach_sig = $this->config['allow_sig'] && $this->user->optionget('attachsig') && $this->auth->acl_get('f_sigs', $forum_id) && $this->auth->acl_get('u_sig');
$s_smilies = $this->config['allow_smilies'] && $this->user->optionget('smilies') && $this->auth->acl_get('f_smilies', $forum_id);
$s_bbcode = $this->config['allow_bbcode'] && $this->user->optionget('bbcode') && $this->auth->acl_get('f_bbcode', $forum_id);
$s_notify = false;
$qr_hidden_fields = array('topic_cur_post_id' => (int) $topic_data['topic_last_post_id'], 'lastclick' => (int) time(), 'topic_id' => (int) $topic_data['topic_id'], 'forum_id' => (int) $forum_id);
// Originally we use checkboxes and check with isset(), so we only provide them if they would be checked
!$s_bbcode ? $qr_hidden_fields['disable_bbcode'] = 1 : true;
!$s_smilies ? $qr_hidden_fields['disable_smilies'] = 1 : true;
!$this->config['allow_post_links'] ? $qr_hidden_fields['disable_magic_url'] = 1 : true;
$s_attach_sig ? $qr_hidden_fields['attach_sig'] = 1 : true;
$s_notify ? $qr_hidden_fields['notify'] = 1 : true;
$topic_data['topic_status'] == ITEM_LOCKED ? $qr_hidden_fields['lock_topic'] = 1 : true;
$this->template->assign_vars(array('S_QUICK_REPLY' => true, 'U_QR_ACTION' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", "mode=reply&f={$forum_id}&t={$topic_id}"), 'QR_HIDDEN_FIELDS' => build_hidden_fields($qr_hidden_fields), 'USERNAME' => $this->request->variable('username', '', true)));
if ($this->config['enable_post_confirm']) {
$captcha = $this->captcha->get_instance($this->config['captcha_plugin']);
$captcha->init(CONFIRM_POST);
}
if ($this->config['enable_post_confirm'] && (isset($captcha) && $captcha->is_solved() === false)) {
$this->template->assign_vars(array('S_CONFIRM_CODE' => true, 'CAPTCHA_TEMPLATE' => $captcha->get_template()));
}
// Add the confirm id/code pair to the hidden fields, else an error is displayed on next submit/preview
if (isset($captcha) && $captcha->is_solved() !== false) {
$this->template->append_var('QR_HIDDEN_FIELDS', build_hidden_fields($captcha->get_hidden_fields()));
}
}
// Ajaxify viewtopic data
if ($this->request->is_ajax() && $this->request->is_set('qr_request')) {
if (!$this->user->data['is_registered'] && $this->config['enable_post_confirm']) {
$captcha = $this->captcha->get_instance($this->config['captcha_plugin']);
$captcha->init(CONFIRM_POST);
// Add the confirm id/code pair to the hidden fields, else an error is displayed on next submit/preview
if (isset($captcha) && $captcha->is_solved() !== false) {
$this->template->append_var('QR_HIDDEN_FIELDS', build_hidden_fields($captcha->get_hidden_fields()));
}
}
// Fix issues if the inserted post is not the first.
if ($this->qr_insert && !$this->qr_first) {
$this->template->alter_block_array('postrow', array('S_FIRST_ROW' => false), false, 'change');
}
$page_title = $event['page_title'];
$this->template->assign_vars(array('S_QUICKREPLY_REQUEST' => true, 'S_QR_NO_FIRST_POST' => $this->qr_insert, 'S_QR_FULL_QUOTE' => $this->config['qr_full_quote']));
$this->template->append_var('QR_HIDDEN_FIELDS', build_hidden_fields(array('qr' => 1, 'qr_cur_post_id' => (int) max($post_list))));
// Output the page
page_header($page_title, false, $forum_id);
page_footer(false, false, false);
$json_response = new \phpbb\json_response();
$json_response->send(array('success' => true, 'result' => $this->template->assign_display('@tatiana5_quickreply/quickreply_template.html', '', true), 'insert' => $this->qr_insert));
}
if ($s_quick_reply) {
include_once $this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext;
// HTML, BBCode, Smilies, Images and Flash status
$bbcode_status = $this->config['allow_bbcode'] && $this->config['qr_bbcode'] && $this->auth->acl_get('f_bbcode', $forum_id) ? true : false;
$smilies_status = $this->config['allow_smilies'] && $this->config['qr_smilies'] && $this->auth->acl_get('f_smilies', $forum_id) ? true : false;
$img_status = $bbcode_status && $this->auth->acl_get('f_img', $forum_id) ? true : false;
$url_status = $this->config['allow_post_links'] ? true : false;
$flash_status = $bbcode_status && $this->auth->acl_get('f_flash', $forum_id) && $this->config['allow_post_flash'] ? true : false;
$quote_status = true;
// Build custom bbcodes array
if ($bbcode_status) {
display_custom_bbcodes();
}
// Generate smiley listing
if ($smilies_status) {
generate_smilies('inline', $forum_id);
}
// Show attachment box for adding attachments if true
$form_enctype = @ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !$this->config['allow_attachments'] || !$this->auth->acl_get('u_attach') || !$this->auth->acl_get('f_attach', $forum_id) ? '' : '" enctype="multipart/form-data';
$allowed = $this->auth->acl_get('f_attach', $forum_id) && $this->auth->acl_get('u_attach') && $this->config['allow_attachments'] && $form_enctype;
$attachment_data = false;
if ($bbcode_status || $smilies_status || $this->config['qr_attach'] && $allowed) {
$this->user->add_lang('posting');
}
if ($this->config['qr_attach'] && $allowed) {
$this->template->assign_vars(array('U_QR_ACTION' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", "mode=reply&f={$forum_id}&t={$topic_id}") . $form_enctype));
include_once $this->phpbb_root_path . 'includes/message_parser.' . $this->php_ext;
$message_parser = new \parse_message();
$message_parser->set_plupload($this->plupload);
$message_parser->set_mimetype_guesser($this->mimetype_guesser);
$message_parser->get_submitted_attachment_data($this->user->data['user_id']);
//.........这里部分代码省略.........
示例2: upload_image
/**
* Insert the image into the database
*/
public static function upload_image(&$image_data, $album_id)
{
global $user, $db;
$sql_ary = array('image_filename' => $image_data['filename'], 'image_name' => $image_data['image_name'], 'image_name_clean' => utf8_clean_string($image_data['image_name']), 'image_user_id' => $user->data['user_id'], 'image_user_colour' => $user->data['user_colour'], 'image_username' => $image_data['username'], 'image_username_clean' => utf8_clean_string($image_data['username']), 'image_user_ip' => $user->ip, 'image_time' => $image_data['image_time'], 'image_album_id' => $image_data['image_album_id'], 'image_status' => phpbb_gallery::$auth->acl_check('i_approve', $album_id) ? phpbb_gallery_image::STATUS_APPROVED : phpbb_gallery_image::STATUS_UNAPPROVED, 'filesize_upload' => $image_data['image_filesize'], 'image_contest' => $image_data['image_contest'], 'image_exif_data' => $image_data['image_exif_data'], 'image_has_exif' => $image_data['image_has_exif']);
$message_parser = new parse_message();
$message_parser->message = utf8_normalize_nfc($image_data['image_desc']);
if ($message_parser->message) {
$message_parser->parse(true, true, true, true, false, true, true, true);
$sql_ary['image_desc'] = $message_parser->message;
$sql_ary['image_desc_uid'] = $message_parser->bbcode_uid;
$sql_ary['image_desc_bitfield'] = $message_parser->bbcode_bitfield;
} else {
$sql_ary['image_desc'] = '';
$sql_ary['image_desc_uid'] = '';
$sql_ary['image_desc_bitfield'] = '';
}
$sql = 'INSERT INTO ' . GALLERY_IMAGES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
$image_id = $db->sql_nextid();
if (phpbb_gallery::$user->get_data('watch_own')) {
$sql_ary = array('image_id' => $image_id, 'user_id' => $user->data['user_id']);
$sql = 'INSERT INTO ' . GALLERY_WATCH_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
}
return array('image_id' => $image_id, 'image_name' => $image_data['image_name']);
}
示例3: test_parse_poll
/**
* @dataProvider get_test_polls
*/
public function test_parse_poll($poll, $expected, $warn_msg = array())
{
$this->prepare_s9e_services();
$message_parser = new parse_message('Me[i]s[/i]sage');
// Add some default values
$poll += array('poll_length' => 123, 'poll_start' => 123, 'poll_last_vote' => 123, 'poll_vote_change' => true, 'enable_bbcode' => true, 'enable_urls' => true, 'enable_smilies' => true, 'img_status' => true);
$message_parser->parse_poll($poll);
$this->assertSame($expected, array_intersect_key($poll, $expected));
$this->assertSame('<r>Me<I><s>[i]</s>s<e>[/i]</e></I>sage</r>', $message_parser->parse(true, true, true, true, true, true, true, false));
$this->assertSame($warn_msg, $message_parser->warn_msg);
}
示例4: parse_message
/**
* Parse BBCode in a message
*
* @param string $message Message to parse
* @return string Parsed message
*/
public function parse_message($message)
{
if (empty($this->bbcode_data)) {
return '';
}
if (!is_object($this->message_parser)) {
if (!class_exists('\\bbcode')) {
require $this->phpbb_root_path . 'includes/bbcode.' . $this->php_ext;
}
if (!class_exists('\\parse_message')) {
require $this->phpbb_root_path . 'includes/message_parser.' . $this->php_ext;
}
$this->message_parser = new \parse_message();
}
$this->message_parser->parse_message($message);
$this->bbcode_data['regexp'] = array($this->bbcode_data['first_pass_match'] => str_replace('$uid', $this->message_parser->bbcode_uid, $this->bbcode_data['first_pass_replace']));
$this->message_parser->bbcodes = array($this->bbcode_data['bbcode_tag'] => $this->bbcode_data);
$this->message_parser->parse_bbcode();
return $this->message_parser->message;
}
示例5: parse_message
// Topic data
'topic_poster' => $row['bug_reporter'],
'topic_replies_real' => null,
'topic_first_post_id' => null,
'topic_last_post_id' => null,
// Post data
'post_id' => null,
'poster_id' => $row['bug_reporter'],
'post_time' => $row['bug_time'],
'post_edit_reason' => null,
'post_edit_locked' => 0,
);
// Parse text
$message_parser = new parse_message();
$message_parser->message = $report_data['report_desc'];
$message_parser->parse(true, $report_data['enable_magic_url'], $report_data['enable_smilies'], true, true, true, true);
// Just to make sure (easier development; although not every database (or table) engine support it )
$db->sql_transaction('begin');
// Insert into (our own) bug database (if adding: without the topic id for the time being)
$sql_ary = array(
'project_id' => $report_data['project_id'],
'report_id' => $report_data['report_id'], // Only here
'report_title' => $report_data['report_title'],
'report_desc' => $message_parser->message,
'report_component' => $report_data['report_component'],
'report_version' => $report_data['report_version'],
'report_status' => $report_data['report_status'],
示例6: main
//.........这里部分代码省略.........
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
$rank_id = request_var('user_rank', 0);
$sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\t\t\t\tSET user_rank = {$rank_id}\n\t\t\t\t\t\tWHERE user_id = {$user_id}";
$db->sql_query($sql);
trigger_error($user->lang['USER_RANK_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id));
}
$sql = 'SELECT *
FROM ' . RANKS_TABLE . '
WHERE rank_special = 1
ORDER BY rank_title';
$result = $db->sql_query($sql);
$s_rank_options = '<option value="0"' . (!$user_row['user_rank'] ? ' selected="selected"' : '') . '>' . $user->lang['NO_SPECIAL_RANK'] . '</option>';
while ($row = $db->sql_fetchrow($result)) {
$selected = $user_row['user_rank'] && $row['rank_id'] == $user_row['user_rank'] ? ' selected="selected"' : '';
$s_rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>';
}
$db->sql_freeresult($result);
$template->assign_vars(array('S_RANK' => true, 'S_RANK_OPTIONS' => $s_rank_options));
break;
case 'sig':
include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx;
include_once $phpbb_root_path . 'includes/functions_display.' . $phpEx;
$enable_bbcode = $config['allow_sig_bbcode'] ? (bool) $this->optionget($user_row, 'sig_bbcode') : false;
$enable_smilies = $config['allow_sig_smilies'] ? (bool) $this->optionget($user_row, 'sig_smilies') : false;
$enable_urls = $config['allow_sig_links'] ? (bool) $this->optionget($user_row, 'sig_links') : false;
$signature = utf8_normalize_nfc(request_var('signature', (string) $user_row['user_sig'], true));
$preview = isset($_POST['preview']) ? true : false;
if ($submit || $preview) {
include_once $phpbb_root_path . 'includes/message_parser.' . $phpEx;
$enable_bbcode = $config['allow_sig_bbcode'] ? request_var('disable_bbcode', false) ? false : true : false;
$enable_smilies = $config['allow_sig_smilies'] ? request_var('disable_smilies', false) ? false : true : false;
$enable_urls = $config['allow_sig_links'] ? request_var('disable_magic_url', false) ? false : true : false;
$message_parser = new parse_message($signature);
// Allowing Quote BBCode
$message_parser->parse($enable_bbcode, $enable_urls, $enable_smilies, $config['allow_sig_img'], $config['allow_sig_flash'], true, $config['allow_sig_links'], true, 'sig');
if (sizeof($message_parser->warn_msg)) {
$error[] = implode('<br />', $message_parser->warn_msg);
}
if (!check_form_key($form_name)) {
$error = 'FORM_INVALID';
}
if (!sizeof($error) && $submit) {
$this->optionset($user_row, 'sig_bbcode', $enable_bbcode);
$this->optionset($user_row, 'sig_smilies', $enable_smilies);
$this->optionset($user_row, 'sig_links', $enable_urls);
$sql_ary = array('user_sig' => (string) $message_parser->message, 'user_options' => $user_row['user_options'], 'user_sig_bbcode_uid' => (string) $message_parser->bbcode_uid, 'user_sig_bbcode_bitfield' => (string) $message_parser->bbcode_bitfield);
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . $user_id;
$db->sql_query($sql);
trigger_error($user->lang['USER_SIG_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id));
}
// Replace "error" strings with their real, localised form
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
}
$signature_preview = '';
if ($preview) {
// Now parse it for displaying
$signature_preview = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false);
unset($message_parser);
}
decode_message($signature, $user_row['user_sig_bbcode_uid']);
$template->assign_vars(array('S_SIGNATURE' => true, 'SIGNATURE' => $signature, 'SIGNATURE_PREVIEW' => $signature_preview, 'S_BBCODE_CHECKED' => !$enable_bbcode ? ' checked="checked"' : '', 'S_SMILIES_CHECKED' => !$enable_smilies ? ' checked="checked"' : '', 'S_MAGIC_URL_CHECKED' => !$enable_urls ? ' checked="checked"' : '', 'BBCODE_STATUS' => $config['allow_sig_bbcode'] ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$phpbb_root_path}faq.{$phpEx}", 'mode=bbcode') . '">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$phpbb_root_path}faq.{$phpEx}", 'mode=bbcode') . '">', '</a>'), 'SMILIES_STATUS' => $config['allow_sig_smilies'] ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], 'IMG_STATUS' => $config['allow_sig_img'] ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => $config['allow_sig_flash'] ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], 'URL_STATUS' => $config['allow_sig_links'] ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], 'L_SIGNATURE_EXPLAIN' => sprintf($user->lang['SIGNATURE_EXPLAIN'], $config['max_sig_chars']), 'S_BBCODE_ALLOWED' => $config['allow_sig_bbcode'], 'S_SMILIES_ALLOWED' => $config['allow_sig_smilies'], 'S_BBCODE_IMG' => $config['allow_sig_img'] ? true : false, 'S_BBCODE_FLASH' => $config['allow_sig_flash'] ? true : false, 'S_LINKS_ALLOWED' => $config['allow_sig_links'] ? true : false));
// Assigning custom bbcodes
display_custom_bbcodes();
示例7: send_pm
/**
* Sends user(s) notification via PM
*
*/
private function send_pm($to_id)
{
global $phpbb_root_path, $phpEx, $user;
if (!class_exists('parse_message')) {
include $phpbb_root_path . 'includes/message_parser.' . $phpEx;
}
if (!function_exists('submit_pm')) {
include $phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx;
}
// Setup the PM message parser.
$message_parser = new parse_message();
$message_parser->message = $this->message_text;
$message_parser->parse(true, true, true, true, true, true, true);
// setup the PM data...
$pm_data = array('from_user_id' => 2, 'from_username' => 'Site Notifications', 'address_list' => array('u' => array($to_id => 'to')), 'icon_id' => 0, 'from_user_ip' => $user->ip, 'enable_bbcode' => true, 'enable_smilies' => true, 'enable_urls' => true, 'enable_sig' => false, 'message' => $message_parser->message, 'bbcode_bitfield' => $message_parser->bbcode_bitfield, 'bbcode_uid' => $message_parser->bbcode_uid);
// Send the PM to the founders.
submit_pm('post', $this->message_title, $pm_data, false);
}
示例8: prepare_text_for_merge
public function prepare_text_for_merge(&$data)
{
// Create message parser instance
include_once $this->phpbb_root_path . 'includes/message_parser.' . $this->php_ext;
$message_parser = new \parse_message();
$text = isset($data['post_text']) ? $data['post_text'] : $data['message'];
$message_parser->message = $text;
// Decode message text properly
$message_parser->decode_message($data['bbcode_uid']);
$text = html_entity_decode($message_parser->message, ENT_COMPAT, 'UTF-8');
return $text;
}
示例9: add_warning
/**
* Insert the warning into the database
*/
function add_warning($user_row, $warning, $send_pm = true, $post_id = 0)
{
global $phpEx, $phpbb_root_path, $config;
global $template, $db, $user, $auth;
if ($send_pm)
{
include_once($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
include_once($phpbb_root_path . 'includes/message_parser.' . $phpEx);
$user_row['user_lang'] = (file_exists($phpbb_root_path . 'language/' . $user_row['user_lang'] . "/mcp.$phpEx")) ? $user_row['user_lang'] : $config['default_lang'];
include($phpbb_root_path . 'language/' . basename($user_row['user_lang']) . "/mcp.$phpEx");
$message_parser = new parse_message();
$message_parser->message = sprintf($lang['WARNING_PM_BODY'], $warning);
$message_parser->parse(true, true, true, false, false, true, true);
$pm_data = array(
'from_user_id' => $user->data['user_id'],
'from_user_ip' => $user->ip,
'from_username' => $user->data['username'],
'enable_sig' => false,
'enable_bbcode' => true,
'enable_smilies' => true,
'enable_urls' => false,
'icon_id' => 0,
'bbcode_bitfield' => $message_parser->bbcode_bitfield,
'bbcode_uid' => $message_parser->bbcode_uid,
'message' => $message_parser->message,
'address_list' => array('u' => array($user_row['user_id'] => 'to')),
);
submit_pm('post', $lang['WARNING_PM_SUBJECT'], $pm_data, false);
}
add_log('admin', 'LOG_USER_WARNING', $user_row['username']);
$log_id = add_log('user', $user_row['user_id'], 'LOG_USER_WARNING_BODY', $warning);
$sql_ary = array(
'user_id' => $user_row['user_id'],
'post_id' => $post_id,
'log_id' => $log_id,
'warning_time' => time(),
);
$db->sql_query('INSERT INTO ' . WARNINGS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_warnings = user_warnings + 1,
user_last_warning = ' . time() . '
WHERE user_id = ' . $user_row['user_id'];
$db->sql_query($sql);
// We add this to the mod log too for moderators to see that a specific user got warned.
$sql = 'SELECT forum_id, topic_id
FROM ' . POSTS_TABLE . '
WHERE post_id = ' . $post_id;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_USER_WARNING', $user_row['username']);
}
示例10: create_message_func
function create_message_func($xmlrpc_params)
{
global $db, $user, $auth, $config, $phpbb_root_path, $phpEx;
$user->setup('ucp');
include_once $phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx;
include_once $phpbb_root_path . 'includes/ucp/ucp_pm_compose.' . $phpEx;
if (!$user->data['is_registered']) {
trigger_error('LOGIN_EXPLAIN_UCP');
}
if (!$config['allow_privmsg']) {
trigger_error('Module not accessible');
}
// Flood check
$current_time = time();
$last_post_time = $user->data['user_lastpost_time'];
if ($last_post_time && $current_time - $last_post_time < intval($config['flood_interval'])) {
trigger_error('FLOOD_ERROR');
}
$params = php_xmlrpc_decode($xmlrpc_params);
if (!is_array($params[0]) || empty($params[0]) || !isset($params[1]) || utf8_clean_string($params[1]) === '' || !isset($params[2])) {
trigger_error('Required paramerter missing');
} else {
$user_name = $params[0];
$_REQUEST['subject'] = $params[1];
$_REQUEST['message'] = $params[2];
$subject = utf8_normalize_nfc(request_var('subject', '', true));
$text_body = utf8_normalize_nfc(request_var('message', '', true));
require_once 'include/emoji.php';
$text_body = emoji_unified_to_names($text_body);
}
$action = 'post';
// default action
if (isset($params[3])) {
if ($params[3] == 1) {
$action = 'reply';
$msg_id = intval($params[4]);
} else {
if ($params[3] == 2) {
$action = 'forword';
$msg_id = intval($params[4]);
}
}
if (!$msg_id) {
trigger_error('NO_MESSAGE');
}
}
if (($action == 'post' || $action == 'reply') && !$auth->acl_get('u_sendpm')) {
trigger_error('NO_AUTH_SEND_MESSAGE');
}
if ($action == 'forward' && (!$config['forward_pm'] || !$auth->acl_get('u_pm_forward'))) {
trigger_error('NO_AUTH_FORWARD_MESSAGE');
}
// Do NOT use request_var or specialchars here
$address_list = array('u' => array());
foreach ($user_name as $msg_to_name) {
$user_id = get_user_id_by_name(trim($msg_to_name));
if ($user_id) {
$address_list['u'][$user_id] = 'to';
} else {
trigger_error('PM_NO_USERS');
}
}
$sql = '';
// What is all this following SQL for? Well, we need to know
// some basic information in all cases before we do anything.
if ($action != 'post') {
$sql = 'SELECT t.folder_id, p.*, u.username as quote_username
FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u
WHERE t.user_id = ' . $user->data['user_id'] . "\n AND p.author_id = u.user_id\n AND t.msg_id = p.msg_id\n AND p.msg_id = {$msg_id}";
}
if ($sql) {
$result = $db->sql_query($sql);
$post = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$post) {
trigger_error('NO_MESSAGE');
}
if (!$post['author_id'] || $post['author_id'] == ANONYMOUS) {
trigger_error('NO_AUTHOR');
}
}
include $phpbb_root_path . 'includes/message_parser.' . $phpEx;
$message_parser = new parse_message();
// Get maximum number of allowed recipients
if ($config['version'] > '3.0.3') {
$sql = 'SELECT MAX(g.group_max_recipients) as max_recipients
FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug
WHERE ug.user_id = ' . $user->data['user_id'] . '
AND ug.user_pending = 0
AND ug.group_id = g.group_id';
$result = $db->sql_query($sql);
$max_recipients = (int) $db->sql_fetchfield('max_recipients');
$db->sql_freeresult($result);
$max_recipients = !$max_recipients ? $config['pm_max_recipients'] : $max_recipients;
} else {
$max_recipients = 10;
}
// If this is a quote/reply "to all"... we may increase the max_recpients to the number of original recipients
if (($action == 'reply' || $action == 'quote') && $max_recipients) {
// We try to include every previously listed member from the TO Header
//.........这里部分代码省略.........
示例11: edit
/**
* comment Controller
* Route: gallery/comment/{image_id}/edit/{comment_id}
*
* @param int $image_id Image ID
* @return Symfony\Component\HttpFoundation\Response A Symfony Response object
*/
public function edit($image_id, $comment_id)
{
$this->user->add_lang_ext('phpbbgallery/core', array('gallery'));
add_form_key('gallery');
$submit = $this->request->variable('submit', false);
$error = $message = '';
// load Image Data
$image_data = $this->image->get_image_data($image_id);
$album_id = (int) $image_data['image_album_id'];
$album_data = $this->loader->get($album_id);
$this->display->generate_navigation($album_data);
$page_title = $image_data['image_name'];
$image_backlink = $this->helper->route('phpbbgallery_image', array('image_id' => $image_id));
$album_backlink = $this->helper->route('phpbbgallery_album', array('album_id' => $album_id));
$image_loginlink = $this->url->append_sid('relative', 'image_page', "album_id={$album_id}&image_id={$image_id}");
if ($comment_id != 0) {
$sql = 'SELECT *
FROM ' . $this->table_comments . '
WHERE comment_id = ' . $comment_id;
$result = $this->db->sql_query($sql);
$comment_data = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
$image_id = (int) $comment_data['comment_image_id'];
} else {
$this->misc->not_authorised($image_backlink, $image_loginlink);
}
$this->gallery_auth->load_user_premissions($this->user->data['user_id']);
if (!$this->gallery_auth->acl_check('c_edit', $album_id, $album_data['album_user_id']) && $mode == 'add') {
if (!$this->gallery_auth->acl_check('m_comments', $album_id, $album_data['album_user_id'])) {
$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD');
}
} else {
if ($comment_data['comment_user_id'] != $this->user->data['user_id'] && !$this->gallery_auth->acl_check('m_comments', $album_id, $album_data['album_user_id'])) {
$this->misc->not_authorised($image_backlink, $image_loginlink);
}
}
$this->user->add_lang('posting');
include_once $this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext;
$bbcode_status = $this->config['allow_bbcode'] ? true : false;
$smilies_status = $this->config['allow_smilies'] ? true : false;
$img_status = $bbcode_status ? true : false;
$url_status = $this->config['allow_post_links'] ? true : false;
$flash_status = false;
$quote_status = true;
include_once $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext;
// Build custom bbcodes array
display_custom_bbcodes();
// Build smilies array
generate_smilies('inline', 0);
//$s_hide_comment_input = (time() < ($album_data['contest_start'] + $album_data['contest_end'])) ? true : false;
$s_hide_comment_input = false;
$this->template->assign_vars(array('BBCODE_STATUS' => $bbcode_status ? sprintf($this->user->lang['BBCODE_IS_ON'], '<a href="' . $this->url->append_sid('phpbb', 'faq', 'mode=bbcode') . '">', '</a>') : sprintf($this->user->lang['BBCODE_IS_OFF'], '<a href="' . $this->url->append_sid('phpbb', 'faq', 'mode=bbcode') . '">', '</a>'), 'IMG_STATUS' => $img_status ? $this->user->lang['IMAGES_ARE_ON'] : $this->user->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => $flash_status ? $this->user->lang['FLASH_IS_ON'] : $this->user->lang['FLASH_IS_OFF'], 'SMILIES_STATUS' => $smilies_status ? $this->user->lang['SMILIES_ARE_ON'] : $this->user->lang['SMILIES_ARE_OFF'], 'URL_STATUS' => $bbcode_status && $url_status ? $this->user->lang['URL_IS_ON'] : $this->user->lang['URL_IS_OFF'], 'S_BBCODE_ALLOWED' => $bbcode_status, 'S_SMILIES_ALLOWED' => $smilies_status, 'S_LINKS_ALLOWED' => $url_status, 'S_BBCODE_IMG' => $img_status, 'S_BBCODE_URL' => $url_status, 'S_BBCODE_FLASH' => $flash_status, 'S_BBCODE_QUOTE' => $quote_status));
$comment_username_req = $comment_data['comment_user_id'] == ANONYMOUS ? true : false;
if ($submit) {
if (!check_form_key('gallery')) {
trigger_error('FORM_INVALID');
}
$sql_ary = array();
$comment_plain = $this->request->variable('message', '', true);
if ($comment_username_req) {
$comment_username = $this->request->variable('username', '');
if ($comment_username == '') {
$error .= ($error ? '<br />' : '') . $this->this->user->lang['MISSING_USERNAME'];
}
if (validate_username($comment_username)) {
$error .= ($error ? '<br />' : '') . $this->user->lang['INVALID_USERNAME'];
$comment_username = '';
}
$sql_ary = array('comment_username' => $comment_username);
}
if ($comment_plain == '') {
$error .= ($error ? '<br />' : '') . $this->user->lang['MISSING_COMMENT'];
}
if (utf8_strlen($comment_plain) > $this->gallery_config->get('comment_length')) {
$error .= ($error ? '<br />' : '') . $this->user->lang['COMMENT_TOO_LONG'];
}
if (!class_exists('bbcode')) {
include $this->phpbb_root_path . 'includes/bbcode.' . $this->php_ext;
}
include_once $this->phpbb_root_path . 'includes/message_parser.' . $this->php_ext;
$message_parser = new \parse_message();
$message_parser->message = utf8_normalize_nfc($comment_plain);
if ($message_parser->message) {
$message_parser->parse(true, true, true, true, false, true, true, true);
}
$sql_ary = array_merge($sql_ary, array('comment' => $message_parser->message, 'comment_uid' => $message_parser->bbcode_uid, 'comment_bitfield' => $message_parser->bbcode_bitfield, 'comment_edit_count' => $comment_data['comment_edit_count'] + 1, 'comment_signature' => $this->auth->acl_get('u_sig') && isset($_POST['attach_sig'])));
if (!$error) {
$this->comment->edit($comment_id, $sql_ary);
$message .= $this->user->lang['COMMENT_STORED'] . '<br />';
if ($this->user->data['user_id'] != $comment_data['comment_user_id']) {
$this->gallery_log->add_log('moderator', 'c_edit', $image_data['image_album_id'], $image_data['image_id'], array('LOG_GALLERY_COMMENT_EDITED', $image_data['image_name']));
}
}
//.........这里部分代码省略.........
示例12: array
}
$db->sql_freeresult($result);
// Find out whether the user is watching the report
if ($user->data['user_id'] != ANONYMOUS) {
$sql = 'SELECT notify_status FROM ' . TOPICS_WATCH_TABLE . " WHERE topic_id = {$report['topic_id']} AND user_id = {$user->data['user_id']}";
$result = $db->sql_query($sql);
$is_subscribed = $db->sql_fetchrow($result) != false;
$db->sql_freeresult($result);
} else {
$is_subscribed = false;
}
// Get submitted data
$comment_data = array('comment_subject' => utf8_normalize_nfc(request_var('comment_subject', '', true)), 'comment_message' => utf8_normalize_nfc(request_var('comment_message', '', true)), 'enable_bbcode' => isset($_POST['disable_bbcode']) ? 0 : 1, 'enable_smilies' => isset($_POST['disable_smilies']) ? 0 : 1, 'enable_magic_url' => isset($_POST['disable_magic_url']) ? 0 : 1);
// Run checks
if (isset($_POST['preview']) || isset($_POST['submit'])) {
$message_parser = new parse_message();
$message_parser->message =& $comment_data['comment_message'];
$message_md5 = md5($message_parser->message);
$message_parser->parse($comment_data['enable_bbcode'], $config['allow_post_links'] ? $comment_data['enable_magic_url'] : false, $comment_data['enable_smilies'], $auth->acl_get('f_img', $report['forum_id']), $auth->acl_get('f_flash', $report['forum_id']), true, $config['allow_post_links']);
if (sizeof($message_parser->warn_msg)) {
$error = $message_parser->warn_msg;
}
}
// Preview comment
if (isset($_POST['preview']) && !empty($comment_data['comment_message'])) {
$template->assign_vars(array('PREVIEW_TEXT' => $message_parser->format_display($comment_data['enable_bbcode'], $comment_data['enable_magic_url'], $comment_data['enable_smilies'], false), 'S_PREVIEW' => true));
}
// Post comment
if (isset($_POST['submit'])) {
if (!check_form_key('add_comment')) {
trigger_error('FORM_INVALID');
示例13: parse_message
{
$karma_power = 1;
}
// Karma comments disable, we'll always karma with max power
if (!$karmamod->config['comments'])
{
$karma_power = $max_karma_power;
}
// Include posting functions
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
$message_parser = new parse_message();
$error = array();
$s_icons = false;
// Icons enabled for this forum?
if ($karmamod->config['icons'])
{
$s_icons = posting_gen_topic_icons('', $icon_id);
}
// HTML, BBCode, Smilies, Images and Flash status
$bbcode_status = ($config['allow_bbcode']) ? true : false;
$smilies_status = ($bbcode_status && $config['allow_smilies']) ? true : false;
$img_status = ($bbcode_status) ? true : false;
$url_status = ($config['allow_post_links']) ? true : false;
$flash_status = ($bbcode_status && $config['allow_post_flash']) ? true : false;
示例14: parse_message
// Signature
if ($enable_sig && $config['allow_sig'] && $preview_signature && $_CLASS['auth']->acl_get('f_sigs', $forum_id)) {
$parse_sig = new parse_message($preview_signature);
$parse_sig->bbcode_uid = $preview_signature_uid;
$parse_sig->bbcode_bitfield = $preview_signature_bitfield;
// Not sure about parameters for bbcode/smilies/urls... in signatures
$parse_sig->format_display($config['allow_html'], $config['allow_bbcode'], true, $config['allow_smilies']);
$preview_signature = $parse_sig->message;
unset($parse_sig);
} else {
$preview_signature = '';
}
$preview_subject = censor_text($subject);
// Poll Preview
if (($mode == 'post' || $mode == 'edit' && $post_id == $topic_first_post_id && (!$poll_last_vote || $_CLASS['auth']->acl_get('m_edit', $forum_id))) && $_CLASS['auth']->acl_get('f_poll', $forum_id)) {
$parse_poll = new parse_message($poll_title);
$parse_poll->bbcode_uid = $message_parser->bbcode_uid;
$parse_poll->bbcode_bitfield = $message_parser->bbcode_bitfield;
$parse_poll->format_display($enable_html, $enable_bbcode, $enable_urls, $enable_smilies);
$_CLASS['core_template']->assign_array(array('S_HAS_POLL_OPTIONS' => sizeof($poll_options), 'S_IS_MULTI_CHOICE' => $poll_max_options > 1 ? true : false, 'POLL_QUESTION' => $parse_poll->message, 'L_POLL_LENGTH' => $poll_length ? sprintf($_CLASS['core_user']->lang['POLL_RUN_TILL'], $_CLASS['core_user']->format_date($poll_length + $poll_start)) : '', 'L_MAX_VOTES' => $poll_max_options == 1 ? $_CLASS['core_user']->lang['MAX_OPTION_SELECT'] : sprintf($_CLASS['core_user']->lang['MAX_OPTIONS_SELECT'], $poll_max_options)));
$parse_poll->message = implode("\n", $poll_options);
$parse_poll->format_display($enable_html, $enable_bbcode, $enable_urls, $enable_smilies);
$preview_poll_options = explode('<br />', $parse_poll->message);
unset($parse_poll);
foreach ($preview_poll_options as $option) {
$_CLASS['core_template']->assign_vars_array('poll_option', array('POLL_OPTION_CAPTION' => $option));
}
unset($preview_poll_options);
}
// Attachment Preview
if (sizeof($message_parser->attachment_data)) {
示例15: md5
// grab md5 'checksum' of new message
$message_md5 = md5($message_parser->message);
$data = array('topic_title' => $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'] : $current_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, 'notify_set' => $post_data['notify_set'], '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);
$output = clean(submit_post($mode, $title, $username, POST_NORMAL, $poll, $data, $update_message, 0));
}
}
// ****************************
// *********** REPLY **********
// ****************************
if ($get == 'reply') {
// don't allow anonymous posting or spam bots will go crazy
if ($user->data['is_registered']) {
include $phpbb_root_path . 'includes/functions_posting.' . $phpEx;
include $phpbb_root_path . 'includes/functions_display.' . $phpEx;
include $phpbb_root_path . 'includes/message_parser.' . $phpEx;
$message_parser = new parse_message();
$message = utf8_normalize_nfc(request_var('txt', '', true));
$message_parser->message =& $message;
$title = utf8_normalize_nfc(request_var('title', '', true));
$username = $user->data['username'];
$update_message = true;
$mode = 'reply';
$forum_id = request_var('fid', '');
$topic_id = request_var('tid', '');
$post_data['poster_id'] = $user->data['user_id'];
$post_data['enable_bbcode'] = true;
$post_data['enable_smilies'] = true;
$post_data['enable_urls'] = true;
// parse message
if ($update_message) {
if (sizeof($message_parser->warn_msg)) {