login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > PHP > Nieuwssystemen > ReNS (Rensjuh's NieuwsSysteem) V1.5.6

ReNS (Rensjuh's NieuwsSysteem) V1.5.6

Auteur: Rens - 22 oktober 2004 - 15:42 - Gekeurd door: Dennisvb - Hits: 24739 - Aantal punten: 4.38 (28 stemmen)





Het nieuwssysteem maakt gebruik van 1 MySQL tabel.
Als er een fout is, in een MySQL query, word dit gemeld door includes/report_mysql.php
De bezoeker krijgt dan een (nette) error te zien, die je zelf in kunt stellen, en de pagina word gestopt.
De error komt dan in mysql_error.log te staan.

Je zult eerst het bestand includes/config.inc.php aan moeten passen. Alle lege velden dien je in te vullen. Het gaat dan om:
$MySQL['host'], $MySQL['user'], $MySQL['pass'], $MySQl['daba'], $admin['username'], $admin['password'], $admin['mailaddr'] en $img['smiles'].

Het voorbeeld en de smilies zal ik zo nog even online zetten.
Ook zet ik dan een download online.

De rest wijst voor zich lijkt me.
Voor vragen kun je me mailen op rensjuh[at]gmail[dot]com

Het systeem bestaat uit de volgende mappen & bestanden:

- nieuwssysteem
lezen.php
overzicht.php
nieuws.php

- admin
form.php
index.php
login.php
logout.php

- classes
class.pagenav.php
ip.php

- functions
text2ubb.php

- includes
config.inc.php
report_mysql.php

- smiles
23 smilies

Veel plezier er mee,
Rensjuh

Owjah, vertel me even wat je ervan vind als je het gebruikt. Vertel er ook meteen bij, wat je vind dat verbeterd moet/kan worden.

V1.5.6
- fix op regel 78 en 80

V1.5.5
- Bestand ip.php toegevoegd

V1.5
- Code aangepast 'De lat ligt hoger'

V1.1
- addslashes() toegevoegd
- stripslashes() toegevoegd

Code:
MySQL tabel
  1. CREATE TABLE nieuws (
  2. id int(11) NOT NULL auto_increment,
  3. titel varchar(255) NOT NULL default '',
  4. door varchar(255) NOT NULL default '',
  5. text text NOT NULL,
  6. datum varchar(10) NOT NULL default '',
  7. tijd varchar(5) NOT NULL default '',
  8. PRIMARY KEY (id)
  9. ) TYPE=MyISAM;


install.php
  1. <?PHP
  2. include("includes/config.inc.php");
  3. $sQuery = "CREATE TABLE nieuws (
  4. id int(11) NOT NULL auto_increment,
  5. titel varchar(255) NOT NULL default '',
  6. door varchar(255) NOT NULL default '',
  7. text text NOT NULL,
  8. datum varchar(10) NOT NULL default '',
  9. tijd varchar(5) NOT NULL default '',
  10. PRIMARY KEY (id)
  11. ) TYPE=MyISAM;";
  12. if(!$sResult = MySQL_Query($sQuery))
  13. {
  14. echo "Error!- De query kan niet uitgevoerd worden!";
  15. echo "<BR>";
  16. echo "<BR>";
  17. } else
  18. {
  19. echo "Query succesvol uitgevoerd!";
  20. }
  21. ?>


lezen.php
  1. <?PHP
  2. // sessie starten
  3.  
  4. // error reporting op E_ALL zetten
  5. // voor gebruik kun je het het beste op E_NONE zetten
  6. // voorkomt dat je layout raar gaat doen bij errors
  7.  
  8. include("includes/config.inc.php");
  9. include("functions/text2ubb.php");
  10. include("classes/class.pagenav.php");
  11. // enkele bestanden includen
  12. // - configuratie bestand
  13. // - functie voor de UBB code
  14. // - class voor de pagina navigatie
  15. ?>
  16. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  17. <HTML>
  18. <HEAD>
  19. <TITLE> Nieuwssysteem </TITLE>
  20. <META NAME="Author" CONTENT="Rensjuh">
  21. <META NAME="Description" CONTENT="Nieuwssysteem voor scripts library Sitemasters.be">
  22. </HEAD>
  23. <BODY>
  24. <?PHP
  25. if(IsSet($_GET['id']) && is_numeric($_GET['id']))
  26. {
  27. // als id is geset in de url en een nummer is
  28. $iId = $_GET['id'];
  29. // id in de var. iId zetten
  30. $sQuery = "SELECT * FROM nieuws WHERE id='".$iId."'";
  31. // SQL Query maken, nieuwsberichten ophalen waar id gelijk is aan iId
  32. $sResult = MySQL_Query($sQuery) or report_mysql("Nieuws ophalen", __FILE__, __LINE__, $sQuery);
  33. // SQL Query uitvoeren, of wanneer het niet uitgevoerd kan worden, een error printen + de error
  34. // in een bestandje zetten
  35. ?>
  36. <Center>
  37. <Table Border='1' BorderColor='#000000' CellPadding='0' CellSpacing='0' Width='500'>
  38. <?PHP
  39. // de while loop beginnen
  40. // zorgt dat het bericht op het scherm gezet word
  41. while($sRecord = MySQL_Fetch_Assoc($sResult))
  42. {
  43. ?>
  44. <Tr Width='500'>
  45. <Td Width='500'>
  46. <Div Style='margin-left: 15px;'>
  47. <?PHP
  48. echo $sRecord['titel']." | ".$sRecord['door']." | ".$sRecord['datum']." om ".$sRecord['tijd']."<BR>";
  49. // Titel | door | datum om tijd
  50. ?>
  51. </Div>
  52. <Hr Width='500' Color='#000000'>
  53. <Div Style='margin-left: 15px;'>
  54. <?PHP
  55. echo text2ubb($sRecord['text']);
  56. // het bericht, eerst door de text2ubb halen, dan op het scherm zetten
  57. ?>
  58. </Div>
  59. </Td>
  60. </Tr>
  61. <?PHP
  62. }
  63. } else
  64. {
  65. ?>
  66. <Tr Width='500'>
  67. <Th Width='500'>
  68. Error!- Verkeerde of geen ID nummer!
  69. </Th>
  70. </Tr>
  71. <?PHP
  72. }
  73. ?>
  74. <Tr Width='500'>
  75. <Td Width='500'>
  76. <Center>
  77. <A HREF='overzicht.php'>Keer terug</A>
  78. </Center>
  79. </Td>
  80. </Tr>
  81. </Table>
  82. </Center>
  83. </BODY>
  84. </HTML>


nieuws.php
  1. <?PHP
  2. // sessie starten
  3.  
  4. // error reporting op E_ALL zetten
  5. // voor gebruik kun je het het beste op E_NONE zetten
  6. // voorkomt dat je layout raar gaat doen bij errors
  7.  
  8. include("includes/config.inc.php");
  9. include("functions/text2ubb.php");
  10. include("classes/class.pagenav.php");
  11. // enkele bestanden includen
  12. // - configuratie bestand
  13. // - functie voor de UBB code
  14. // - class voor de pagina navigatie
  15. ?>
  16. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  17. <HTML>
  18. <HEAD>
  19. <TITLE> Nieuwssysteem </TITLE>
  20. <META NAME="Author" CONTENT="Rensjuh">
  21. <META NAME="Description" CONTENT="Nieuwssysteem voor scripts library Sitemasters.be">
  22. </HEAD>
  23. <BODY>
  24. <?PHP
  25. $sQuery = "SELECT * FROM nieuws ORDER BY id DESC LIMIT 0, ".$max['nieuws'];
  26. // SQL Query maken
  27. // Uit 'nieuws' ophalen, de X-aantal laatste berichten
  28. // in te stellen in het configuratie bestand
  29. $sResult = MySQL_Query($sQuery) or report_mysql("Nieuws ophalen", __FILE__, __LINE__, $sQuery);
  30. // SQL Query uitvoeren
  31. // kan hij niet uitgevoerd worden, error maken + in bestand plaatsen
  32. ?>
  33. <Center>
  34. <?PHP
  35. while($sRecord = MySQL_Fetch_Assoc($sResult))
  36. {
  37. ?>
  38. <Table Border='1' BorderColor='#000000' CellPadding='0' CellSpacing='0' Width='500' style='margin-top: 20px;'>
  39. <Tr Width='500'>
  40. <Td Width='500'>
  41. <Div Style='margin-left: 15px;'>
  42. <?PHP
  43. echo "<A HREF='lezen.php?id=".$sRecord['id']."'>".$sRecord['titel']."</A> | ".$sRecord['door']." | ".$sRecord['datum']." om ".$sRecord['tijd']."<BR>";
  44. // titel | door | datum om tijd
  45. ?>
  46. </Div>
  47. <Hr Width='500' Color='#000000'>
  48. <Div Style='margin-left: 15px;'>
  49. <?PHP
  50. echo text2ubb($sRecord['text']);
  51. // haal het bericht eerst door de functie
  52. // text2ubb heen
  53. // daarna met smilies + ubb op het scherm printen
  54. ?>
  55. </Div>
  56. </Td>
  57. </Tr>
  58. </Table>
  59. <?PHP
  60. }
  61. ?>
  62. <BR>
  63. <Table Border='1' BorderColor='#000000' CellPadding='0' CellSpacing='0' Width='500'>
  64. <Tr Width='500'>
  65. <Td Width='500'>
  66. <Div Style='margin-left: 15px;'>
  67. <?PHP
  68. $iAantal = MySQL_Num_Rows($sResult);
  69. if($iAantal == 0)
  70. {
  71. echo "Er zijn <B>geen</B> nieuwsberichten.<BR>";
  72. } else if($iAantal == 1)
  73. {
  74. echo "Er is <B>1</B> nieuwsbericht.<BR>";
  75. } else
  76. {
  77. echo "Er zijn <B>".$iAantal."</B> nieuwsberichten.<BR>";
  78. }
  79. ?>
  80.  
  81. &raquo;<A HREF='overzicht.php' Title='Nieuwsoverzicht'>Nieuwsoverzicht</A>
  82. </Div>
  83. </Td>
  84. </Tr>
  85. </Table>
  86. </Center>
  87. </BODY>
  88. </HTML>


overzicht.php
  1. <?PHP
  2. include("includes/config.inc.php");
  3. include("classes/class.pagenav.php");
  4. ?>
  5. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  6. <HTML>
  7. <HEAD>
  8. <TITLE> Nieuwssysteem </TITLE>
  9. <META NAME="Author" CONTENT="Rensjuh">
  10. <META NAME="Description" CONTENT="Nieuwssysteem voor scripts library Sitemasters.be">
  11. </HEAD>
  12. <BODY>
  13. <?PHP
  14. // deze query is voor het tellen van het aantal nieuwsberichten
  15. // het word doorgegeven aan classes/class.pagenav.php
  16. // die er vervolgens een pagina navigatie meemaakt.
  17. $sql = "SELECT * FROM nieuws";
  18. $res = MySQL_Query($sql) or report_mysql("Nieuws ophalen", __FILE__, __LINE__, $sql);
  19. $aantal = MySQL_Num_Rows($res);
  20.  
  21. if(IsSet($_GET['nav']))
  22. {
  23. $nav = $_GET['nav'];
  24. } else
  25. {
  26. $nav = "";
  27. }
  28.  
  29. $nav = new pagenav ($aantal, $max['overzicht'], $nav, "PageID=1");
  30. $van = $nav->get_startpoint(); // startpunt voor ophalen nieuwsberichten
  31.  
  32. // deze query is de echte query.
  33. // door deze query worden de nieuwsberichten voor die pagina
  34. // opgehaald. Dus bijv: vanaf 50 worden de volgende 50 opgehaald
  35. $sql = "SELECT * FROM nieuws ORDER BY id DESC LIMIT ".$van.", ".$max['overzicht'];
  36. $res = MySQL_Query($sql) or report_mysql("Nieuws ophalen", __FILE__, __LINE__, $sql);
  37. $num = MySQL_Num_Rows($res);
  38. if ($num > 0)
  39. {
  40. ?>
  41. <center>
  42. <Table Border='1' BorderColor='#000000' CellPadding='0' CellSpacing='0' Width='500'>
  43. <Tr Width='500'>
  44. <Td ColSpan='3'>
  45. <div align='center'>
  46. <?PHP
  47. echo $nav->makenav();
  48. ?>
  49. </div>
  50. </Td>
  51. </Tr>
  52. <?PHP
  53. while($rec = MySQL_Fetch_Assoc($res))
  54. {
  55. ?>
  56. <Tr Width='500'>
  57. <Td Width='50'>
  58. <?PHP
  59. echo $rec['id'];
  60. ?>
  61. </Td>
  62. <Td Width='300'>
  63. <?PHP
  64. echo "<A HREF='lezen.php?id=".$rec['id']."'>".$rec['titel']."</A>";
  65. ?>
  66. </Td>
  67. <Td Width='150'>
  68. <?PHP
  69. echo "<B>".$rec['datum']."</B> om <B>".$rec['tijd']."</B>";
  70. ?>
  71. </Td>
  72. </Tr>
  73. <?PHP
  74. }
  75. ?>
  76. </Table>
  77. </center>
  78. <?PHP
  79. }
  80. ?>
  81. </BODY>
  82. </HTML>


admin/form.php
  1. <?PHP
  2. // sessie starten voor de admin
  3.  
  4. // error reporting op E_ALL zetten
  5. // voor gebruik kun je het het beste op E_NONE zetten
  6. // voorkomt dat je layout raar gaat doen bij errors
  7.  
  8. include("../includes/config.inc.php");
  9. // het configuratie bestand includen
  10. ?>
  11. <!--
  12. de functie maken voor het klikbaar maken van smilies + ubb knoppen
  13. -->
  14. <script language="JavaScript">
  15. function smile (code){
  16. document.form.bericht.value = document.form.bericht.value + code;
  17. document.form.bericht.focus();
  18. }
  19. </script>
  20. <?PHP
  21. // checken of gebruiker is ingelogd en/of admin is
  22.  
  23. // niet ingelogd, echo een error
  24. if(!IsSet($_SESSION['login']) || $_SESSION['login'] != TRUE)
  25. {
  26. ?>
  27. Error!- Je hebt niet de juiste rechten!
  28. <BR>
  29. <Meta HTTP-Equiv="refresh" Content="3;url=index.php">
  30. <?PHP
  31. } else
  32. {
  33. // wel ingelogd
  34. // checken of er al gesubmit is
  35. // als er nog niet op de knop is geklikt, een formulier laten zien
  36. if(!IsSet($_POST['submit']))
  37. {
  38. ?>
  39. <Form Method='POST' Action='form.php' name='form'>
  40. <Tr Width='550'>
  41. <Td Width='150'>
  42. Door:
  43. </Td>
  44. <Td Width='450'>
  45. <Input Type='TEXT' Name='door' style='width: 350px; margin-left: 25px; margin-right: 25px;'>
  46. </Td>
  47. </Tr>
  48.  
  49. <Tr Width='550'>
  50. <Td Width='150'>
  51. Titel:
  52. </Td>
  53. <Td Width='450'>
  54. <Input Type='TEXT' Name='titel' style='width: 350px; margin-left: 25px;margin-right: 25px;'>
  55. </Td>
  56. </Tr>
  57.  
  58. <Tr Width='550'>
  59. <Td ColSpan='2'>
  60. <Center>
  61. <Input Type='BUTTON' Name='[b][/b]' Value='[b][/b]' style='width: 99px;' onClick='javascript: smile("[b][/b]");'>
  62. echo "<Input Type='BUTTON' Name='[u][/u]' Value='[u][/u]' style='width: 99px;' onClick='javascript: smile("[u][/u]");'>
  63. <Input Type='BUTTON' Name='[i][/i]' Value='[i][/i]' style='width: 99px;' onClick='javascript: smile("[i][/i]");'>
  64. <Input Type='BUTTON' Name='[email][/email]' Value='[email][/email]' style='width: 99px;' onClick='javascript: smile("[email][/email]");'>
  65. <Input Type='BUTTON' Name='[url][/url]' Value='[url][/url]' style='width: 99px;' onClick='javascript: smile("[url][/url]");'>
  66. </Center>
  67. </Td>
  68. </Tr>
  69.  
  70. <Tr Width='550'>
  71. <Td ColSpan='2'>
  72. <Center>
  73. <IMG Src='<?PHP echo$img['smiles']; ?>."/icon_arrow.gif' onClick='javascript: smile(":arrow:")'>
  74. <IMG Src='<?PHP echo$img['smiles']; ?>/icon_biggrin.gif' onClick='javascript: smile(":D");'>
  75. <IMG Src='<?PHP echo$img['smiles']; ?>/icon_confused.gif' onClick='javascript: smile(":S");'>
  76. <IMG Src='<?PHP echo$img['smiles']; ?>/icon_cool.gif' onClick='javascript: smile("8)");'>
  77. <IMG Src='<?PHP echo$img['smiles']; ?>/icon_cry.gif' onClick='javascript: smile(":*(");'>
  78.  
  79. <IMG Src='<?PHP echo$img['smiles']; ?>/icon_eek.gif' onClick='javascript: smile(":shock:");'>
  80. <IMG Src='<?PHP echo$img['smiles']; ?>/icon_evil.gif' onClick='javascript: smile(":evil:");'>
  81. <IMG Src='<?PHP echo$img['smiles']; ?>/icon_exclaim.gif' onClick='javascript: smile(":!:");'>
  82. <IMG Src='<?PHP echo$img['smiles']; ?>/icon_frown.gif' onClick='javascript: smile("^:(");'>
  83. <IMG Src='<?PHP echo$img['smiles']; ?>/icon_idea.gif' onClick='javascript: smile(":idea:");'>
  84.  
  85. <IMG Src='<?PHP echo$img['smiles']; ?>/icon_lol.gif' onClick='javascript: smile(":lol:");'>
  86. <IMG Src='<?PHP echo$img['smiles']; ?>/icon_mad.gif' onClick='javascript: smile(":x");'>
  87. <IMG Src='<?PHP echo$img['smiles']; ?>/icon_mrgreen.gif' onClick='javascript: smile(":mrgreen:");'>
  88. <IMG Src='<?PHP echo$img['smiles']; ?>/icon_neutral.gif' onClick='javascript: smile(":|");'>
  89. <IMG Src='<?PHP echo$img['smiles']; ?>/icon_question.gif' onClick='javascript: smile(":?:");'>
  90.  
  91. <IMG Src='<?PHP echo$img['smiles']; ?>/icon_razz.gif' onClick='javascript: smile(":P");'>
  92. <IMG Src='<?PHP echo$img['smiles']; ?>/icon_redface.gif' onClick='javascript: smile(":oops:");'>
  93. <IMG Src='<?PHP echo$img['smiles']; ?>/icon_rolleyes.gif' onClick='javascript: smile(":roll:");'>
  94. <IMG Src='<?PHP echo$img['smiles']; ?>/icon_sad.gif' onClick='javascript: smile(":(");'>
  95. <IMG Src='<?PHP echo$img['smiles']; ?>/icon_smile.gif' onClick='javascript: smile(":)");'>
  96.  
  97. <IMG Src='<?PHP echo$img['smiles']; ?>/icon_surprised.gif' onClick='javascript: smile(":o");'>
  98. <IMG Src='<?PHP echo$img['smiles']; ?>/icon_twisted.gif' onClick='javascript: smile(":twisted:");'>
  99. <IMG Src='<?PHP echo$img['smiles']; ?>/icon_wink.gif' onClick='javascript: smile(":wink:");'>
  100. </Center>
  101. </Td>
  102. </Tr>
  103.  
  104. <Tr Width='550'>
  105. <Td Width='150'>
  106. Bericht:
  107. </Td>
  108. <Td Width='450'>
  109. <Textarea Name='bericht' style='width: 350px; height: 150px; margin-left: 25px;margin-right: 25px;'>
  110. </Textarea>
  111. </Td>
  112. </Tr>
  113.  
  114. <Tr Width='550'>
  115. <Td ColSpan='2'>
  116. <Input Type='SUBMIT' Name='submit' Value='Submit!' style='width: 100px; margin-left: 25px;margin-right: 25px;'>
  117. </Td>
  118. </Tr>
  119. <?PHP
  120. } else
  121. {
  122. // als er wel gesubmit is alles ophalen + checken
  123. ?>
  124. <Tr Width='550'>
  125. <Td ColSpan='2'>
  126. <?PHP
  127. if(!IsSet($_POST['door']) || empty($_POST['door']))
  128. {
  129. // als het veld 'door' niet geset is, of leeg is
  130. ?>
  131. Error!- Geen naam ingevuld!
  132. <BR>
  133. <A HREF='javascript:history.go(-1);'>Keer terug!</A>
  134. <?PHP
  135. } else if(!IsSet($_POST['titel']) || empty($_POST['titel']))
  136. {
  137. // als het veld 'titel' niet geset is, of leeg is
  138. ?>
  139. Error!- Geen titel ingevuld!
  140. <BR>
  141. <A HREF='javascript:history.go(-1);'>Keer terug!</A>
  142. <?PHP
  143. } else if(!IsSet($_POST['bericht']) || empty($_POST['bericht']))
  144. {
  145. // als het veld 'bericht' niet geset is, of leeg is
  146. ?>
  147. Error!- Geen bericht ingevuld!
  148. <BR>
  149. <A HREF='javascript:history.go(-1);'>Keer terug!</A>
  150. <?PHP
  151. } else
  152. {
  153. // als alles goed ingevuld is de SQL Query maken
  154. $sQuery = "INSERT INTO nieuws (id, titel, door, text, datum, tijd) VALUES ('', '".addslashes($_POST['titel'])."', '".addslashes($_POST['door'])."', '".addslashes($_POST['bericht'])."', '".date("d-m-Y")."', '".date("H:i")."')";
  155. $sResult = MySQL_Query($sQuery) or report_mysql("Nieuws invoegen", __FILE__, __LINE__, $sQuery);
  156. // SQL Query uitvoeren, of als hij niet uitgevoerd kan worden een error
  157. // op het scherm zetten
  158. ?>
  159. Het nieuwsbericht is succesvol toegevoegd.
  160. <BR>
  161. Klik <A HREF='index.php'>hier</A> om terug te keren naar de beginpagina.
  162. <BR>
  163. Klik <A HREF='logout.php'>hier</A> om uit te loggen.
  164. <?PHP
  165. }
  166. }
  167. }
  168. ?>


admin/index.php
  1. <?PHP
  2. // sessie starten voor de admin
  3.  
  4. // error reporting op E_ALL zetten
  5. // voor gebruik kun je het het beste op E_NONE zetten
  6. // voorkomt dat je layout raar gaat doen bij errors
  7.  
  8. include("../classes/ip.php");
  9. $ip = new ip;
  10. $ipadres = $ip->GetIP();
  11. // class includen voor het achterhalen van IP adres
  12. ?>
  13. <Center>
  14. <Table Border='1' BorderColor='#000000' CellPadding='2' CellSpacing='2' Width='500'>
  15. <?PHP
  16. if(!IsSet($_SESSION['username']))
  17. {
  18. // als de username nog niet geset is in de sessie
  19. // het inlog formulier includen
  20. include("login.php");
  21. } else if(IsSet($_SESSION['username']))
  22. {
  23. // als hij wel geset is, checken of de user niet probeert
  24. // om de sessie van een admin te stelen
  25. if(IsSet($_SESSION['ipad']))
  26. {
  27. // als het ip adres is geset in de sessie
  28. if($_SESSION['ipad'] == $ipadres)
  29. {
  30. // en het ip adres van de gebruiker hetzelfde is
  31. // een formulier laten zien om een nieuwsbericht
  32. // toe te voegen in de database
  33. include("form.php");
  34. ?>
  35. <Tr Width='500'>
  36. <Td ColSpan='2'>
  37. <A HREF='logout.php'>Uitloggen</A>
  38. </Td>
  39. </Tr>
  40. <?PHP
  41. } else
  42. {
  43. // als het ip adres niet hetzelfde is
  44. // een error laten zien
  45. ?>
  46. <Tr Width='500'>
  47. <Td ColSpan='2'>
  48. Hack poging!
  49. </Td>
  50. </Tr>
  51. <?PHP
  52. }
  53. }
  54. }
  55. ?>
  56. </Table>


admin/login.php
  1. <?PHP
  2. // sessie starten voor de admin
  3.  
  4. include("../includes/config.inc.php");
  5. // het configuratie bestand includen
  6. // hier kan het script enkele gegevens uit ophalen
  7. // in dit script de username + password van de admin
  8.  
  9. // error reporting op E_ALL zetten
  10. // voor gebruik kun je het het beste op E_NONE zetten
  11. // voorkomt dat je layout raar gaat doen bij errors
  12. if(IsSet($_SESSION['username']))
  13. {
  14. ?>
  15. <Meta HTTP-Equiv=\"refresh\" Content=\"0;Url=index.php\">
  16. <?PHP
  17. } else
  18. {
  19. if(!IsSet($_POST['submit']))
  20. {
  21. ?>
  22. <Form Method='POST' Action='<?PHP echo $_SERVER['PHP_SELF']; ?>'>
  23. <Tr Width='500'>
  24. <Td Width='150'>
  25. Username:
  26. </Td>
  27. <Td Width='400'>
  28. <Input Type='TEXT' Name='username' style='width: 350px; margin-left: 25px;margin-right: 25px;'>
  29. </Td>
  30. </Tr>
  31.  
  32. <Tr Width='500'>
  33. <Td Width='150'>
  34. Password:
  35. </Td>
  36. <Td Width='400'>
  37. <Input Type='PASSWORD' Name='password' style='width: 350px; margin-left: 25px;margin-right: 25px;'>
  38. </Td>
  39. </Tr>
  40.  
  41. <Tr Width='500'>
  42. <Td ColSpan='2'>
  43. <Center>
  44. <Input Type='SUBMIT' Name='submit' Value='Login!' style='width: 100px; margin-left: 25px;margin-right: 25px;'>
  45. </Center>
  46. </Td>
  47. </Tr>
  48. <?PHP
  49. } else
  50. {
  51. ?>
  52. <Tr Width='500'>
  53. <Td Width='500'>
  54. <?PHP
  55. if(!IsSet($_POST['username']) || empty($_POST['password']))
  56. {
  57. ?>
  58. Error!- Geen username!
  59. <BR>
  60. <A HREF='javascript:history.go(-1);'>Keer terug!</A>
  61. <?PHP
  62. } else if(!IsSet($_POST['password']) || empty($_POST['password']))
  63. {
  64. ?>
  65. Error!- Geen username!
  66. <BR>
  67. <A HREF='javascript:history.go(-1);'>Keer terug!</A>
  68. <?PHP
  69. } else if($_POST['username'] == $admin['username'] && $_POST['password'] == $admin['password'])
  70. {
  71. $_SESSION['login'] = TRUE;
  72. $_SESSION['username'] = $_POST['username'];
  73. $_SESSION['ipad'] = $_SERVER['REMOTE_ADDR'];
  74. ?>
  75. Je bent succesvol ingelogd!
  76. <Meta HTTP-Equiv=\"refresh\" Content=\"3;Url=index.php\">
  77. <?PHP
  78. } else
  79. {
  80. ?>
  81. Error!- Kan niet inloggen!
  82. <BR>
  83. Verkeerde username + wachtwoord combinatie!
  84. <?PHP
  85. }
  86. ?>
  87. </Td>
  88. </Tr>
  89. <?PHP
  90. }
  91. }
  92. ?>


admin/logout.php
  1. <?PHP
  2.  
  3. // sessie starten voor de admin
  4.  
  5. // error reporting op E_ALL zetten
  6. // voor gebruik kun je het het beste op E_NONE zetten
  7. // voorkomt dat je layout raar gaat doen bij errors
  8. if(!IsSet($_SESSION['login']) || $_SESSION['login'] != TRUE)
  9. {
  10. ?>
  11. Error!- Je bent niet ingelogd!
  12. <BR>
  13. <Meta HTTP-Equiv=\"refresh\" Content=\"3;url=../nieuws.php\">
  14. <?PHP
  15. } else
  16. {
  17. ?>
  18. Je bent succesvol uitgelogd!
  19. <BR>
  20. <Meta HTTP-Equiv=\"refresh\" Content=\"3;url=../nieuws.php\">
  21. <?PHP
  22. }
  23. ?>


classes/class.pagenav.php
  1. <?PHP
  2. class pagenav
  3. {
  4. function pagenav ($totaal, $perpage, $current, $linkstart)
  5. {
  6. /*
  7.   $totaal = Totaal aantal items (mysql_num_rows)
  8.   $perpage = Het max. aantal items per pagina
  9.   $current = Is de huidige $nav pagina (?nav=2 oid)
  10.   $linkstart = Is wat achter de ? en voor &nav= staat. Voorbeeld: $linkstart = "PageID=1&Mail=ja&Skin=1";
  11.   */
  12. $this->totaal = $totaal;
  13. $this->perpage = $perpage;
  14. if (!$current > 0) $current = 1;
  15. $this->current = $current;
  16. $this->linkstart = $linkstart;
  17. }
  18.  
  19. function get_startpoint ()
  20. {
  21. /*
  22.   Met deze functie krijg je een getal terug wat je voor LIMIT $getal, $aantal kan gebruiken.
  23.   */
  24. $p = $this->current - 1;
  25. $r = $p * $this->perpage;
  26. return $r;
  27. }
  28.  
  29. function makenav ()
  30. {
  31. /*
  32.   Deze functie maakt het pagina navigatie menu
  33. Hij geeft een string terug met daarin: Vorige | 1 | 2 | 3 | 4 | Volgende
  34.   */
  35. $this->pages = $this->totaal / $this->perpage;
  36. $this->pages = ceil($this->pages);
  37.  
  38. for ($i = 1; $i < $this->pages + 1; $i++)
  39. {
  40. if ($this->current == $i)
  41. {
  42. $nav[] = "<B>".$i."</B>";
  43. }
  44. else
  45. {
  46. $nav[] = "<a href='?" . $this->linkstart . "&nav=" . $i . "'>".$i."</a>";
  47. }
  48. }
  49.  
  50. if ($this->current != 1)
  51. {
  52. array_unshift($nav, "<a href='?" . $this->linkstart . "&nav=" . ($this->current - 1) . "'>Vorige</a>");
  53. }
  54. else
  55. {
  56. array_unshift($nav, "Vorige");
  57. }
  58.  
  59. if ($this->current < $this->pages)
  60. {
  61. $nav[] = "<a href='?" . $this->linkstart . "&nav=" . ($this->current + 1) . "'>Volgende</a>";
  62. }
  63. else
  64. {
  65. $nav[] = "Volgende";
  66. }
  67. $nav = implode (" | ", $nav);
  68. return $nav;
  69. }
  70. }
  71. ?>


classes/ip.php
  1. <?PHP
  2. class ip
  3. {
  4. function getIp()
  5. {
  6. if(getenv("HTTP_X_FORWARDED_FOR"))
  7. {
  8. $ip = getenv("HTTP_X_FORWARDED_FOR");
  9. } elseif(getenv("HTTP_CLIENT_IP"))
  10. {
  11. $ip = getenv("HTTP_CLIENT_IP");
  12. } else
  13. {
  14. $ip = $_SERVER["REMOTE_ADDR"];
  15. }
  16. return $ip;
  17. }
  18. }
  19. ?>


functions/text2ubb.php
  1. <?PHP
  2. function text2ubb ($text)
  3. {
  4. global $img;
  5. // \n ==> <BR>
  6. $text = nl2br($text);
  7.  
  8. // Bold, Underline & Italic maken
  9. $text = preg_replace("/\[b\][\n\r]*(.*?)\[\/b\]/is",'<b>\\1</b>', $text);
  10. $text = preg_replace("/\[u\][\n\r]*(.*?)\[\/u\]/is",'<u>\\1</u>', $text);
  11. $text = preg_replace("/\[i\][\n\r]*(.*?)\[\/i\]/is",'<i>\\1</i>', $text);
  12.  
  13. // http:// links maken
  14. $text = eregi_replace("\[url\][[:space:]]*(http://)?([^\\[]*)[[:space:]]*\[/url\]","<a href=\"http://\\2\" target=\"_blank\">http://\\2</a>", $text);
  15. $text = eregi_replace("\\[url=(http://)?([^\\[]*)\\][[:space:]]*([^\\[]*)[[:space:]]*\\[/url\\]","<a href=\"http://\\2\" target=\"_blank\">\\3</a>", $text);
  16.  
  17. // email links maken
  18. $text = preg_replace("#(\[email\])(.*)(\[\/email\])#i","<a href=\"mailto:\\2\">\\2</a>", $text);
  19. $text = eregi_replace("\\[email=([\\[a-zA-Z0-9.@:]*)\\]([^\\[]*)", "<a href='mailto:\\1'>\\2</A>",$text);
  20. $text = preg_replace("#(^|[ \n\r\t])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+)#i", "\\1<a href='mailto:\\2@\\3'>\\2@\\3</a>", $text);
  21. $text = str_replace("[/email]", "</A>", $text);
  22.  
  23. // auto. links genereren
  24. $text = preg_replace("#(^|[ \n\r\t])www.([a-z\-0-9]+).([a-z]{2,4})($|[ \n\r\t])#i", "\\1<a href=\"http://www.\\2.\\3\" target=\"_blank\">www.\\2.\\3</a>\\4", $text);
  25.  
  26. // FTP://, HTTP://, HTTPS:// links maken
  27. $text = preg_replace("#(^|[ \n\r\t])(((ftp://)|(http://)|(https://))([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+))#i", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $text);
  28.  
  29. // Smilies maken
  30. $text = str_replace(":arrow:", "<img src='".$img['smiles']."/icon_arrow.gif'>", $text);
  31. $text = str_replace(":D", "<img src='".$img['smiles']."/icon_biggrin.gif'>", $text);
  32. $text = str_replace(":S", "<img src='".$img['smiles']."/icon_confused.gif'>", $text);
  33. $text = str_replace("8)", "<img src='".$img['smiles']."/icon_cool.gif'>", $text);
  34. $text = str_replace(":*(", "<img src='".$img['smiles']."/icon_cry.gif'>", $text);
  35.  
  36. $text = str_replace(":shock:", "<img src='".$img['smiles']."/icon_eek.gif'>", $text);
  37. $text = str_replace(":evil:", "<img src='".$img['smiles']."/icon_evil.gif'>", $text);
  38. $text = str_replace(":!:", "<img src='".$img['smiles']."/icon_exclaim.gif'>", $text);
  39. $text = str_replace("^:(", "<img src='".$img['smiles']."/icon_frown.gif'>", $text);
  40. $text = str_replace(":idea:", "<img src='".$img['smiles']."/icon_idea.gif'>", $text);
  41.  
  42. $text = str_replace(":lol:", "<img src='".$img['smiles']."/icon_lol.gif'>", $text);
  43. $text = str_replace(":x", "<img src='".$img['smiles']."/icon_mad.gif'>", $text);
  44. $text = str_replace(":mrgreen:", "<img src='".$img['smiles']."/icon_mrgreen.gif'>", $text);
  45. $text = str_replace(":|", "<img src='".$img['smiles']."/icon_neutral.gif'>", $text);
  46. $text = str_replace(":?", "<img src='".$img['smiles']."/icon_question.gif'>", $text);
  47.  
  48. $text = str_replace(":P", "<img src='".$img['smiles']."/icon_razz.gif'>", $text);
  49. $text = str_replace(":oops:", "<img src='".$img['smiles']."/icon_redface.gif'>", $text);
  50. $text = str_replace(":roll:", "<img src='".$img['smiles']."/icon_rolleyes.gif'>", $text);
  51. $text = str_replace(":(", "<img src='".$img['smiles']."/icon_sad.gif'>", $text);
  52. $text = str_replace(":)", "<img src='".$img['smiles']."/icon_smile.gif'>", $text);
  53.  
  54. $text = str_replace(":o", "<img src='".$img['smiles']."/icon_surprised.gif'>", $text);
  55. $text = str_replace(":twisted:", "<img src='".$img['smiles']."/icon_twisted.gif'>", $text);
  56. $text = str_replace(":wink:", "<img src='".$img['smiles']."/icon_wink.gif'>", $text);
  57.  
  58. echo $text;
  59. }
  60. ?>


includes/config.inc.php
  1. <?PHP
  2. include("report_mysql.php");
  3.  
  4. // ================ MySQL Gegevens -Begin- ================ \\
  5. // Pas het onderstaande aan naar jou MySQL gegevens
  6. $MySQL['host'] = ""; // Je MySQL host
  7. $MySQL['user'] = ""; // Je MySQL username
  8. $MySQL['pass'] = ""; // Je MySQL password
  9. $MySQL['daba'] = ""; // Je MySQL database
  10. $MySQL['conn'] = MySQL_Connect($MySQL['host'], $MySQL['user'], $MySQL['pass']) or report_mysql("Verbinding maken", __FILE__, __LINE__, $MySQL['conn']);
  11. $MySQL['sele'] = MySQL_Select_DB($MySQL['daba']) or report_mysql("Database selecteren", __FILE__, __LINE__, $MySQL['sele']);
  12. // ================ MySQL Gegevens -Einde- ================ \\
  13.  
  14.  
  15. // ================ Admin Gegevens -Begin- ================ \\
  16. $admin['username'] = ""; // Je admin username
  17. $admin['password'] = ""; // Je admin password
  18. $admin['mailaddr'] = ""; // Je admin email adres
  19. // ================ Admin Gegevens -Einde- ================ \\
  20.  
  21.  
  22. // ================ Images Gegevens -Begin- ================ \\
  23. $img['smiles'] = "smiles"; // Je path naar je smiles !!! ZONDER end-slash !!!
  24. // ================ Images Gegevens -Einde- ================ \\
  25.  
  26.  
  27. $max['overzicht'] = 50; // Max. aantal berichten per pagina op overzicht.php
  28. $max['nieuws'] = 3; // Max. aantal berichten op nieuws.php
  29.  
  30. ?>


includes/report_mysql.php
  1. <?PHP
  2.  
  3. function report_mysql($functie, $file, $line, $sql)
  4. {
  5. global $admin;
  6. // Error setten die de user te zien krijgt
  7. $error = "Sorry, maar er is een onverwachte fout in de database opgetreden.<BR>";
  8. $error .= "Neem a.u.b. contact op met <A HREF='mailto:".$admin['mailaddr']."'>".$admin['username']."</A>";
  9.  
  10. // MySQL Error ophalen
  11. $mysql_error = MySQL_Error();
  12.  
  13. // Datum + tijd setten
  14. $date = date("d-m-Y");
  15. $tijd = date("H:i");
  16.  
  17. // file openen
  18. if(!$fp = fopen("mysql_error.log", "a+"))
  19. {
  20. ?>
  21. Error!- Kan het logbestand niet openen!<BR>
  22. <?PHP
  23. } else
  24. {
  25. // de code zetten om de error + informatie naar
  26. // het bestand mysql_error.log te schrijven
  27.  
  28. // het bestand zal in de map komen te staan waar het
  29. // opgevraagd word
  30. // als het op de index word opgevraagd, zal het bestand
  31. // in dezelfde map komen te staan als waar de index in staat
  32. fputs($fp, "SQL Error!\n");
  33. fputs($fp, "Datum: ".$date."\n");
  34. fputs($fp, "Tijd: ".$tijd."\n");
  35. fputs($fp, "De functie: ".$functie."\n");
  36. fputs($fp, "Het bestand: ".$file."\n");
  37. fputs($fp, "Regelnummer: ".$line."\n");
  38. fputs($fp, "SQL Error: ".$mysql_error."\n");
  39. fputs($fp, "SQL Query: ".$sql."\n");
  40. fputs($fp, "================================\n\n");
  41. }
  42. // de error op het scherm zetten
  43. echo $error;
  44.  
  45. // zorgen dat het script afbreekt
  46. }
  47.  
  48. ?>
Download code! Download code (.txt)

Download dit script!
 Stemmen
Niet ingelogd.

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