function smileys($text, $specialchars = 0, $calledfrom = 'root') { if ($specialchars) { $text = unhtmlspecialchars($text); } $splits = preg_split("/(\\[[\\/]{0,1}code\\])/si", $text, -1, PREG_SPLIT_DELIM_CAPTURE); $anz = count($splits); for ($i = 0; $i < $anz; $i++) { $opentags = 0; $closetags = 0; $match = false; if (strtolower($splits[$i]) == "[code]") { $opentags++; for ($z = $i + 1; $z < $anz; $z++) { if (strtolower($splits[$z]) == "[code]") { $opentags++; } if (strtolower($splits[$z]) == "[/code]") { $closetags++; } if ($closetags == $opentags) { $match = true; break; } } } if ($match == false) { $splits[$i] = replace_smileys($splits[$i], $calledfrom); } else { $i = $z; } } $text = implode("", $splits); if ($specialchars) { $text = htmlspecialchars($text); } return $text; }
/** * Formats the given message. * @param string $message Message to format * @param bool $allowHTML Allow HTML in message * @param bool $allowBBCode Allow BBCode in message * @param bool $allowSmileys Allow Smileys in message * @param bool $wordFilter Use the word filter on this message * @param bool $clearHTML Clear HTML completely from the message * @return string Formatted message */ function format_message($message, $allowHTML, $allowBBCode, $allowSmileys, $wordFilter, $clearHTML = false) { if ($wordFilter) { $message = filter_badwords($message); } if ($clearHTML) { $message = html_entity_decode($message); $message = strip_tags($message); } else { if ($allowHTML) { $message = html_entity_decode($message); } } if ($allowBBCode) { $message = replace_bbcode($message); } if ($allowSmileys) { $message = replace_smileys($message); } return $message; }