2 /************************************************************************
3 * MXChange v0.2.1 Start: 08/25/2003 *
4 * =============== Last change: 07/01/2005 *
6 * -------------------------------------------------------------------- *
8 * -------------------------------------------------------------------- *
9 * Short description : Main loader file. Loads our needed stuff *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Hauptladedatei. Laedt alle benoetigten Dateien *
12 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
18 * This program is free software; you can redistribute it and/or modify *
19 * it under the terms of the GNU General Public License as published by *
20 * the Free Software Foundation; either version 2 of the License, or *
21 * (at your option) any later version. *
23 * This program is distributed in the hope that it will be useful, *
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
26 * GNU General Public License for more details. *
28 * You should have received a copy of the GNU General Public License *
29 * along with this program; if not, write to the Free Software *
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
32 ************************************************************************/
35 //xdebug_start_trace();
37 // Load security stuff here (Oh, I hope this is not unsecure? Am I paranoia??? ;-) )
38 require_once("inc/libs/security_functions.php");
40 // Init "action" and "what"
41 global $what, $action, $startTime;
42 $GLOBALS['startTime'] = microtime(true);
44 $GLOBALS['what'] = ""; $GLOBALS['action'] = "";
45 $GLOBALS['userid'] = 0;
47 // Fix missing module to "index"
48 if (empty($_GET['module'])) $_GET['module'] = "index";
50 // Secure action/what if present
51 if (!empty($_GET['action'])) $GLOBALS['action'] = secureString($_GET['action']);
52 if (!empty($_GET['what'])) $GLOBALS['what'] = secureString($_GET['what']);
54 // Secure the module name (very important line!)
55 $GLOBALS['module'] = secureString($_GET['module']);
57 // Needed include files
58 require("inc/config.php");
62 // Is still logged in so we welcome him with his name
63 $result = SQL_QUERY_ESC("SELECT surname, family FROM `"._MYSQL_PREFIX."_user_data` WHERE userid=%s LIMIT 1",
64 array($GLOBALS['userid']), __FILE__, __LINE__);
65 if (SQL_NUMROWS($result) == 1) {
66 // Load surname and family's name and build the username
67 list($s, $f) = SQL_FETCHROW($result);
68 $username = $s." ".$f;
70 // Additionally admin?
73 $username .= " ("._ADMIN_SHORT.")";
76 // Hmmm, logged in and no valid userid?
77 $username = "<I>"._UNKNOWN."</I>";
80 destroy_user_session();
83 $GLOBALS['userid'] = 0;
87 SQL_FREERESULT($result);
88 } elseif (IS_ADMIN()) {
92 // He's a guest, hello there... ;-)
97 include (PATH."inc/header.php");
99 // Modules are by default not valid!
100 $MOD_VALID = false; $check = "failed";
101 if ((getConfig('maintenance') == "Y") && (!IS_ADMIN()) && ($GLOBALS['module'] != "admin")) {
102 // Maintain mode is active and you are no admin
103 ADD_FATAL(LANG_DOWN_MAINTAINCE);
104 } elseif (($link) && ($db) && (sizeof($FATAL) == 0)) {
105 // Did we found the module listed in allowed modules and are we successfully connected?
106 $check = CHECK_MODULE($GLOBALS['module']);
112 // Construct module name
113 define('__MODULE', sprintf("%sinc/modules/%s.php", PATH, SQL_ESCAPE($GLOBALS['module'])));
115 // Does the module exists on local file system?
116 if ((FILE_READABLE(__MODULE)) && (sizeof($FATAL) == 0)) {
117 // Module is valid, active and located on the local disc...
119 } elseif (!empty($URL)) {
120 // An URL was specified so we load the de-referrer module
121 LOAD_URL(DEREFERER($URL));
122 } elseif (sizeof($FATAL) == 0) {
123 ADD_FATAL(LANG_MOD_REG_404_1.$GLOBALS['module'].LANG_MOD_REG_404_2);
128 ADD_FATAL(LANG_MOD_REG_404_1.$GLOBALS['module'].LANG_MOD_REG_404_2);
132 if (!FILE_READABLE(PATH."inc/modules/".$GLOBALS['module'].".php")) {
133 // Module does addionally not exists
134 ADD_FATAL(LANG_MOD_REG_404_1.$GLOBALS['module'].LANG_MOD_REG_404_2);
138 ADD_FATAL(LANG_MOD_LOCKED_1.$GLOBALS['module'].LANG_MOD_LOCKED_2);
142 DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown status %s return from module check. Module=%s", $check, $GLOBALS['module']));
143 ADD_FATAL(LANG_MOD_UNKNOWN_1.$check.LANG_MOD_UNKNOWN_2);
146 } elseif (sizeof($FATAL) == 0) {
148 ADD_FATAL(MYSQL_ERRORS);
151 if (($MOD_VALID) && (defined('__MODULE'))) {
152 /////////////////////////////////////////////
153 // Main including line DO NOT REMOVE/EDIT! //
154 /////////////////////////////////////////////
156 // Everything is okay so we can load the module
160 // Next-to-end add the footer
161 include (PATH."inc/footer.php");