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("inc/libs/security_functions.php");
40 // Init "action" and "what"
41 $GLOBALS['startTime'] = microtime(true);
42 $GLOBALS['output_mode'] = 0;
43 $GLOBALS['what'] = "";
44 $GLOBALS['action'] = "";
45 $GLOBALS['userid'] = 0;
46 $GLOBALS['module'] = "";
48 // Needed include files
49 require("inc/config.php");
51 // Fix missing module to "index"
52 if (!REQUEST_ISSET_GET(('module'))) REQUEST_SET_GET('module', "index");
56 // Is still logged in so we welcome him with his name
57 $result = SQL_QUERY_ESC("SELECT surname, family FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
58 array($GLOBALS['userid']), __FILE__, __LINE__);
59 if (SQL_NUMROWS($result) == 1) {
60 // Load surname and family's name and build the username
61 list($s, $f) = SQL_FETCHROW($result);
62 $username = $s." ".$f;
64 // Additionally admin?
67 $username .= " ({--_ADMIN_SHORT--})";
70 // Hmmm, logged in and no valid userid?
71 $username = "<em>{--_UNKNOWN--}</em>";
74 destroy_user_session();
77 $GLOBALS['userid'] = 0;
81 SQL_FREERESULT($result);
82 } elseif (IS_ADMIN()) {
84 $username = getMessage('_ADMIN');
86 // He's a guest, hello there... ;-)
87 $username = getMessage('_GUEST');
91 LOAD_INC_ONCE("inc/header.php");
93 // Modules are by default not valid!
94 $MOD_VALID = false; $check = "failed";
95 if ((getConfig('maintenance') == "Y") && (!IS_ADMIN()) && ($GLOBALS['module'] != "admin")) {
96 // Maintain mode is active and you are no admin
97 addFatalMessage(__FILE__, __LINE__, getMessage('LANG_DOWN_MAINTAINCE'));
98 } elseif ((SQL_IS_LINK_UP()) && (getTotalFatalErrors() == 0)) {
99 // Construct module name
100 define('__MODULE', sprintf("inc/modules/%s.php", SQL_ESCAPE($GLOBALS['module'])));
102 // Did we found the module listed in allowed modules and are we successfully connected?
103 $check = CHECK_MODULE($GLOBALS['module']);
109 // Does the module exists on local file system?
110 if ((FILE_READABLE(constant('__MODULE'))) && (getTotalFatalErrors() == 0)) {
111 // Module is valid, active and located on the local disc...
113 } elseif (!empty($URL)) {
114 // An URL was specified so we load the de-referrer module
115 LOAD_URL(DEREFERER($URL));
116 } elseif (getTotalFatalErrors() == 0) {
117 addFatalMessage(__FILE__, __LINE__, sprintf(getMessage('LANG_MOD_REG_404'), $GLOBALS['module']));
122 addFatalMessage(__FILE__, __LINE__, sprintf(getMessage('LANG_MOD_REG_404'), $GLOBALS['module']));
126 if (!FILE_READABLE(constant('__MODULE'))) {
127 // Module does addionally not exists
128 addFatalMessage(__FILE__, __LINE__, sprintf(getMessage('LANG_MOD_REG_404'), $GLOBALS['module']));
132 addFatalMessage(__FILE__, __LINE__, sprintf(getMessage('LANG_MOD_REG_LOCKED'), $GLOBALS['module']));
136 DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown status %s return from module check. Module=%s", $check, $GLOBALS['module']));
137 addFatalMessage(__FILE__, __LINE__, sprintf(getMessage('LANG_MOD_REG_UNKNOWN'), $check));
140 } elseif (getTotalFatalErrors() == 0) {
142 addFatalMessage(__FILE__, __LINE__, getMessage('MYSQL_ERRORS'));
145 if (($MOD_VALID) && (defined('__MODULE'))) {
146 /////////////////////////////////////////////
147 // Main including line DO NOT REMOVE/EDIT! //
148 /////////////////////////////////////////////
150 // Everything is okay so we can load the module
151 LOAD_INC_ONCE(constant('__MODULE'));
154 // Next-to-end add the footer
155 LOAD_INC_ONCE("inc/footer.php");