[ PHPXref.com ] [ Generated: Sun Jul 20 20:18:29 2008 ] [ Siteframe 5.0.2 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> archive.php (source)

   1  <?php
   2  // $Id: archive.php,v 1.9 2005/11/25 17:04:11 glen Exp $
   3  // Copyright (c)2005, Glen Campbell. All rights reserved.
   4  
   5  require_once  'siteframe.inc';
   6  
   7  $year = $_GET['y'];
   8  $month = $_GET['m'];
   9  $day = $_GET['d'];
  10  $fid = $_GET['f'];
  11  
  12  if (!$year && !$month && !$day)
  13      abort(lang('err_badarchive'));
  14  
  15  if ($year && $month && $day)
  16  {
  17      $PAGE->assign('archive_type', $atype='day');
  18      $timestr = sprintf("%04d-%02d-%02d", $year, $month, $day);
  19  }
  20  else if ($year && $month)
  21  {
  22      $PAGE->assign('archive_type', $atype='month');
  23      $timestr = sprintf("%04d-%02d-%02d", $year, $month, 1);
  24  }
  25  else
  26  {
  27      $PAGE->assign('archive_type', $atype='year');
  28      $timestr = sprintf("%04d-%02d-%02d", $year, 1, 1);
  29  }
  30  $PAGE->assign('unixtime', strtotime($timestr.' 00:00:00'));
  31  $PAGE->assign('year', $year);
  32  $PAGE->assign('month', $month);
  33  $PAGE->assign('day', $day);
  34  
  35  $url = sprintf("%s/archive.php?", config('site_path'));
  36  
  37  switch($atype)
  38  {
  39  case 'day':
  40      $where = sprintf(
  41          "page_created BETWEEN '%s' AND '%s'",
  42          $timestr.' 00:00:00',
  43          $timestr.' 23:59:59');
  44      $url .= sprintf('y=%d&amp;m=%d;&amp;d=%d', $year, $month, $day);
  45      break;
  46  case 'month':
  47      $where = sprintf(
  48          "page_created >= '%s' AND page_created < DATE_ADD('%s', INTERVAL 1 MONTH)",
  49          $timestr.' 00:00:00',
  50          $timestr.' 00:00:00');
  51      $url .= sprintf('y=%d&amp;m=%d', $year, $month);
  52      break;
  53  case 'year':
  54      $where = sprintf(
  55          "page_created >= '%s' AND page_created < DATE_ADD('%s', INTERVAL 1 YEAR)",
  56          $timestr.' 00:00:00',
  57          $timestr.' 00:00:00');
  58      $url .= sprintf('y=%d', $year);
  59      break;
  60  }
  61  if ($fid)
  62  {
  63      $f = new Folder($fid);
  64      $where .= sprintf(' AND page_folder_id=%d ', $fid);
  65      $PAGE->assign('folder', $f->get_all());
  66  }
  67  
  68  // get pagination info
  69  // select page
  70  if (isset($_GET['page']))
  71      $page = $_GET['page'];
  72  else
  73      $page = 1;
  74  
  75  // find the total number of pages
  76  $p = new Page;
  77  $q = sprintf("SELECT COUNT(*) FROM %s WHERE %s", $p->table_name(), $where);
  78  $result = $DB->query($q);
  79  check_db();
  80  list($total) = $result->fetch_row();
  81  
  82  // determine start and end
  83  $rpp = config('recent_items');
  84  $start = ($page-1)*$rpp;
  85  
  86  // fetch all the pages for the time period selected
  87  $arr = array();
  88  $p = new Page;
  89  $q = sprintf("SELECT page_id FROM %s WHERE %s ORDER BY page_id DESC",
  90          $p->table_name(), $where);
  91  $myquery = new Query('Page', $q, $start, $rpp);
  92  while($obj = $myquery->get_all())
  93      $arr[] = $obj;
  94  
  95  // assign variables
  96  $PAGE->assign('items', $arr);
  97  $PAGE->assign('item_template', $TEMPLATES['index_item']);
  98  $PAGE->assign('page', $page);
  99  $PAGE->assign('num_pages', intval($total/$rpp)+(($total%$rpp)?1:0));
 100  $PAGE->assign('url', $url);
 101  $PAGE->assign('sep', '&amp;');
 102  
 103  // display the page
 104  $PAGE->display();
 105  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]