login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > PHP > Nieuwssystemen > Lucky News

Lucky News

Auteur: LuckyLuke - 07 maart 2005 - 17:17 - Gekeurd door: Joel - Hits: 23617 - Aantal punten: 3.80 (10 stemmen)





Link is dood, ik ben bezig met v2: http://luckynews.lucasvd.nl

Nadat ik mijn eerste script weer eens zag, ook een nieuws systeem, schrok ik nogal van de lelijke code. Daarom heb ik maar is besloten om nog een nieuws systeem te gaan maken. en zie hier het resultaat.

Belangrijkste functie's:
-Nieuws toevoegen/bewerken/verwijderen
-Reacties toevoegen/bewerken/verwijderen
-Categoriën toevoegen/bewerken/verwijderen
-IP ban
-Heel uitgebreid theming systeem
-Meerdere moderators
-Veel instellingen zijn configureerbaar in de admin
-Nieuws kan via RSS verkregen worden
-BBcode
-Smilies
-Uitgebreide admin
-Gemakkelijke installatie

En nog vele andere optie's!

Voorbeeld: http://luckynews.hyrule-castle.nl/
Admin Demo: http://luckynews.hyrule-castle.nl/
Username: admin_demo
pass: demo_admin
Download: http://luckynews.hyrule-castle.nl/Lucky%20News.zip

Ik en Yorick hebben flink geocht naar bugs, maar als je er toch nog 1 kan vinden meld het dan mij even. 

