mirror of
https://git.code.sf.net/p/quake/website
synced 2024-11-28 06:53:50 +00:00
200 lines
5.3 KiB
PHP
200 lines
5.3 KiB
PHP
<?
|
|
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 monthForm ()
|
|
{
|
|
?><FORM name="bymonth" method="get" action="/old_news.php"><?
|
|
tableBoxHeader ('black', tableHeadColor);
|
|
tableTitle ("Search by Month", 1, tableHeadColor);
|
|
?><TD align="center"><?
|
|
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++ ) {
|
|
printf("<OPTION>%02d</OPTION>", $i);
|
|
}
|
|
?>
|
|
</SELECT>
|
|
</TD>
|
|
<TD align="center">
|
|
<STRONG>Year:</STRONG>
|
|
</TD>
|
|
<TD align="center">
|
|
<SELECT name="year">
|
|
<OPTION SELECTED>2000</OPTION>
|
|
</SELECT>
|
|
</TD>
|
|
</TR>
|
|
<TR vAlign="center">
|
|
<TD align="center" colSpan="4">
|
|
<INPUT TYPE="submit" VALUE="Search">
|
|
</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 listMonths ()
|
|
{
|
|
$startyear = 2000;
|
|
$today = getdate ();
|
|
|
|
while ($startyear <= $today['year']) {
|
|
for ($month = $today['mon']+1 ; $month > 1 ; $month--) {
|
|
echo '<P><A href="old_news.php?month=' .
|
|
date ("m", mktime (0,0,0,$month,0,0,0)) .
|
|
'&year=' . date ("Y", mktime (0,0,0,0,0,$today['year']+1,0)) . '">' .
|
|
date ("F, Y", mktime (0,0,0,$month,0,$today['year'],0)) .
|
|
'</A>';
|
|
}
|
|
$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', '<P>No current news!');
|
|
}
|
|
} else {
|
|
newsItem ('now', 'Web Server', '<P>No news in database!');
|
|
}
|
|
mysql_close ($conn);
|
|
} else {
|
|
newsItem ('Now', 'Web Server', '<P>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', '<P>No news for this month!');
|
|
}
|
|
} else {
|
|
newsItem ('now', 'Web Server', '<P>No news in database!');
|
|
}
|
|
mysql_close ($conn);
|
|
} else {
|
|
newsItem ('Now', 'Web Server', '<P>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', '<STRONG>SQL error!</STRONG> Please contact the <A href="mailto:deek@quakeforge.net">Webmaster</A>.');
|
|
}
|
|
}
|
|
?>
|