0d26db9cf0367e5f4f55f78e8f9dc4b55c09443e
[mailer.git] / modules.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    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  * 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                  *
22  *                                                                      *
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.                                  *
27  *                                                                      *
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.                         *
32  *                                                                      *
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,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // XDEBUG call
40 //xdebug_start_trace();
41
42 // Load security stuff here
43 require('inc/libs/security_functions.php');
44
45 // Init start time
46 $GLOBALS['startTime'] = microtime(true);
47
48 // Init output mode and module
49 $GLOBALS['output_mode'] = 0;
50 $GLOBALS['module'] = '';
51
52 // Needed include files
53 require('inc/config-global.php');
54
55 // Fix missing module to 'index'
56 if (!REQUEST_ISSET_GET('module')) REQUEST_SET_GET('module', 'index');
57
58 // The header file
59 loadIncludeOnce('inc/header.php');
60
61 // Modules are by default not valid!
62 $isModuleValid = false; $check = 'failed';
63 if ((getConfig('maintenance') == 'Y') && (!IS_ADMIN()) && (getModule() != 'admin')) {
64         // Maintain mode is active and you are no admin
65         addFatalMessage(__FILE__, __LINE__, getMessage('LANG_DOWN_MAINTAINCE'));
66 } elseif ((SQL_IS_LINK_UP()) && (getTotalFatalErrors() == 0)) {
67         // Construct module name
68         $GLOBALS['module_inc'] =  sprintf("inc/modules/%s.php", SQL_ESCAPE(getModule()));
69
70         // Did we found the module listed in allowed modules and are we successfully connected?
71         $check = checkModulePermissions(getModule());
72         switch ($check) {
73                 case 'cache_miss': // The cache is gone
74                 case 'admin_only': // Admin-only access
75                 case 'mem_only': // Member-only access
76                 case 'done': // All fine!
77                         // Does the module exists on local file system?
78                         if ((isFileReadable($GLOBALS['module_inc'])) && (getTotalFatalErrors() == 0)) {
79                                 // Module is valid, active and located on the local disc...
80                                 $isModuleValid = true;
81                         } elseif (!empty($URL)) {
82                                 // An URL was specified so we load the de-referrer module
83                                 redirectToUrl(DEREFERER($URL));
84                         } elseif (getTotalFatalErrors() == 0) {
85                                 addFatalMessage(__FILE__, __LINE__, sprintf(getMessage('LANG_MOD_REG_404'), getModule()));
86                         }
87                         break;
88
89                 case '404':
90                         addFatalMessage(__FILE__, __LINE__, sprintf(getMessage('LANG_MOD_REG_404'), getModule()));
91                         break;
92
93                 case 'locked':
94                         if (!isFileReadable($GLOBALS['module_inc'])) {
95                                 // Module does addionally not exists
96                                 addFatalMessage(__FILE__, __LINE__, sprintf(getMessage('LANG_MOD_REG_404'), getModule()));
97                         } // END - if
98
99                         // Add fatal message
100                         addFatalMessage(__FILE__, __LINE__, sprintf(getMessage('LANG_MOD_REG_LOCKED'), getModule()));
101                         break;
102
103                 default:
104                         DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown status %s return from module check. Module=%s", $check, getModule()));
105                         addFatalMessage(__FILE__, __LINE__, sprintf(getMessage('LANG_MOD_REG_UNKNOWN'), $check));
106                         break;
107         }
108 } elseif (getTotalFatalErrors() == 0) {
109         // MySQL problems!
110         addFatalMessage(__FILE__, __LINE__, getMessage('MYSQL_ERRORS'));
111 }
112
113 if (($isModuleValid === true) && (isset($GLOBALS['module_inc']))) {
114         /////////////////////////////////////////////
115         // Main including line DO NOT REMOVE/EDIT! //
116         /////////////////////////////////////////////
117         //
118         // Everything is okay so we can load the module
119         loadIncludeOnce($GLOBALS['module_inc']);
120 } // END - if
121
122 // Next-to-end add the footer
123 loadIncludeOnce('inc/footer.php');
124
125 //
126 ?>