2 /************************************************************************
3 * Mailer v0.2.1-FINAL 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 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2011 by Mailer Developer Team *
20 * For more information visit: http://www.mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
39 //* DEBUG: */ xdebug_start_trace();
41 // Load security stuff here
42 require('inc/libs/security_functions.php');
45 $GLOBALS['startTime'] = microtime(true);
47 // Init output mode and module
48 $GLOBALS['output_mode'] = '0';
49 $GLOBALS['module'] = 'unknown';
51 // Needed include files
52 require('inc/config-global.php');
55 setContentType('text/html');
58 loadIncludeOnce('inc/header.php');
60 // Modules are by default not valid!
61 $isModuleValid = false;
63 // Init module state as 'failed' (always failed first)
64 $moduleState = 'failed';
66 // Is the maintenance mode active or goes all well?
67 if ((isExtensionActive('maintenance')) && (isMaintenanceEnabled()) && (!isAdmin()) && (getModule() != 'admin')) {
68 // Maintain mode is active and you are no admin
69 addFatalMessage(__FILE__, __LINE__, '{--MAILER_DOWN_FOR_MAINTENANCE--}');
70 } elseif ((SQL_IS_LINK_UP()) && (!ifFatalErrorsDetected())) {
71 // Construct module name
72 $GLOBALS['module_inc'] = sprintf("inc/modules/%s.php", getModule());
74 // Check module permission (again)
75 $moduleState = checkModulePermissions();
77 // Which permission/error state do we have?
78 switch ($moduleState) {
79 case 'cache_miss': // The cache is gone
80 case 'admin_only': // Admin-only access
81 case 'mem_only': // Member-only access
82 case 'done': // All fine!
83 // Does the module exists on local file system?
84 if ((isIncludeReadable($GLOBALS['module_inc'])) && (!ifFatalErrorsDetected())) {
85 // Module is valid, active and located on the local disc...
86 $isModuleValid = true;
87 } elseif (!ifFatalErrorsDetected()) {
92 addFatalMessage(__FILE__, __LINE__, '{--MODULE_REGISTRY_404--}');
94 // Set module to error module (non-existent!)
101 setHttpStatus('404');
104 addFatalMessage(__FILE__, __LINE__, '{--MODULE_REGISTRY_404--}');
109 setHttpStatus('403 FORBIDDEN');
111 if (!isIncludeReadable($GLOBALS['module_inc'])) {
112 // Set HTTP status again
113 setHttpStatus('404 NOT FOUND');
115 // Module does addionally not exists
116 addFatalMessage(__FILE__, __LINE__, '{--MODULE_REGISTRY_404--}');
120 addFatalMessage(__FILE__, __LINE__, '{--MODULE_REGISTRY_IS_LOCKED--}');
124 // Unknown module status
125 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown status %s return from module check. Module=%s", $moduleState, getModule()));
126 addFatalMessage(__FILE__, __LINE__, '{%message,UNKNOWN_MODULE_STATUS=' . $moduleState . '%}');
129 } elseif (!ifFatalErrorsDetected()) {
130 // SQL problems detected
131 addFatalMessage(__FILE__, __LINE__, '{--MYSQL_ERRORS--}');
134 if (($isModuleValid === true) && (isset($GLOBALS['module_inc']))) {
135 // Everything is okay so we can load the module
136 loadIncludeOnce($GLOBALS['module_inc']);
139 // Add the footer (this will call shutdown())
140 loadIncludeOnce('inc/footer.php');