| 1 | <?php |
|---|
| 2 | // $Id: archive.php,v 1.3 2005/09/04 20:46:11 onokazu Exp $ |
|---|
| 3 | // ------------------------------------------------------------------------ // |
|---|
| 4 | // XOOPS - PHP Content Management System // |
|---|
| 5 | // Copyright (c) 2000 XOOPS.org // |
|---|
| 6 | // <http://www.xoops.org/> // |
|---|
| 7 | // ------------------------------------------------------------------------- // |
|---|
| 8 | // This program is free software; you can redistribute it and/or modify // |
|---|
| 9 | // it under the terms of the GNU General Public License as published by // |
|---|
| 10 | // the Free Software Foundation; either version 2 of the License, or // |
|---|
| 11 | // (at your option) any later version. // |
|---|
| 12 | // // |
|---|
| 13 | // You may not change or alter any portion of this comment or credits // |
|---|
| 14 | // of supporting developers from this source code or any supporting // |
|---|
| 15 | // source code which is considered copyrighted (c) material of the // |
|---|
| 16 | // original comment or credit authors. // |
|---|
| 17 | // // |
|---|
| 18 | // This program is distributed in the hope that it will be useful, // |
|---|
| 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|---|
| 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|---|
| 21 | // GNU General Public License for more details. // |
|---|
| 22 | // // |
|---|
| 23 | // You should have received a copy of the GNU General Public License // |
|---|
| 24 | // along with this program; if not, write to the Free Software // |
|---|
| 25 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
|---|
| 26 | // ------------------------------------------------------------------------ // |
|---|
| 27 | ###################################################################### |
|---|
| 28 | # Original version: |
|---|
| 29 | # [11-may-2001] Kenneth Lee - http://www.nexgear.com/ |
|---|
| 30 | ###################################################################### |
|---|
| 31 | |
|---|
| 32 | include '../../mainfile.php'; |
|---|
| 33 | $xoopsOption['template_main'] = 'news_archive.html'; |
|---|
| 34 | include XOOPS_ROOT_PATH.'/header.php'; |
|---|
| 35 | include_once './class/class.newsstory.php'; |
|---|
| 36 | include_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/calendar.php'; |
|---|
| 37 | //error_reporting(E_ALL); |
|---|
| 38 | $lastyear = 0; |
|---|
| 39 | $lastmonth = 0; |
|---|
| 40 | |
|---|
| 41 | $months_arr = array(1 => _CAL_JANUARY, 2 => _CAL_FEBRUARY, 3 => _CAL_MARCH, 4 => _CAL_APRIL, 5 => _CAL_MAY, 6 => _CAL_JUNE, 7 => _CAL_JULY, 8 => _CAL_AUGUST, 9 => _CAL_SEPTEMBER, 10 => _CAL_OCTOBER, 11 => _CAL_NOVEMBER, 12 => _CAL_DECEMBER); |
|---|
| 42 | |
|---|
| 43 | $fromyear = (isset($_GET['year'])) ? intval ($_GET['year']): 0; |
|---|
| 44 | $frommonth = (isset($_GET['month'])) ? intval($_GET['month']) : 0; |
|---|
| 45 | |
|---|
| 46 | $useroffset = ""; |
|---|
| 47 | if($xoopsUser){ |
|---|
| 48 | $timezone = $xoopsUser->timezone(); |
|---|
| 49 | if(isset($timezone)){ |
|---|
| 50 | $useroffset = $xoopsUser->timezone(); |
|---|
| 51 | }else{ |
|---|
| 52 | $useroffset = $xoopsConfig['default_TZ']; |
|---|
| 53 | } |
|---|
| 54 | } |
|---|
| 55 | $result = $xoopsDB->query("SELECT published FROM ".$xoopsDB->prefix("stories")." WHERE published>0 AND published<=".time()." AND expired <= ".time()." ORDER BY published DESC"); |
|---|
| 56 | if (!$result) { |
|---|
| 57 | exit(); |
|---|
| 58 | |
|---|
| 59 | } else { |
|---|
| 60 | $years = array(); |
|---|
| 61 | $months = array(); |
|---|
| 62 | $i = 0; |
|---|
| 63 | while (list($time) = $xoopsDB->fetchRow($result)) { |
|---|
| 64 | $time = formatTimestamp($time, "mysql", $useroffset); |
|---|
| 65 | if (preg_match("/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})/", $time, $datetime)) { |
|---|
| 66 | $this_year = intval($datetime[1]); |
|---|
| 67 | $this_month = intval($datetime[2]); |
|---|
| 68 | if (empty($lastyear)) { |
|---|
| 69 | $lastyear = $this_year; |
|---|
| 70 | } |
|---|
| 71 | if ($lastmonth == 0) { |
|---|
| 72 | $lastmonth = $this_month; |
|---|
| 73 | $months[$lastmonth]['string'] = $months_arr[$lastmonth]; |
|---|
| 74 | $months[$lastmonth]['number'] = $lastmonth; |
|---|
| 75 | } |
|---|
| 76 | if ($lastyear != $this_year) { |
|---|
| 77 | $years[$i]['number'] = $lastyear; |
|---|
| 78 | $years[$i]['months'] = $months; |
|---|
| 79 | $months = array(); |
|---|
| 80 | $lastmonth = 0; |
|---|
| 81 | $lastyear = $this_year; |
|---|
| 82 | $i++; |
|---|
| 83 | } |
|---|
| 84 | if ($lastmonth != $this_month) { |
|---|
| 85 | $lastmonth = $this_month; |
|---|
| 86 | $months[$lastmonth]['string'] = $months_arr[$lastmonth]; |
|---|
| 87 | $months[$lastmonth]['number'] = $lastmonth; |
|---|
| 88 | } |
|---|
| 89 | } |
|---|
| 90 | } |
|---|
| 91 | $years[$i]['number'] = $this_year; |
|---|
| 92 | $years[$i]['months'] = $months; $xoopsTpl->assign('years', $years); |
|---|
| 93 | } |
|---|
| 94 | |
|---|
| 95 | if ($fromyear != 0 && $frommonth != 0) { |
|---|
| 96 | $xoopsTpl->assign('show_articles', true); |
|---|
| 97 | $xoopsTpl->assign('lang_articles', _NW_ARTICLES); |
|---|
| 98 | $xoopsTpl->assign('currentmonth', $months_arr[$frommonth]); |
|---|
| 99 | $xoopsTpl->assign('currentyear', $fromyear); |
|---|
| 100 | $xoopsTpl->assign('lang_actions', _NW_ACTIONS); |
|---|
| 101 | $xoopsTpl->assign('lang_date', _NW_DATE); |
|---|
| 102 | $xoopsTpl->assign('lang_views', _NW_VIEWS); |
|---|
| 103 | |
|---|
| 104 | // must adjust the selected time to server timestamp |
|---|
| 105 | $timeoffset = $useroffset - $xoopsConfig['server_TZ']; |
|---|
| 106 | $monthstart = mktime(0 - $timeoffset, 0, 0, $frommonth, 1, $fromyear); |
|---|
| 107 | $monthend = mktime(23 - $timeoffset, 59, 59, $frommonth + 1, 0, $fromyear); |
|---|
| 108 | $monthend = ($monthend > time()) ? time() : $monthend; |
|---|
| 109 | $sql = "SELECT * FROM ".$xoopsDB->prefix("stories")." WHERE published > $monthstart and published < $monthend ORDER by published DESC"; |
|---|
| 110 | $result = $xoopsDB->query($sql); |
|---|
| 111 | $count = 0; |
|---|
| 112 | while ($myrow = $xoopsDB->fetchArray($result)) { |
|---|
| 113 | $article = new NewsStory($myrow); |
|---|
| 114 | $story = array(); |
|---|
| 115 | $story['title'] = "<a href='index.php?storytopic=".$article->topicid()."'>".$article->topic_title()."</a>: <a href='article.php?storyid=".$article->storyid()."'>".$article->title()."</a>"; |
|---|
| 116 | $story['counter'] = $article->counter(); |
|---|
| 117 | $story['date'] = formatTimestamp($article->published(),"m",$useroffset); |
|---|
| 118 | $story['print_link'] = 'print.php?storyid='.$article->storyid(); |
|---|
| 119 | $story['mail_link'] = 'mailto:?subject='.sprintf(_NW_INTARTICLE, $xoopsConfig['sitename']).'&body='.sprintf(_NW_INTARTFOUND, $xoopsConfig['sitename']).': '.XOOPS_URL.'/modules/'.$xoopsModule->dirname().'/article.php?storyid='.$article->storyid(); |
|---|
| 120 | $xoopsTpl->append('stories', $story); |
|---|
| 121 | $count++; |
|---|
| 122 | } |
|---|
| 123 | $xoopsTpl->assign('lang_printer', _NW_PRINTERFRIENDLY); |
|---|
| 124 | $xoopsTpl->assign('lang_sendstory', _NW_SENDSTORY); |
|---|
| 125 | $xoopsTpl->assign('lang_storytotal', sprintf(_NW_THEREAREINTOTAL, $count)); |
|---|
| 126 | } else { |
|---|
| 127 | $xoopsTpl->assign('show_articles', false); |
|---|
| 128 | } |
|---|
| 129 | $xoopsTpl->assign('lang_newsarchives', _NW_NEWSARCHIVES); |
|---|
| 130 | include XOOPS_ROOT_PATH."/footer.php"; |
|---|
| 131 | ?> |
|---|