|
From: FlorinCB <ory...@us...> - 2008-10-07 03:18:05
|
Update of /cvsroot/mxbb/core/includes/sessions/phpbb3 In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv14471 Modified Files: bbcode.php Log Message: fixed smilies bbcode Index: bbcode.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/sessions/phpbb3/bbcode.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** bbcode.php 7 Oct 2008 02:30:31 -0000 1.2 --- bbcode.php 7 Oct 2008 02:54:41 -0000 1.3 *************** *** 1393,1396 **** --- 1393,1397 ---- * Smilies pass. * + * compatible with phpBB3 blocks * * @param string $message *************** *** 1398,1402 **** * */ ! function smilies_pass($message) { static $orig, $repl; --- 1399,1403 ---- * */ ! function smilies3_pass($message) { static $orig, $repl; *************** *** 1425,1429 **** $replace[] = '<!-- s' . $row['code'] . ' --><img src="{SMILIES_PATH}/' . $row['smiley_url'] . '" alt="' . $row['code'] . '" title="' . $row['emotion'] . '" /><!-- s' . $row['code'] . ' -->'; } ! $db->sql_freeresult($result); if (sizeof($match)) --- 1426,1431 ---- $replace[] = '<!-- s' . $row['code'] . ' --><img src="{SMILIES_PATH}/' . $row['smiley_url'] . '" alt="' . $row['code'] . '" title="' . $row['emotion'] . '" /><!-- s' . $row['code'] . ' -->'; } ! ! $db->sql_freeresult($result); if (sizeof($match)) *************** *** 1446,1454 **** } ! $message = str_replace("{SMILIES_PATH}", $this->smiley_path_url . $this->smilies_path . '/' . $smilies[$i][$this->smiley_url], ' ' . $message . ' '); ! $message = substr($message, 1, -1); ! return $message; } /** --- 1448,1503 ---- } ! $message = str_replace("{SMILIES_PATH}", $this->smiley_path_url . $this->smilies_path . $smilies[$i][$this->smiley_url], ' ' . $message . ' '); ! return $message; } + + /** + * Smilies pass. + * + * compatible with phpBB2 blocks + * + * @param string $message + * @return string + * + */ + function smilies_pass($message) + { + static $orig, $repl; + global $board_config, $mx_root_path, $phpbb_root_path, $phpEx; + + if (!isset($orig)) + { + global $db; + $orig = $repl = array(); + + $sql = 'SELECT * FROM ' . SMILIES_TABLE; + if( !$result = $db->sql_query($sql) ) + { + mx_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)" . preg_quote($smilies[$i]['code'], "/") . "(?=.\W|\W.|\W$)/"; + $repl[] = '<img src="' . $this->smiley_path_url . $board_config['smilies_path'] . '/' . $smilies[$i][$this->smiley_url] . '" alt="' . $smilies[$i][$this->emotion] . '" border="0" />'; + } + } + + if (count($orig)) + { + $message = preg_replace($orig, $repl, ' ' . $message . ' '); + $message = substr($message, 1, -1); + } + + return $message; + } /** |