| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | /** |
|---|
| 4 | * Jlog |
|---|
| 5 | * |
|---|
| 6 | * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | * it under the terms of the GNU General Public License as published by |
|---|
| 8 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | * (at your option) any later version. |
|---|
| 10 | * |
|---|
| 11 | * This program is distributed in the hope that it will be useful, |
|---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | * GNU General Public License for more details. |
|---|
| 15 | * |
|---|
| 16 | * You should have received a copy of the GNU General Public License |
|---|
| 17 | * along with this program; if not, write to the Free Software |
|---|
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 19 | * |
|---|
| 20 | * $HeadURL$ |
|---|
| 21 | * $Rev$ |
|---|
| 22 | * $Author$ |
|---|
| 23 | * $Date$ |
|---|
| 24 | **/ |
|---|
| 25 | |
|---|
| 26 | require_once('./config.inc.php'); |
|---|
| 27 | require_once(JLOG_LIBPATH . '/bootstrap.php'); |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | $get = strip($_GET); |
|---|
| 31 | if(isset($get['cat'])) $cat_y_link = "cat=".$get['cat']; |
|---|
| 32 | $yl = new Year_Links($get['y'], JLOG_START_YEAR, archive(), $l, $cat_y_link); |
|---|
| 33 | if(isset($get['show'])) $p = (int) escape_for_mysql($get['show']); |
|---|
| 34 | else $p = 0; |
|---|
| 35 | $amount = 5; |
|---|
| 36 | |
|---|
| 37 | $c['meta']['robots'] = "noindex, follow"; |
|---|
| 38 | |
|---|
| 39 | if(isset($get['cat'])) { |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | $c['meta']['title'] = $categories->get($categories->get_id($get['cat']), 'name'); |
|---|
| 43 | $c['main'] .= "<h2>".$l['content_categories_header']." ".$categories->get($categories->get_id($get['cat']), 'name')." ".$yl->get_selected_year()."</h2>"; |
|---|
| 44 | $c['main'] .= "<p>".$categories->get($categories->get_id($get['cat']), 'description')."</p>"; |
|---|
| 45 | |
|---|
| 46 | $sql_archive = " |
|---|
| 47 | SELECT |
|---|
| 48 | ".JLOG_DB_CONTENT.".*, |
|---|
| 49 | ".JLOG_DB_CONTENT.".date as mysql_date, |
|---|
| 50 | DATE_FORMAT(".JLOG_DB_CONTENT.".date, '%c') AS month, |
|---|
| 51 | DATE_FORMAT(".JLOG_DB_CONTENT.".date, '%Y') AS year, |
|---|
| 52 | UNIX_TIMESTAMP(".JLOG_DB_CONTENT.".date) AS date |
|---|
| 53 | FROM ".JLOG_DB_CONTENT." |
|---|
| 54 | LEFT JOIN ".JLOG_DB_CATASSIGN." |
|---|
| 55 | ON ".JLOG_DB_CONTENT.".id = ".JLOG_DB_CATASSIGN.".content_id |
|---|
| 56 | WHERE ".JLOG_DB_CATASSIGN.".cat_id = '".escape_for_mysql($categories->get_id($get['cat']))."' |
|---|
| 57 | AND YEAR(".JLOG_DB_CONTENT.".date) = '".escape_for_mysql($yl->get_selected_year())."' |
|---|
| 58 | ORDER BY mysql_date DESC;"; |
|---|
| 59 | |
|---|
| 60 | $c['main'] .= "<p>".$yl->get_linklist()."</p>"; |
|---|
| 61 | |
|---|
| 62 | } |
|---|
| 63 | elseif(empty($get['y'])) { |
|---|
| 64 | $c['meta']['title'] = $l['content_archive_header']; |
|---|
| 65 | $c['main'] = "<h2>".$c['meta']['title']."</h2>"; |
|---|
| 66 | |
|---|
| 67 | $sql_archive = "SELECT |
|---|
| 68 | *, |
|---|
| 69 | date as mysql_date, |
|---|
| 70 | DATE_FORMAT(date, '%c') AS month, |
|---|
| 71 | DATE_FORMAT(".JLOG_DB_CONTENT.".date, '%Y') AS year, |
|---|
| 72 | UNIX_TIMESTAMP(date) AS date |
|---|
| 73 | FROM ".JLOG_DB_CONTENT." |
|---|
| 74 | WHERE section = 'weblog' |
|---|
| 75 | ORDER BY mysql_date DESC |
|---|
| 76 | LIMIT ".$p.", ".$amount.";"; |
|---|
| 77 | |
|---|
| 78 | $sql_count = "SELECT count(*) AS count FROM ".JLOG_DB_CONTENT." WHERE section = 'weblog'"; |
|---|
| 79 | |
|---|
| 80 | $count_query = new Query($sql_count); |
|---|
| 81 | if($count_query->error()) { |
|---|
| 82 | echo "<pre>\n"; |
|---|
| 83 | echo $count_query->getError(); |
|---|
| 84 | echo "</pre>\n"; |
|---|
| 85 | die(); |
|---|
| 86 | } |
|---|
| 87 | $_count = $count_query->fetch(); |
|---|
| 88 | $count_query->free(); |
|---|
| 89 | $count = $_count['count']; |
|---|
| 90 | } |
|---|
| 91 | else { |
|---|
| 92 | if(!empty($get['m'])) $where_month = " AND MONTH(date) = '".escape_for_mysql($get['m'])."'"; |
|---|
| 93 | $c['meta']['title'] = $l['content_archive_header']; |
|---|
| 94 | $c['main'] = "<h2>".$c['meta']['title']." ".$yl->get_selected_year()."</h2>"; |
|---|
| 95 | |
|---|
| 96 | $sql_archive = "SELECT |
|---|
| 97 | *, |
|---|
| 98 | date as mysql_date, |
|---|
| 99 | DATE_FORMAT(date, '%c') AS month, |
|---|
| 100 | DATE_FORMAT(".JLOG_DB_CONTENT.".date, '%Y') AS year, |
|---|
| 101 | UNIX_TIMESTAMP(date) AS date |
|---|
| 102 | FROM ".JLOG_DB_CONTENT.$where_from." |
|---|
| 103 | WHERE |
|---|
| 104 | YEAR(date) = '".escape_for_mysql($yl->get_selected_year())."' |
|---|
| 105 | ".$where_month." |
|---|
| 106 | AND section = 'weblog' |
|---|
| 107 | ORDER BY mysql_date;"; |
|---|
| 108 | |
|---|
| 109 | $c['main'] .= "<p>".$yl->get_linklist()."</p>"; |
|---|
| 110 | } |
|---|
| 111 | |
|---|
| 112 | $cc = count_comments(); |
|---|
| 113 | |
|---|
| 114 | $archive = new Query($sql_archive); |
|---|
| 115 | if($archive->error()) { |
|---|
| 116 | echo "<pre>\n"; |
|---|
| 117 | echo $archive->getError(); |
|---|
| 118 | echo "</pre>\n"; |
|---|
| 119 | die(); |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | $months = array_flip($l['months']); |
|---|
| 123 | |
|---|
| 124 | if($archive->numRows() > 0) { |
|---|
| 125 | // initialise variables to keep track of last posts month and year |
|---|
| 126 | $last_month = false; |
|---|
| 127 | $last_year = false; |
|---|
| 128 | |
|---|
| 129 | while ($daten = $archive->fetch()) { |
|---|
| 130 | if(empty($daten)) break 1; |
|---|
| 131 | |
|---|
| 132 | // did we already reach a new month or year? |
|---|
| 133 | if (($last_month != $daten['month']) OR ($last_year != $daten['year'])) { |
|---|
| 134 | if ($last_month) { $c['main'] .= " </div>\n"; } |
|---|
| 135 | $c['main'] .= " <h3>".array_search($daten['month'], $months)." ".$daten['year']."</h3>\n"; |
|---|
| 136 | $c['main'] .= " <div class='archive'>\n"; |
|---|
| 137 | // set last month and year to values of current post |
|---|
| 138 | $last_month = $daten['month']; |
|---|
| 139 | $last_year = $daten['year']; |
|---|
| 140 | } |
|---|
| 141 | $c['main'] .= do_teaser($daten, $cc, "<h4>", "</h4>"); |
|---|
| 142 | } |
|---|
| 143 | if(empty($get['y'])) { |
|---|
| 144 | $c['main'] .= "<p class='archivenavigation'>"; |
|---|
| 145 | if(($p - $amount) >= 0) { |
|---|
| 146 | $c['main'] .= "<a href='?show=".($p - $amount)."'><strong><—</strong> ".$l['content_archive_preview']."</a>"; |
|---|
| 147 | $c['meta']['aditionalheader'] .= ' <link rel="prev" href="?show='.($p - $amount).'" title="'.$l['content_archive_preview'].'" />'."\n"; |
|---|
| 148 | } |
|---|
| 149 | if((($p - $amount) >= 0) && (($p + $amount) < $count)) $c['main'] .= " | "; |
|---|
| 150 | if(($p + $amount) < $count) { |
|---|
| 151 | $c['main'] .= "<a href='?show=".($p + $amount)."'>".$l['content_archive_next']." <strong>—></strong></a>"; |
|---|
| 152 | $c['meta']['aditionalheader'] .= ' <link rel="next" href="?show='.($p + $amount).'" title="'.$l['content_archive_next'].'" />'."\n"; |
|---|
| 153 | } |
|---|
| 154 | $c['main'] .= "</p>"; |
|---|
| 155 | } |
|---|
| 156 | $c['main'] .= "</div>\n"; |
|---|
| 157 | } |
|---|
| 158 | |
|---|
| 159 | |
|---|
| 160 | require(JLOG_BASEPATH.'scripts'.DIRECTORY_SEPARATOR.'do_template.php'); |
|---|
| 161 | echo $body; |
|---|
| 162 | |
|---|
| 163 | // eof |
|---|