login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > PHP > Gastenboeken > Gastenboek + ubb en smileys met database

Gastenboek + ubb en smileys met database

Auteur: djmatti - 02 november 2006 - 19:42 - Gekeurd door: Wijnand - Hits: 16672 - Aantal punten: 4.50 (11 stemmen)




Ubb van het gastenboek mede mogelijk gemaakt door GTW, en met hulp van GTW is dat gastenboek gemaakt.

de smileys moeten in de map: images in die map moet de map: forum in die map moet de map yellow en daarin moeten de smileys!

De smileys zitten in de download

Er zit een functie in tegen flooding/dubbelpost, de user kan slechts 1x per minuut posten

verder zit er een scheldwoordfilter in (kom je vanzelf tegen als je in het script kijkt) alles kan je verder naar eigen wensen aanpassen

Veel succes ermee
Mvg djmatti

Code:
Verbinding.php
  1. <?php
  2. $dbhost = "localhost";
  3. $db = "databasenaam";
  4. $username = "username";
  5. $dbww = "pass";
  6. mysql_connect($dbhost,$username,$dbww);
  7. ?>

Toon.php
  1. <?php
  2. include("forum_ubb.php");
  3. include("verbinding.php");
  4. $query = "SELECT Name, Email, Message FROM Guestbook ORDER BY ID Desc";
  5. $result = mysql_query($query) or die ("mysql error!");
  6. $num = mysql_num_rows($result);
  7.  
  8. while($obj=mysql_fetch_object($result)){
  9. $name = $obj->Name;
  10. $email = $obj->Email;
  11. $msg = $obj->Message;
  12. ?>
  13. <table border="1" align="center">
  14. <tr><td>Geplaatst door:</td>
  15. <td><?=$name;?></td></tr>
  16. <tr><td>E-mail:</td>
  17. <td><?=$email;?></td></tr>
  18. <tr><td>Bericht:</td>
  19. <td><?=replace($msg);?></td></tr>
  20. </table><br />
  21. <?php } ?>
  22.  
  23. <center><a href="toevoegen.php">Voeg een bericht toe</a></center>


toevoegen.php
  1. <?php
  2. include "verbinding.php";
  3. include "forum_ubb.php";
  4. if ($_POST["submit"]) {
  5. if(isset($_COOKIE['gastenboekcookie'])){
  6. die("Om fout gebruik (flooding / dubbelposts) van het forum te voorkomen kun je slechts 1 bericht per minuut plaatsen.");
  7. exit();
  8. }
  9. $naam = $_POST['naam'];
  10. $email = $_POST['email'];
  11. $msg = $_POST['msg'];
  12.  
  13. $naam = htmlspecialchars($naam);
  14. $email = htmlspecialchars($email);
  15. $msg = htmlspecialchars($msg);
  16.  
  17. $naam = strip_tags($naam);
  18. $email = strip_tags($email);
  19. $msg = strip_tags($msg);
  20. /* scheldwoordfilter je kan zelf nog toevoegen */
  21. $msg = addslashes($msg);
  22. $msg = eregi_replace('klote','***',$msg);
  23. $msg = eregi_replace('kut','***',$msg);
  24. /*einde scheldwoord filter*/
  25. $sql = "INSERT INTO Guestbook SET Name='$naam', Email='$email', Message='$msg'";
  26. $query = mysql_query($sql) or die("bericht niet geplaatst!");
  27. echo "Bericht succesvol geplaatst <a href=\"toon.php\">Ga terug naar het gastenboek</a>";
  28. setcookie("gastenboekcookie","geset",time()+100,"/");
  29. } else { ?>
  30.  
  31. <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
  32. Naam: <input type="text" name="naam"><br>
  33. Email: <input type="text" name="email"><br>
  34. Bericht: <textarea name="msg" rows="5" cols="30"></textarea><br>
  35. <input type="submit" name="submit" value="submit">
  36. </form>
  37. <?php } ?>

