Advertisement
Guest User

news.php

a guest
Dec 1st, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.99 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3.  
  4. <head>
  5.     <title>EntranceRT</title>
  6.  
  7.     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  8.     <meta http-equiv="imagetoolbar" content="no" />
  9.     <meta http-equiv="Content-Language" content="de" />
  10.  
  11.     <link rel="stylesheet" href="style.css" type="text/css" />
  12. </head>
  13. <body>
  14.  
  15.     <div id="ram">
  16.    
  17.         <div id="header">
  18.             <h1>GrafixxNews</h1>
  19.         </div>
  20.    
  21.        
  22.         <div id="content">
  23.        
  24. <?php // news.php
  25.  
  26. include('config.inc.php');  // DB-Verbindung einbinden
  27.  
  28. // Sofern Kategorie angegeben
  29. if(isset($_GET['cat'])){
  30.  
  31.     $where = "WHERE cat = '".clean_it($_GET['cat'])."'";
  32.    
  33.     echo "<h2 class=\"blue\">Abgelegtes unter '".clean_it($_GET['cat'])."'</h2>";  
  34.  
  35.     $pfad = "news.php?cat=".urlencode(clean_it($_GET['cat']))."go=";
  36.    
  37. }else{
  38.  
  39.     $pfad = "news.php?go=";
  40. }
  41.  
  42. // News auslesen
  43. $abfrage = mysql_query("SELECT id FROM news ".$where."");
  44. $total = mysql_num_rows($abfrage);                  // Anzahl aller Zeilen in DB ermitteln
  45.  
  46. // ---------------------- Seitennavigationsdaten --------------------------------------------------
  47.  
  48. $per_page = "5";            // Anzahl der News die Pro Seite ausgegeben werden sollen
  49. $p = "5";                  // Anzahl der Links die in der Seitenavigation ausgegeben werden
  50.  
  51. isset($_GET['go']) ? $go = clean_it($_GET['go']) : $go = ''; // Variable definieren
  52.  
  53. // Blaetterfunktion aufrufen
  54. list ($start, $ende) = get_navi($go, $total, $pfad, false, $per_page, $p);
  55. // ---------------------- ENDE Seitennavigationsdaten----------------------------------------------
  56.  
  57. $abfrage = mysql_query("SELECT id, autor, title, cat, news, DATE_FORMAT(date, '%d.%m.%Y') AS datum FROM news ".$where." ORDER BY date DESC LIMIT $start,$ende");
  58.  
  59. // News ausgeben ausgeben
  60. while($row = mysql_fetch_object($abfrage)){
  61.    
  62.    // Anzahl der Kommentare ermitteln
  63.     $comments = mysql_query("SELECT id FROM comments WHERE news_id='$row->id'");
  64.     $com_num = mysql_num_rows($comments); // Anzahl der Kommentare
  65.    
  66.     echo "<div class=\"news\">\n";
  67.     echo "<h2>".$row->title."\n <small>verfasst von ".$row->autor." am ".$row->datum." | \n";
  68.    
  69.     if(!empty($row->cat)){  // sofern Kategorie angegeben
  70.         echo "abgelegt unter: <a href=\"news.php?cat=".urlencode($row->cat)."\">".$row->cat."</a> | \n";
  71.     }
  72.     echo "<a href=\"comments.php?id=".$row->id."\">Kommentare ".$com_num."</a></small>\n </h2>";
  73.  
  74.     if(isset($_GET['cat'])){    // Kategorieseite nur einen Auszug ausgeben
  75.         $max_show = "250"; // max 450 Zeichen anzeigen
  76.  
  77.         if (strlen($row->news) > $max_show){ // sofern $news mehr als 450 Zeichen enthaelt
  78.             echo "<p>".bbcode(substr($row->news, 0, strpos($row->news, ".", 120 )+1 ))."\n";
  79.             // Ab 150 Zeichen nach nem punkt suchen und alles das was davor enthalten ist ausgeben
  80.    
  81.             echo "<a href=\"comments.php?id=".$row->id."\" class=\"right\">read more...</a>\n";
  82.             echo "<br style=\"clear: right;\" /></p>"; // link ausgeben
  83.         }else{ // komplett ausgeben
  84.             echo "<p>".bbcode($row->news)."</p>";
  85.         }
  86.     }else{
  87.         echo "<p>".bbcode($row->news)."</p>";
  88.     }
  89.     echo "</div>\n";
  90.  
  91. } // close while
  92.  
  93. // -------------------------------------- Seitennavigation ausgeben ----------------------------
  94.  
  95. get_navi($go, $total, $pfad, true, $per_page, $p);
  96.  
  97. // -------------------------------------- Seitennavigation ende --------------------------------
  98.  
  99. ?>
  100.  
  101. </div>
  102.    
  103.     </div>
  104.    
  105.     <div id="footer">
  106.         <p class="right">Valid <a href="http://validator.w3.org/check/referer" title="This page validates as XHTML 1.0 Transitional">
  107.         <abbr title="eXtensible HyperText Markup Language">XHTML</abbr></a> |
  108.         Valid <a href="http://jigsaw.w3.org/css-validator/check/referer" title="CSS ist valide!"><abbr title="Cascading Style Sheets">
  109.         CSS</abbr></a>&nbsp;&nbsp;</p>
  110.                
  111.         <p><a href="http://unnecessary.de">GrafixxNews</a> ยท <a href="http://alice-grafixx.de">
  112.         Alice-Grafixx.de</a></p>
  113.     </div> 
  114.        
  115.    
  116. </body>
  117. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement