<?php

$domain = $_SERVER[REMOTE_ADDR];
$from = $_SERVER[HTTP_REFERER]; 

$host = $_SERVER[REMOTE_HOST];

require 'include/MyTemplate.class.php';

$T = new MyTemplate();

$Maintpl= "template/index.tpl";

/* set template which contains nested template, which will be shown at the top and bottom of the page */
$T->setFile('page', $Maintpl);


if (!isset($_GET['pageId']))
	{
		$page="home";
		$Filecontent="contents/home.html";
		$title = "Homepage";
	}
else
   {
 //   if (ereg("\.\.",$_GET['pageId'])) exit();
    $page=$_GET['pageId'];
    $Filecontent="contents/$page.html";
	$title = $page;
}

if (!$Handle = fopen ($Filecontent, "r")) {
			 print "Errore nel reperimento dei dati**";
			 exit;
			}

			if (!$Content = fread ($Handle, filesize ($Filecontent)) ){
					 print "Errore nel reperimento dei dati 2";
					 exit;
			}
fclose ($Handle);

 
 $importantDatesContent="contents/importantDates";
 if (!$Handle = fopen ($importantDatesContent, "r")) {
			 print "Errore nel reperimento dei dati**";
			 exit;
			}

			if (!$importantDates = fread ($Handle, filesize ($importantDatesContent)) ){
					 print "Errore nel reperimento dei dati 2";
					 exit;
			}
fclose ($Handle);
 
 
$T->assignVars('content', $Content);
$T->assignVars('importantDates', $importantDates);
$T->fprint('page');


?>