forum_ubb
  1. <?php
  2. function replace($text){
  3. /*bold*/ $text = preg_replace("#\[b\](.*?)\[/b\]#si","<b>\\1</b>", $text);
  4. /*underline*/ $text = preg_replace("#\[u\](.*?)\[/u\]#si","<u>\\1</u>", $text);
  5. /* italic*/ $text = preg_replace("#\[i\](.*?)\[/i\]#si","<i>\\1</i>", $text);
  6. /*url 1*/ $text = preg_replace("#\[url\](.*?)\[/url\]#si","<a href=\\1 target=_blank>\\1</a>", $text);
  7. /*url 2*/ $text = preg_replace("#\[url=(.*?)\](.*?)\[/url\]#si","<a href=\\1 target=_blank>\\2</a>", $text);
  8. /*imagetag*/ $text = preg_replace("#\[img\](.*?)\[/img\]#si","<img src=\\1>", $text);
  9. /*align*/ $text = preg_replace("#\[align=(.*?)\](.*?)\[/align\]#si","<p align=\\1>\\2</p>", $text);
  10. /*size*/ $text = preg_replace("#\[size=(.*?)\](.*?)\[/size\]#si","<font size=\\1>\\2</font>", $text);
  11. /*color*/ $text = preg_replace("#\[color=(.*?)\](.*?)\[/color\]#si","<font color=\\1>\\2</font>", $text);
  12. /*face*/ $text = preg_replace("#\[font=(.*?)\](.*?)\[/font\]#si","<font face=\\1>\\2</font>", $text);
  13. /*quote*/ $text = preg_replace("#\[quote\](.*?)\[/quote\]#si",'Citaat:<table border="1" align="right" width="94%" style="background-color:#CCCCCC;border-style:inset;"><tr><td>\\1</td></tr></table><br /><br />', $text);
  14. /*special quote*/ $text = preg_replace("#\[quote=(.*?)\](.*?)\[/quote\]#si", '\\1 zei:<table border="1" align="right" width="94%" style="background-color:#CCCCCC;border-style:inset;"><tr><td>\\2</td></tr></table><br /><br />', $text);
  15. $text = nl2br($text);
  16. /*smiley's :P */
  17. $text = str_replace(":arrow:",'<img src="images/forum/yellow/aroow.gif" />',$text);
  18. $text = str_replace("|)",'<img src="images/forum/yellow/badgrin.gif" />',$text);
  19. $text = str_replace(":D",'<img src="images/forum/yellow/biggrin.gif" />',$text);
  20. $text = str_replace(":d",'<img src="images/forum/yellow/biggrin.gif" />',$text);
  21. $text = str_replace(":-D",'<img src="images/forum/yellow/biggrin.gif" />',$text);
  22. $text = str_replace(":-d",'<img src="images/forum/yellow/biggrin.gif" />',$text);
  23. $text = str_replace(":S",'<img src="images/forum/yellow/confused.gif" />',$text);
  24. $text = str_replace(":?",'<img src="images/forum/yellow/confused.gif" />',$text);
  25. $text = str_replace(":cool:",'<img src="images/forum/yellow/cool.gif" />',$text);
  26. $text = str_replace("8)",'<img src="images/forum/yellow/cool.gif" />',$text);
  27. $text = str_replace(":cry:",'<img src="images/forum/yellow/cry.gif" />',$text);
  28. $text = str_replace(":'(",'<img src="images/forum/yellow/cry.gif" />',$text);
  29. $text = str_replace(":\/:",'<img src="images/forum/yellow/doubt.gif" />',$text);
  30. $text = str_replace(":evil:",'<img src="images/forum/yellow/evil.gif" />',$text);
  31. $text = str_replace(":!:",'<img src="images/forum/yellow/exclaim.gif" />',$text);
  32. $text = str_replace(":idea:",'<img src="images/forum/yellow/idea.gif" />',$text);
  33. $text = str_replace(":)",'<img src="images/forum/yellow/lol.gif" />',$text);
  34. $text = str_replace(":@",'<img src="images/forum/yellow/mad.gif" />',$text);
  35. $text = str_replace(":|",'<img src="images/forum/yellow/neutral.gif" />',$text);
  36. $text = str_replace(":?:",'<img src="images/forum/yellow/question.gif" />',$text);
  37. $text = str_replace(":P",'<img src="images/forum/yellow/razz.gif" />',$text);
  38. $text = str_replace(":p",'<img src="images/forum/yellow/razz.gif" />',$text);
  39. $text = str_replace(":-P",'<img src="images/forum/yellow/razz.gif" />',$text);
  40. $text = str_replace(":-p",'<img src="images/forum/yellow/razz.gif" />',$text);
  41. $text = str_replace(":$",'<img src="images/forum/yellow/redface.gif" />',$text);
  42. $text = str_replace(":roll:",'<img src="images/forum/yellow/rolleyes.gif" />',$text);
  43. $text = str_replace("8-)",'<img src="images/forum/yellow/rolleyes.gif" />',$text);
  44. $text = str_replace(":(",'<img src="images/forum/yellow/sad.gif" />',$text);
  45. $text = str_replace(":-(",'<img src="images/forum/yellow/sad.gif" />',$text);
  46. $text = str_replace(":sad:",'<img src="images/forum/yellow/sad.gif" />',$text);
  47. $text = str_replace(":shock:",'<img src="images/forum/yellow/shock.gif" />',$text);
  48. $text = str_replace(":smile:",'<img src="images/forum/yellow/smile.gif" />',$text);
  49. $text = str_replace(":o",'<img src="images/forum/yellow/suprised.gif" />',$text);
  50. $text = str_replace(":O",'<img src="images/forum/yellow/suprised.gif" />',$text);
  51. $text = str_replace(":-o",'<img src="images/forum/yellow/suprised.gif" />',$text);
  52. $text = str_replace(":-O",'<img src="images/forum/yellow/suprised.gif" />',$text);
  53. $text = str_replace(":wink:",'<img src="images/forum/yellow/wink.gif" />',$text);
  54. $text = str_replace(";)",'<img src="images/forum/yellow/wink.gif" />',$text);
  55. $text = str_replace(";-)",'<img src="images/forum/yellow/wink.gif" />',$text);
  56. $text = str_replace("^^",'<img src="images/forum/yellow/^^.gif" />',$text);
  57. /* einde smiley's */
  58. return $text;
  59. }
  60. ?>

mysql tabel
  1. Create Table Guestbook (
  2. ID int(10) NOT NULL auto_increment,
  3. Name Varchar(50) NOT NULL,
  4. Email Varchar(50) NOT NULL,
  5. Message Text NOT NULL,
  6. PRIMARY KEY (ID)
  7. ) TYPE=MyISAM;
Download code! Download code (.txt)

 Stemmen
Niet ingelogd.

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