Jlog PHP Cross Reference Blogging Systems

Source: /archive.php - 130 lines - 5121 bytes - Summary - Text - Print

   1  <?php
   2   require('.'.DIRECTORY_SEPARATOR.'personal'.DIRECTORY_SEPARATOR.'settings.inc.php');
   3  
   4   $get = strip($_GET);
   5   if(isset($get['cat'])) $cat_y_link = "cat=".$get['cat'];
   6   $yl = new Year_Links($get['y'], JLOG_START_YEAR, archive(), $l, $cat_y_link);
   7   if(isset($get['show'])) $p = (int) escape_for_mysql($get['show']);
   8   else $p = 0;
   9   $amount = 5;
  10  
  11   $c['meta']['robots']       = "noindex, follow";
  12      
  13      if(isset($get['cat'])) {
  14  
  15  
  16        $c['meta']['title'] = $categories->get($categories->get_id($get['cat']), 'name');
  17        $c['main'] .= "<h2>".$l['content_categories_header']." ".$categories->get($categories->get_id($get['cat']), 'name')." ".$yl->get_selected_year()."</h2>";
  18        $c['main'] .= "<p>".$categories->get($categories->get_id($get['cat']), 'description')."</p>";
  19  
  20          $sql_archive = "
  21           SELECT
  22            ".JLOG_DB_CONTENT.".*,
  23            ".JLOG_DB_CONTENT.".date as mysql_date,
  24            DATE_FORMAT(".JLOG_DB_CONTENT.".date, '%c') AS month,
  25            DATE_FORMAT(".JLOG_DB_CONTENT.".date, '%Y') AS year,
  26            UNIX_TIMESTAMP(".JLOG_DB_CONTENT.".date) AS date
  27            FROM ".JLOG_DB_CONTENT."
  28            LEFT JOIN ".JLOG_DB_CATASSIGN." 
  29             ON ".JLOG_DB_CONTENT.".id = ".JLOG_DB_CATASSIGN.".content_id
  30              WHERE ".JLOG_DB_CATASSIGN.".cat_id = '".escape_for_mysql($categories->get_id($get['cat']))."'
  31              AND YEAR(".JLOG_DB_CONTENT.".date) = '".escape_for_mysql($yl->get_selected_year())."'
  32            ORDER BY mysql_date DESC;";
  33  
  34          $c['main'] .= "<p>".$yl->get_linklist()."</p>";
  35  
  36      }
  37      elseif(empty($get['y'])) {
  38          $c['meta']['title'] = $l['content_archive_header'];
  39          $c['main'] = "<h2>".$c['meta']['title']."</h2>";
  40          
  41          $sql_archive = "SELECT
  42                      *,
  43                      date as mysql_date,
  44                      DATE_FORMAT(date, '%c') AS month,
  45                      DATE_FORMAT(".JLOG_DB_CONTENT.".date, '%Y') AS year,
  46                      UNIX_TIMESTAMP(date) AS date
  47                FROM ".JLOG_DB_CONTENT."
  48                WHERE section = 'weblog'
  49                ORDER BY mysql_date DESC
  50                LIMIT ".$p.", ".$amount.";";
  51  
  52          $sql_count = "SELECT count(*) AS count FROM ".JLOG_DB_CONTENT." WHERE section = 'weblog'";
  53  
  54          $count_query = new Query($sql_count);
  55              if($count_query->error()) {
  56                  echo "<pre>\n";
  57                  echo $count_query->getError();
  58                  echo "</pre>\n";
  59                  die();
  60              }
  61          $_count = $count_query->fetch();
  62          $count_query->free();
  63          $count = $_count['count'];
  64      }
  65      else {
  66          if(!empty($get['m'])) $where_month = " AND MONTH(date) = '".escape_for_mysql($get['m'])."'";
  67          $c['meta']['title'] = $l['content_archive_header'];
  68          $c['main'] = "<h2>".$c['meta']['title']." ".$yl->get_selected_year()."</h2>";
  69  
  70          $sql_archive = "SELECT
  71                      *,
  72                      date as mysql_date,
  73                      DATE_FORMAT(date, '%c') AS month,
  74                      DATE_FORMAT(".JLOG_DB_CONTENT.".date, '%Y') AS year,
  75                      UNIX_TIMESTAMP(date) AS date
  76                FROM ".JLOG_DB_CONTENT.$where_from."
  77                WHERE
  78                 YEAR(date) = '".escape_for_mysql($yl->get_selected_year())."'
  79                ".$where_month."
  80                 AND section = 'weblog'
  81                ORDER BY mysql_date;";
  82  
  83          $c['main'] .= "<p>".$yl->get_linklist()."</p>";
  84      }
  85   
  86   $cc = count_comments();
  87  
  88      $archive = new Query($sql_archive);
  89       if($archive->error()) {
  90          echo "<pre>\n";
  91          echo $archive->getError();
  92          echo "</pre>\n";
  93          die();
  94       }
  95  
  96  $months = array_flip($l['months']);
  97  
  98  if($archive->numRows() > 0) {
  99      while ($daten = $archive->fetch()) {
 100       if(empty($daten)) break 1;
 101      
 102       $mo = $mon;
 103       $mon = $daten['month'];
 104       if ($mo != $mon) {
 105              if ($mo != "" AND $mo != $mon) { $c['main'] .=  "    </div>\n"; }
 106              $c['main'] .= "   <h3>".array_search($mon, $months)." ".$daten['year']."</h3>\n";
 107              $c['main'] .= "    <div class='archive'>\n";
 108       }
 109        $c['main'] .= do_teaser($daten, $cc, "<h4>", "</h4>");
 110      }
 111      if(empty($get['y'])) {
 112          $c['main'] .= "<p class='archivenavigation'>";
 113          if(($p - $amount) >= 0) {
 114              $c['main'] .= "<a href='?show=".($p - $amount)."'><strong>&lt;&mdash;</strong> ".$l['content_archive_preview']."</a>";
 115              $c['meta']['aditionalheader'] .= '  <link rel="prev" href="?show='.($p - $amount).'" title="'.$l['content_archive_preview'].'" />'."\n";
 116          }
 117          if((($p - $amount) >= 0) && (($p + $amount) < $count)) $c['main'] .= " | ";
 118          if(($p + $amount) < $count) {
 119              $c['main'] .= "<a href='?show=".($p + $amount)."'>".$l['content_archive_next']." <strong>&mdash;&gt;</strong></a>";
 120              $c['meta']['aditionalheader'] .= '  <link rel="next" href="?show='.($p + $amount).'" title="'.$l['content_archive_next'].'" />'."\n";
 121          }
 122          $c['main'] .= "</p>";
 123       }
 124       $c['main'] .= "</div>\n";
 125  }
 126  
 127  
 128  require (JLOG_BASEPATH.'scripts'.DIRECTORY_SEPARATOR.'do_template.php');
 129  echo $body;
 130  ?>

title

Description

title

Description

title

Description

title

title

Body