2000-07-08 04:06:04 +00:00
|
|
|
<?
|
|
|
|
/*
|
|
|
|
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 '<TR>' .
|
|
|
|
' <TD>' .
|
|
|
|
' <DL>' .
|
|
|
|
' <DT><FONT SIZE="-1">' . "Posted on $date by $user</FONT></DT>" .
|
|
|
|
" <DD><P>$text</DD>" .
|
|
|
|
' </DL>' .
|
|
|
|
' </TD>' .
|
|
|
|
'</TR>';
|
|
|
|
}
|
|
|
|
|
|
|
|
function newsEntry ($array)
|
|
|
|
{
|
|
|
|
need ("date");
|
|
|
|
|
|
|
|
if ($array[n_user] == "Theoddone33") $user = "theoddone33";
|
|
|
|
return '<TR>' .
|
|
|
|
' <TD>' .
|
|
|
|
' <DL>' .
|
|
|
|
' <DT><FONT SIZE="-1"> Posted on ' . dateFromSQLDateTime ($array[n_date]) . ' by ' . $array[n_user] . '</FONT></DT>' .
|
|
|
|
' <DD><P>' . StripSlashes ($array[n_news]) . '</DD>' .
|
|
|
|
' </DL>' .
|
|
|
|
' </TD>' .
|
|
|
|
'</TR>';
|
|
|
|
}
|
|
|
|
|
|
|
|
function monthForm ()
|
|
|
|
{
|
|
|
|
?><FORM name="bymonth" method="get" action="/old_news.php"><?
|
|
|
|
tableBoxHeader ('black', tableHeadColor);
|
|
|
|
tableTitle ("Search by Month", 1, tableHeadColor);
|
2001-01-04 21:58:34 +00:00
|
|
|
?><TD align="center"><?
|
2000-07-08 04:06:04 +00:00
|
|
|
tableHeader("100%", featureBgColor);
|
|
|
|
?>
|
|
|
|
<TR vAlign="center">
|
|
|
|
<TD align="center">
|
|
|
|
<STRONG>Month:</STRONG>
|
|
|
|
</TD>
|
|
|
|
<TD align="center">
|
|
|
|
<SELECT name="month">
|
|
|
|
<?
|
|
|
|
for ( $i = 1 ; $i < 13 ; $i++ ) {
|
2001-02-12 17:25:01 +00:00
|
|
|
printf ("<OPTION>%02d</OPTION>", $i);
|
2000-07-08 04:06:04 +00:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
</SELECT>
|
|
|
|
</TD>
|
|
|
|
<TD align="center">
|
|
|
|
<STRONG>Year:</STRONG>
|
|
|
|
</TD>
|
|
|
|
<TD align="center">
|
|
|
|
<SELECT name="year">
|
2001-01-04 21:25:00 +00:00
|
|
|
<OPTION>2000</OPTION>
|
2001-02-12 17:25:01 +00:00
|
|
|
<OPTION selected>2001</OPTION>
|
2000-07-08 04:06:04 +00:00
|
|
|
</SELECT>
|
|
|
|
</TD>
|
|
|
|
</TR>
|
|
|
|
<TR vAlign="center">
|
|
|
|
<TD align="center" colSpan="4">
|
2001-02-12 17:25:01 +00:00
|
|
|
<INPUT type="submit" value="Search">
|
2000-07-08 04:06:04 +00:00
|
|
|
</TD>
|
|
|
|
</TR>
|
|
|
|
<?
|
|
|
|
tableFooter ();
|
|
|
|
tableBoxFooter ();
|
|
|
|
?>
|
|
|
|
</FORM>
|
|
|
|
<?
|
|
|
|
}
|
|
|
|
|
|
|
|
function keywordForm ()
|
|
|
|
{
|
|
|
|
?><FORM name="bystring" method="get" action="/old_news.php"><?
|
|
|
|
tableBoxHeader ('black', tableHeadColor);
|
|
|
|
tableTitle ("Search by String", 1, tableHeadColor);
|
|
|
|
?><TD align="center"><?
|
|
|
|
tableHeader("100%", featureBgColor);
|
|
|
|
?>
|
|
|
|
<TR vAlign="center">
|
|
|
|
<TD align="center">
|
|
|
|
<STRONG>String:</STRONG>
|
|
|
|
</TD>
|
|
|
|
<TD align="center">
|
|
|
|
<INPUT name="string" type="text" size="25">
|
|
|
|
</TD>
|
|
|
|
</TR>
|
|
|
|
<TR vAlign="center">
|
|
|
|
<TD align="center" colSpan="2">
|
|
|
|
<INPUT TYPE="submit" VALUE="Search">
|
|
|
|
</TD>
|
|
|
|
</TR>
|
|
|
|
<?
|
|
|
|
tableFooter ();
|
|
|
|
tableBoxFooter ();
|
|
|
|
?>
|
|
|
|
</FORM>
|
|
|
|
<?
|
|
|
|
}
|
|
|
|
|
|
|
|
function fetchNewsEntry ($number)
|
|
|
|
{
|
|
|
|
need('date');
|
|
|
|
|
2001-05-03 04:35:36 +00:00
|
|
|
$conn = @mysql_pconnect (sqlHost, sqlUser, sqlPass);
|
|
|
|
if ($conn) {
|
|
|
|
$query = 'SELECT n_date, n_user, n_news FROM news_main' .
|
|
|
|
" ORDER BY n_date DESC LIMIT $number";
|
|
|
|
$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);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return 0;
|
2000-07-08 04:06:04 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
2001-05-03 04:35:36 +00:00
|
|
|
mysql_close ($conn);
|
2000-07-08 04:06:04 +00:00
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
2001-05-03 04:35:36 +00:00
|
|
|
// return (list (dateFromSQLDateTime ($n_date), $n_user, StripSlashes($n_news)));
|
2000-07-08 18:43:38 +00:00
|
|
|
return 0;
|
2000-07-08 04:06:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function latestNews ($length)
|
|
|
|
{
|
2001-05-06 02:38:07 +00:00
|
|
|
if (sqlAvail) {
|
2001-05-03 04:35:36 +00:00
|
|
|
$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++) {
|
|
|
|
$news[$i] = mysql_fetch_array ($result);
|
|
|
|
echo newsEntry ($news[$i]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
newsItem ('now', 'Web Server', '<P>No current news!');
|
2000-07-08 04:06:04 +00:00
|
|
|
}
|
|
|
|
} else {
|
2001-05-03 04:35:36 +00:00
|
|
|
newsItem ('now', 'Web Server', '<P>No news in database!');
|
2000-07-08 04:06:04 +00:00
|
|
|
}
|
2001-05-03 04:35:36 +00:00
|
|
|
mysql_close ($conn);
|
2000-07-08 04:06:04 +00:00
|
|
|
} else {
|
2001-05-03 04:35:36 +00:00
|
|
|
include 'cache.php';
|
|
|
|
return 1;
|
2000-07-08 04:06:04 +00:00
|
|
|
}
|
2001-05-03 04:35:36 +00:00
|
|
|
return 0;
|
2000-07-08 04:06:04 +00:00
|
|
|
} else {
|
2001-05-03 04:35:36 +00:00
|
|
|
newsItem ('now', 'Web Server', '<P>No SQL server available!');
|
2001-05-03 04:39:07 +00:00
|
|
|
return 0;
|
2000-07-08 04:06:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function monthlyNews ($month, $year)
|
|
|
|
{
|
|
|
|
// Do sanity checking on dates
|
2001-05-06 02:53:19 +00:00
|
|
|
if (((!is_int ($year)) || $year < 2000)) {
|
|
|
|
$year = date ('Y', time ());
|
2000-07-08 04:06:04 +00:00
|
|
|
}
|
2001-05-06 03:03:58 +00:00
|
|
|
|
2000-07-08 04:06:04 +00:00
|
|
|
if ($month < 1 || $month > 12) {
|
|
|
|
$month = date ('m', time ());
|
|
|
|
}
|
2001-05-06 03:03:58 +00:00
|
|
|
|
|
|
|
$date = sprintf ("%02d-%02d", $year - 2000, $month);
|
2001-05-06 03:05:19 +00:00
|
|
|
echo $date;
|
2000-07-08 04:06:04 +00:00
|
|
|
|
2001-05-06 02:38:07 +00:00
|
|
|
if (sqlAvail) {
|
2001-05-03 04:35:36 +00:00
|
|
|
$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', '<P>No news for this month!');
|
2000-07-08 04:06:04 +00:00
|
|
|
}
|
|
|
|
} else {
|
2001-05-03 04:35:36 +00:00
|
|
|
newsItem ('now', 'Web Server', '<P>No news in database!');
|
2000-07-08 04:06:04 +00:00
|
|
|
}
|
2001-05-03 04:35:36 +00:00
|
|
|
mysql_close ($conn);
|
2000-07-08 04:06:04 +00:00
|
|
|
} else {
|
2001-05-03 04:35:36 +00:00
|
|
|
newsItem ('now', 'Web Server', '<STRONG>SQL error!</STRONG> Please contact the <A href="mailto:deek@quakeforge.net">Webmaster</A>.');
|
2000-07-08 04:06:04 +00:00
|
|
|
}
|
|
|
|
} else {
|
2001-05-03 04:35:36 +00:00
|
|
|
newsItem ('now', 'Web Server', '<P>No SQL server available');
|
2000-07-08 04:06:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function searchNews ($string)
|
|
|
|
{
|
2001-05-06 02:38:07 +00:00
|
|
|
if (sqlAvail) {
|
2001-05-03 04:35:36 +00:00
|
|
|
$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'");
|
2000-07-08 04:06:04 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
newsItem ('now', 'Web Server', "No news found matching '$string'");
|
|
|
|
}
|
2001-05-03 04:35:36 +00:00
|
|
|
mysql_close ($conn);
|
|
|
|
} else {
|
|
|
|
newsItem ('now', 'Web Server', '<STRONG>SQL error!</STRONG> Please contact the <A href="mailto:deek@quakeforge.net">Webmaster</A>.');
|
2000-07-08 04:06:04 +00:00
|
|
|
}
|
2001-05-03 04:35:36 +00:00
|
|
|
} else {
|
|
|
|
newsItem ('now', 'Web Server', '<P>No SQL server available');
|
2000-07-08 04:06:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|