/* news.php SQL-based news reading library Copyright (C) 2000 Contributors of the QuakeForge Project Please see the file "AUTHORS" for a list of contributors This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to: Free Software Foundation, Inc. 59 Temple Place - Suite 330 Boston, MA 02111-1307, USA. */ have ('news'); function newsItem ($date, $user, $text) { if ($user == "Theoddone33") $user = "theoddone33"; echo '
$text
' . StripSlashes ($array[n_news]) . '
No current news!'); } } else { newsItem ('now', 'Web Server', '
No news in database!'); } mysql_close ($conn); } else { include 'cache.php'; return 1; } return 0; } function monthlyNews ($month, $year) { // Do sanity checking on dates if (((!is_int ($year)) || $year < 2000)) { $year = date ('Y', time ()); } if ($month < 1 || $month > 12) { $month = date ('m', time ()); } $date = "$year-$month"; $conn = @mysql_pconnect (sqlHost, sqlUser, sqlPass); if ($conn) { $query = 'SELECT n_date, n_user, n_news FROM news_main' . " WHERE n_date BETWEEN '$date-00 00:00:00'" . " AND '$date-31 23:59:59'" . ' ORDER BY n_date DESC'; $result = @mysql_db_query (sqlDB, $query, $conn); if ($result) { $numRows = @mysql_num_rows ($result); if ($numRows) { for ($i = 0 ; $i < $numRows ; $i++) { $news[$i] = mysql_fetch_array ($result); echo newsEntry ($news[$i]); } } else { newsItem ('now', 'Web Server', '
No news for this month!'); } } else { newsItem ('now', 'Web Server', '
No news in database!'); } mysql_close ($conn); } else { newsItem ('now', 'Web Server', 'SQL error! Please contact the Webmaster.'); } } function searchNews ($string) { $search = AddSlashes ("%$string%"); $conn = @mysql_pconnect (sqlHost, sqlUser, sqlPass); if ($conn) { $query = 'SELECT n_date, n_user, n_news FROM news_main' . " WHERE n_news LIKE '$search'" . ' ORDER BY n_date DESC'; $result = @mysql_db_query (sqlDB, $query, $conn); if ($result) { $numRows = @mysql_num_rows ($result); if ($numRows) { for ($i = 0 ; $i < $numRows ; $i++) { $news[$i] = mysql_fetch_array ($result); echo newsEntry ($news[$i]); } } else { newsItem ('now', 'Web Server', "No news found matching '$string'"); } } else { newsItem ('now', 'Web Server', "No news found matching '$string'"); } mysql_close ($conn); } else { newsItem ('now', 'Web Server', 'SQL error! Please contact the Webmaster.'); } } ?>