Public paste
boe
By: testje | Date: Dec 1 2007 20:31 | Format: PHP | Expires: never | Size: 7.36 KB | Hits: 1249

  1. <script language="javascript" type="text/javascript">
  2. tinyMCE.init({
  3.         mode : "textareas",
  4.         theme : "advanced",
  5.         theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright, justifyfull,bullist,numlist,undo,redo,link,unlink",
  6.         theme_advanced_buttons2 : "",
  7.         theme_advanced_buttons3 : "",
  8.         theme_advanced_toolbar_location : "top",
  9.         theme_advanced_toolbar_align : "left",
  10.         theme_advanced_statusbar_location : "bottom",
  11.         extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]"
  12. });
  13. </script>
  14.  
  15. <div id="location">
  16.     U bevindt zich hier: <a href="index.php">Webber</a> &rsaquo; <a href="index.php?section=modules">Modules</a> &rsaquo; <a href="index.php?section=modules&amp;view=news">Nieuws</a> &rsaquo; <a href="index.php?section=content&amp;view=news&amp;action=add">Nieuwsbericht schrijven</a>
  17. </div>
  18. <h1>Nieuwsbericht schrijven</h1>
  19.  
  20. <?php
  21. if ($_POST['submit']) {
  22. // Variablen
  23.     $title              = $_POST['title'];
  24.     $hours      = $_POST['hours'];
  25.     $minutes    = $_POST['minutes'];
  26.     $seconds    = $_POST['seconds'];
  27.     $days       = $_POST['days'];
  28.     $months     = $_POST['months'];
  29.     $year       = $_POST['year'];
  30.         $text           = $_POST['text'];
  31.         $author         = $_POST['author'];
  32.         $category       = $_POST['category'];
  33.  
  34.     $date = mktime($hours, $minutes, $secondes, $months, $days, $year);
  35.        
  36. $title_db = escape($title);
  37. $date_db = ($date);
  38. $text_db = escape($text);
  39. $author_db = escape($author);
  40. $category_db = escape($category);
  41.  
  42.     mysql_query("INSERT INTO mod_news (`title` , `date` , `text` , `author` , `category` )
  43.     VALUES ($title_db, $date_db, $text_db, $author_db, $category_db)
  44.    ");
  45.        
  46.         //print '<div class="succes">Pagina toegevoegd!</div><meta http-equiv="refresh" content="1;URL=index.php?section=modules&amp;view=news" />';
  47.         }
  48. ?>
  49. <form action="" method="post">
  50.     <fieldset><legend>Schrijf een nieuwsbericht</legend>
  51.        
  52.         <table class="add">
  53.             <tr>
  54.                 <td style="width: 50%;">Titel:</td>
  55.                 <td style="width: 50%;">Datum:</td>
  56.             <tr>
  57.                 <td style="width: 50%;"><input name="title" size="50" /></td>
  58.                 <td style="width: 50%;"><?php
  59.  
  60. $tijd = time();
  61.  
  62. $stakker = getDates($tijd);
  63.  
  64. print '<select name="days" class="select">'."n";
  65. foreach ($stakker['days'] as $key => $value) {
  66.     if ($key !== 'selected') {
  67.         print '<option value="'.$value.'"';
  68.         if ($key == $stakker['days']['selected']) {
  69.             print ' selected="selected"';
  70.         }
  71.         print ">$value</option>n";
  72.     }
  73. }
  74. print '</select>';
  75.  
  76. print '<select name="months" class="select">'."n";
  77. foreach ($stakker['months'] as $key => $value) {
  78.     if ($key !== 'selected') {
  79.         print '<option value="'.$key.'"';
  80.         if ($key == $stakker['months']['selected']) {
  81.             print ' selected="selected"';
  82.         }
  83.         print ">$value</option>n";
  84.     }
  85. }
  86. print '</select>';
  87.  
  88. print '<select name="year" class="select">'."n";
  89. foreach ($stakker['year'] as $key => $value) {
  90.     if ($key !== 'selected') {
  91.         print '<option value="'.$value.'"';
  92.         if ($key == $stakker['year']['selected']) {
  93.             print ' selected="selected"';
  94.         }
  95.         print ">$value</option>n";
  96.     }
  97. }
  98. print '</select>';
  99.  
  100. print '<select name="hours" class="select">'."n";
  101. foreach ($stakker['hours'] as $key => $value) {
  102.     if ($key !== 'selected') {
  103.         print '<option value="'.$value.'"';
  104.         if ($key == $stakker['hours']['selected']) {
  105.             print ' selected="selected"';
  106.         }
  107.         print ">$value</option>n";
  108.     }
  109. }
  110. print '</select>';
  111.  
  112. print '<select name="minutes" class="select">'."n";
  113. foreach ($stakker['minutes'] as $key => $value) {
  114.     if ($key !== 'selected') {
  115.         print '<option value="'.$value.'"';
  116.         if ($key == $stakker['minutes']['selected']) {
  117.             print ' selected="selected"';
  118.         }
  119.         print ">$value</option>n";
  120.     }
  121. }
  122. print '</select>';
  123.  
  124. print '<select name="seconds" class="select" style="display: none;">'."n";
  125. foreach ($stakker['seconds'] as $key => $value) {
  126.     if ($key !== 'selected') {
  127.         print '<option value="'.$value.'"';
  128.         if ($key == $stakker['seconds']['selected']) {
  129.             print ' selected="selected"';
  130.         }
  131.         print ">$value</option>n";
  132.     }
  133. }
  134. print '</select>';
  135.  
  136.  
  137.  
  138. function getDates($timestamp = false) {
  139.    
  140.     $maanden = array(1 => "januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december");
  141.     $toret['months'] = $maanden;
  142.    
  143.     if ($timestamp) {
  144.         $dag = date('d', $timestamp);
  145.         $uur = date('G', $timestamp);
  146.         $minuten = date('i', $timestamp);
  147.         $maand = date('n', $timestamp);
  148.         $seconden = date('s', $timestamp);
  149.         $jaar = date('Y', $timestamp);
  150.        
  151.         $toret['months']['selected'] = $maand;
  152.         $toret['days']['selected'] = $dag;
  153.         $toret['hours']['selected'] = $uur;
  154.         $toret['minutes']['selected'] = $minuten;
  155.         $toret['seconds']['selected'] = $seconden;
  156.         $toret['year']['selected'] = $jaar;
  157.     }
  158.    
  159.     for ($i = 1; $i <= 31; $i++) {
  160.         $toret['days'][$i] = $i;
  161.     }
  162.     for ($i = 0; $i <= 23; $i++) {
  163.         $toret['hours'][$i] = $i;
  164.     }
  165.     for ($i = 0; $i <= 59; $i++) {
  166.         if (strlen($i) == 1) {
  167.             $toret['minutes'][$i] = '0'.$i;
  168.             $toret['seconds'][$i] = '0'.$i;
  169.         }
  170.         else {
  171.             $toret['minutes'][$i] = $i;
  172.             $toret['seconds'][$i] = $i;
  173.         }
  174.     }
  175.     for ($i = 1970; $i <= date('Y') + 2; $i++) {
  176.         $toret['year'][$i] = $i;
  177.     }
  178.     return $toret;
  179. }
  180.  
  181. ?></td>
  182.             </tr>
  183.             <tr>
  184.                 <td colspan="2">Inhoud:</td>
  185.             </tr>
  186.             <tr>
  187.                 <td colspan="2"><textarea name="text" cols="117" rows="20"> </textarea></td>
  188.             </tr>
  189.             <tr>
  190.                 <td style="width: 50%;">Auteur:</td>
  191.                 <td style="width: 50%;">Categorie:</td>
  192.             <tr>
  193.                 <td style="width: 50%;">        
  194.                 <select name="author">        
  195.                                 <?php
  196.                                         $sql = mysql_query("select * from users");
  197.                                         if (mysql_num_rows($sql)) {
  198.                                 while ($row = mysql_fetch_assoc($sql)) {
  199.  
  200.                                   print '
  201.                                   <option value="'.$row['name'].'">'.$row['name'].'</option>
  202.                                   ';
  203.                                   }
  204.                                   }
  205.                                 ?>
  206.                 </select>
  207.                 </td>
  208.                 <td style="width: 50%;">
  209.                 <select name="category">        
  210.                                 <?php
  211.                                         $sql = mysql_query("select * from mod_news_cats");
  212.                                         if (mysql_num_rows($sql)) {
  213.                                 while ($row = mysql_fetch_assoc($sql)) {
  214.  
  215.                                   print '
  216.                                   <option value="'.$row['category'].'">'.$row['category'].'</option>
  217.                                   ';
  218.                                   }
  219.                                   }
  220.                                 ?>
  221.                 </select>
  222.                 </td>
  223.             </tr>
  224.         </table>
  225.     </fieldset>    
  226.     <fieldset><legend>Opties</legend>
  227.         <input value="toevoegen" name="submit" type="submit" class="button" />&nbsp;
  228.         <input value="annuleren" type="submit" onclick="javascript:history.back()" class="button" />
  229.     </fieldset>
  230.        
  231.         </form>