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 * $Date:: 2009-03-06 20:24:32 +0100 (Fr, 06. Mär 2009) $ *
15 * $Tag:: 0.2.1-FINAL $ *
16 * $Author:: stelzi $ *
17 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2008 by Roland Haeder *
21 * For more information visit: http://www.mxchange.org *
23 * This program is free software; you can redistribute it and/or modify *
24 * it under the terms of the GNU General Public License as published by *
25 * the Free Software Foundation; either version 2 of the License, or *
26 * (at your option) any later version. *
28 * This program is distributed in the hope that it will be useful, *
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
31 * GNU General Public License for more details. *
33 * You should have received a copy of the GNU General Public License *
34 * along with this program; if not, write to the Free Software *
35 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
37 ************************************************************************/
40 //xdebug_start_trace();
42 // Load security stuff here (Oh, I hope this is not unsecure? Am I paranoia??? ;-) )
43 require("inc/libs/security_functions.php");
45 // Init "action" and "what"
46 $GLOBALS['startTime'] = microtime(true);
47 $GLOBALS['output_mode'] = 0;
48 $GLOBALS['what'] = "";
49 $GLOBALS['action'] = "";
50 $GLOBALS['userid'] = 0;
51 $GLOBALS['module'] = "";
53 // Needed include files
54 require("inc/config.php");
56 // Fix missing module to "index"
57 if (!REQUEST_ISSET_GET(('module'))) REQUEST_SET_GET('module', "index");
61 // Is still logged in so we welcome him with his name
62 $result = SQL_QUERY_ESC("SELECT surname, family FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
63 array($GLOBALS['userid']), __FILE__, __LINE__);
64 if (SQL_NUMROWS($result) == 1) {
65 // Load surname and family's name and build the username
66 list($s, $f) = SQL_FETCHROW($result);
67 $username = $s." ".$f;
69 // Additionally admin?
72 $username .= " ({--_ADMIN_SHORT--})";
75 // Hmmm, logged in and no valid userid?
76 $username = "<em>{--_UNKNOWN--}</em>";
79 destroy_user_session();
82 $GLOBALS['userid'] = 0;
86 SQL_FREERESULT($result);
87 } elseif (IS_ADMIN()) {
89 $username = getMessage('_ADMIN');
91 // He's a guest, hello there... ;-)
92 $username = getMessage('_GUEST');
96 LOAD_INC_ONCE("inc/header.php");
98 // Modules are by default not valid!
99 $MOD_VALID = false; $check = "failed";
100 if ((getConfig('maintenance') == "Y") && (!IS_ADMIN()) && ($GLOBALS['module'] != "admin")) {
101 // Maintain mode is active and you are no admin
102 addFatalMessage(__FILE__, __LINE__, getMessage('LANG_DOWN_MAINTAINCE'));
103 } elseif ((SQL_IS_LINK_UP()) && (getTotalFatalErrors() == 0)) {
104 // Construct module name
105 define('__MODULE', sprintf("inc/modules/%s.php", SQL_ESCAPE($GLOBALS['module'])));
107 // Did we found the module listed in allowed modules and are we successfully connected?
108 $check = checkModulePermissions($GLOBALS['module']);
114 // Does the module exists on local file system?
115 if ((FILE_READABLE(constant('__MODULE'))) && (getTotalFatalErrors() == 0)) {
116 // Module is valid, active and located on the local disc...
118 } elseif (!empty($URL)) {
119 // An URL was specified so we load the de-referrer module
120 LOAD_URL(DEREFERER($URL));
121 } elseif (getTotalFatalErrors() == 0) {
122 addFatalMessage(__FILE__, __LINE__, sprintf(getMessage('LANG_MOD_REG_404'), $GLOBALS['module']));
127 addFatalMessage(__FILE__, __LINE__, sprintf(getMessage('LANG_MOD_REG_404'), $GLOBALS['module']));
131 if (!FILE_READABLE(constant('__MODULE'))) {
132 // Module does addionally not exists
133 addFatalMessage(__FILE__, __LINE__, sprintf(getMessage('LANG_MOD_REG_404'), $GLOBALS['module']));
137 addFatalMessage(__FILE__, __LINE__, sprintf(getMessage('LANG_MOD_REG_LOCKED'), $GLOBALS['module']));
141 DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown status %s return from module check. Module=%s", $check, $GLOBALS['module']));
142 addFatalMessage(__FILE__, __LINE__, sprintf(getMessage('LANG_MOD_REG_UNKNOWN'), $check));
145 } elseif (getTotalFatalErrors() == 0) {
147 addFatalMessage(__FILE__, __LINE__, getMessage('MYSQL_ERRORS'));
150 if (($MOD_VALID) && (defined('__MODULE'))) {
151 /////////////////////////////////////////////
152 // Main including line DO NOT REMOVE/EDIT! //
153 /////////////////////////////////////////////
155 // Everything is okay so we can load the module
156 LOAD_INC_ONCE(constant('__MODULE'));
159 // Next-to-end add the footer
160 LOAD_INC_ONCE("inc/footer.php");