Default times reduced in surfbar
[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  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
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.                                  *
22  *                                                                      *
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.                         *
27  *                                                                      *
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,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // APD call (if you have this apache extension and want to debug this script for us)
35 //apd_set_pprof_trace();
36
37 // Load security stuff here (Oh, I hope this is not unsecure? Am I paranoia??? ;-) )
38 require_once ("inc/libs/security_functions.php");
39
40 // Init "action" and "what"
41 global $what, $action, $startTime;
42 $GLOBALS['startTime'] = microtime(true);
43 $CSS = 0;
44 $GLOBALS['what'] = ""; $GLOBALS['action'] = "";
45 $GLOBALS['userid'] = 0;
46
47 if (!empty($_GET['action'])) $GLOBALS['action'] = secureString($_GET['action']);
48 if (!empty($_GET['what'])) $GLOBALS['what'] = secureString($_GET['what']);
49 if (empty($_GET['module'])) $_GET['module'] = "index";
50
51 // Secure the module name (very important line!)
52 $GLOBALS['module'] = htmlentities(strip_tags($_GET['module']), ENT_QUOTES);
53
54 // Needed include files
55 require ("inc/config.php");
56
57 // Check if logged in
58 if (IS_LOGGED_IN()) {
59         // Is still logged in so we welcome him with his name
60         $result = SQL_QUERY_ESC("SELECT surname, family FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
61          array($GLOBALS['userid']), __FILE__, __LINE__);
62         if (SQL_NUMROWS($result) == 1) {
63                 // Load surname and family's name and build the username
64                 list($s, $f) = SQL_FETCHROW($result);
65                 $username = $s." ".$f;
66
67                 // Update only cookies and no login data!
68                 UPDATE_LOGIN_DATA(false);
69         } else {
70
71                 // Hmmm, logged in and no valid cookies???
72                 $username = "<I>"._UNKNOWN."</I>";
73         }
74
75         // Free memory
76         SQL_FREERESULT($result);
77 } elseif (IS_ADMIN()) {
78         $username = _ADMIN;
79 } else {
80         // He's a guest, hello there... ;-)
81         $username = _GUEST;
82 }
83
84 // The header file
85 include (PATH."inc/header.php");
86
87 // Modules are by default not valid!
88 $MOD_VALID = false; $check = "failed";
89 if ((!empty($_CONFIG['maintenance'])) && ($_CONFIG['maintenance'] == "Y") && (!IS_ADMIN()) && ($GLOBALS['module'] != "admin")) {
90         // Maintain mode is active and you are no admin
91         ADD_FATAL(LANG_DOWN_MAINTAINCE);
92 } elseif (($link) && ($db) && (sizeof($FATAL) == 0)) {
93         // Did we found the module listed in allowed modules and are we successfully connected?
94         $check = CHECK_MODULE($GLOBALS['module']);
95         switch ($check)
96         {
97         case "admin_only":
98         case "mem_only":
99         case "done":
100                 // Construct module name
101                 define('__MODULE', sprintf("%sinc/modules/%s.php", PATH, $GLOBALS['module']));
102
103                 // Does the module exists on local file system?
104                 if (((file_exists(__MODULE)) && (is_readable(__MODULE))) && (sizeof($FATAL) == 0)) {
105                         // Module is valid, active and located on the local disc...
106                         $MOD_VALID = true;
107                 } elseif (!empty($URL)) {
108                         // An URL was specified so we load the de-referrer module
109                         LOAD_URL(DEREFERER($URL));
110                 } elseif (sizeof($FATAL) == 0) {
111                         ADD_FATAL(LANG_MOD_REG_404_1.$GLOBALS['module'].LANG_MOD_REG_404_2);
112                 }
113                 break;
114
115         case "404":
116                 ADD_FATAL(LANG_MOD_REG_404_1.$GLOBALS['module'].LANG_MOD_REG_404_2);
117                 break;
118
119         case "locked":
120                 if (!file_exists(PATH."inc/modules/".$GLOBALS['module'].".php"))
121                 {
122                         // Module does addionally not exists
123                         ADD_FATAL(LANG_MOD_REG_404_1.$GLOBALS['module'].LANG_MOD_REG_404_2);
124                 }
125                 ADD_FATAL(LANG_MOD_LOCKED_1.$GLOBALS['module'].LANG_MOD_LOCKED_2);
126                 break;
127
128         default:
129                 ADD_FATAL(LANG_MOD_UNKNOWN_1.$check.LANG_MOD_UNKNOWN_2);
130                 break;
131         }
132 }
133  elseif (sizeof($FATAL) == 0)
134 {
135         // MySQL problems!
136         ADD_FATAL(MYSQL_ERRORS);
137 }
138
139 if ($MOD_VALID) {
140         /////////////////////////////////////////////
141         // Main including line DO NOT REMOVE/EDIT! //
142         /////////////////////////////////////////////
143         //
144         // Everything is okay so we can load the module
145         include (__MODULE);
146 }
147
148 // Next-to-end add the footer
149 include (PATH."inc/footer.php");
150
151 //
152 ?>