function newsItem( $date, $user, $text ) { if ($user == "Theoddone33") $user = "theoddone33"; echo '
' . $text . '
' . date ("F, Y", mktime (0,0,0,$month,0,$today['year'],0)) . ''; } $today['year']--; } } function latestNews ( $length ) { need('date sql'); $conn = @mysql_pconnect (sqlHost, sqlUser, sqlPass); if ($conn) { $query = 'SELECT n_date, n_user, n_news FROM news_main' . " WHERE n_date > DATE_SUB(NOW(), INTERVAL $length)" . ' 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++) { list ($n_date, $n_user, $n_news) = mysql_fetch_row ($result); newsItem (dateFromSQLDateTime ($n_date), $n_user, StripSlashes($n_news)); } } else { newsItem ('now', 'Web Server', '
No current news!'); } } else { newsItem ('now', 'Web Server', '
No news in database!'); } mysql_close ($conn); } else { newsItem ('Now', 'Web Server', '
Error: Could not connect to SQL server to fetch news. Please notify the server administrator.'); } } function monthlyNews ( $month, $year ) { need('date sql'); // 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++) { list ($n_date, $n_user, $n_news) = mysql_fetch_row ($result); newsItem (dateFromSQLDateTime ($n_date), $n_user, StripSlashes($n_news)); } } 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', '
Error: Could not connect to SQL server to fetch news. Please notify the server administrator.'); } } function searchNews ( $string ) { need ('date sql'); $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) { tableBoxHeader( 'black', tableHeadColor ); tableTitle( "Search Results", 1, tableHeadColor ); for ($i = 0 ; $i < $numRows ; $i++) { list ($n_date, $n_user, $n_news) = mysql_fetch_row ($result); newsItem (dateFromSQLDateTime ($n_date), $n_user, StripSlashes($n_news)); } tableBoxFooter(); } 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.'); } } ?>