| [ PHPXref.com ] | [ Generated: Sun Jul 20 19:48:29 2008 ] | [ PHPNews 1.3.0 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 error_reporting (E_ALL ^ E_NOTICE); 3 /********************************************* 4 * --------------- * 5 * | Archive.php | * 6 * --------------- * 7 * PHPNews - 1.3.0 Release * 8 * Open Source Project started by Pierce Ward * 9 * * 10 * Software Distributed at: * 11 * http://newsphp.sourceforge.net * 12 * ========================================== * 13 * (c) 2003, 2005 Pierce Ward (Big P) * 14 * All rights reserved. * 15 * ========================================== * 16 * This program has been written under the * 17 * terms of the GNU General Public Licence as * 18 * published by the Free Software Foundation. * 19 * * 20 * The GNU GPL can be found in gpl.txt * 21 *********************************************/ 22 23 /* Get the absolute path */ 24 $path = __FILE__; 25 $path = str_replace('archive.php', '', $path); 26 27 include($path . 'settings.php'); 28 29 /* Don't edit - Connects to DB */ 30 $dbcon = mysql_connect($db_server, $db_user, $db_passwd); 31 mysql_select_db($db_name); 32 33 /* Grabs Settings and puts it in an Array */ 34 $result = mysql_query('SELECT variable,value FROM ' . $db_prefix . 'settings'); 35 $dbQueries++; 36 37 $Settings = array(); 38 while ($row = mysql_fetch_array($result)) 39 { 40 $Settings[$row[0]] = $row[1]; 41 } 42 43 /* Include The Language File */ 44 $lang = $Settings['language']; 45 46 if(!file_exists($path . 'languages/' . $lang . '.news.lng')) 47 { 48 include_once ($path . 'languages/en_GB.news.lng'); 49 setlocale(LC_TIME, $lang); 50 } 51 else 52 { 53 include_once($path . 'languages/' . $lang . '.news.lng'); 54 setlocale(LC_TIME, $lang); 55 } 56 $language = $lng; 57 58 /* 59 Archive Functions 60 You can call each function by its name, eg. 61 <? byMonth(); ?> 62 You can only call either byMonth(); or byCat(); 63 not both in the same page. 64 */ 65 66 /* Display News in Archive by Month/Year */ 67 function byMonth() 68 { 69 global $Settings, $language, $path, $_SERVER, $db_prefix; 70 71 /* Order the news by Month/Year */ 72 if (!$_GET['month'] && !$_GET['year']) 73 { 74 $SQL_query = mysql_query('SELECT DISTINCT month,year FROM ' . $db_prefix . 'news ORDER by id DESC'); 75 76 while ($arc = mysql_fetch_assoc($SQL_query)) 77 { 78 /* Get the total number of posts per month */ 79 $total = mysql_query('SELECT count(*) as total FROM ' . $db_prefix . 'news WHERE month = \'' . $arc['month'] . '\' AND year = \'' . $arc['year'] . '\''); 80 $var = mysql_fetch_assoc($total); 81 82 /* Set up Variables for Template */ 83 $month = strftime('%B', mktime(0, 0, 0, $arc['month'], 1, 0)); 84 $year = $arc['year']; 85 $numPosts = $var['total']; 86 $url = $_SERVER['PHP_SELF']; 87 88 include ($path . 'templates/date_temp.php'); 89 } 90 } 91 /* Display links to the articles */ 92 else if (isset($_GET['month']) && isset($_GET['year'])) 93 { 94 $SQL_query = mysql_query('SELECT n.id,n.posterid,n.postername,n.subject,n.time,p.username,p.email' 95 . ' FROM ' . $db_prefix . 'news AS n' 96 . ' LEFT JOIN ' . $db_prefix . 'posters AS p ON(n.posterid=p.id)' 97 . ' WHERE month=\'' . $_GET['month']. '\' AND year=\'' . $_GET['year'] . '\'' 98 . ' AND n.trusted = 1' 99 . ' ORDER by n.id DESC'); 100 101 while ($posts = mysql_fetch_assoc($SQL_query)) 102 { 103 /* Set up easy variables */ 104 $url = $Settings['siteurl']; 105 $id = $posts['id']; 106 $subject = stripslashes($posts['subject']); 107 $username = $posts['username']; 108 $time = strftime($Settings['shorttimeformat'], $posts['time']); 109 110 if (!$username) 111 { 112 $username = $posts['postername']; 113 } 114 115 if ($posts['email'] != '') 116 { 117 $username = '<a href="mailto:' . $posts['email'] . '">' . $username . '</a>'; 118 } 119 else 120 { 121 $username = $username; 122 } 123 124 include ($path . 'templates/link_temp.php'); 125 } 126 } 127 /* Otherwise, something went wrong, so print out an error message */ 128 else 129 { 130 echo '<b>' , $language['CONTENT_ERROR'] , '</b>: ' , $language['CONTENT_ERRORREQUIREDVARIABLE']; 131 } 132 } 133 134 /* Display News in Archive ordered by Categories */ 135 function byCat() 136 { 137 global $Settings, $language, $path, $_SERVER, $db_prefix; 138 139 /* Sort News by Categories */ 140 if (!$_GET['cat']) 141 { 142 $SQL_query = mysql_query('SELECT DISTINCT * FROM ' . $db_prefix . 'categories ORDER by id ASC'); 143 while ($cat = mysql_fetch_assoc($SQL_query)) 144 { 145 $url = $_SERVER['PHP_SELF']; 146 $catid = $cat['id']; 147 $category = $cat['catname']; 148 149 if ($cat['caticon'] != '') 150 { 151 $caticon = '<img src="' . $cat['caticon'] . '" border="0" alt="' . $category . '">'; 152 } 153 else 154 { 155 $caticon = ''; 156 } 157 158 include ($path . 'templates/cat_temp.php'); 159 } 160 } 161 /* Sort News by month, with News from selected Category only */ 162 else if (isset($_GET['cat']) && !isset($_GET['month']) && !isset($_GET['year'])) 163 { 164 $SQL_query = mysql_query('SELECT DISTINCT month,year FROM ' . $db_prefix . 'news ORDER by id DESC'); 165 166 while ($cat = mysql_fetch_assoc($SQL_query)) 167 { 168 /* Get the total number of posts per month */ 169 $total = mysql_query('SELECT count(*) as total FROM ' . $db_prefix . 'news WHERE catid = \'' . $_GET['cat'] . '\' AND month=\'' . $cat['month'] . '\' AND year=\'' . $cat['year'] . '\''); 170 $var = mysql_fetch_assoc($total); 171 172 /* Set up easy Variables */ 173 $month = strftime('%B', mktime(0, 0, 0, $cat['month'], 1, 0)); 174 $year = $cat['year']; 175 $numPosts = $var['total']; 176 $url = $_SERVER['PHP_SELF']; 177 $catid = $_GET['cat']; 178 179 include ($path . 'templates/catdate_temp.php'); 180 } 181 } 182 /* Display the news links from the Category */ 183 else if (isset($_GET['cat']) && isset($_GET['month']) && isset($_GET['year'])) 184 { 185 $SQL_query = mysql_query('SELECT n.id,n.posterid,n.postername,n.subject,n.time,p.username,p.email' 186 . ' FROM ' . $db_prefix . 'news AS n' 187 . ' LEFT JOIN ' . $db_prefix . 'posters AS p ON(n.posterid=p.id)' 188 . ' WHERE catid=\'' . $_GET['cat'] . '\' AND month=\'' . $_GET['month']. '\' AND year=\'' . $_GET['year'] . '\'' 189 . ' AND n.trusted = 1' 190 . ' ORDER by n.id DESC'); 191 192 while ($posts = mysql_fetch_assoc($SQL_query)) 193 { 194 /* Set up easy variables */ 195 $url = $Settings['siteurl']; 196 $id = $posts['id']; 197 $subject = stripslashes($posts['subject']); 198 $username = $row['username']; 199 $time = strftime($Settings['shorttimeformat'], $posts['time']); 200 201 if (!$username) 202 { 203 $username = $posts['postername']; 204 } 205 206 if ($row['email'] != '') 207 { 208 $username = '<a href="mailto:' . $row['email'] . '">' . $username . '</a>'; 209 } 210 else 211 { 212 $username = $username; 213 } 214 215 include ($path . 'templates/link_temp.php'); 216 } 217 } 218 else 219 { 220 /* Otherwise, something went wrong, so print out an error message */ 221 echo '<b>' , $language['CONTENT_ERROR'] , '</b>: ' , $language['CONTENT_ERRORREQUIREDVARIABLE']; 222 } 223 } 224 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |