login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > PHP > UBB & Smilies > Ubb functie

Ubb functie

Auteur: Sjaakmans - 14 augustus 2005 - 00:40 - Gekeurd door: nemesiskoen - Hits: 10665 - Aantal punten: 3.06 (9 stemmen)



Om hem te gebruiken doe je bijv dit:
  1. <?
  2. $text = replace($iets);
  3.  
  4. echo $text;
  5. ?>


Niet moeilijk toch?

Code:
  1. <?php
  2. function replace($text){
  3. $text = htmlspecialchars($text);
  4. $text = nl2br($text);
  5.  
  6. $sqles = mysql_query("SELECT * FROM `forbidden`");
  7. while($for = mysql_fetch_object($sqles)){
  8. $text = str_replace($for->word, $for->replacement, $text);
  9. }
  10.  
  11.  
  12. $text = preg_replace("#\[b\](.*?)\[/b\]#si","<b>\\1</b>", $text);
  13. $text = preg_replace("#\[u\](.*?)\[/u\]#si","<u>\\1</u>", $text);
  14. $text = preg_replace("#\[i\](.*?)\[/i\]#si","<i>\\1</i>", $text);
  15.  
  16. $text = preg_replace("#\[url\](.*?)\[/url\]#si","<a href=\\1 target=_blank>\\1</a>", $text);
  17. $text = preg_replace("#\[url=(.*?)\](.*?)\[/url\]#si","<a href=\\1 target=_blank>\\2</a>", $text);
  18.  
  19. $text = preg_replace("#\[img\](.*?)\[/img\]#si","<img src=\\1>", $text);
  20.  
  21. $text = preg_replace("#\[color=(.*?)\](.*?)\[/color\]#si","<font color=\\1>\\2</font>", $text);
  22.  
  23. $text = preg_replace("#\[move\](.*?)\[/move\]#si","<marquee>\\1</marquee>", $text);
  24.  
  25. $text = preg_replace("#\[edit\](.*?)\[/edit\]#si","<font color=orange><b>Edit</b></font>: \\1", $text);
  26.  
  27. $smiles = array(':!:'=>'!',
  28. ':@'=>'angry',
  29. ':yes:'=>'approve',
  30. ':D'=>'big',
  31. ':bump:'=>'blackeye',
  32. ':$'=>'blush',
  33. ':box:'=>'box',
  34. ':buckfish:'=>'buckfush',
  35. ':burp:'=>'burp',
  36. ':beer:'=>'cheers',
  37. ':C'=>'clown',
  38. '(h)'=>'cool',
  39. ':dead:'=>'dead',
  40. ':s'=>'dry',
  41. ':evil:'=>'evil',
  42. ':)'=>'happy',
  43. 'hmmm'=>'hmm',
  44. '(k)'=>'kiss',
  45. ':lol:'=>'laugh',
  46. ':o'=>'ohmy',
  47. ':O'=>'ohmy',
  48. ':oops:'=>'oops',
  49. ':puke:'=>'pukeface',
  50. ':?:'=>'question',
  51. ':('=>'sad',
  52. ':T'=>'shy',
  53. ':t'=>'shy',
  54. ':|'=>'sleep',
  55. ':hup:'=>'thumbsup',
  56. ':P'=>'tongue',
  57. ':p'=>'tongue',
  58. ':d'=>'v.happy',
  59. ':D'=>'v.happy',
  60. ':S'=>'wacko',
  61. ':s'=>'wacko',
  62. ';)'=>'wink',
  63. ';-)'=>'wink2');
  64. foreach($smiles as $smile=>$image){
  65. $text = str_replace($smile,"<img src=http://hierjesite.nl/images/smilies/".$image.".gif>", $text);
  66. }
  67.  
  68.  
  69. return $text;
  70. }
  71. ?>


En dit stukje:
  1. <?php
  2. $sqles = mysql_query("SELECT * FROM `forbidden`");
  3. while($for = mysql_fetch_object($sqles)){
  4. $text = str_replace($for->word, $for->replacement, $text);
  5. }
  6. ?>

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 veranderenDownload code! Download code (.txt)

 Stemmen
Niet ingelogd.

 Reacties
Post een reactie
Lees de reacties (4)
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.047s