Removed comment introduced by Profi-Concept, this comment should fine (in a much...
[mailer.git] / modules.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 08/25/2003 *
4  * ===================                          Last change: 07/01/2005 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : modules.php                                      *
8  * -------------------------------------------------------------------- *
9  * Short description : Main loader file. Loads our needed stuff         *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Hauptladedatei. Laedt alle benoetigten Dateien   *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
20  * For more information visit: http://www.mxchange.org                  *
21  *                                                                      *
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.                                  *
26  *                                                                      *
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.                         *
31  *                                                                      *
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,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // XDEBUG call
39 //* DEBUG: */ xdebug_start_trace();
40
41 // Load security stuff here
42 require('inc/libs/security_functions.php');
43
44 // Init start time
45 $GLOBALS['startTime'] = microtime(true);
46
47 // Init output mode and module
48 $GLOBALS['output_mode'] = '0';
49 $GLOBALS['module'] = 'unknown';
50
51 // Needed include files
52 require('inc/config-global.php');
53
54 // Set content type
55 setContentType('text/html');
56
57 // The header file
58 loadIncludeOnce('inc/header.php');
59
60 // Modules are by default not valid!
61 $isModuleValid = false;
62 $URL = '';
63 $check = 'failed';
64
65 // Is the maintenance mode active or goes all well?
66 if ((isExtensionActive('maintenance')) && (getConfig('maintenance') == 'Y') && (!isAdmin()) && (getModule() != 'admin')) {
67         // Maintain mode is active and you are no admin
68         addFatalMessage(__FILE__, __LINE__, '{--MAILER_DOWN_FOR_MAINTENANCE--}');
69 } elseif ((SQL_IS_LINK_UP()) && (!ifFatalErrorsDetected())) {
70         // Construct module name
71         $GLOBALS['module_inc'] =  sprintf("inc/modules/%s.php", getModule());
72
73         // Check module permission (again)
74         $check = checkModulePermissions();
75         switch ($check) {
76                 case 'cache_miss': // The cache is gone
77                 case 'admin_only': // Admin-only access
78                 case 'mem_only': // Member-only access
79                 case 'done': // All fine!
80                         // Does the module exists on local file system?
81                         if ((isIncludeReadable($GLOBALS['module_inc'])) && (!ifFatalErrorsDetected())) {
82                                 // Module is valid, active and located on the local disc...
83                                 $isModuleValid = true;
84                         } elseif (!ifFatalErrorsDetected()) {
85                                 // Set HTTP status
86                                 setHttpStatus('404');
87
88                                 // Module not found!
89                                 addFatalMessage(__FILE__, __LINE__, getMaskedMessage('MODULE_REGISTRY_404', getModule()));
90
91                                 // Set module to error module (non-existent!)
92                                 setModule('error');
93                         }
94                         break;
95
96                 case '404':
97                         // Set HTTP status
98                         setHttpStatus('404');
99
100                         // Add fatal message
101                         addFatalMessage(__FILE__, __LINE__, getMaskedMessage('MODULE_REGISTRY_404', getModule()));
102                         break;
103
104                 case 'locked':
105                         // Set HTTP status
106                         setHttpStatus('403');
107
108                         if (!isIncludeReadable($GLOBALS['module_inc'])) {
109                                 // Set HTTP status
110                                 setHttpStatus('404');
111
112                                 // Module does addionally not exists
113                                 addFatalMessage(__FILE__, __LINE__, getMaskedMessage('MODULE_REGISTRY_404', getModule()));
114                         } // END - if
115
116                         // Add fatal message
117                         addFatalMessage(__FILE__, __LINE__, getMaskedMessage('MODULE_IS_LOCKED', getModule()));
118                         break;
119
120                 default:
121                         // Unknown module status
122                         logDebugMessage(__FILE__, __LINE__, sprintf("Unknown status %s return from module check. Module=%s", $check, getModule()));
123                         addFatalMessage(__FILE__, __LINE__, getMaskedMessage('UNKNOWN_MODULE_STATUS', $check));
124                         break;
125         } // END - switch
126 } elseif (!ifFatalErrorsDetected()) {
127         // MySQL problems detected
128         addFatalMessage(__FILE__, __LINE__, '{--MYSQL_ERRORS--}');
129 }
130
131 if (($isModuleValid === true) && (isset($GLOBALS['module_inc']))) {
132         // Everything is okay so we can load the module
133         loadIncludeOnce($GLOBALS['module_inc']);
134 } // END - if
135
136 // Add the footer (this will call shutdown())
137 loadIncludeOnce('inc/footer.php');
138
139 // [EOF]
140 ?>