Ubb functie
Auteur: Sjaakmans - 14 augustus 2005 - 00:40 - Gekeurd door: nemesiskoen - Hits: 10792 - Aantal punten: 3.06 (9 stemmen)
Om hem te gebruiken doe je bijv dit:
<?
$text = replace($iets);
echo $text;
?>
<?
$text = replace( $iets ) ;
?>
Niet moeilijk toch?
Code:
<?php
function replace($text){
$text = htmlspecialchars($text);
$text = nl2br($text);
$sqles = mysql_query("SELECT * FROM `forbidden`");
while($for = mysql_fetch_object($sqles)){
$text = str_replace($for->word, $for->replacement, $text);
}
$text = preg_replace("#\[b\](.*?)\[/b\]#si","<b>\\1</b>", $text);
$text = preg_replace("#\[u\](.*?)\[/u\]#si","<u>\\1</u>", $text);
$text = preg_replace("#\[i\](.*?)\[/i\]#si","<i>\\1</i>", $text);
$text = preg_replace("#\[url\](.*?)\[/url\]#si","<a href=\\1 target=_blank>\\1</a>", $text);
$text = preg_replace("#\[url=(.*?)\](.*?)\[/url\]#si","<a href=\\1 target=_blank>\\2</a>", $text);
$text = preg_replace("#\[img\](.*?)\[/img\]#si","<img src=\\1>", $text);
$text = preg_replace("#\[color=(.*?)\](.*?)\[/color\]#si","<font color=\\1>\\2</font>", $text);
$text = preg_replace("#\[move\](.*?)\[/move\]#si","<marquee>\\1</marquee>", $text);
$text = preg_replace("#\[edit\](.*?)\[/edit\]#si","<font color=orange><b>Edit</b></font>: \\1", $text);
$smiles = array(':!:'=>'!',
':@'=>'angry',
':yes:'=>'approve',
':D'=>'big',
':bump:'=>'blackeye',
':$'=>'blush',
':box:'=>'box',
':buckfish:'=>'buckfush',
':burp:'=>'burp',
':beer:'=>'cheers',
':C'=>'clown',
'(h)'=>'cool',
':dead:'=>'dead',
':s'=>'dry',
':evil:'=>'evil',
':)'=>'happy',
'hmmm'=>'hmm',
'(k)'=>'kiss',
':lol:'=>'laugh',
':o'=>'ohmy',
':O'=>'ohmy',
':oops:'=>'oops',
':puke:'=>'pukeface',
':?:'=>'question',
':('=>'sad',
':T'=>'shy',
':t'=>'shy',
':|'=>'sleep',
':hup:'=>'thumbsup',
':P'=>'tongue',
':p'=>'tongue',
':d'=>'v.happy',
':D'=>'v.happy',
':S'=>'wacko',
':s'=>'wacko',
';)'=>'wink',
';-)'=>'wink2');
foreach($smiles as $smile=>$image){
$text = str_replace($smile,"<img src=http://hierjesite.nl/images/smilies/".$image.".gif>", $text);
}
return $text;
}
?>
<?php
function replace( $text ) {
$text = str_replace ( $for -> word , $for -> replacement , $text ) ; }
$text = preg_replace ( "#\[b\](.*?)\[/b\]#si" , "<b>\\1 </b>" , $text ) ; $text = preg_replace ( "#\[u\](.*?)\[/u\]#si" , "<u>\\1 </u>" , $text ) ; $text = preg_replace ( "#\[i\](.*?)\[/i\]#si" , "<i>\\1 </i>" , $text ) ;
$text = preg_replace ( "#\[url\](.*?)\[/url\]#si" , "<a href=\\1 target=_blank>\\1 </a>" , $text ) ; $text = preg_replace ( "#\[url=(.*?)\](.*?)\[/url\]#si" , "<a href=\\1 target=_blank>\\2 </a>" , $text ) ;
$text = preg_replace ( "#\[img\](.*?)\[/img\]#si" , "<img src=\\1 >" , $text ) ;
$text = preg_replace ( "#\[color=(.*?)\](.*?)\[/color\]#si" , "<font color=\\1 >\\2 </font>" , $text ) ;
$text = preg_replace ( "#\[move\](.*?)\[/move\]#si" , "<marquee>\\1 </marquee>" , $text ) ;
$text = preg_replace ( "#\[edit\](.*?)\[/edit\]#si" , "<font color=orange><b>Edit</b></font>: \\1 " , $text ) ;
$smiles = array ( ':!:' => '!' , ':@' => 'angry' ,
':yes:' => 'approve' ,
':D' => 'big' ,
':bump:' => 'blackeye' ,
':$' => 'blush' ,
':box:' => 'box' ,
':buckfish:' => 'buckfush' ,
':burp:' => 'burp' ,
':beer:' => 'cheers' ,
':C' => 'clown' ,
'(h)' => 'cool' ,
':dead:' => 'dead' ,
':s' => 'dry' ,
':evil:' => 'evil' ,
':)' => 'happy' ,
'hmmm' => 'hmm' ,
'(k)' => 'kiss' ,
':lol:' => 'laugh' ,
':o' => 'ohmy' ,
':O' => 'ohmy' ,
':oops:' => 'oops' ,
':puke:' => 'pukeface' ,
':?:' => 'question' ,
':(' => 'sad' ,
':T' => 'shy' ,
':t' => 'shy' ,
':|' => 'sleep' ,
':hup:' => 'thumbsup' ,
':P' => 'tongue' ,
':p' => 'tongue' ,
':d' => 'v.happy' ,
':D' => 'v.happy' ,
':S' => 'wacko' ,
':s' => 'wacko' ,
';)' => 'wink' ,
';-)' => 'wink2' ) ;
foreach ( $smiles as $smile => $image ) {
$text = str_replace ( $smile , "<img src=http://hierjesite.nl/images/smilies/" . $image . ".gif>" , $text ) ; }
return $text ;
}
?>
En dit stukje:
<?php
$sqles = mysql_query("SELECT * FROM `forbidden`");
while($for = mysql_fetch_object($sqles)){
$text = str_replace($for->word, $for->replacement, $text);
}
?>
<?php
$text = str_replace ( $for -> word , $for -> replacement , $text ) ; }
?>
mag je eruit laten je kan het ook gebruiken maar dan moet je een table toevoegen die niet meer in mijn database staat hehe. Oud script eigenlijk
De smilies heb ik ook niet meer moet je anders maar eff door je eigen veranderen Download code (.txt)
Stemmen
Niet ingelogd.