Darn, can't just move the translation of < and > to after the gramelin code because the gramelin code inserts <img> tags.

This works, however. Around line 923 of libs/ubbthreads.inc.php, translate the smiley code characters also. Now they'll match the text, if they occur.

Change:
Code
if ($smiley) {
    @eval("\$string = $code;");
To:
Code
if ($smiley) {
   $smiley = str_replace( '&', '&amp;', $smiley );
   $smiley = str_replace( '<', '&lt;', $smiley );
   $smiley = str_replace( '>', '&gt;', $smiley );
   @eval("\$string = $code;");
This works on my system.

Another advantage of this is you can now safely insert $smiley into the ALT of the image tags that follow a few lines down (the first two). I've also inserted TITLEs to help explain the gramelins to anyone that doesn't recognize them.

OK, so this is the entire IF statement:
Code
if ($smiley) {
   $smiley = str_replace( '&', '&amp;', $smiley );
   $smiley = str_replace( '<', '&lt;', $smiley );
   $smiley = str_replace( '>', '&gt;', $smiley );

   @eval("\$string = $code;");
   $string = preg_quote($string,'/');
   $smiley = preg_quote($smiley,'/');
   for($i = 0; $i< 2; $i++) {
      $body = preg_replace("/( |\n|^|\r\])$smiley( |$|\n|\r|\[)/i","\\1<img src=\"{$config['BASE_URL']}/images/graemlins/default/$image\" alt=\"$smiley\" title=\"$string\" height=\"$height\" width=\"$width\" />\\2",$body);
   }
   $body = preg_replace("/(\[|:)$string(\]|:)/i","<img src=\"{$config['BASE_URL']}/images/graemlins/default/$image\" alt=\"$smiley\" title=\"$string\" height=\"$height\" width=\"$width\" />",$body);
} else {
   @eval("\$string = $code;");
   $string = preg_quote($string,'/');
   $body = preg_replace("/(\[|:)$string(\]|:)/i","<img src=\"{$config['BASE_URL']}/images/graemlins/default/$image\" alt=\"\" title=\"$string\" height=\"$height\" width=\"$width\" />",$body);
}

This also fulfills this suggestion.

Last edited by GregH; 11/06/2006 7:25 AM.