Fixes for SQL execution and deprecated files removed
[mailer.git] / modules.php
index 3787101d996b47b7f8642cc51900be9dfb0efe20..f8c1a88e383c282ba09f5e0b85ddaccd413db36b 100644 (file)
@@ -35,7 +35,7 @@
 //xdebug_start_trace();
 
 // Load security stuff here (Oh, I hope this is not unsecure? Am I paranoia??? ;-) )
-require_once ("inc/libs/security_functions.php");
+require_once("inc/libs/security_functions.php");
 
 // Init "action" and "what"
 global $what, $action, $startTime;
@@ -55,12 +55,12 @@ if (!empty($_GET['what'])) $GLOBALS['what'] = secureString($_GET['what']);
 $GLOBALS['module'] = secureString($_GET['module']);
 
 // Needed include files
-require ("inc/config.php");
+require("inc/config.php");
 
 // Check if logged in
 if (IS_MEMBER()) {
        // Is still logged in so we welcome him with his name
-       $result = SQL_QUERY_ESC("SELECT surname, family FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
+       $result = SQL_QUERY_ESC("SELECT surname, family FROM `"._MYSQL_PREFIX."_user_data` WHERE userid=%s LIMIT 1",
         array($GLOBALS['userid']), __FILE__, __LINE__);
        if (SQL_NUMROWS($result) == 1) {
                // Load surname and family's name and build the username
@@ -98,7 +98,7 @@ include (PATH."inc/header.php");
 
 // Modules are by default not valid!
 $MOD_VALID = false; $check = "failed";
-if ((!empty($_CONFIG['maintenance'])) && ($_CONFIG['maintenance'] == "Y") && (!IS_ADMIN()) && ($GLOBALS['module'] != "admin")) {
+if ((getConfig('maintenance') == "Y") && (!IS_ADMIN()) && ($GLOBALS['module'] != "admin")) {
        // Maintain mode is active and you are no admin
        ADD_FATAL(LANG_DOWN_MAINTAINCE);
 } elseif (($link) && ($db) && (sizeof($FATAL) == 0)) {
@@ -129,33 +129,33 @@ if ((!empty($_CONFIG['maintenance'])) && ($_CONFIG['maintenance'] == "Y") && (!I
                break;
 
        case "locked":
-               if (!FILE_READABLE(PATH."inc/modules/".$GLOBALS['module'].".php"))
-               {
+               if (!FILE_READABLE(PATH."inc/modules/".$GLOBALS['module'].".php")) {
                        // Module does addionally not exists
                        ADD_FATAL(LANG_MOD_REG_404_1.$GLOBALS['module'].LANG_MOD_REG_404_2);
-               }
+               } // END - if
+
+               // Add fatal message
                ADD_FATAL(LANG_MOD_LOCKED_1.$GLOBALS['module'].LANG_MOD_LOCKED_2);
                break;
 
        default:
+               DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown status %s return from module check. Module=%s", $check, $GLOBALS['module']));
                ADD_FATAL(LANG_MOD_UNKNOWN_1.$check.LANG_MOD_UNKNOWN_2);
                break;
        }
-}
- elseif (sizeof($FATAL) == 0)
-{
+} elseif (sizeof($FATAL) == 0) {
        // MySQL problems!
        ADD_FATAL(MYSQL_ERRORS);
 }
 
-if ($MOD_VALID) {
+if (($MOD_VALID) && (defined('__MODULE'))) {
        /////////////////////////////////////////////
        // Main including line DO NOT REMOVE/EDIT! //
        /////////////////////////////////////////////
        //
        // Everything is okay so we can load the module
        include (__MODULE);
-}
+} // END - if
 
 // Next-to-end add the footer
 include (PATH."inc/footer.php");