PHP gevorderde |
|
Hallo,
Het is me gelukt om smilies te krijgen.Enkel wil ik ook nog [ b ][/ b ],...
Maar alleen... Het lukt me niet om als ik [ b ] heb een [/ b ] te laten plaatsen.(met dezelfde knop)
Me script:
<?php
function replace($bericht){
$bericht = htmlspecialchars($bericht);
$bericht = nl2br($bericht);
$bericht = preg_replace("#\[b\](.*?)\[/b\]#si","<b>\\1</b>", $bericht);
$bericht = preg_replace("#\[u\](.*?)\[/u\]#si","<u>\\1</u>", $bericht);
$bericht = preg_replace("#\[i\](.*?)\[/i\]#si","<i>\\1</i>", $bericht);
$bericht = preg_replace("#\[url\](.*?)\[/url\]#si","<a href=\\1 target=_blank>\\1</a>", $bericht);
$bericht = preg_replace("#\[url=(.*?)\](.*?)\[/url\]#si","<a href=\\1 target=_blank>\\2</a>", $bericht);
$bericht = preg_replace("#\[img\](.*?)\[/img\]#si","<img src=\\1>", $bericht);
$bericht = preg_replace("#\[color=(.*?)\](.*?)\[/color\]#si","<font color=\\1>\\2</font>", $bericht);
$smiles = array('(ARROW)'=>'arrow.gif',
'(BADGRIN)'=>'badgrin.gif',
'(BIGGRIN)'=>'biggrin.gif',
'(CONFUSED)'=>'confused.gif',
'(COOL)'=>'cool.gif',
'(CRY)'=>'cry.gif',
'(DOUBT)'=>'doubt.gif',
'(EVIL)'=>'evil.gif',
'(EXCLAIM)'=>'exclaim.gif',
'(IDEA)'=>'idea.gif',
'(LOL)'=>'lol.gif',
'(MAD)'=>'mad.gif',
'(NEUTRAL)'=>'neutral.gif',
'(QUESTION)'=>'question.gif',
'(RAZZ)'=>'razz.gif',
'(REDFACE)'=>'redface.gif',
'(ROLLEYES)'=>'rolleyes.gif',
'(SAD)'=>'sad.gif',
'(SHOCK)'=>'shock.gif',
'(SMILE)'=>'smile.gif',
'(SURPRISED)'=>'surprised.gif',
'(WINK)'=>'wink.gif');
foreach($smiles as $smile=>$image){
$bericht = str_replace($smile,"<img src=/provenzano/smilies/".$image.">", $bericht);
}
return $bericht;
}
<script type="text/javascript">
function replaceSmilie(smilie) {
document.priveber.bericht.value += smilie+" ";
document.priveber.bericht.focus();
}
</script>
<a href="javascript:replaceSmilie('(ARROW)')"><img src="smilies/arrow.gif" border="0"></a>
<a href="javascript:replaceSmilie('(BADGRIN)')" ><img src="smilies/badgrin.gif" border="0"></a>
<a href="javascript:replaceSmilie('(BIGGRIN)')" ><img src="smilies/biggrin.gif" border="0"></a>
<a href="javascript:replaceSmilie('(CONFUSED)')" ><img src="smilies/confused.gif" border="0"></a>
<a href="javascript:replaceSmilie('(COOL)')" ><img src="smilies/cool.gif" border="0"></a>
<a href="javascript:replaceSmilie('(CRY)')" ><img src="smilies/cry.gif" border="0"></a>
<a href="javascript:replaceSmilie('(DOUBT)')" ><img src="smilies/doubt.gif" border="0"></a>
<a href="javascript:replaceSmilie('(EVIL)')" ><img src="smilies/evil.gif" border="0"></a>
<a href="javascript:replaceSmilie('(EXCLAIM)')" ><img src="smilies/exclaim.gif" border="0"></a>
<a href="javascript:replaceSmilie('(IDEA)')" ><img src="smilies/idea.gif" border="0"></a>
<a href="javascript:replaceSmilie('(LOL)')" ><img src="smilies/lol.gif" border="0"></a>
<a href="javascript:replaceSmilie('(MAD)')" ><img src="smilies/mad.gif" border="0"></a>
<a href="javascript:replaceSmilie('(NEUTRAL)')" ><img src="smilies/neutral.gif" border="0"></a>
<a href="javascript:replaceSmilie('(QUESTION)')" ><img src="smilies/question.gif" border="0"></a>
<a href="javascript:replaceSmilie('(RAZZ)')" ><img src="smilies/razz.gif" border="0"></a>
<a href="javascript:replaceSmilie('(REDFACE)')" ><img src="smilies/redface.gif" border="0"></a>
<a href="javascript:replaceSmilie('(ROLLEYES)')" ><img src="smilies/rolleyes.gif" border="0"></a>
<a href="javascript:replaceSmilie('(SAD)')" ><img src="smilies/sad.gif" border="0"></a>
<a href="javascript:replaceSmilie('(SHOCK)')" ><img src="smilies/shock.gif" border="0"></a>
<a href="javascript:replaceSmilie('(SMILE)')" ><img src="smilies/smile.gif" border="0"></a>
<a href="javascript:replaceSmilie('(SURPRISED)')" ><img src="smilies/surprised.gif" border="0"></a>
<a href="javascript:replaceSmilie('(WINK)')" ><img src="smilies/wink.gif" border="0"></a>
?>
<?php function replace($bericht){ $bericht = nl2br($bericht); $bericht = preg_replace("#\[b\](.*?)\[/b\]#si","<b>\\1</b>", $bericht); $bericht = preg_replace("#\[u\](.*?)\[/u\]#si","<u>\\1</u>", $bericht); $bericht = preg_replace("#\[i\](.*?)\[/i\]#si","<i>\\1</i>", $bericht); $bericht = preg_replace("#\[url\](.*?)\[/url\]#si","<a href=\\1 target=_blank>\\1</a>", $bericht); $bericht = preg_replace("#\[url=(.*?)\](.*?)\[/url\]#si","<a href=\\1 target=_blank>\\2</a>", $bericht); $bericht = preg_replace("#\[img\](.*?)\[/img\]#si","<img src=\\1>", $bericht); $bericht = preg_replace("#\[color=(.*?)\](.*?)\[/color\]#si","<font color=\\1>\\2</font>", $bericht); $smiles = array('(ARROW)'=>'arrow.gif', '(BADGRIN)'=>'badgrin.gif', '(BIGGRIN)'=>'biggrin.gif', '(CONFUSED)'=>'confused.gif', '(COOL)'=>'cool.gif', '(CRY)'=>'cry.gif', '(DOUBT)'=>'doubt.gif', '(EVIL)'=>'evil.gif', '(EXCLAIM)'=>'exclaim.gif', '(IDEA)'=>'idea.gif', '(LOL)'=>'lol.gif', '(MAD)'=>'mad.gif', '(NEUTRAL)'=>'neutral.gif', '(QUESTION)'=>'question.gif', '(RAZZ)'=>'razz.gif', '(REDFACE)'=>'redface.gif', '(ROLLEYES)'=>'rolleyes.gif', '(SAD)'=>'sad.gif', '(SHOCK)'=>'shock.gif', '(SMILE)'=>'smile.gif', '(SURPRISED)'=>'surprised.gif', '(WINK)'=>'wink.gif'); foreach($smiles as $smile=>$image){ $bericht = str_replace($smile,"<img src=/provenzano/smilies/".$image.">", $bericht); } return $bericht; } <script type="text/javascript"> function replaceSmilie(smilie) { document.priveber.bericht.value += smilie+" "; document.priveber.bericht.focus(); } </script> <a href="javascript:replaceSmilie('(ARROW)')"><img src="smilies/arrow.gif" border="0"></a> <a href="javascript:replaceSmilie('(BADGRIN)')" ><img src="smilies/badgrin.gif" border="0"></a> <a href="javascript:replaceSmilie('(BIGGRIN)')" ><img src="smilies/biggrin.gif" border="0"></a> <a href="javascript:replaceSmilie('(CONFUSED)')" ><img src="smilies/confused.gif" border="0"></a> <a href="javascript:replaceSmilie('(COOL)')" ><img src="smilies/cool.gif" border="0"></a> <a href="javascript:replaceSmilie('(CRY)')" ><img src="smilies/cry.gif" border="0"></a> <a href="javascript:replaceSmilie('(DOUBT)')" ><img src="smilies/doubt.gif" border="0"></a> <a href="javascript:replaceSmilie('(EVIL)')" ><img src="smilies/evil.gif" border="0"></a> <a href="javascript:replaceSmilie('(EXCLAIM)')" ><img src="smilies/exclaim.gif" border="0"></a> <a href="javascript:replaceSmilie('(IDEA)')" ><img src="smilies/idea.gif" border="0"></a> <a href="javascript:replaceSmilie('(LOL)')" ><img src="smilies/lol.gif" border="0"></a> <a href="javascript:replaceSmilie('(MAD)')" ><img src="smilies/mad.gif" border="0"></a> <a href="javascript:replaceSmilie('(NEUTRAL)')" ><img src="smilies/neutral.gif" border="0"></a> <a href="javascript:replaceSmilie('(QUESTION)')" ><img src="smilies/question.gif" border="0"></a> <a href="javascript:replaceSmilie('(RAZZ)')" ><img src="smilies/razz.gif" border="0"></a> <a href="javascript:replaceSmilie('(REDFACE)')" ><img src="smilies/redface.gif" border="0"></a> <a href="javascript:replaceSmilie('(ROLLEYES)')" ><img src="smilies/rolleyes.gif" border="0"></a> <a href="javascript:replaceSmilie('(SAD)')" ><img src="smilies/sad.gif" border="0"></a> <a href="javascript:replaceSmilie('(SHOCK)')" ><img src="smilies/shock.gif" border="0"></a> <a href="javascript:replaceSmilie('(SMILE)')" ><img src="smilies/smile.gif" border="0"></a> <a href="javascript:replaceSmilie('(SURPRISED)')" ><img src="smilies/surprised.gif" border="0"></a> <a href="javascript:replaceSmilie('(WINK)')" ><img src="smilies/wink.gif" border="0"></a> ?>
|