本文整理汇总了PHP中phpbb_preg_quote函数的典型用法代码示例。如果您正苦于以下问题:PHP phpbb_preg_quote函数的具体用法?PHP phpbb_preg_quote怎么用?PHP phpbb_preg_quote使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了phpbb_preg_quote函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate_username
function validate_username($username)
{
global $db, $lang, $userdata;
// Remove doubled up spaces
$username = preg_replace('#\\s+#', ' ', $username);
// Limit username length
$username = substr(str_replace("\\'", "'", $username), 0, 25);
$username = str_replace("'", "''", $username);
$sql = "SELECT username\n FROM " . USERS_TABLE . "\n WHERE LOWER(username) = '" . strtolower($username) . "'";
if ($result = $db->sql_query($sql)) {
if ($row = $db->sql_fetchrow($result)) {
if ($userdata['session_logged_in'] && $row['username'] != $userdata['username'] || !$userdata['session_logged_in']) {
$db->sql_freeresult($result);
return array('error' => true, 'error_msg' => $lang['Username_taken']);
}
}
}
$db->sql_freeresult($result);
$sql = "SELECT group_name\n FROM " . GROUPS_TABLE . "\n WHERE LOWER(group_name) = '" . strtolower($username) . "'";
if ($result = $db->sql_query($sql)) {
if ($row = $db->sql_fetchrow($result)) {
$db->sql_freeresult($result);
return array('error' => true, 'error_msg' => $lang['Username_taken']);
}
}
$db->sql_freeresult($result);
$sql = "SELECT disallow_username\n FROM " . DISALLOW_TABLE;
if ($result = $db->sql_query($sql)) {
if ($row = $db->sql_fetchrow($result)) {
do {
if (preg_match("#\\b(" . str_replace("\\*", ".*?", phpbb_preg_quote($row['disallow_username'], '#')) . ")\\b#i", $username)) {
$db->sql_freeresult($result);
return array('error' => true, 'error_msg' => $lang['Username_disallowed']);
}
} while ($row = $db->sql_fetchrow($result));
}
}
$db->sql_freeresult($result);
$sql = "SELECT word\n FROM " . WORDS_TABLE;
if ($result = $db->sql_query($sql)) {
if ($row = $db->sql_fetchrow($result)) {
do {
if (preg_match("#\\b(" . str_replace("\\*", ".*?", phpbb_preg_quote($row['word'], '#')) . ")\\b#i", $username)) {
$db->sql_freeresult($result);
return array('error' => true, 'error_msg' => $lang['Username_disallowed']);
}
} while ($row = $db->sql_fetchrow($result));
}
}
$db->sql_freeresult($result);
// Don't allow " and ALT-255 in username.
if (strstr($username, '"') || strstr($username, '"') || strstr($username, chr(160))) {
return array('error' => true, 'error_msg' => $lang['Username_invalid']);
}
return array('error' => false, 'error_msg' => '');
}
示例2: validate_username
function validate_username($username)
{
global $db, $lang, $userdata;
$username = str_replace("\\'", "''", $username);
$sql = "SELECT username \r\n\t\tFROM " . USERS_TABLE . " \r\n\t\tWHERE LOWER(username) = '" . strtolower($username) . "'";
if ($result = $db->sql_query($sql)) {
if ($row = $db->sql_fetchrow($result)) {
if ($userdata['session_logged_in'] && $row['username'] != $userdata['username'] || !$userdata['session_logged_in']) {
return array('error' => true, 'error_msg' => $lang['Username_taken']);
}
}
}
$sql = "SELECT group_name\r\n\t\tFROM " . GROUPS_TABLE . " \r\n\t\tWHERE LOWER(group_name) = '" . strtolower($username) . "'";
if ($result = $db->sql_query($sql)) {
if ($row = $db->sql_fetchrow($result)) {
return array('error' => true, 'error_msg' => $lang['Username_taken']);
}
}
$sql = "SELECT disallow_username\r\n\t\tFROM " . DISALLOW_TABLE;
if ($result = $db->sql_query($sql)) {
while ($row = $db->sql_fetchrow($result)) {
if (preg_match("#\\b(" . str_replace("\\*", ".*?", phpbb_preg_quote($row['disallow_username'], '#')) . ")\\b#i", $username)) {
return array('error' => true, 'error_msg' => $lang['Username_disallowed']);
}
}
}
$sql = "SELECT word \r\n\t\tFROM " . WORDS_TABLE;
if ($result = $db->sql_query($sql)) {
while ($row = $db->sql_fetchrow($result)) {
if (preg_match("#\\b(" . str_replace("\\*", ".*?", phpbb_preg_quote($row['word'], '#')) . ")\\b#i", $username)) {
return array('error' => true, 'error_msg' => $lang['Username_disallowed']);
}
}
}
// Don't allow " in username.
if (strstr($username, '"')) {
return array('error' => true, 'error_msg' => $lang['Username_invalid']);
}
return array('error' => false, 'error_msg' => '');
}
示例3: obtain_acronym_list
/**
* Obtain list of acronyms and build preg style replacement arrays for use by the calling script
*/
function obtain_acronym_list()
{
global $k_config, $user, $db;
//Fix ref: http://www.stargate-portal.com/forum/viewtopic.php?f=29&t=591&p=6857 syntron //
if (!class_exists('acm')) {
global $phpbb_root, $phpEx;
require $phpbb_root_path . 'includes/acm/acm_file.' . $phpEx;
}
if (($acronyms = $this->get('_word_acronyms')) === false) {
$sql = 'SELECT acronym, meaning
FROM ' . K_ACRONYMS_TABLE . "\n\t\t\t\t\tWHERE lang = '" . $user->data['user_lang'] . "'\n\t\t\t\t\tORDER BY LENGTH(TRIM(acronym))\tDESC";
$result = $db->sql_query($sql, 600);
$acronyms = array();
while ($row = $db->sql_fetchrow($result)) {
$acronyms['match'][] = '#(' . phpbb_preg_quote($row['acronym'], '#') . ')#';
$acronyms['replace'][] = '<acronym title="' . $row['meaning'] . '">\\1</acronym>';
}
$db->sql_freeresult($result);
$this->put('_word_acronyms', $acronyms);
}
return $acronyms;
}
示例4: smilies_news
function smilies_news($message)
{
static $orig, $repl;
if (!isset($orig)) {
global $db, $config;
$orig = $repl = array();
//$sql = "SELECT * FROM " . SMILIES_TABLE;
$sql = "SELECT code, smile_url FROM " . SMILIES_TABLE . " ORDER BY smilies_order";
$result = $db->sql_query($sql, 0, 'smileys_');
$host = extract_current_hostname();
$orig = array();
$repl = array();
while ($row = $db->sql_fetchrow($result)) {
$orig[] = "/(?<=.\\W|\\W.|^\\W)" . phpbb_preg_quote($row['code'], "/") . "(?=.\\W|\\W.|\\W\$)/";
$repl[] = '<img src="http://' . $host . $config['script_path'] . $config['smilies_path'] . '/' . $row['smile_url'] . '" alt="" />';
}
}
if (sizeof($orig)) {
$message = preg_replace($orig, $repl, ' ' . $message . ' ');
$message = substr($message, 1, -1);
}
return $message;
}
示例5: mysql_query
}
$hasil4 = mysql_query("SELECT `mod_download`.*,`mod_cat_download`.`kategori`,\n\t\t \t\tMATCH(`mod_download`.`judul`,`mod_download`.`keterangan`,`mod_download`.`url`) AGAINST ('{$search}' IN BOOLEAN MODE) AS score \n\t \t\t\tFROM `mod_download` LEFT JOIN `mod_cat_download` ON `mod_cat_download`.`kid`=`mod_download`.`kid` where MATCH(`mod_download`.`judul`,`mod_download`.`keterangan`,`mod_download`.`url`) AGAINST ('{$search}' IN BOOLEAN MODE) \n\t \t\t\t ORDER BY score DESC\n\t \t\t\tLIMIT {$offset}, {$limit}");
if ($jumlah > 0) {
$open['finds'] = true;
$open['caption'] = 'Ditemukan <b>' . $jumlah . '</b> Download Dengan Kata Kunci : <b>' . $search . '</b>';
while ($data = mysql_fetch_assoc($hasil4)) {
///// fungsi hightlight
//////////////////////////////////////////////////////////////////////////////////////////////////////////
$highlight = $search;
if (isset($search)) {
// Split words and phrases
$words = explode(' ', trim(htmlspecialchars(urldecode($search))));
$highlight_match = '';
for ($i = 0; $i < sizeof($words); $i++) {
if (trim($words[$i]) != '') {
$highlight_match .= ($highlight_match != '' ? '|' : '') . str_replace('*', '\\w*', phpbb_preg_quote($words[$i], '#'));
}
}
unset($words);
}
$JUDUL = str_replace('\\"', '"', substr(preg_replace('#(\\>(((?>([^><]+|(?R)))*)\\<))#se', "preg_replace('#(" . $highlight_match . ")#i', '<span style=\"color:orange\">\\\\1</span>', '\\0')", '>' . $data['judul'] . '<'), 1, -1));
$KETERANGAN = str_replace('\\"', '"', substr(preg_replace('#(\\>(((?>([^><]+|(?R)))*)\\<))#se', "preg_replace('#(" . $highlight_match . ")#i', '<span style=\"color:orange\">\\\\1</span>', '\\0')", '>' . $data['keterangan'] . '<'), 1, -1));
$ceknew = empty($ceknew) ? '' : $ceknew;
$open['List'][] = array('judul' => $JUDUL, 'keterangan' => $KETERANGAN, 'url' => $data['url'], 'hit' => $data['hit'], 'date' => date('Y-m-d H:i:s', $data['date']), 'id' => $data['id'], 'kid' => $data['kid'], 'kategori' => $data['kategori'], 'size' => $data['size'], 'newlinks' => cek_baru($data['id'], 1209600, 'id', 'mod_link'));
}
} else {
$open['finds'] = false;
$open['caption'] = 'Tidak Ditemukan Dengan Kata Kunci : <b>' . $search . '</b>';
}
$j = new JSON_obj();
echo $j->encode($open);
示例6: encode
function encode($str)
{
if ($this->encoding == '') {
return $str;
}
// define start delimimter, end delimiter and spacer
$end = "?=";
$start = "=?{$this->encoding}?B?";
$spacer = "{$end}\r\n {$start}";
// determine length of encoded text within chunks and ensure length is even
$length = 75 - strlen($start) - strlen($end);
$length = floor($length / 2) * 2;
// encode the string and split it into chunks with spacers after each chunk
$str = chunk_split(base64_encode($str), $length, $spacer);
// remove trailing spacer and add start and end delimiters
$str = preg_replace('#' . phpbb_preg_quote($spacer, '#') . '$#', '', $str);
return $start . $str . $end;
}
示例7: obtain_word_list
function obtain_word_list(&$orig_word, &$replacement_word)
{
global $db, $cache;
if ($cache->exists('word_censors')) {
$censors = $cache->get('word_censors');
$orig_word = $censors['orig_word'];
$replacement_word = $censors['replacement_word'];
unset($censors);
} else {
//
// Define censored word matches
//
$sql = "SELECT word, replacement\n FROM " . WORDS_TABLE;
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, 'Could not get censored words from database', '', __LINE__, __FILE__, $sql);
}
if ($row = $db->sql_fetchrow($result)) {
do {
// Intellicensor © 2004 Jonathan Motta < phpbb@rusticweb.com >
$ic_word = '';
$ic_first = 0;
$ic_chars = preg_split('//', $row['word'], -1, PREG_SPLIT_NO_EMPTY);
foreach ($ic_chars as $char) {
if ($ic_first == 1 && $char != '*') {
$ic_word .= '_';
}
$ic_word .= $char;
$ic_first = 1;
}
$ic_search = array('\\*', 's', 'a', 'b', 'l', 'i', 'o', 'p', '_');
$ic_replace = array('\\w*?', '(?:s|\\$)', '(?:a|\\@)', '(?:b|8|3)', '(?:l|1|i|\\!)', '(?:i|1|l|\\!)', '(?:o|0)', '(?:p|\\?)', '(?:_|\\W)*');
$orig_word[] = '#(?<=^|\\W)(' . str_replace($ic_search, $ic_replace, phpbb_preg_quote($ic_word, '#')) . ')(?=\\W|$)#i';
// $orig_word[] = '#\b(' . str_replace('\*', '\w*?', phpbb_preg_quote($row['word'], '#')) . ')\b#i';
$replacement_word[] = $row['replacement'];
} while ($row = $db->sql_fetchrow($result));
}
$db->sql_freeresult($result);
$cache->put('word_censors', array('orig_word' => $orig_word, 'replacement_word' => $replacement_word));
}
return true;
}
示例8: smilies_pass
function smilies_pass($message)
{
global $db, $board_config;
static $smilies;
if (empty($smilies)) {
$sql = "SELECT code, smile_url\r\n\t\t\tFROM " . SMILIES_TABLE;
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, "Couldn't obtain smilies data", "", __LINE__, __FILE__, $sql);
}
if (!$db->sql_numrows($result)) {
return $message;
}
$smilies = $db->sql_fetchrowset($result);
}
usort($smilies, 'smiley_sort');
for ($i = 0; $i < count($smilies); $i++) {
$orig[] = "/(?<=.\\W|\\W.|^\\W)" . phpbb_preg_quote($smilies[$i]['code'], "/") . "(?=.\\W|\\W.|\\W\$)/";
$repl[] = '<img src="' . $board_config['smilies_path'] . '/' . $smilies[$i]['smile_url'] . '" alt="' . $smilies[$i]['smile_url'] . '" border="0" />';
}
if ($i > 0) {
$message = preg_replace($orig, $repl, ' ' . $message . ' ');
$message = substr($message, 1, -1);
}
return $message;
}
示例9: smilies_pass
function smilies_pass($message)
{
static $orig, $repl;
if (!isset($orig)) {
global $db, $images, $portal_config, $var_cache, $phpbb_root_path, $config;
$orig = $repl = array();
if (!$orig) {
$sql = 'SELECT * FROM ' . SMILIES_TABLE;
if (!($result = $db->sql_query($sql))) {
trigger_error($user->lang['ERROR_SMILIES_DATA'], __LINE__, __FILE__, $sql);
}
$smilies = $db->sql_fetchrowset($result);
if (count($smilies)) {
usort($smilies, "smiley_sort");
}
for ($i = 0; $i < count($smilies); $i++) {
$orig[] = "/(?<=.\\W|\\W.|^\\W)" . phpbb_preg_quote($smilies[$i]['code'], "/") . "(?=.\\W|\\W.|\\W\$)/";
$repl[] = '<img src="' . $phpbb_root_path . $config['smilies_path'] . '/' . $smilies[$i]['smiley_url'] . '" alt="' . $smilies[$i]['emotion'] . '" border="0" />';
}
if ($portal_config['cache_enabled']) {
$var_cache->save($orig, 'orig2', 'smilies');
$var_cache->save($repl, 'repl2', 'smilies');
}
}
}
if (count($orig)) {
$message = preg_replace($orig, $repl, ' ' . $message . ' ');
$message = substr($message, 1, -1);
}
return $message;
}
示例10: obtain_autolinks_list
function obtain_autolinks_list($forum_id)
{
global $db;
$where = $forum_id ? ' WHERE link_forum = 0 OR link_forum IN (' . $forum_id . ')' : ' WHERE link_forum = -1';
$sql = "SELECT * FROM " . AUTOLINKS . $where;
$result = $db->sql_query($sql, 0, 'autolinks_', TOPICS_CACHE_FOLDER);
$autolinks = array();
while ($row = $db->sql_fetchrow($result)) {
// Munge word boundaries to stop autolinks from linking to
// themselves or other autolinks in step 2 in the function below.
$row['link_url'] = preg_replace('/(\\b)/', '\\1ALSPACEHOLDER', $row['link_url']);
$row['link_comment'] = preg_replace('/(\\b)/', '\\1ALSPACEHOLDER', $row['link_comment']);
if ($row['link_style']) {
$row['link_style'] = preg_replace('/(\\b)/', '\\1ALSPACEHOLDER', $row['link_style']);
$style = ' style="' . htmlspecialchars($row['link_style']) . '" ';
} else {
$style = ' ';
}
$autolinks['match'][] = '/(?<![\\/\\w@\\.:-])(?!\\.\\w)(' . phpbb_preg_quote($row['link_keyword'], '/') . ')(?![\\/\\w@:-])(?!\\.\\w)/i';
if ($row['link_int']) {
$autolinks['replace'][] = '<a href="' . append_sid(htmlspecialchars($row['link_url'])) . '" target="_self"' . $style . 'title="' . htmlspecialchars($row['link_comment']) . '">' . htmlspecialchars($row['link_title']) . '</a>';
} else {
$autolinks['replace'][] = '<a href="' . htmlspecialchars($row['link_url']) . '" target="_blank"' . $style . 'title="' . htmlspecialchars($row['link_comment']) . '">' . htmlspecialchars($row['link_title']) . '</a>';
}
}
$db->sql_freeresult($result);
return $autolinks;
}
示例11: execute
//.........这里部分代码省略.........
$observer->set('default.validation.status', 'Swear');
$observer->set('login.request.status', 'Swear');
return FALSE;
}
}
//----------------------------------------------------------------------------------------
// username approximate matching
// we need to munge the name now and attempt to standardize the lookups
$userdata =& SC::get('userdata');
$username = str_replace("\\'", "''", $username);
$checkname = strtolower(preg_replace("/^[_\\-\\+\\=\\)\\(\\^\\#\\!\\~\\'\\s\\.]+/", '', $username));
$checkname = preg_replace("/[_\\-\\+\\=\\)\\(\\^\\#\\!\\~\\'\\s\\.]+\$/", '', $checkname);
$checkname = preg_replace("/[\\-\\+\\=\\^\\#\\!\\~\\s\\.]/", '_', $checkname);
// compressed length check
if (strlen(trim($username)) <= 2) {
$observer->set('error.title', 'Username Error');
$observer->set('error.message', 'Your username must be at least 3 characters.');
return FALSE;
}
// invalid character check
if (!preg_match('/^[a-zA-z0-9_\\-\\+\\=\\)\\(\\^\\#\\!\\~\\s\\.]+$/', $username)) {
$observer->set('error.title', 'Username Error');
$observer->set('error.message', 'Your username contains invalid characters.');
return FALSE;
}
// check for at least one letter
if (!preg_match("/[a-zA-Z]/", $username)) {
$observer->set('error.title', 'Username Error');
$observer->set('error.message', 'Your username must have at least one letter.');
return FALSE;
}
// check for double spaces
if (preg_match("/ /", $username)) {
$observer->set('error.title', 'Username Error');
$observer->set('error.message', 'Your username cannot have 2 spaces in a row.');
return FALSE;
}
// Don't allow " in username.
if (strstr($username, '"') || strstr($username, ',')) {
$observer->set('error.title', 'Username Error');
$observer->set('error.message', 'Your username cannot contain quotations or commas.');
return FALSE;
}
// check for exact username
$dao =& DaoFactory::create('users');
$dao->byExactUsername(strtolower($username));
$rs =& $dao->execute();
if (!$rs->isSuccess()) {
$observer->set('error.title', 'Username Error');
$observer->set('error.message', 'Unable to validate username.');
$observer->set('error.line', __LINE__);
$observer->set('error.file', __FILE__);
$observer->set('error.debug', $rs);
return FALSE;
}
while ($row = $rs->sql_fetchrow(DB_ASSOC)) {
if ($userdata['session_logged_in'] && $row['username'] != $userdata['username'] || !$userdata['session_logged_in']) {
if (strtolower($row['username']) == strtolower($username)) {
$observer->set('error.title', 'Username Error');
$observer->set('error.message', 'That username is already taken.');
return FALSE;
} else {
$observer->set('error.title', 'Username Error');
$observer->set('error.message', 'Your username is too similar to the username of ' . $row['username']);
return FALSE;
}
}
}
// perform a wildcard search for special character matching
if (strtolower($username) != $checkname) {
$dao =& DaoFactory::create('users');
$dao->byUsername(preg_replace('/_/', '\\_', $checkname));
$rs =& $dao->execute();
while ($row = $rs->sql_fetchrow(DB_ASSOC)) {
if ($userdata['session_logged_in'] && $row['username'] != $userdata['username'] || !$userdata['session_logged_in']) {
if (strtolower($row['username']) == strtolower($username)) {
$observer->set('error.title', 'Username Error');
$observer->set('error.message', 'That username is already taken.');
return FALSE;
} else {
$observer->set('error.title', 'Username Error');
$observer->set('error.message', 'Your username is too similar to the username of ' . $row['username']);
return FALSE;
}
}
}
}
// check wordlist filter
$dao =& DaoFactory::create('words');
$dao->setWhat('word');
$rs =& $dao->execute();
while ($row = $rs->sql_fetchrow(DB_ASSOC)) {
if (preg_match("#\\b(" . str_replace("\\*", ".*?", phpbb_preg_quote($row['word'], '#')) . ")\\b#i", $username)) {
$observer->set('error.title', 'Username Error');
$observer->set('error.message', 'Your username contains invalid characters.');
return FALSE;
}
}
return TRUE;
}
示例12: obtain_word_list
function obtain_word_list(&$orig_word, &$replacement_word)
{
global $db;
//
// Define censored word matches
//
$result = $db->sql_query("SELECT word, replacement FROM\t " . WORDS_TABLE);
if ($row = $db->sql_fetchrow($result)) {
do {
$orig_word[] = '#\\b(' . str_replace('\\*', '\\w*?', phpbb_preg_quote($row['word'], '#')) . ')\\b#i';
$replacement_word[] = $row['replacement'];
} while ($row = $db->sql_fetchrow($result));
}
return true;
}
示例13: smilies_pass
function smilies_pass($message)
{
static $orig, $repl;
if (!isset($orig))
{
global $db, $board_config;
$orig = $repl = array();
$sql = 'SELECT code, smile_url FROM ' . SMILIES_TABLE;
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't obtain smilies data", "", __LINE__, __FILE__, $sql);
}
$smilies = $db->sql_fetchrowset($result);
usort($smilies, 'smiley_sort');
for($i = 0; $i < count($smilies); $i++)
{
$orig[] = "/(?<=.\W|\W.|^\W)" . phpbb_preg_quote($smilies[$i]['code'], "/") . "(?=.\W|\W.|\W$)/";
$smile_file_path = get_file_path($smilies[$i]['smile_url'], $board_config['smilies_path'] . '/');
$repl[] = '<img src="'. $smile_file_path . '" alt="' . $smilies[$i]['smile_url'] . '" border="0" />';
}
}
if (count($orig))
{
$message = preg_replace($orig, $repl, ' ' . $message . ' ');
$message = substr($message, 1, -1);
}
return $message;
}
示例14: smart_pass
function smart_pass($message)
{
static $orig, $repl;
if (!isset($orig)) {
global $db, $board_config;
$orig = $repl = array();
$sql = 'SELECT * FROM ' . SMART_TABLE;
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, "Couldn't obtain smart tag data", "", __LINE__, __FILE__, $sql);
}
$smart_tags = $db->sql_fetchrowset($result);
if (count($smart_tags)) {
usort($smart_tags, 'smart_sort');
}
for ($i = 0, $max = count($smart_tags); $i < $max; $i++) {
$orig[] = '#\\b(' . phpbb_preg_quote($smart_tags[$i]['smart'], "/") . ')\\b#';
//$orig[] = "/(?<=.\W|\W.|^\W)" . phpbb_preg_quote($acronyms[$i]['acronym'], "/") . "(?=.\W|\W.|\W$)/";
$repl[] = '<a href="' . $smart_tags[$i]['url'] . '" target="_blank">' . $smart_tags[$i]['smart'] . '</a>';
}
}
if (count($orig)) {
$segments = preg_split('#(<a href=.+?>.+?</a>|<.+?>)#s', $message, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
$message = '';
foreach ($segments as $seg) {
if ($seg[0] != '<' && $seg[0] != '[') {
$message .= str_replace('\\"', '"', substr(preg_replace('#(\\>(((?>([^><]+|(?R)))*)\\<))#se', "preg_replace(\$orig, \$repl, '\\0')", '>' . $seg . '<'), 1, -1));
} else {
$message .= $seg;
}
}
}
return $message;
}
示例15: smilies_pass
/**
* smilies_pass processing
*/
function smilies_pass($message)
{
static $orig, $repl;
if (!isset($orig)) {
global $db, $images, $portal_config;
$orig = $repl = array();
if (!$orig) {
$sql = 'SELECT * FROM ' . SMILIES_TABLE;
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, "Couldn't obtain smilies data", "", __LINE__, __FILE__, $sql);
}
$smilies = $db->sql_fetchrowset($result);
if (count($smilies)) {
usort($smilies, "smiley_sort");
}
for ($i = 0; $i < count($smilies); $i++) {
$orig[] = "/(?<=.\\W|\\W.|^\\W)" . phpbb_preg_quote($smilies[$i]['code'], "/") . "(?=.\\W|\\W.|\\W\$)/";
$repl[] = '<img src="images/smilies/' . $images['smilies'] . '/' . $smilies[$i]['smiley_url'] . '" alt="' . $smilies[$i]['emotion'] . '" border="0" />';
}
}
}
if (count($orig)) {
$message = preg_replace($orig, $repl, ' ' . $message . ' ');
$message = substr($message, 1, -1);
}
return $message;
}