<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
/*function getmicrotime(){ 
    list($usec, $sec) = explode(" ",microtime()); 
        return ((float)$usec + (float)$sec); 
	    } */
$startgen = microtime (true);
$sqltimegen = 0;

// yeah, I know, this is B A D 
extract($_GET);
extract($_POST);

include_once "include/standard.inc.php";
include_once "include/news.inc.php";
include_once "include/lang.inc.php";

echo "<html xmlns='http://www.w3.org/1999/xhtml'>";

if ($lang == "fr")
{	
	$back_to_menu = "Retour au menu";
}
else
{
	$back_to_menu = "Back to menu";
}
//$sqltimegen = 0;
//global $sqltimegen;
//set_include_path('include');
//parse_ini_file("config/pip.ini");


// visites
$sqlstartgen = microtime (true);
$lvc_include_dir = 'visit/include/';
//include($lvc_include_dir.'new-visitor.inc.php3');
$sqlendgen = microtime(true);
$sqltimegen += ($sqlendgen - $sqlstartgen);
if ($modulepage == "commentnews")
	$page = "billet.$idnews";
//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";
*/
include "themes/default/theme.php";
if (!isset($section) || $section == "")
        $section="pages";

if ($lastslash = strrpos($page, "/"))
{
	$section="pages/".substr($page, 0, $lastslash);
	$page = substr($page, $lastslash+1);
}
if ($page == "")
	$page="index";

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

$left = 0;
$right = 1;

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

//extract($themeset, EXTR_OVERWRITE);

include "include/head.inc.php";
if (file_exists("$section/$page.head.php"))
	include "$section/$page.head.php";
echo "</head>\n";
//include "include/body.inc.php";
//echo "\n<body onload=\"useStyleAgain('TourmentineThemeCookie'); show2(); \" onunload=\"rememberStyle('TourmentineThemeCookie');\">\n";
echo "<body>";
echo "\n<!--**********************************\n";
echo "    *           HEADER               *\n";
echo "    **********************************-->\n\n";
// ************** haut de page ******************
/*if (!isset($header) || ($header ==1))
{*/
        include "header.php";
//}

echo "\n<div class='headercenterpage'></div>\n";
echo "\n<div class='mainpage'>\n";
//echo "\n<table width='100%'><tr>\n"; // tableau principal

// *************** gauche *****************
if (isset($left) && ($left ==1))
{
	echo "\n<div class='colonne'>\n";
	echo "\n<!--********************************\n";
	echo "    *        COLONNE GAUCHE        *\n";
	echo "    ********************************-->\n\n";
	
	$cachefile = "tmp/left.cache.php";
	if (!file_exists($cachefile) || (filemtime($cachefile) < filemtime("modules")) || (filemtime($cachefile) < filemtime("left.php")))
	{
		$cachecontent = "<!-- Partie mise en cache (".date("d/m/Y@H:i:s").")-->\n\n";
//		$cachecontent .= "<td valign='top' class='colonne'>\n";
		//$cachecontent .= file_get_contents("http://".$_SERVER["HTTP_HOST"]."/left.php");
		$cachecontent .= file_get_contents("http://old.tourmentine.com/left.php");
		//$cachecontent .= "</td>\n";
		$cachecontent .= "\n<!-- fin Partie mise en cache -->\n\n";
		
		$cachecontent = str_replace("<!--NOCACHE","<?php",$cachecontent);
		$cachecontent = str_replace("NOCACHE-->","?>",$cachecontent);

		$fp = fopen($cachefile,"w");
		fwrite($fp,$cachecontent);
		fclose($fp);
	}
	
	include $cachefile;
	unset($cachefile);
	echo "</div>";
}

// ************** centre ****************

echo "<div class='centerpage'>";
//echo "<td class='pageseparator'><img src='/modules/share/trans.gif' alt='' title='' width='20' /></td><td valign='top'>\n\n";

echo "\n<!--********************************\n";
echo "    *           CENTRE             *\n";
echo "    ********************************-->\n\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 "commentnews":
		
                /*if (!isset($FileNews))
		{
			if (file_exists("modules/news/news.$lang.csv"))
                               	$FileNews = "modules/news/news.$lang";
			else
                            	$FileNews = "modules/news/news";
		}*/
		//echo "<!-- FileNews : $FileNews -->";
		if (strstr($_SERVER["REDIRECT_URL"],"billet"))
		{
		$cachefile = "tmp/billet.$idnews.$lang.cache.php";
		if (!file_exists($cachefile) || (filemtime($cachefile) < filemtime("modules/news")))
		{
			$cachecontent = "<!-- Partie mise en cache (".date("d/m/Y@H:i:s").")-->\n\n";
			//$cachecontent .= file_get_contents("http://".$_SERVER["HTTP_HOST"]."/include/logo.inc.php");
			//$cachecontent .= file_get_contents("http://".$_SERVER["HTTP_HOST"]."/modules/commentnews.php?idnews=".$idnews."&lang=".$lang);
			$cachecontent .= file_get_contents("http://old.tourmentine.com/include/logo.inc.php");
			$cachecontent .= file_get_contents("http://old.tourmentine.com/modules/commentnews.php?idnews=".$idnews."&lang=".$lang);
			
			$cachecontent .= "\n<!-- fin Partie mise en cache -->\n\n";

			$cachecontent = str_replace("<!--NOCACHE","<?php",$cachecontent);
			$cachecontent = str_replace("NOCACHE-->","?>",$cachecontent);
			
			echo $cachecontent;
			$fp = fopen($cachefile,"w");
			fwrite($fp,$cachecontent);
			fclose($fp);
		}
		else include $cachefile;
		unset($cachefile);
		}	
		else
		{
			//echo "<!--preview: $preview-->";
			include "include/logo.inc.php";
                        if (isset($File))
                                $FileNews = $File;

                        if (!isset($FileNews))
			{
				if (file_exists("modules/news/news.$lang.csv"))
                                	$FileNews = "modules/news/news.$lang";
				else
                                	$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";
			if ($lang == "fr")
				$titre = "Commentaires";
			else
                        	$titre = "Comments";
                        //$goldbooktype = "comment";
                        $forumfile = "$FileNews.$idnews.forum.csv";
			//echo "<!--forumfile:$forumfile-->";
                        include "modules/magicbox.php";
			}
                	echo "<div align='center' class='retour_au_menu'><a href='/index.$lang.html'>&gt;$back_to_menu&lt;</a><br /></div>";
                        //$modulepage = "commentbook";
                        // unset($goldbooktype);
                        // unset($NewsFile);
                        // unset($File);
                        break;
                case "backend":
                        if (isset($File))
                                $FileNews = $File;

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

                        include "modules/genbackend.php";
                        break;
                
		default:
			if (file_exists("$section/index.$lang.php"))
                        	include "$section/index.$lang.php";
			else
                        	include "$section/index.php";
        }
}
else
{
// ---- affichage des pages ----

	if ($page != "index")
	{
		
		if (file_exists("$section/$page.$lang.php"))
		{
                	include "$section/$page.$lang.php";
			echo "<div align='center' class='retour_au_menu'><a href='/index.$lang.html'>&gt;$back_to_menu&lt;</a><br /></div>";
		}
		else if (file_exists("$section/$page.php"))
		{
			include "$section/$page.php";
                        echo "<div align='center' class='retour_au_menu'><a href='/index.$lang.html'>&gt;$back_to_menu&lt;</a><br /></div>";
		}
		else
		{
			if (file_exists("$section/index.$lang.php"))
                        	include "$section/index.$lang.php";
			else
				include "$section/index.php";
		}

	}
        else
        {
                //include "include/logo.inc.php";
		// si url �ronn�e, affiche la page d'acceuil

		if (file_exists("$section/index.$lang.php"))
                       	include "$section/index.$lang.php";
		else
       		        include "$section/index.php";
        }
}
//echo "</td>";
echo "</div>";
// *************** droite *************************
unset ($headclass);
if ($right == 1)
{
	echo "\n<div class='colonne'>\n";
	echo "\n<!--********************************\n";
	echo "    *        COLONNE DROITE        *\n";
	echo "    ********************************-->\n\n";
	
//	echo "<td class='pageseparator'><img src='/modules/share/trans.gif' alt='' width='20' /></td>";
  //      echo "<td align='right' valign='top' width='135'>";
//        include_once "right.php";
//        echo "</td></tr>";
	if (file_exists("$section/right.$lang.php"))
	{
		$cachefile = "tmp/$section/right.$lang.cache.php";
                $filetocache = "$section/right.$lang.php";
	}
	else if (file_exists("$section/right.php"))
	{
		$cachefile = "tmp/$section/right.cache.php";
		$filetocache = "$section/right.php";
	}
	else if (file_exists("right.$lang.php"))
	{
		$cachefile = "tmp/right.$lang.cache.php";
                $filetocache = "right.$lang.php";
	}
	else
	{
		$cachefile = "tmp/right.en.cache.php";
		$filetocache = "right.en.php";
	}
	if (!file_exists($cachefile) || (filemtime($cachefile) < filemtime("modules")) || (filemtime($cachefile) < filemtime($filetocache)))
	{
		$cachecontent = "<!-- Partie mise en cache (".date("d/m/Y@H:i:s").")-->\n\n";
		//              $cachecontent .= "<td valign='top' class='colonne'>\n";
		//$cachecontent .= file_get_contents("http://".$_SERVER["HTTP_HOST"]."/".$filetocache);
		$cachecontent .= file_get_contents("http://old.tourmentine.com/".$filetocache);
		//$cachecontent .= "</td>\n";
		$cachecontent .= "\n<!-- fin Partie mise en cache -->\n\n";

		$cachecontent = str_replace("<!--NOCACHE","<?php",$cachecontent);
		$cachecontent = str_replace("NOCACHE-->","?>",$cachecontent);

		$fp = fopen($cachefile,"w");
		fwrite($fp,$cachecontent);
		fclose($fp);
	}

	include $cachefile;
	unset($cachefile);
	echo "</div>";
}
echo "</div>";


//****************** pied de page *********************
if ($lang == "fr")
{
echo "\n\n<!--********************************\n";
echo "    *         PIED DE PAGE         *\n";
echo "    ********************************-->\n\n";
include "footer.php";
}
else if ($lang == "es")
{
echo "\n\n<!--********************************\n";
echo "    *             FOOTER           *\n";
echo "    ********************************-->\n\n";
include "footer.es.php";
}
else
{
echo "\n\n<!--********************************\n";
echo "    *             FOOTER           *\n";
echo "    ********************************-->\n\n";
include "footer.en.php";
}

//echo "</div></div>";
$endgen = microtime(true);
$timegen = round($endgen - $startgen, 2);
echo "\n<!-- page g�n�r�e en ".$timegen."s"; 
	if ($sqltimegen != 0)
	{
		$sqltimegen = round($sqltimegen, 2);
		echo " (dont ".$sqltimegen." de SQL)";
	}
echo " -->\n\n";
?>
</body>
</html>