mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
Added a fix for smillies_pass function by Ashe
See this topic for details: http://www.phpbb.com/phpBB/viewtopic.php?p=166905 Yeilds a very large performance increase on long topics git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@2660 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
9d5befd6da
commit
0f712ff771
1 changed files with 26 additions and 32 deletions
|
@ -738,39 +738,33 @@ function bbcode_array_pop(&$stack)
|
|||
//
|
||||
function smilies_pass($message)
|
||||
{
|
||||
global $db, $board_config;
|
||||
static $smilies;
|
||||
static $orig, $repl;
|
||||
|
||||
if( empty($smilies) )
|
||||
if (!isset($orig))
|
||||
{
|
||||
$sql = "SELECT code, smile_url
|
||||
FROM " . SMILIES_TABLE;
|
||||
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);
|
||||
}
|
||||
|
||||
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$)/";
|
||||
$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 )
|
||||
if (count($orig))
|
||||
{
|
||||
$message = preg_replace($orig, $repl, ' ' . $message . ' ');
|
||||
$message = substr($message, 1, -1);
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue