本文整理汇总了PHP中preparse_bbcode函数的典型用法代码示例。如果您正苦于以下问题:PHP preparse_bbcode函数的具体用法?PHP preparse_bbcode怎么用?PHP preparse_bbcode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了preparse_bbcode函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convert_posts
function convert_posts($message)
{
$pattern = array('#\\[b:[a-z0-9]{10}\\]#i', '#\\[/b:[a-z0-9]{10}\\]#i', '#\\[i:[a-z0-9]{10}\\]#i', '#\\[/i:[a-z0-9]{10}\\]#i', '#\\[u:[a-z0-9]{10}\\]#i', '#\\[/u:[a-z0-9]{10}\\]#i', '#\\[list=([a-z0-9]):[a-z0-9]{10}\\]#i', '#\\[list:[a-z0-9]{10}\\]#i', '#\\[/list:[a-z0-9]:[a-z0-9]{10}\\]#i', '#\\[\\*:[a-z0-9]{10}\\]#i', '#\\[color=(.*?):[a-z0-9]{10}\\]#i', '#\\[/color:[a-z0-9]{10}\\]#i', '#:roll:#i', '#:wink:#i', '#\\[img:[a-z0-9]{10}\\]#i', '#\\[/img:[a-z0-9]{10}\\]#i', '#\\[size=[0-9]{1}:[a-z0-9]{10}\\]#i', '#\\[size=[0-9]{2}:[a-z0-9]{10}\\]#i', '#\\[/size:[a-z0-9]{10}\\]#i', '#\\[quote:(.*?)\\]#i', '#\\[/quote:[a-z0-9]{10}\\]#i', '#\\[code:[0-9]:[a-z0-9]{10}\\]#i', '#\\[/code:[0-9]:[a-z0-9]{10}\\]#i');
$replace = array('[b]', '[/b]', '[i]', '[/i]', '[u]', '[/u]', '[list=$1]', '[list]', '[/list]', '[*]', '[color=$1]', '[/color]', ':rolleyes:', ';)', '[img]', '[/img]', '', '', '', '[quote]', '[/quote]', '[code]', '[/code]');
$errors = array();
return preparse_bbcode(preg_replace($pattern, $replace, $message), $errors);
}
示例2: error
// Preparse signatures
// Preparse signatures
case 'preparse_sigs':
$query_str = '?stage=rebuild_idx';
// If we don't need to parse the sigs, skip this stage
if (isset($pun_config['o_parser_revision']) && $pun_config['o_parser_revision'] >= UPDATE_TO_PARSER_REVISION) {
break;
}
require PUN_ROOT . 'include/parser.php';
// Fetch users to process this cycle
$result = $db->query('SELECT id, signature FROM ' . $db->prefix . 'users WHERE id > ' . $start_at . ' ORDER BY id ASC LIMIT ' . PER_PAGE) or error('Unable to fetch users', __FILE__, __LINE__, $db->error());
$temp = array();
$end_at = 0;
while ($cur_item = $db->fetch_assoc($result)) {
echo sprintf($lang_update['Preparsing item'], $lang_update['signature'], $cur_item['id']) . '<br />' . "\n";
$db->query('UPDATE ' . $db->prefix . 'users SET signature = \'' . $db->escape(preparse_bbcode($cur_item['signature'], $temp, true)) . '\' WHERE id = ' . $cur_item['id']) or error('Unable to update user', __FILE__, __LINE__, $db->error());
$end_at = $cur_item['id'];
}
// Check if there is more work to do
if ($end_at > 0) {
$result = $db->query('SELECT 1 FROM ' . $db->prefix . 'users WHERE id > ' . $end_at . ' ORDER BY id ASC LIMIT 1') or error('Unable to fetch next ID', __FILE__, __LINE__, $db->error());
if ($db->num_rows($result) > 0) {
$query_str = '?stage=preparse_sigs&start_at=' . $end_at;
}
}
break;
// Rebuild the search index
// Rebuild the search index
case 'rebuild_idx':
$query_str = '?stage=finish';
// If we don't need to update the search index, skip this stage
示例3: ucwords
if (mb_strlen($message) > 65535) {
$errors[] = $lang_post['Too long message'];
} else {
if (!$pun_config['p_message_all_caps'] && mb_strtoupper($message) == $message && $pun_user['g_id'] > PUN_MOD) {
$message = ucwords(mb_strtolower($message));
}
}
}
// MOD CONVENIENT FORUM URL BEGIN
//if ($pun_config['o_convenient_url_enable'] == 1)
convert_forum_url($message);
// MOD CONVENIENT FORUM URL END
// Validate BBCode syntax
if ($pun_config['p_message_bbcode'] == 1 && strpos($message, '[') !== false && strpos($message, ']') !== false) {
include_once PUN_ROOT . 'include/parser.php';
$message = preparse_bbcode($message, $errors);
}
include PUN_ROOT . 'include/search_idx.php';
$hide_smilies = isset($_POST['hide_smilies']) ? 1 : 0;
$subscribe = isset($_POST['subscribe']) ? 1 : 0;
// Did everything go according to plan?
if (!$errors && !isset($_POST['preview'])) {
// MERGE POSTS BEGIN
$merged = false;
if (isset($_POST['merge'])) {
$_POST['merge'] = 1;
} else {
$_POST['merge'] = 0;
}
if (!$pun_user['is_guest'] && !$fid && (($is_admmod && $_POST['merge']) == 1 || !$is_admmod) && $cur_posting['poster_id'] && $cur_posting['message'] && $_SERVER['REQUEST_TIME'] - $cur_posting['posted'] < $pun_config['o_timeout_merge']) {
// Preparing separator
示例4: message
if (pun_strlen($form['signature']) > $pun_config['p_sig_length']) {
message(sprintf($lang_prof_reg['Sig too long'], $pun_config['p_sig_length'], pun_strlen($form['signature']) - $pun_config['p_sig_length']));
} else {
if (substr_count($form['signature'], "\n") > $pun_config['p_sig_lines'] - 1) {
message(sprintf($lang_prof_reg['Sig too many lines'], $pun_config['p_sig_lines']));
} else {
if ($form['signature'] && $pun_config['p_sig_all_caps'] == '0' && is_all_uppercase($form['signature']) && !$pun_user['is_admmod']) {
$form['signature'] = utf8_ucwords(utf8_strtolower($form['signature']));
}
}
}
// Validate BBCode syntax
if ($pun_config['p_sig_bbcode'] == '1') {
require PUN_ROOT . 'include/parser.php';
$errors = array();
$form['signature'] = preparse_bbcode($form['signature'], $errors, true);
if (count($errors) > 0) {
message('<ul><li>' . implode('</li><li>', $errors) . '</li></ul>');
}
}
}
break;
case 'display':
$form = array('disp_topics' => pun_trim($_POST['form']['disp_topics']), 'disp_posts' => pun_trim($_POST['form']['disp_posts']), 'show_smilies' => isset($_POST['form']['show_smilies']) ? '1' : '0', 'show_img' => isset($_POST['form']['show_img']) ? '1' : '0', 'show_img_sig' => isset($_POST['form']['show_img_sig']) ? '1' : '0', 'show_avatars' => isset($_POST['form']['show_avatars']) ? '1' : '0', 'show_sig' => isset($_POST['form']['show_sig']) ? '1' : '0');
if ($form['disp_topics'] != '') {
$form['disp_topics'] = intval($form['disp_topics']);
if ($form['disp_topics'] < 3) {
$form['disp_topics'] = 3;
} else {
if ($form['disp_topics'] > 75) {
$form['disp_topics'] = 75;
示例5: message
// Validate signature
if (pun_strlen($form['signature']) > $pun_config['p_sig_length']) {
message($lang_prof_reg['Sig too long'] . ' ' . $pun_config['p_sig_length'] . ' ' . $lang_prof_reg['characters'] . '.');
} else {
if (substr_count($form['signature'], "\n") > $pun_config['p_sig_lines'] - 1) {
message($lang_prof_reg['Sig too many lines'] . ' ' . $pun_config['p_sig_lines'] . ' ' . $lang_prof_reg['lines'] . '.');
} else {
if ($form['signature'] && $pun_config['p_sig_all_caps'] == '0' && strtoupper($form['signature']) == $form['signature'] && $pun_user['g_id'] > PUN_MOD) {
$form['signature'] = ucwords(strtolower($form['signature']));
}
}
}
// Validate BBCode syntax
if ($pun_config['p_sig_bbcode'] == '1' && strpos($form['signature'], '[') !== false && strpos($form['signature'], ']') !== false) {
require PUN_ROOT . 'include/parser.php';
$form['signature'] = preparse_bbcode($form['signature'], $foo, true);
}
if (!isset($form['use_avatar']) || $form['use_avatar'] != '1') {
$form['use_avatar'] = '0';
}
break;
case 'display':
$form = extract_elements(array('disp_topics', 'disp_posts', 'show_smilies', 'show_img', 'show_img_sig', 'show_avatars', 'show_sig', 'style'));
if ($form['disp_topics'] != '' && intval($form['disp_topics']) < 3) {
$form['disp_topics'] = 3;
}
if ($form['disp_topics'] != '' && intval($form['disp_topics']) > 75) {
$form['disp_topics'] = 75;
}
if ($form['disp_posts'] != '' && intval($form['disp_posts']) < 3) {
$form['disp_posts'] = 3;
示例6: preparse_bbcode
/**
* Use FluxBB's parser to preparse BBCode tags for message
*
* @param type $message
* @param type &$errors
* @return type
*/
function preparse_bbcode($message, &$errors)
{
global $re_list, $lang_common;
$errors = array();
require_once PUN_ROOT . 'include/parser.php';
$message = preparse_bbcode($message, $errors);
if (!empty($errors)) {
conv_log('convert_message: bbcode error: ' . implode(', ', $errors));
}
return $message;
}
示例7: convert_message
/**
* Convert BBcode
*/
function convert_message($message)
{
static $patterns, $replacements;
global $re_list;
$errors = array();
require_once PUN_ROOT . 'include/parser.php';
if (!isset($patterns)) {
$patterns = array('%\\[quote=\'(.*?)\'.*?\\]\\s*%si' => '[quote=$1]', '%\\[/?(font|size|align)(?:\\=[^\\]]*)?\\]%i' => '');
}
$message = preg_replace(array_keys($patterns), array_values($patterns), $message);
if (!isset($replacements)) {
$replacements = array('[php]' => '[code]', '[/php]' => '[/code]');
}
return preparse_bbcode(str_replace(array_keys($replacements), array_values($replacements), $message), $errors);
}
示例8: array
require FORUM_ROOT . 'include/parser.php';
}
// Now we're definitely using UTF-8, so we convert the output properly
$forum_db->set_names('utf8');
// Determine where to start
if ($start_at == 0) {
$start_at = 1;
}
$end_at = $start_at + PER_PAGE;
// Fetch users to process this cycle
$query = array('SELECT' => 'id, signature', 'FROM' => 'users', 'WHERE' => 'id >= ' . $start_at . ' AND id < ' . $end_at, 'ORDER BY' => 'id');
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
while ($cur_item = $forum_db->fetch_assoc($result)) {
echo 'Preparsing signature ' . $cur_item['id'] . '…<br />' . "\n";
$preparse_errors = array();
$query = array('UPDATE' => 'users', 'SET' => 'signature = \'' . $forum_db->escape(preparse_bbcode($cur_item['signature'], $preparse_errors, true)) . '\'', 'WHERE' => 'id = ' . $cur_item['id']);
$forum_db->query_build($query) or error(__FILE__, __LINE__);
}
// Check if there is more work to do
$query = array('SELECT' => 'id', 'FROM' => 'users', 'WHERE' => 'id >= ' . $end_at, 'ORDER BY' => 'id ASC', 'LIMIT' => '1');
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
$start_id = $forum_db->result($result);
if (is_null($start_id) || $start_id === false) {
$query_str = '?stage=finish';
} else {
$query_str = '?stage=preparse_sigs&req_per_page=' . PER_PAGE . '&start_at=' . $start_id;
}
unset($start_id);
break;
// Show results page
// Show results page
示例9: prepare_message
private function prepare_message(&$errors)
{
if (!isset($_POST['req_message'])) {
message(App::$lang_common['Bad request']);
}
$message = forum_linebreaks(forum_trim($_POST['req_message']));
if ($message == '') {
$errors[] = App::$lang['No message'];
} else {
if (strlen($message) > App::$forum_config['o_reputation_maxmessage']) {
$errors[] = sprintf(App::$lang['Too long message'], App::$forum_config['o_reputation_maxmessage']);
}
}
if (App::$forum_config['p_message_bbcode'] == '1' || App::$forum_config['o_make_links'] == '1') {
if (!defined('FORUM_PARSER_LOADED')) {
require FORUM_ROOT . 'include/parser.php';
}
$message = preparse_bbcode($message, $errors);
}
return $message;
}
示例10: pun_pm_preview
function pun_pm_preview($receiver, $subject, $body, &$errors)
{
global $forum_config, $forum_page, $lang_pun_pm, $forum_user;
if ($body == '') {
$errors[] = $lang_pun_pm['Empty body'];
} elseif (strlen($body) > FORUM_MAX_POSTSIZE_BYTES) {
$errors[] = sprintf($lang_pun_pm['Too long message'], forum_number_format(strlen($body)), forum_number_format(FORUM_MAX_POSTSIZE_BYTES));
} elseif ($forum_config['p_message_all_caps'] == '0' && utf8_strtoupper($body) == $body && !$forum_page['is_admmod']) {
$body = utf8_ucwords(utf8_strtolower($body));
}
// Validate BBCode syntax
if ($forum_config['p_message_bbcode'] == '1' || $forum_config['o_make_links'] == '1') {
global $smilies;
if (!defined('FORUM_PARSER_LOADED')) {
require FORUM_ROOT . 'include/parser.php';
}
$body = preparse_bbcode($body, $errors);
}
($hook = get_hook('pun_pm_fn_preview_pre_errors_check')) ? eval($hook) : null;
if (count($errors)) {
return false;
}
$message['sender'] = $forum_user['username'];
$message['sender_id'] = $forum_user['id'];
$message['body'] = $body;
$message['subject'] = $subject;
$message['status'] = 'draft';
$message['sent_at'] = time();
($hook = get_hook('pun_pm_fn_preview_end')) ? eval($hook) : null;
return pun_pm_message($message, 'inbox');
}
示例11: setup_variables
public function setup_variables($errors, $is_admmod)
{
$post = array();
if (!$this->user->is_guest) {
$post['username'] = $this->user->username;
$post['email'] = $this->user->email;
} else {
$post['username'] = feather_trim($this->request->post('req_username'));
$post['email'] = strtolower(feather_trim($this->config['p_force_guest_email'] == '1' ? $this->request->post('req_email') : $this->request->post('email')));
}
if ($this->request->post('req_subject')) {
$post['subject'] = feather_trim($this->request->post('req_subject'));
}
$post['hide_smilies'] = $this->request->post('hide_smilies') ? '1' : '0';
$post['subscribe'] = $this->request->post('subscribe') ? '1' : '0';
$post['stick_topic'] = $this->request->post('stick_topic') && $is_admmod ? '1' : '0';
$post['message'] = feather_linebreaks(feather_trim($this->request->post('req_message')));
// Validate BBCode syntax
if ($this->config['p_message_bbcode'] == '1') {
require_once FEATHER_ROOT . 'include/parser.php';
$post['message'] = preparse_bbcode($post['message'], $errors);
}
// Replace four-byte characters (MySQL cannot handle them)
$post['message'] = strip_bad_multibyte_chars($post['message']);
$post['time'] = time();
return $post;
}
示例12: setup_variables
public function setup_variables($cur_post, $is_admmod, $can_edit_subject, $errors)
{
global $pd;
$post = array();
$post['hide_smilies'] = $this->request->post('hide_smilies') ? '1' : '0';
$post['stick_topic'] = $this->request->post('stick_topic') ? '1' : '0';
if (!$is_admmod) {
$post['stick_topic'] = $cur_post['sticky'];
}
// Clean up message from POST
$post['message'] = feather_linebreaks(feather_trim($this->request->post('req_message')));
// Validate BBCode syntax
if ($this->config['p_message_bbcode'] == '1') {
require_once FEATHER_ROOT . 'include/parser.php';
$post['message'] = preparse_bbcode($post['message'], $errors);
}
// Replace four-byte characters (MySQL cannot handle them)
$post['message'] = strip_bad_multibyte_chars($post['message']);
// Get the subject
if ($can_edit_subject) {
$post['subject'] = feather_trim($this->request->post('req_subject'));
}
return $post;
}
示例13: startescrow_send_message
function startescrow_send_message($body, $subject, $receiver_username, $amount, &$message_id)
{
global $lang_escrows, $forum_user, $forum_db, $forum_url, $forum_config, $forum_flash;
$errors = array();
$receiver_id = startescrow_get_receiver_id($receiver_username, $errors);
if ($receiver_id == 'NULL' && empty($errors)) {
$errors[] = $lang_escrows['Empty receiver'];
}
// Clean up body from POST
$body = forum_linebreaks($body);
if ($body == '') {
$errors[] = $lang_escrows['Empty body'];
} elseif (strlen($body) > FORUM_MAX_POSTSIZE_BYTES) {
$errors[] = sprintf($lang_escrows['Too long message'], forum_number_format(strlen($body)), forum_number_format(FORUM_MAX_POSTSIZE_BYTES));
} elseif ($forum_config['p_message_all_caps'] == '0' && utf8_strtoupper($body) == $body && !$forum_page['is_admmod']) {
$body = utf8_ucwords(utf8_strtolower($body));
}
// Validate BBCode syntax
if ($forum_config['p_message_bbcode'] == '1' || $forum_config['o_make_links'] == '1') {
global $smilies;
if (!defined('FORUM_PARSER_LOADED')) {
require FORUM_ROOT . 'include/parser.php';
}
$body = preparse_bbcode($body, $errors);
}
// Sending message to the buyer
$btcaddress = get_free_btcaddress($errors);
//book the address
if (count($errors)) {
return $errors;
}
$now = time();
// Send new message
// Save to DB
$query = array('INSERT' => 'sender_id, receiver_id, status, lastedited_at, read_at, subject, body', 'INTO' => 'pun_pm_messages', 'VALUES' => $forum_user['id'] . ', ' . $receiver_id . ', \'sent\', ' . $now . ', 0, \'' . $forum_db->escape($subject) . '\', \'' . $forum_db->escape($body) . '\'');
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
$endtime = $now + $forum_config['o_empty_escrow_duration'] * 3600;
$endtime = date('Y-m-d H:i:s ', $endtime);
// Send message to the buyer
$body = sprintf($lang_escrows['Escrow buyer message'], $endtime, $amount, $btcaddress);
// Save to DB
$query = array('INSERT' => 'receiver_id, sender_id, status, lastedited_at, read_at, subject, body', 'INTO' => 'pun_pm_messages', 'VALUES' => $forum_user['id'] . ', ' . $receiver_id . ', \'sent\', ' . $now . ', 0, \'' . $forum_db->escape($subject) . '\', \'' . $forum_db->escape($body) . '\'');
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
// ########### Add to escrows table
$query = array('INSERT' => 'time, buyerid, sellerid, amount, subject, status, recivedtime, btcaddress', 'INTO' => 'escrows', 'VALUES' => $now . ', ' . $forum_user['id'] . ', ' . $receiver_id . ', ' . $amount . ', \'' . $forum_db->escape($subject) . '\', 0, 0, \'' . $btcaddress . '\'');
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
startescrow_clear_cache($receiver_id);
// Clear cached 'New messages' in the user table
$forum_flash->add_info($lang_escrows['Escrow started']);
redirect(forum_link($forum_url['pun_pm_inbox']), $lang_escrows['Message sent']);
}
示例14: update_profile
//.........这里部分代码省略.........
// A list of words that the title may not contain
// If the language is English, there will be some duplicates, but it's not the end of the world
$forbidden = array('member', 'moderator', 'administrator', 'banned', 'guest', utf8_strtolower($lang_common['Member']), utf8_strtolower($lang_common['Moderator']), utf8_strtolower($lang_common['Administrator']), utf8_strtolower($lang_common['Banned']), utf8_strtolower($lang_common['Guest']));
if (in_array(utf8_strtolower($form['title']), $forbidden)) {
message($lang_profile['Forbidden title']);
}
}
}
break;
case 'messaging':
$form = array('jabber' => feather_trim($this->request->post('form_jabber')), 'icq' => feather_trim($this->request->post('form_icq')), 'msn' => feather_trim($this->request->post('form_msn')), 'aim' => feather_trim($this->request->post('form_aim')), 'yahoo' => feather_trim($this->request->post('form_yahoo')));
// If the ICQ UIN contains anything other than digits it's invalid
if (preg_match('%[^0-9]%', $form['icq'])) {
message($lang_prof_reg['Bad ICQ']);
}
break;
case 'personality':
$form = array();
// Clean up signature from POST
if ($this->config['o_signatures'] == '1') {
$form['signature'] = feather_linebreaks(feather_trim($this->request->post('signature')));
// Validate signature
if (feather_strlen($form['signature']) > $this->config['p_sig_length']) {
message(sprintf($lang_prof_reg['Sig too long'], $this->config['p_sig_length'], feather_strlen($form['signature']) - $this->config['p_sig_length']));
} elseif (substr_count($form['signature'], "\n") > $this->config['p_sig_lines'] - 1) {
message(sprintf($lang_prof_reg['Sig too many lines'], $this->config['p_sig_lines']));
} elseif ($form['signature'] && $this->config['p_sig_all_caps'] == '0' && is_all_uppercase($form['signature']) && !$this->user->is_admmod) {
$form['signature'] = utf8_ucwords(utf8_strtolower($form['signature']));
}
// Validate BBCode syntax
if ($this->config['p_sig_bbcode'] == '1') {
require FEATHER_ROOT . 'include/parser.php';
$errors = array();
$form['signature'] = preparse_bbcode($form['signature'], $errors, true);
if (count($errors) > 0) {
message('<ul><li>' . implode('</li><li>', $errors) . '</li></ul>');
}
}
}
break;
case 'display':
$form = array('disp_topics' => feather_trim($this->request->post('form_disp_topics')), 'disp_posts' => feather_trim($this->request->post('form_disp_posts')), 'show_smilies' => $this->request->post('form_show_smilies') ? '1' : '0', 'show_img' => $this->request->post('form_show_img') ? '1' : '0', 'show_img_sig' => $this->request->post('form_show_img_sig') ? '1' : '0', 'show_avatars' => $this->request->post('form_show_avatars') ? '1' : '0', 'show_sig' => $this->request->post('form_show_sig') ? '1' : '0');
if ($form['disp_topics'] != '') {
$form['disp_topics'] = intval($form['disp_topics']);
if ($form['disp_topics'] < 3) {
$form['disp_topics'] = 3;
} elseif ($form['disp_topics'] > 75) {
$form['disp_topics'] = 75;
}
}
if ($form['disp_posts'] != '') {
$form['disp_posts'] = intval($form['disp_posts']);
if ($form['disp_posts'] < 3) {
$form['disp_posts'] = 3;
} elseif ($form['disp_posts'] > 75) {
$form['disp_posts'] = 75;
}
}
// Make sure we got a valid style string
if ($this->request->post('form_style')) {
$styles = forum_list_styles();
$form['style'] = feather_trim($this->request->post('form_style'));
if (!in_array($form['style'], $styles)) {
message($lang_common['Bad request'], '404');
}
}