<?php
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
defined('MAXIMUS') OR include_once('mainfile.php');

if (is_file("".$cache."/Configuration/".$cache_prefix."_configadvance.php")){
include_once("".$cache."/Configuration/".$cache_prefix."_configadvance.php");
}

global $admin_file, $file;
$modpath = '';
if (!isset($mop)) { $mop='modload'; }
if (!isset($mod_file)) { $mod_file='index'; }
if (!isset($file)) { $file='index.php'; }

define('HOME_FILE', true);
define('MODULE_FILE', true);
$_SERVER['SCRIPT_NAME'] = 'modules.php';
if (file_exists("".$cache."/Configuration/".$cache_prefix."_cache_main.php")) {
if (is_file("".$cache."/Configuration/".$cache_prefix."_cache_main.php")) {
include_once("".$cache."/Configuration/".$cache_prefix."_cache_main.php");}
$name = stripslashes($main_module);
 } else {
$sql = "SELECT `main_module` from `".TABLE_MAIN."` ";
if ( !($result = $GLOBALS['db']->sql_query($sql)) )
{ query_die(GENERAL_ERROR, 'Could not obtain config index', '', __LINE__, __FILE__, $sql);}
$row      = $GLOBALS['db']->sql_fetchrow($result);
$name     = stripslashes($row['main_module']);


$chemin   = "".$cache."/Configuration/".$cache_prefix."_cache_main.php";
$content  = "";
$content .= "<?php\n defined(\"MAXIMUS\") OR Header(\"Location: ../index.php\"); \n";
$content .= "\$main_module = \"$name\";\n";
$fichier  = fopen($chemin, "w");
fwrite( $fichier, $content );
fclose( $fichier );


$GLOBALS['db']->sql_freeresult($result);
}

if (isset($url) AND defined('ADMIN_ALLOW')) {
	echo "<meta http-equiv='refresh' content='0; url=$url'>";
	die();
}

if ( $httpref==1 ) {
	if (is_file('kernel/addons/http_pref.php')) {
		include_once('kernel/addons/http_pref.php');
	}
}

$name     = trim($name);
$file     = trim($file);
$mod_file = trim($mod_file);
$mop      = trim($mop);
if (stripos_clone($name,'..') || (isset($file) && stripos_clone($file,".."))  || stripos_clone($mod_file,"..") || stripos_clone($mop,"..")) {
		echo 'You are so cool...';
} else {
	$modpath .= "modules/".$name."/".$mod_file.".php";
	if (file_exists($modpath)) {
		if (is_file("$modpath")) {
			include_once("$modpath");
		 }
	} else {
		define('INDEX_FILE', true);
		if (is_file('kernel/addons/home_probleme.php')) {
			include_once('kernel/addons/home_probleme.php');
		}
	}
}