UPDATED: to include smilies in comments as wellI tested this briefly & it worked fine for me...
NOTE: I changed the function a bit for the $smiliesDir variable. I'm assuming that the smilies directory is in the main snews directory.
TO ADD SMILIES IN POSTSIn the snews.php file right after the line error_reporting (E_ALL ^ E_NOTICE);
add this:
function bb_smilies($text)
{
$smiliesDir = s('website')."smilies/"; // location from the smilies
$smilies = array(':)' => "icon_smile.gif" ,
':-)' => "icon_smile.gif" ,
':(' => "icon_sad.gif" ,
':-(' => "icon_sad.gif" ,
':S' => "icon_confused.gif" ,
':s' => "icon_confused.gif" ,
':-S' => "icon_confused.gif" ,
':-s' => "icon_confused.gif" ,
':D' => "icon_biggrin.gif" ,
':d' => "icon_biggrin.gif" ,
':-D' => "icon_biggrin.gif" ,
':-d' => "icon_biggrin.gif" ,
':O' => "icon_surprised.gif" ,
':o' => "icon_surprised.gif" ,
':-O' => "icon_surprised.gif" ,
':-o' => "icon_surprised.gif" ,
':|' => "icon_neutral.gif" ,
':-|' => "icon_neutral.gif" ,
':P' => "icon_razz.gif" ,
':p' => "icon_razz.gif" ,
':-P' => "icon_razz.gif" ,
':-p' => "icon_razz.gif" ,
'(6)' => "icon_twisted.gif" ,
':@' => "icon_mad.gif" ,
':-@' => "icon_mad.gif" ,
':$' => "icon_redface.gif" ,
':-$' => "icon_redface.gif" ,
'(H)' => "icon_cool.gif" ,
'(h)' => "icon_cool.gif" ,
';)' => "icon_wink.gif" ,
';-)' => "icon_wink.gif" ,
':\'(' => "icon_cry.gif" ,
':-\'(' => "icon_cry.gif" ,
'8)' => "icon_rolleyes.gif" ,
'8-)' => "icon_rolleyes.gif" ,
':A' => "icon_evil.gif" ,
':a' => "icon_evil.gif" ,
':-A' => "icon_evil.gif" ,
':-a' => "icon_evil.gif" ,
':L' => "icon_lol.gif" ,
':l' => "icon_lol.gif" ,
':-L' => "icon_lol.gif" ,
':-l' => "icon_lol.gif" ,
':X' => "icon_eek.gif" ,
':x' => "icon_eek.gif" ,
':-X' => "icon_eek.gif" ,
':-x' => "icon_eek.gif" ,
'(Y)' => "icon_yes.gif" ,
'(y)' => "icon_yes.gif" ,
'(N)' => "icon_no.gif" ,
'(n)' => "icon_no.gif" ,
'(})' => "icon_arrow.gif" ,
':}' => "icon_arrow.gif" ,
'(!)' => "icon_exclaim.gif" ,
'(?)' => "icon_question.gif" ,
'(%)' => "icon_idea.gif" ,
'(mr)' => "icon_mrgreen.gif" ,
':-#' => "icon_silent.gif" ,
'(cyc)' => "icon_cyclops.gif" ,
'(sick)'=> "icon_sick.gif"
);
foreach ($smilies AS $find => $character)
{
$text = str_replace(htmlentities($find), "<img src=\"". $smiliesDir . $character ."\" alt=\"\" />", $text);
}
return $text;
}
Next find this line:
echo substr(stripslashes($fulltext), 0, $shorten);
and replace it with this:
echo bb_smilies(substr(stripslashes($fulltext), 0, $shorten));
TO ADD SMILIES IN COMMENTSin the comments function find the line
echo "<div class='comments'><p>" .cleanXSS($r['comment']). "</p>";
and replace with:
echo "<div class='comments'><p>" .bb_smilies(cleanXSS($r['comment'])). "</p>";