Code:
  1. ##########################################################
  2. config.php leeg laten!
  3. #######################################################
  4.  
  5. ##########################################################
  6. index.php
  7. #######################################################
  8. <?php
  9. require_once("init.php");
  10. define('PAGE_TITLE', "Home");
  11. require_once(HEADERF);
  12.  
  13. $action = (isset($_GET['action']) ? $_GET['action'] : "news");
  14.  
  15. if(!$action || $action == "news") {
  16. $pn->setTable(MPREFIX."news");
  17. $pn->setMax($config['max_news']);
  18. $pn->setOrder("news_id", "DESC");
  19. $pn->setWhere(" WHERE news_active=1");
  20. $pn->getTotal();
  21. $pn->showNews("news");
  22. echo $pn ->createNav();
  23. } else if($action == "archive") {
  24. $pn->setTable(MPREFIX."news");
  25. $pn->setMax(10000000000);
  26. $pn->setOrder("news_id", "DESC");
  27. $pn->setWhere(" WHERE news_active=1");
  28. $pn->getTotal();
  29. echo "<table width='100%' class='fborder'>
  30. <tr>
  31. <td colspan='3' class='forumheader'>Nieuws archief</td>
  32. </tr>
  33. ";
  34. $pn->showNews("cat");
  35.  
  36. echo "</table>";
  37. echo $pn->createNav();
  38. }
  39.  
  40. require_once(FOOTERF);
  41. ?>
  42.  
  43. ###################################################
  44. read.php
  45. ###################################################
  46. <?php
  47. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  48. | Lucky News Nieuws systeem. (c) Copyright 2005 Lucas van Dijk
  49. | File: read.php
  50. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  51.  
  52. require_once("init.php");
  53. define('PAGE_TITLE', "Lees nieuws");
  54. require_once(HEADERF);
  55. $action = (isset($_GET['action']) ? $_GET['action'] : "comments");
  56. $news_id = (isset($_GET['news_id']) ? $_GET['news_id'] : false);
  57.  
  58. if(!$news_id) {
  59. show_error(GENERAL, "Geen id opgegeven");
  60. }
  61.  
  62. if(isset($_POST['post_comment'])) {
  63. extract($_POST);
  64.  
  65. if(!$name || !$comment) {
  66. show_error(MESSAGE, "Geen bericht of naam ingevuld. Ga terug en probeer het opnieuw");
  67. }
  68.  
  69. $name = htmlspecialchars(addslashes($name));
  70. $comment = htmlspecialchars(addslashes($comment));
  71. $sql = "INSERT INTO ".MPREFIX."comments (comment_news_id, comment_author, comment_date, comment_body, comment_ip)
  72. VALUES (".$news_id.", '".$name."', ".time().", '".$comment."', '".$_SERVER['REMOTE_ADDR']."')";
  73. if(!$result = mysql_query($sql)) {
  74. show_error(GENERAL, "Kon reactie niet toevoegen", __LINE__, __FILE__, $sql);
  75. }
  76. tablerender("Ok", "Uw reactie is toegevoegd.");
  77. }
  78.  
  79. if($action == "extended") {
  80. $pn->setTable(MPREFIX."news");
  81. $pn->setMax(1);
  82. $pn->setOrder("news_id", "DESC");
  83. $pn->setWhere(" WHERE news_id=".$news_id);
  84. $pn->getTotal();
  85. $pn->showNews("extended");
  86. }
  87.  
  88. if($action == "comments") {
  89. //
  90. // Show news item
  91. //
  92. $sql = "SELECT * FROM ".MPREFIX."news WHERE news_id=".$news_id;
  93. if(!$result = mysql_query($sql)) {
  94. show_error(GENERAL, "Kon nieuws niet selecteren", __LINE__, __FILE__, $sql);
  95. }
  96. $newsrow = mysql_fetch_array($result);
  97. $ns -> showNews_item($newsrow, "comments");
  98.  
  99. echo "<h4>Reacties</h4>";
  100. //
  101. // Show comments
  102. //
  103. $pn->setTable(MPREFIX."comments");
  104. $pn->setMax($config['max_comments']);
  105. $pn->setOrder("comment_id", "DESC");
  106. $pn->setWhere(" WHERE comment_news_id=".$news_id);
  107. $pn->getTotal();
  108. echo $pn->createNav();
  109. $pn->showComments();
  110. echo $pn->createNav();
  111.  
  112. }
  113.  
  114. if($action == "post_comment") {
  115. $text = "
  116. <form method='post' action='read.php?action=comments&amp;news_id=".$news_id."'>
  117. <table width='100%' cellpadding='0' cellspacing=0' border='0'>
  118. <tr>
  119. <td width='50%' valign='top'>Naam:</td>
  120. <td width='50%' valign='top'><input type='text' name='name' size='40' maxlength='20' class='tbox'></td>
  121. </tr>
  122. <tr>
  123. <td width='50%' valign='top'>Reactie:</td>
  124. <td width='50%' valign='top'><textarea id='commentform' name='comment' class='tbox' cols='40' rows='7'></textarea><br />".$msg -> render_help('commentform')."</td>
  125. </tr>
  126. <tr>
  127. <td colspan='2' style='text-align: center'><input type='submit' name='post_comment' value='Toevoegen!' class='button'></td>
  128. </tr>
  129. </table>
  130.  
  131. </form>";
  132. tablerender("Plaats reactie", $text);
  133. }
  134.  
  135.  
  136. require_once(FOOTERF);
  137.  
  138.  
  139. ?>
  140.  
  141. ######################################################
  142. category.php
  143. ######################################################
  144. <?php
  145. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  146. | Lucky News Nieuws systeem. (c) Copyright 2005 Lucas van Dijk
  147. | File: category.php
  148. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  149.  
  150. require_once("init.php");
  151. define('PAGE_TITLE', "CategorieŽn");
  152. require_once(HEADERF);
  153.  
  154.  
  155. if(!isset($_GET['cat_id'])) {
  156. $pn->setTable(MPREFIX."categories");
  157. $pn->setMax(1000000);
  158. $pn->setOrder("category_name", "ASC");
  159. $pn->showCats("cats");
  160. } else {
  161. $id = (isset($_GET['cat_id']) ? $_GET['cat_id'] : false);
  162. if(!$id) {
  163. show_error(GENERAL, "Geen id opgegeven");
  164. }
  165. $sql = "SELECT * FROM ".MPREFIX."categories WHERE category_id=".$id;
  166. if(!$result = mysql_query($sql)) {
  167. show_error(GENERAL, "Kon categorie niet selecteren", __LINE__, __FILE__, $sql);
  168. }
  169. $catrow = mysql_fetch_array($result);
  170.  
  171. $pn->setTable(MPREFIX."news");
  172. $pn->setMax($config['max_news']);
  173. $pn->setOrder("news_id", "DESC");
  174. $pn->setWhere(" WHERE news_category=".$id);
  175. $pn->getTotal();
  176.  
  177. echo "<table width='100%' class='fborder'>
  178. <tr>
  179. <td colspan='3' class='forumheader'>".$catrow['category_name']."</td>
  180. </tr>
  181. ";
  182. $pn -> showNews("cat");
  183. echo "</table>";
  184. echo $pn -> createNav();
  185. }
  186. require_once(FOOTERF);
  187.  
  188.  
  189.  
  190. ?>
  191.  
  192. ######################################################
  193. init.php
  194. ######################################################
  195. <?
  196. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  197. | Lucky News Nieuws systeem. (c) Copyright 2005 Lucas van Dijk
  198. | File: init.php
  199. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  200.  
  201. include('config.php');
  202. error_reporting(E_ERROR | E_WARNING | E_PARSE);
  203. //error_reporting(E_ALL);
  204. $start_time = microtime();
  205.  
  206. if(!defined('PATH')) {
  207. // Not installed, redirect
  208. header("Location: install.php");
  209. }
  210.  
  211. //
  212. // Define some dirs
  213. //
  214. $link_prefix = "";
  215. $url_prefix = substr($_SERVER['PHP_SELF'], strlen(PATH), strrpos($_SERVER['PHP_SELF'], "/") + 1 - strlen(PATH));
  216. $tmp = explode("?", $url_prefix);
  217. $num_levels=substr_count($tmp[0], "/");
  218.  
  219. for ($i = 1; $i <= $num_levels; $i++) {
  220. $link_prefix .= "../";
  221. }
  222. define('LN_ROOT', $link_prefix);
  223. define('LN_IMAGE', LN_ROOT."images/");
  224.  
  225. if (preg_match("/\[(.*?)\].*?/i", $_SERVER['QUERY_STRING'], $matches)) {
  226. define("LN_QUERY", str_replace($matches[0], "", eregi_replace("/?".session_name().".*", "", $_SERVER['QUERY_STRING'])));
  227. } else {
  228. define("LN_QUERY", eregi_replace("/?".session_name().".*", "", $_SERVER['QUERY_STRING']));
  229. }
  230.  
  231. //
  232. // Include some files
  233. //
  234. include_once("includes/error_functions.php");
  235. include_once("includes/functions_misc.php");
  236. include_once("includes/template.php");
  237. include_once("includes/page_nav.php");
  238. include_once("includes/show_class.php");
  239. include_once("includes/user_class.php");
  240. include_once("includes/message_class.php");
  241. include_once("includes/rss_class.php");
  242.  
  243. //
  244. // Define class vars
  245. //
  246. $tp = new template;
  247. $ns = new show;
  248. $pn = new pageNav;
  249. $us = new user;
  250. $msg = new message;
  251. $rss = new rss;
  252.  
  253. //
  254. // Connect to DB
  255. //
  256. $connect = mysql_connect($dbServer, $dbUser, $dbPass);
  257. $selectDb = mysql_select_db($dbDbName);
  258. if(!$connect || !$selectDb) {
  259. show_error(CRITICAL, "Kon niet met de database verbinding maken.", __LINE__, __FILE__);
  260. }
  261. //
  262. // Create config array
  263. //
  264. $sql = "SELECT * FROM ".$mprefix."config";
  265. if(!$result = mysql_query($sql)) {
  266. show_error(CRITICAL, "Fout bij het selecteren uit de config tabel!", __LINE__, __FILE__, $sql);
  267. }
  268. while($row = mysql_fetch_array($result)) {
  269. $config[$row['config_name']] = $row['config_value'];
  270. }
  271.  
  272. //
  273. // Error levels
  274. //
  275. define('CRITICAL', 1);
  276. define('GENERAL', 2);
  277. define('MESSAGE', 3);
  278.  
  279. //
  280. // User levels
  281. //
  282. define('HEAD_ADMIN', 1);
  283. define('ADMIN', 2);
  284. define('MOD', 3);
  285. define('ALL', 4);
  286.  
  287. //
  288. // Other constants
  289. //
  290. define('SITENAME', $config['site_name']);
  291. define('SITEDISCLAIMER', $config['sitedisclaimer']);
  292. define('TIMEZONE', $config['timezone']);
  293. define('THEME', LN_ROOT."themes/".$config['theme']."/");
  294. define('MPREFIX', $mprefix);
  295.  
  296.  
  297. //
  298. // Theme
  299. //
  300. $themeFile = THEME."theme.php";
  301. if(file_exists($themeFile)) {
  302. include($themeFile);
  303. } else {
  304. show_error(CRITICAL, "Theme kan niet worden geladen! Zorg dat je een theme.php bestand in je theme hebt!");
  305. }
  306.  
  307. //
  308. // Header and footer
  309. //
  310. define("HEADERF", LN_ROOT."themes/templates/header.php");
  311. define("FOOTERF", LN_ROOT."themes/templates/footer.php");
  312.  
  313. //
  314. // If user logged in get information and set his ID
  315. //
  316. if(isset($_SESSION['user_id'])) {
  317. $us -> setId($_SESSION['user_id']);
  318. $user_info = $us -> getInfo();
  319. }
  320.  
  321. //
  322. // Check if banned
  323. //
  324. $ip = $_SERVER['REMOTE_ADDR'];
  325. $sql = "SELECT * FROM ".MPREFIX."banlist WHERE ban_ip='".$ip."'";
  326. if(!$result = mysql_query($sql)) {
  327. show_error(GENERAL, "Kon IP niet selecteren!", __LINE__, __FILE__, $sql);
  328. }
  329. $aantal = mysql_num_rows($result);
  330. if($aantal > 0 && $user_info['user_rank'] != HEAD_ADMIN) {
  331. require_once(HEADERF);
  332. $ban = mysql_fetch_array($result);
  333. tablerender("Fout!", "Je bent gebanned van deze site! Je mag de site niet meer bezoeken.<br />
  334. <b>Rede:</b><br />".$ban['ban_reason']);
  335. require_once(FOOTERF);
  336. }
  337. ?>
  338.  
  339. #######################################################
  340. login.php
  341. #######################################################
  342. <?php
  343. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  344. | Lucky News Nieuws systeem. (c) Copyright 2005 Lucas van Dijk
  345. | File: login.php
  346. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  347.  
  348. require_once("init.php");
  349. define('PAGE_TITLE', "Inloggen");
  350. require_once(HEADERF);
  351.  
  352. if(!isset($_POST['submit'])) {
  353. $text = "<form method='post' action='login.php'>
  354. <table width='100%' class='fborder'>
  355. <tr>
  356. <td width='40%' class='forumheader3' valign='top'>Username:</td>
  357. <td width='60%' class='forumheader3' valign='top'><input type='text' name='username' class='tbox' size='40'></td>
  358. </tr>
  359. <tr>
  360. <td width='40%' class='forumheader3' valign='top'>Wachtwoord:</td>
  361. <td width='60%' class='forumheader3' valign='top'><input type='password' name='password' class='tbox' size='40'></td>
  362. </tr>
  363. <tr>
  364. <td colspan='2' class='forumheader2' style='text-align: center'><input type='submit' name='submit' value='Inloggen!' class='button'></td>
  365. </tr>
  366. </table>
  367. </form>";
  368. tablerender("Inloggen", $text);
  369. } else {
  370. $password = md5($_POST['password']);
  371. $username = $_POST['username'];
  372.  
  373. $sql = "SELECT * FROM ".MPREFIX."users WHERE user_name='".$username."' AND user_pass='".$password."'";
  374. if(!$result = mysql_query($sql)) {
  375. show_error(GENERAL, "Kon gebruikers niet selecteren.", __LINE__, __FILE__, $sql);
  376. }
  377. $aantal = mysql_num_rows($result);
  378.  
  379. if($aantal > 0) {
  380. $user = mysql_fetch_array($result);
  381. $_SESSION['user_id'] = $user['user_id'];
  382. $text = "Je bent nu ingelogd. Klik <a href='".LN_ROOT."admin/index.php'>hier</a> om naar de admin te gaan.";
  383. } else {
  384. $text = "Je hebt een verkeerd wachtwoord of gebruikersnaam op gegeven. Ga terug en probeer het opnieuw.";
  385. }
  386. tablerender("", $text);
  387. }
  388.  
  389. require_once(FOOTERF);
  390. ?>
  391.  
  392. ######################################################
  393. install.php
  394. ######################################################
  395. <?
  396. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  397. | Lucky News Nieuws systeem. (c) Copyright 2005 Lucas van Dijk
  398. | File: install.php
  399. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  400.  
  401. $stage = (isset($_GET['stage']) ? $_GET['stage'] : 1);
  402. $PATH = substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], "/"))."/";
  403. ?>
  404. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  405. <html>
  406. <head>
  407. <title>Lucky news installeren</title>
  408. <style type="text/css">
  409. body {
  410. font-size: 12px;
  411. color: #fff;
  412. font-family: tahoma, verdana, arial, sans-serif;
  413. background-color: #500000;
  414. margin:0px;
  415. text-align:left
  416. }
  417.  
  418. .selected {
  419. background-color: #620000;
  420. font-size: 12px;
  421. border: 1px dashed #bebebe;
  422. }
  423. .notselected {
  424. background-color: #840000;
  425. font-size: 12px;
  426. }
  427. .darkrow {
  428. background-color: #620000;
  429. font-size: 12px;
  430. }
  431. .lightrow {
  432. background-color: #840000;
  433. font-size: 12px;
  434. }
  435. .background {
  436. background-color: #840000;
  437. font-size: 12px;
  438. }
  439. .button {
  440. color: #fff;
  441. font-size: 10px;
  442. font-family: Verdana, Arial, Helvetica, sans-serif;
  443. background-color: #5d0000;
  444. text-align: center;
  445. border: solid 1px #370000
  446. }
  447. .tbox {
  448. color: #fff;
  449. font-size: 10px;
  450. font-family: Verdana, Arial, Helvetica, sans-serif;
  451. background-color: #620000;
  452. border: solid 1px #370000
  453. }
  454. .ttl_area { background-color: #620000; width: 75%; text-align: center; padding-top: 2px; padding-bottom: 2px; border-bottom: 1px solid #370000 }
  455. </style>
  456. </head>
  457. <body>
  458.  
  459. <?
  460. <div align="center">
  461. <div class="ttl_area">
  462. <img src="images/logo.gif" alt="" border="0">
  463. </div>
  464. <table width="75%" cellpadding="0" cellspacing="0" border="0">
  465. <tr>
  466. <td colspan="3" class="lightrow">Stap:</td>
  467. </tr>
  468. <tr>
  469. <td width="33%" class="'.($stage == 1 ? "selected" : "notselected").'">1. Welkom!</td>
  470. <td width="33%" class="'.($stage == 2 ? "selected" : "notselected").'">2. Gegevens invoeren</td>
  471. <td width="33%" class="'.($stage == 3 ? "selected" : "notselected").'">3. Klaar!</td>
  472. </tr>
  473. </table>';
  474. if($stage == 1) {
  475. echo '<table width="75%" cellpadding="0" cellspacing="0" border="0">
  476. <tr>
  477. <td class="background">
  478. <h3>Welkom!</h3>
  479. Welkom bij het installatie script van Lucky News. Dit script zal het nieuws systeem installeren.<br />
  480. We hebben wel wat gegevens van je nodig dus klik op de knop om verder te gaan!
  481. </td>
  482. </tr>
  483. <tr>
  484. <td class="darkrow" style="text-align: center"><input type="button" value="Verder!" onclick="document.location=\''.$_SERVER['PHP_SELF'].'?stage=2\'" class="button"></td>
  485. </tr>
  486. </table>';
  487. } else if($stage == 2) {
  488. echo '
  489. <form method="post" action="install.php?stage=3">
  490. <table width="75%" cellpadding="0" cellspacing="0" border="0">
  491. <tr>
  492. <td colspan="2" class="darkrow">Gegevens invoeren</td>
  493. </tr>
  494. <tr>
  495. <td class="lightrow" colspan="2"><b>Mysql gegevens</b></td>
  496. </tr>
  497. <tr>
  498. <td class="background">Mysql host</td>
  499. <td class="background"><input type="text" name="mysql_host" class="tbox" size="35"></td>
  500. </tr>
  501. <tr>
  502. <td class="background">Mysql username</td>
  503. <td class="background"><input type="text" name="mysql_user" class="tbox" size="35"></td>
  504. </tr>
  505. <tr>
  506. <td class="background">Mysql password</td>
  507. <td class="background"><input type="text" name="mysql_pass" class="tbox" size="35"></td>
  508. </tr>
  509. <tr>
  510. <td class="background">Mysql database</td>
  511. <td class="background"><input type="text" name="mysql_db" class="tbox" size="35"></td>
  512. </tr>
  513. <tr>
  514. <td class="background">Mysql prefix</td>
  515. <td class="background"><input type="text" name="mprefix" class="tbox" size="35" value="ln_"></td>
  516. </tr>
  517. <tr>
  518. <td colspan="2" class="lightrow"><b>Admin gegevens</b></td>
  519. </tr>
  520. <tr>
  521. <td class="background">Username</td>
  522. <td class="background"><input type="text" name="username" class="tbox" size="35"></td>
  523. </tr>
  524. <tr>
  525. <td class="background">Email</td>
  526. <td class="background"><input type="text" name="email" class="tbox" size="35"></td>
  527. </tr>
  528. <tr>
  529. <td class="background">Wachtwoord</td>
  530. <td class="background"><input type="password" name="pass1" class="tbox" size="35"></td>
  531. </tr>
  532. <tr>
  533. <td class="background">Wachtwoord (bevestigen)</td>
  534. <td class="background"><input type="password" name="pass2" class="tbox" size="35"></td>
  535. </tr>
  536. <tr>
  537. <td colspan="2" class="darkrow" style="text-align: center"><input type="submit" class="button" name="submit" value="Installeren!"></td>
  538. </tr>
  539. </table>';
  540. } else if($stage == 3 && isset($_POST['submit'])) {
  541. $text = '';
  542.  
  543. extract($_POST);
  544. if(!$mysql_host || !$mysql_user || !$mysql_pass || !$mysql_db || !$username || !$pass1) {
  545. die("U heeft iets niet ingevuld! Ga terug en probeer het opnieuw!");
  546. }
  547.  
  548. //
  549. // News table
  550. //
  551. $queries[] = "
  552. CREATE TABLE ".$_POST['mprefix']."news (
  553. news_id INT NOT NULL AUTO_INCREMENT ,
  554. news_author VARCHAR( 100 ) NOT NULL ,
  555. news_title VARCHAR( 255 ) NOT NULL ,
  556. news_category INT NOT NULL ,
  557. news_date INT NOT NULL ,
  558. news_body TEXT NOT NULL ,
  559. news_extended TEXT NOT NULL ,
  560. news_active INT NOT NULL ,
  561. news_allow_comments INT NOT NULL ,
  562. PRIMARY KEY ( news_id )
  563. );";
  564.  
  565. //
  566. // Catgeories table
  567. //
  568. $queries[] = "
  569. CREATE TABLE ".$_POST['mprefix']."categories (
  570. category_id INT NOT NULL AUTO_INCREMENT ,
  571. category_desc VARCHAR( 255 ) NOT NULL ,
  572. category_name VARCHAR( 100 ) NOT NULL ,
  573. category_icon VARCHAR( 150 ) NOT NULL ,
  574. PRIMARY KEY ( category_id )
  575. );";
  576.  
  577. //
  578. // Users table
  579. //
  580. $queries[] = "
  581. CREATE TABLE ".$_POST['mprefix']."users (
  582. user_id INT NOT NULL AUTO_INCREMENT ,
  583. user_name VARCHAR( 100 ) NOT NULL ,
  584. user_email VARCHAR( 100 ) NOT NULL ,
  585. user_pass VARCHAR( 150 ) NOT NULL ,
  586. user_rank INT NOT NULL ,
  587. PRIMARY KEY ( user_id )
  588. );";
  589.  
  590. //
  591. // Config table
  592. //
  593. $queries[] = "
  594. CREATE TABLE ".$_POST['mprefix']."config (
  595. config_name TEXT NOT NULL ,
  596. config_value TEXT NOT NULL
  597. );";
  598.  
  599. //
  600. // News comments table
  601. //
  602. $queries[] = "CREATE TABLE ".$_POST['mprefix']."comments (
  603. comment_id INT NOT NULL AUTO_INCREMENT ,
  604. comment_news_id INT NOT NULL ,
  605. comment_author VARCHAR( 100 ) NOT NULL ,
  606. comment_date INT NOT NULL ,
  607. comment_body TEXT NOT NULL ,
  608. comment_ip VARCHAR( 100 ) NOT NULL ,
  609. PRIMARY KEY ( comment_id )
  610. );";
  611.  
  612. //
  613. // Banlist table
  614. //
  615. $queries[] = "CREATE TABLE ".$_POST['mprefix']."banlist (
  616. ban_id INT NOT NULL AUTO_INCREMENT ,
  617. ban_ip VARCHAR( 20 ) NOT NULL ,
  618. ban_reason TEXT NOT NULL ,
  619. PRIMARY KEY ( ban_id )
  620. );";
  621.  
  622. //
  623. // Config values
  624. //
  625. $queries[] = "
  626. INSERT INTO ".$_POST['mprefix']."config (config_name, config_value) VALUES ('theme', 'Raid Silver')";
  627. $queries[] = "
  628. INSERT INTO ".$_POST['mprefix']."config (config_name, config_value) VALUES ('max_news', '5')";
  629. $queries[] = "
  630. INSERT INTO ".$_POST['mprefix']."config (config_name, config_value) VALUES ('max_comments', '10')";
  631. $queries[] = "
  632. INSERT INTO ".$_POST['mprefix']."config (config_name, config_value) VALUES ('max_admin', '15')";
  633. $queries[] = "
  634. INSERT INTO ".$_POST['mprefix']."config (config_name, config_value) VALUES ('site_name', 'Lucky News nieuws systeem')";
  635. $queries[] = "
  636. INSERT INTO ".$_POST['mprefix']."config (config_name, config_value) VALUES ('site_desc', 'Een beschrijving over je site. ')";
  637. $queries[] = "
  638. INSERT INTO ".$_POST['mprefix']."config (config_name, config_value) VALUES ('timezone', '1')";
  639. $queries[] = "
  640. INSERT INTO ".$_POST['mprefix']."config (config_name, config_value) VALUES ('sitedisclaimer', '&copy; Copyright 2005 bij (je site naam).')";
  641. $queries[] = "
  642. INSERT INTO ".$_POST['mprefix']."config (config_name, config_value) VALUES ('date_format', 'd M Y H:i:s')";
  643. $queries[] = "
  644. INSERT INTO ".$_POST['mprefix']."config (config_name, config_value) VALUES ('max_rss', '10')";
  645. $queries[] = "
  646. INSERT INTO ".$_POST['mprefix']."config (config_name, config_value) VALUES ('filter', 'worden,die,gefilterd,moeten,worden')";
  647. $queries[] = "
  648. INSERT INTO ".$_POST['mprefix']."config (config_name, config_value) VALUES ('logo', '{LN_IMAGE}logo.gif')";
  649. $queries[] = "
  650. INSERT INTO ".$_POST['mprefix']."config (config_name, config_value) VALUES ('filter_replace', '-filter-')";
  651. $queries[] = "
  652. INSERT INTO ".$_POST['mprefix']."config (config_name, config_value) VALUES ('enable_bbcode', 'TRUE')";
  653. $queries[] = "
  654. INSERT INTO ".$_POST['mprefix']."config (config_name, config_value) VALUES ('enable_smilies', '1')";
  655.  
  656.  
  657. //
  658. //Admin
  659. //
  660. $queries[] = "
  661. INSERT INTO ".$_POST['mprefix']."users (user_name, user_email, user_pass, user_rank) VALUES ('".$_POST['username']."', '".$_POST['email']."', '".md5($_POST['pass1'])."', 1)";
  662.  
  663. if($_POST['pass1'] != $_POST['pass2']) {
  664. die("De wachtwoorden komen niet overeen! Ga terug en probeer het opnieuw!");
  665. }
  666.  
  667. $connect = mysql_connect($_POST['mysql_host'], $_POST['mysql_user'], $_POST['mysql_pass']);
  668. mysql_select_db($_POST['mysql_db']);
  669.  
  670. if(!$connect) {
  671. $text .= "<b>Kon niet met de database verbinden!</b>";
  672. $error = true;
  673. }
  674. foreach($queries as $sql_query) {
  675. $text .= $sql_query;
  676. if(!$result = mysql_query($sql_query)) {
  677. $text .= "<br /><font style='color: #FF0000'>Mislukt: ".mysql_error()."</font><br /><br />";
  678. $error = true;
  679. } else {
  680. $text .= "<br /><font style='color: #00FF00'>Gelukt!</font><br /><br />";
  681. }
  682. }
  683.  
  684.  
  685. if(is_writeable('config.php')) {
  686. if($file = fopen('config.php', "w")) {
  687. $write = "
  688. <?
  689. //
  690. // Lucky news auto generated config file
  691. //
  692.  
  693. \$dbServer = \"".$_POST['mysql_host']."\";
  694. \$dbUser = \"".$_POST['mysql_user']."\";
  695. \$dbPass = \"".$_POST['mysql_pass']."\";
  696. \$dbDbName = \"".$_POST['mysql_db']."\";
  697. \$mprefix = \"".$_POST['mprefix']."\";
  698.  
  699. define('PATH', '".$PATH."');
  700. ?>
  701. ";
  702. if(!fwrite($file, $write)) {
  703. $text .= "<font style='color: #FF0000;'>Kon de gegevens niet schrijven naar het config.php bestand!</font><br /><br />";
  704. $error = true;
  705. }
  706. } else {
  707. $text .= "<font style='color: #FF0000;'>Kon config.php niet openen!</font><br /><br />";
  708. $error = true;
  709. }
  710. } else {
  711. $text .= "<font style='color: #FF0000;'>config.php is niet beschrijfbaar!</font><br /><br />";
  712. $error = true;
  713. }
  714.  
  715. if(!isset($error)) {
  716. $text .= "<b>Alles is succesvol geinstalleerd! Verwijder dit bestand nu van de server en ga naar je admin om alles te configureren.</b>";
  717. } else {
  718. $text .= "<b>Er is een fout opgetreden. Als je niet weet hoe je het moet oplossen, neem dan contact op met de maker.</b>";
  719. }
  720.  
  721.  
  722.  
  723.  
  724. echo '
  725. <table width="75%" cellpadding="0" cellspacing="0" border="0">
  726. <tr>
  727. <td class="darkrow">Installeren...</td>
  728. </tr>
  729. <tr>
  730. <td class="background">
  731. '.$text.'
  732. </td>
  733. </tr>
  734. </table>';
  735. } else {
  736. $stage = 1;
  737. }
  738. ?>
  739. </div>
  740. </body>
  741. </html>
  742.  
  743. #######################################
  744. ER ZIJN NOG MEER BESTANDEN MAAR DAT IS ZOVEEL EN HEB NIET ZO ZIN OM DAT ALLEMAAL TE GAAN PLAATSEN. DOWNLOAD HET MAAR VOOR DE SORCE VAN DE ANDERE BESTANDEN
  745. ############################################
Download code! Download code (.txt)

 Bekijk een voorbeeld van dit script!
 Stemmen
Niet ingelogd.

 Reacties
Post een reactie
Lees de reacties (27)
© 2002-2023 Sitemasters.be - Regels - Laadtijd: 0.083s