mirror of
https://git.code.sf.net/p/quake/website
synced 2025-02-17 09:21:29 +00:00
News stuff: all the SQL-accessing news stuff is now in news_funcs.php --
I'm considering moving this into lib/news.php, once I get permission from Dan Olson to GPL his contributions to that file.
This commit is contained in:
parent
bd29c47355
commit
927f37abfc
5 changed files with 243 additions and 107 deletions
|
@ -1,6 +1,6 @@
|
|||
<? // Preamble
|
||||
$pageName = "News";
|
||||
$focused = "home"; // Dock icon name to gets a border
|
||||
$focused = "home"; // Dock icon name to get a border
|
||||
require("parts/preamble.php"); // Load most of document
|
||||
?>
|
||||
<!--SEARCHME-->
|
||||
|
@ -10,7 +10,7 @@
|
|||
tableBoxHeader( 'black', tableHeadColor );
|
||||
tableTitle( 'Latest News', 1, tableHeadColor );
|
||||
require("news_funcs.php");
|
||||
include("cur_news.php");
|
||||
latestNews('1 month');
|
||||
tableBoxFooter();
|
||||
?></TD>
|
||||
</TR>
|
||||
|
|
18
news.php
18
news.php
|
@ -3,11 +3,21 @@
|
|||
$focused = "none"; // Dock icon name to gets a border
|
||||
require("parts/preamble.php"); // Load most of document
|
||||
?>
|
||||
<!--SEARCHME-->
|
||||
<? require("news_funcs.php");
|
||||
listMonths ();
|
||||
<?
|
||||
require("news_funcs.php");
|
||||
?>
|
||||
<!--NOSEARCH-->
|
||||
<TABLE cellSpacing="2" cellPadding="0" border="0">
|
||||
<TR vAlign="top">
|
||||
<TD align="center">
|
||||
<? monthForm (); ?>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR vAlign="top">
|
||||
<TD align="center">
|
||||
<? keywordForm (); ?>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<?
|
||||
require("parts/postamble.php"); // Finish this sucker up
|
||||
?>
|
||||
|
|
228
news_funcs.php
228
news_funcs.php
|
@ -1,28 +1,200 @@
|
|||
<?
|
||||
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 listMonths ( )
|
||||
{
|
||||
$startyear = 2000;
|
||||
$today = getdate ();
|
||||
while ($startyear <= $today['year'])
|
||||
{
|
||||
for ($month = $today['mon']+1 ; $month > 1 ; $month--)
|
||||
{
|
||||
echo '<P><A HREF="old_news.php?mon=' .
|
||||
date ("m", mktime (0,0,0,$month,0,0,0)) .
|
||||
'&yr=' .
|
||||
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 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>.');
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
need ('date sql');
|
||||
require("news_funcs.php");
|
||||
$searchString = "'%$string%'";
|
||||
$conn = @mysql_pconnect (sqlHost, sqlUser, sqlPass);
|
||||
if ($conn) {
|
||||
$query = 'SELECT n_date, n_user, n_news FROM news_main WHERE '.
|
||||
'n_news LIKE ' . $searchString . ' ORDER BY n_date DESC';
|
||||
$result = @mysql_db_query (sqlDB, $query, $conn);
|
||||
if ($result) {
|
||||
$numRows = @mysql_num_rows ($result);
|
||||
if ($numRows) {
|
||||
echo '<TABLE width="100%" cellSpacing="0" cellPadding="0" border="0">'.
|
||||
' <TR vAlign="top"> <TD colSpan="2">';
|
||||
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();
|
||||
echo '</TD></TR></TABLE>';
|
||||
} else {
|
||||
echo '<P>No news found matching "' . $string . '"';
|
||||
}
|
||||
} else {
|
||||
echo '<P>No news found matching "' . $string . '"\n';
|
||||
}
|
||||
mysql_close ($conn);
|
||||
} else {
|
||||
echo '<P>SQL error, please contact the webmaster.';
|
||||
}
|
||||
?>
|
67
old_news.php
67
old_news.php
|
@ -1,42 +1,29 @@
|
|||
<?
|
||||
if (((!is_int($yr)) || $yr < 2000)) $yr = date('Y',time());
|
||||
if ($mon < 1 || $mon > 12) $mon = date('m',time());
|
||||
$pageName = 'News: '. date("F, Y", mktime(0,0,0,$mon+1,0,$yr,0));
|
||||
$focused = "none";
|
||||
require("parts/preamble.php"); // Load most of document
|
||||
|
||||
need ('date sql');
|
||||
require ("news_funcs.php");
|
||||
echo '<TABLE width="100%" cellSpacing="0" cellPadding="0" border="0"> <TR vAlign="top"> <TD colSpan="2">';
|
||||
tableBoxHeader( 'black', tableHeadColor );
|
||||
tableTitle( $pageName, 1, tableHeadColor );
|
||||
|
||||
$mydate = $yr . '-' . $mon;
|
||||
$conn = @mysql_pconnect (sqlHost, sqlUser, sqlPass);
|
||||
if ($conn) {
|
||||
$query = 'SELECT n_date, n_user, n_news FROM news_main WHERE '.
|
||||
'n_date BETWEEN \'' . $mydate . '-00 00:00:00\' AND '.
|
||||
'\'' . $mydate . '-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.');
|
||||
}
|
||||
tableBoxFooter();
|
||||
echo '</TD></TR></TABLE>';
|
||||
require("parts/postamble.php");
|
||||
$pageName = 'News Archives';
|
||||
$focused = "home"; // Dock icon name to get a border
|
||||
require("parts/preamble.php"); // Load most of document
|
||||
?>
|
||||
<!--NOSEARCH-->
|
||||
<TABLE width="100%" cellSpacing="0" cellPadding="0" border="0">
|
||||
<TR vAlign="top">
|
||||
<TD colSpan="2"><?
|
||||
tableBoxHeader( 'black', tableHeadColor );
|
||||
tableTitle( $pageName, 1, tableHeadColor );
|
||||
require ("news_funcs.php");
|
||||
if ($month || $year) {
|
||||
monthlyNews ($month, $year);
|
||||
} else {
|
||||
if ($string) {
|
||||
searchNews ($string);
|
||||
} else {
|
||||
newsItem ('now', 'Web Server', "You didn't specify a search, giving up.");
|
||||
}
|
||||
}
|
||||
tableBoxFooter ();
|
||||
?></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<!--NOSEARCH-->
|
||||
<?
|
||||
require("parts/postamble.php"); // Finish this sucker up
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue