<?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                                 */
/************************************************************************/
define('MODULE_FILE', true);
defined('MAXIMUS') OR include_once('mainfile.php');
defined('MAXIMUS') OR die ('Access denied modules.php MAXIMUS directly...');

if (empty($name)) { header ("location: index.php"); }

if (isset($name) && $name == $_REQUEST['name']) {
$name = addslashes(htmlentities(trim($name)));

function restrited_module($title) {
    $pagetitle = "- $title";
    incoh();
    Max_OpenTable();
    echo "<center>$title";
    br('2');
    echo "<img src='images/cancel.png' alt='' />";
    br('2');
    echo ""._GOBACK."</center><br />";
    Max_CloseTable();
    incof();
    die ();
}

    if (stristr($name,'http\:\/\/')) { die('Hi&nbsp;and&nbsp;Bye'); }
    if (!isset($file)) { $file = "index"; }
    if (stristr($file,'http\:\/\/')) { die('Hi&nbsp;and&nbsp;Bye'); }
    $urle = $modstring = strtolower($_SERVER['QUERY_STRING']);
    if (stristr($name,'\.\.') OR ((stripos_clone('&file=nickpage',$modstring) || stripos_clone('&user=',$modstring)) AND ($name=='Private_Messages' OR $name=='Forums' OR $name=='Members_List'))) header('Location: index.php');
    global $nukeuser;
    if (defined('USER_ALLOW')) {
    $nukeuser = base64_decode($user);
    $nukeuser = addslashes($nukeuser);
    } else {
    $nukeuser = "";
    }
    $sql = "SELECT HIGH_PRIORITY `active`, `view`, `groups` FROM `".TABLE_MODULES."` WHERE `title`='".addslashes($name)."' AND `install`='1' ";
    if ( !($result = $GLOBALS['db']->sql_query($sql)) )
{ query_die(CORE_ERROR, 'Could not obtain config modules', '', __LINE__, __FILE__, $sql);}
    $row        = $GLOBALS['db']->sql_fetchrow($result);
    $mod_active = $GLOBALS['db']->XMFbin($row['active']);
    $view       = $GLOBALS['db']->XMFnum($row['view']);
    $groups     = stripslashes($row['groups']);
    if (($mod_active == 1) OR ($mod_active == 0 AND defined('ADMIN_ALLOW'))) {
	if (!isset($mop) OR $mop != $_REQUEST['mop']) { $mop = 'modload';}
        if (!isset($file) OR $file != $_REQUEST['file']) { $file = 'index';}
	if ( stristr($name,'\.\.') || stristr($file,'\.\.') || stristr($mop,'\.\.') ) {
	restrited_module(""._SOCOOL."");
        } else {
            $ThemeSel = get_theme();
            if (is_file("themes/".$ThemeSel."/modules/".$name."/".$file.".php")) {
                $modpath = "themes/".$ThemeSel."/";
            } else {
                $modpath = "";
            }
            $modpath .= "modules/".$name."/".$file.".php";
            if (file_exists($modpath)) {

if ( ($view == 0) || ($view == 1 AND (defined('USER_ALLOW') OR defined('ADMIN_ALLOW'))) || ($view == 2 AND defined('ADMIN_ALLOW')) || ($view == 3) || ($view > 3 AND in_groups($groups)) ) {
if (is_file("$modpath")) { include_once("$modpath"); }
     } else {
restrited_module(""._RESTRICTEDAREA."");
        }
     } else {
restrited_module(""._FILENOTFOUND."");
            }
        }
    } else {
restrited_module(""._MODULENOTACTIVE."");
    }
} else {
restrited_module(""._MODULENOTFOUND."");
}