<?php

/*
--------------------------------------------------------------------
FLATCALENDAR - Calendar block for FlatNuke (http://www.flatnuke.org)
--------------------------------------------------------------------

Author:		Marco Segato
Website:	http://marcosegato.altervista.org/
email:		segatom (at) users.sourceforge.net

Author:		Giovanni Piller Cottrer
Website:	http://gigasoft.altervista.org
email:		giovanni.piller (at) gmail.com

Version:	0.10 - 20061015

License:	GNU General Public License 2

*/


// do not let users directly access this file
if (eregi("section.php",$_SERVER['PHP_SELF'])) {
	Header("Location: ../../index.php");
	die();
}

// security convertions
$req = getparam("REQUEST_URI", PAR_SERVER, SAN_NULL);
$url = basename($req);
$aa  = getparam("aa", PAR_GET, SAN_FLAT);
$mm  = getparam("mm", PAR_GET, SAN_FLAT);
$dd  = getparam("dd", PAR_GET, SAN_FLAT);

// Flanuke configuration
global $mesi, $fuso_orario;

// variables definition
$okmese = array(0,0,0,0,0,0,0,0,0,0,0,0);
$okanno = array();


if(($aa!="" AND is_numeric($aa) AND $aa>(date("Y")-1000) AND $aa<(date("Y")+1000)) AND ($mm!="" AND is_numeric($mm) AND $mm>0 AND $mm<13) AND ($dd!="" AND is_numeric($dd) AND $dd>0 AND $dd<32)) {
	$my_modlist = array();
	$handle = opendir('news');
	while ($file = readdir($handle)) {
		if (!( $file=="." or $file==".." )) {
			array_push($my_modlist, $file);
		}
	}
	closedir($handle);
	if(count($my_modlist)>0) {
		rsort($my_modlist);
	}
	#print_r($my_modlist); //-> TEST
	for ($i=0; $i < sizeof($my_modlist); $i++) {
		$tmp = str_replace(".xml","",$my_modlist[$i]);
		$giorno = date("d",$tmp+(3600*$fuso_orario));
		$mese   = date("m",$tmp+(3600*$fuso_orario));
		$anno   = date("Y",$tmp+(3600*$fuso_orario));
		if ($mese<10) {
			$mese = str_replace("0","",$mese);
		}
		if($anno==$aa AND $mese==$mm AND $giorno==$dd) {
			$string = get_file('news/'.$my_modlist[$i]);
			$title  = get_xml_element("fn:title",$string);
			$reads  = get_xml_element("fn:reads",$string);
			$id     = str_replace(".xml","",$my_modlist[$i]);
			echo "\n<img src='themes/$theme/images/read.png' alt='Read' />&nbsp;";
			echo "<a href='index.php?mod=read&amp;id=$id' title='"._FLEGGI." news: $title'>$title</a>&nbsp;";
			echo "(".date("d/m/Y - H:i",$id+(3600*$fuso_orario)).") "._LETTO." $reads "._VOLTE."<br />";
		}
	}
} else echo _NORESULT;

?>
