News
/* if requested, get old news */
if ( isset($getvars['y']) && is_numeric($getvars['y'])
&& isset($getvars['m']) && is_numeric($getvars['m']) )
{
// paranoia, just in case is_numeric() ever has a vuln
preg_replace ("/[^0-9]/", "", $getvars['y']);
preg_replace ("/[^0-9]/", "", $getvars['m']);
$month = $getvars['m'];
$year = $getvars['y'];
$limitmonth = 1;
}
else
{
sscanf (gmdate ("n", $timenow), "%d", $month);
sscanf (gmdate ("Y", $timenow), "%d", $year);
}
if ( isset($getvars['d']) && is_numeric($getvars['d']) )
{
preg_replace ("/[^0-9]/", "", $getvars['d']);
$day = $getvars['d'];
$limitday = 1;
}
else
{
sscanf (gmdate ("d", $timenow), "%d", $day);
}
$lastmodtime = gmdate("D, d M Y H:i:s",filemtime($files["news-entries"]));
printf ("- ");
if ($limitmonth || $limitday)
{
// limited display of news requested, eg to a day or month.
#print "debug: $limitmonth $limitday $year $month";
// handle the limitmonth case.
if (!$limitday && isset ($newsentries[$year][$month]))
foreach ($newsentries[$year][$month] as $dkey => $text)
{
#printf ("debug: %d %d %d
- %d-%02d-%02d:%s ", $year, $month, $dkey, $text); displaydayentries ($newsentries[$year][$month][$dkey], $year, $month, $dkey); } // specific day case else if (isset ($newsentries[$year][$month][$day])) displaydayentries ($newsentries[$year][$month][$day], $year, $month, $day); else printf ("no news..."); // something wrong or user played with url.. } else { // general view of recent news. while ($displayed <= $newsdefaultdisplay && $limittimes > 0) { #printf ("debug: %d %d %d
", $year, $month, $day); #printf ("
", $year, $month, $day); if (isset ($newsentries[$year][$month][$day])) { displaydayentries ($newsentries[$year][$month][$day], $year, $month, $day); $displayed++; } $day--; /* skip through empty months */ if ($day == 0) { $day = 31; do { $month--; if ($month == 0) { $month = 12; $year--; } } while (!isset ($newsentries[$year][$month]) && $year > 2002); } # just in case $limittimes--; } } // if month was limited user got the whole months worth of news, // so find the next month with news, to link old news to.. if ($limitmonth > 0) { do { $month--; if ($month == 0) { $month = 12; $year--; } } while (!isset($newsentries[$year][$month]) && $year > 2002); } if (isset($newsentries[$year][$month])) printf ("
Older news", $year,$month); ?>