aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/bbcode.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/bbcode.php')
-rw-r--r--phpBB/includes/bbcode.php54
1 files changed, 53 insertions, 1 deletions
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php
index fc0fe4beef..ea0d6b2437 100644
--- a/phpBB/includes/bbcode.php
+++ b/phpBB/includes/bbcode.php
@@ -713,4 +713,56 @@ function bbcode_array_pop(&$stack)
return($return_val);
}
-?>
+//
+// Smilies code ... would this be better tagged on to the end of bbcode.php?
+// Probably so and I'll move it before B2
+//
+function smilies_pass($message)
+{
+ global $db, $board_config;
+ static $smilies;
+
+ if( empty($smilies) )
+ {
+ $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$)/";
+ $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;
+}
+
+function smiley_sort($a, $b)
+{
+ if ( strlen($a['code']) == strlen($b['code']) )
+ {
+ return 0;
+ }
+
+ return ( strlen($a['code']) > strlen($b['code']) ) ? -1 : 1;
+}
+
+?> \ No newline at end of file