...

View Full Version : Disable smiley in code



celestine
06-03-2004, 03:27 AM
Hi

I'm coding a forum and would like to disable smilies in between the [ code ] string. Problem is that I have 2 arrays that do the smiley and formatting functions but I can't seem to modify the function to insert the code check in.



$codes = array(
"\n" => "<br />",

'' => '<b>',
'' => '</b>',
'' => '<i>',
'' => '</i>',

'' => '<u>',
'' => '</u>',

'' => '<ol>',
'' => '</ol>',
'' => '<li>',
'' => '</li>',

'' => '<ul>',
'' => '</ul>',
'
' => '<div class="code">',
'' => '</div>',

'' => '<center>',
'' => '</center>',

'' => '<strike>',
'' => '</strike>',

'
' => '<div class="quote">',
'' => '</div>'
);

$smilies = array(
':)' => 'smile.gif',
':smile:' => 'smile.gif',
':cool:' => 'cool.gif',
':grin:' => 'vhappy.gif',
':D' => 'vhappy.gif',

':sad:' => 'sad.gif',
':wink:' => 'wink.gif',
':b' => 'tounge.gif',
':p' => 'tounge.gif',

':mad:' => 'mad.gif',
':evil:' => 'evil.gif',
':pirate:' => 'pirate.gif',
':grrr:' => 'grrr.png',

':dead:' => 'dead.png',
':wtf:' => 'wtf.png',
':sweat:' => 'llsweatdrop.gif',

':day:' => 'bday.gif',
':lol:' => 'lol.gif',
':cry:' => 'cry.gif',

':bla:' => 'bla.gif',
':o.o:' => 'oO.gif',
':zz:' => 'sleep.gif',

':err:' => 'err.png',
':sleep:' => 'sleep.gif',
':psh:' => 'psh.png',

':shock:' => 'shock.png',
':@.@' => 'twitch.gif',
':ship:' => 'ship.gif',
':love:' => 'love.gif',

':hammer:' => 'hammer.gif',
':Blush' => 'blush.gif',
':clap:' => 'clapping.gif',
':hug:' => 'hug.gif'
);

foreach($codes as $code=>$html) { $tr_entry = str_replace($code, $html, $tr_entry); }
foreach($smilies as $smile=>$image) {

$tr_entry = str_replace($smile, "<img src=\"smilies/$image\">", $tr_entry);
$tr_entry = str_replace("$#39;","'", $tr_entry);
}


can someone enlighten me? thanks for the trouble.

sweenster
06-03-2004, 01:36 PM
why not set a variable $code=1 whenever the {code} tag is opened, then set $code=0 when the {/code} tag is closed.

Then put an IF statement on the function that prints the smileys that only allows them to be displayed if $code=0

celestine
06-04-2004, 02:57 AM
do I use regex to look for {code} or I edit the function array to set
'[code]' => '$code=1',
instead? Thanks for helping.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum