<?php

$page=$_GET["page"];
$modulepage=$_GET["modulepage"];

function getmicrotime(){ 
    list($usec, $sec) = explode(" ",microtime()); 
        return ((float)$usec + (float)$sec); 
	    } 
$startgen = getmicrotime ();
// visites
//$lvc_include_dir = 'visit/include/';
//include($lvc_include_dir.'new-visitor.inc.php3');

/*include "include/random.inc.php";
include "include/timer.inc.php";*/

//$param = parse_ini_file("config/pip.ini");
//extract($param);

/* $NewsFileLogo = "modules/news/logos";
$couleur = RandomColors(); */

include "include/theme.inc.php";

if (file_exists("themes/$theme/theme.php"))
        include "themes/$theme/theme.php";
else
        include "themes/e/theme.php";

if (!isset($section) || $section == "")
        $section="pages";

if ($page == "index")
	$page="menu";

if (isset($File))
        $FileNews = $File;

// if (!isset($FileNews))
//        $FileNews = "modules/news/news";

extract($themeset, EXTR_OVERWRITE);

include "include/head.inc.php";
include "include/body.inc.php";

// ************** haut de page ******************
/*if (!isset($header) || ($header ==1))
{
        include "header.php";
}*/

echo "<table border='0' width='100%'><tr>\n"; // tableau principal

// *************** gauche *****************
if (!isset($left) || ($left ==1))
{
//echo "<div class='ltop'>";
        $cachefile = "tmp/left.cache.html";
        if (!file_exists($cachefile) || (filemtime($cachefile) < filemtime("modules/liens")))
        {
                $cachecontent=file_get_contents("http://tma.tourmentine.com/left.php");
                $fp = fopen($cachefile,"w");
                fwrite($fp,$cachecontent);
                fclose($fp);
        }
        echo "\n\n<!-- Partie mise en cache (".date("d/m/Y@H:i:s", filemtime($cachefile)).")-->\n\n";
        echo "<td valign='top' class='colonne'>\n";
        include $cachefile;
        echo "</td>\n";
        echo "\n<!-- fin Partie mise en cache -->\n\n";
//	echo "</div>";
}
// ************** centre ****************
echo "<td class='pageseparator'><img src='/modules/share/trans.gif' alt='' title='' width='20' class='border0' /></td><td valign='top'>\n";

// --- gestion des modules ---
if (isset($modulepage))
{
        //include "include/logo.inc.php";
       switch($modulepage)
        {
                case "sondage":

                        extract($themeset, EXTR_OVERWRITE);

                        $headstartcode = "<font name='verdana' size='3' class='centerhead'>";
                        $headendcode ="</font>";
                        $bodyclass="centerbody";
                        $module = "sondage";
                        $titre = "Résultats du sondage";

                        include "modules/magicbox.php";
                        break; 
		case "goldbook":
			unset($NbMaxPost);
                        extract($themeset, EXTR_OVERWRITE);

                        $headstartcode = "<font size='3' class='centerhead'>";
                        $headendcode ="</font>";
                        $bodyclass = "centerbody";
                        $module = "goldbook";
                        $titre = "Livre d'or";
                        $GoldbookFile = "goldbook";
			echo "<br /><br /><br />\n<div align='center'><h1>Laissez-nous un message...</h1></div><br />\n";
                        include "modules/magicbox.php";
                        unset($bodyclass);
                        break;

                case "addnews":
                        extract($themeset, EXTR_OVERWRITE);

                        if (isset($File))
                                $FileNews = $File;

                        // fichier de news par défaut
                        if (!isset($FileNews))
                                $FileNews = "modules/news/news";

                        $headstartcode = "<font name='verdana' size='3' class='centerhead'>";
                        $headendcode ="</font>";
                        $bodyclass = "centerbody";
                        $module = "admin/addnews";
                        $titre = "Ajout d'une nouvelle";

                        include "modules/magicbox.php";
                        unset($bodyclass);
                        // unset($NewsFile);
                        // unset($File);
                        break;

                case "affnews":

                        if (isset($File))
                                $FileNews = $File;

                        if (!isset($FileNews))
                                $FileNews = "modules/news/pipnews";

                        // appel direct du module affnews ; magicbox est appelé par ce dernier
                        include "modules/affnews.php";
                        unset($NewsFile);
                        // unset($newsnb);
                        //unset($File);
                        break;

                case "commentnews":
                        if (isset($File))
                                $FileNews = $File;

                        if (!isset($FileNews))
                                $FileNews = "modules/news/news";

                        $modulepage="affnews";
                        $start=$idnews;
                        $NbMaxNews=1;
                        include "modules/affnews.php";

                        $headstartcode = "<font name='verdana' size='3' class='centerhead'>";
                        $headendcode ="</font>";
                        $bodyclass = "centerbody";
                        $module = "forum";
                        $titre = "Commentaires";
                        //$goldbooktype = "comment";
                        $forumfile = "$FileNews.$idnews.forum.csv";
                        include "modules/magicbox.php";
                        //$modulepage = "commentbook";
                        // unset($goldbooktype);
                        // unset($NewsFile);
                        // unset($File);
                        break;
		case "print":
			if (isset($File))
                                $FileNews = $File;

                        if (!isset($FileNews))
                                $FileNews = "modules/news/news";

			include "modules/print.php";
			break;

                case "backend":
                        if (isset($File))
                                $FileNews = $File;

                        if (!isset($FileNews))
                                $FileNews = "modules/news/news";

                        include "modules/genbackend.php";
                        break;
                case "chatlogin":
                        extract($themeset, EXTR_OVERWRITE);
                        $bodyclass = "centerbody";
                        $module = "kikchat/login";
                        $headstartcode = "<font name='verdana' size='3' class='centerhead'>";
                        $headendcode ="</font>";
                        $titre = "Bienvenue sur le chat";
                        $bodystartcode="<div align=center>";
                        $bodyendcode="</div>";

                        $footerbox = 1;
                        $footerboxtext = "Retour au menu";
                        $footerlien = "/";

                        include "modules/magicbox.php";
                        unset($bodyclass);

                        break;
                case "kikchat":
                        extract($themeset, EXTR_OVERWRITE);
                        $bodyclass = "centerbody";
                        $module = "kikchat/post";
                        $titre = "Kik it Productions' Live Chat";
                        $headlien = "http://www.kik-it.com";
		$footerbox = 1;
        		$footerboxtext = "Retour au menu";
        		$footerlien = "/";

                        include "modules/magicbox.php";
                        unset($bodyclass);
                        break;
		case "affimage":
                        extract($themeset, EXTR_OVERWRITE);

                        // $headstartcode = "<font name='verdana' size=4 class='centerhead'>";
                        // $headendcode ="</font>";
                        $bodyclass = "centerbody";

                        $module = "affimages";
                        $titre = $image;
			$footerbox = 1;
        		$footerboxtext = "Retour au menu";
        		$footerlien = "/";

			include "modules/magicbox.php";
                        unset($bodyclass);
			break;

                default:
                        include "pages/menu.php";
		
        }
	
}
 else
{
// ---- affichage des pages ----
//echo "<div align='center'>";
	if (isset($section) && isset($page) && $page != "menu")
	{
				// si url éronnée, affiche la page d'acceuil
		if (file_exists("$section/$page.php"))
		{
			/* echo "<div id='left'>"; */
                	include_once "$section/$page.php";
			/* echo "</div>";*/
		}
		else
			include_once "pages/menu.php";

                echo "<div class='center'><a href='/'>&gt;Retour à la page d'accueil&lt;</a><br /></div>";
	}
        else
        {
                //include "include/logo.inc.php";
                include "pages/menu.php";
        }
}
echo "</td>";
// *************** droite *************************

/*if (!isset($right) || ($right == 1))
{
	echo "<td><img src='/modules/share/trans.gif' alt='' width='20' /></td>";
        echo "<td align='right' valign='top' width='135'>";
        include_once "right.php";
        echo "</td>";
}*/
echo "</tr></table>";
//****************** pied de page *********************
//require_once "footer.php";

$endgen = getmicrotime();
$timegen = round($endgen - $startgen, 2);
echo "\n<!-- page générée en $timegen secondes -->\n\n";
?>
<?php /*
<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://stats.tourmentine.com/piwik/" : "http://stats.tourmentine.com/piwik/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script><script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 5);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
</script><noscript><p><img src="http://stats.tourmentine.com/piwik/piwik.php?idsite=5" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tracking Code -->
*/
?>
</body>
</html>
