Several fixes and and improvements:
[mailer.git] / inc / modules / index.php
index 7a3af51f1157d26e5674ea560473c99543c438b6..e43f6869353d526f5fc19065bd60181383510bb8 100644 (file)
  ************************************************************************/
 
 // Some security stuff...
-if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
-{
+if (!defined('__SECURITY')) {
        $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
        require($INC);
-}
- elseif (!EXT_IS_ACTIVE("sql_patches", true))
-{
+} elseif (!EXT_IS_ACTIVE("sql_patches", true)) {
        // The extension "sql_patches" *MUST* be activated or you have lot's of problems!
-       LOAD_URL(URL."/modules.php?module=admin");
-}
-
-// When the frameset is active redirect the user :)
-if (frameset_active)
-{
-       LOAD_URL(URL."/modules.php?module=frameset");
+       LOAD_URL("modules.php?module=admin");
 }
 
 // Load adverstising template
@@ -56,10 +47,15 @@ define('__GUEST_ADVERT', LOAD_TEMPLATE("guest_advert", true));
 LOAD_TEMPLATE("guest_header");
 
 // Add message here
-if (!empty($_GET['msg']))
-{
-       switch ($_GET['msg'])
-       {
+if (!empty($_GET['msg'])) {
+       // Default extension is "unknown"
+       $ext = "unknown";
+
+       // Is extension given?
+       if (!empty($_GET['ext'])) $ext = SQL_ESCAPE($_GET['ext']);
+
+       // Which message shall we output?
+       switch ($_GET['msg']) {
                case CODE_LOGOUT_DONE      : $msg = LOGOUT_DONE; break;
                case CODE_LOGOUT_FAILED    : $msg = "<SPAN class=\"guest_failed\">".LOGOUT_FAILED."</SPAN>"; break;
                case CODE_DATA_INVALID     : $msg = MAIL_DATA_INVALID; break;
@@ -68,59 +64,60 @@ if (!empty($_GET['msg']))
                case CODE_USER_404         : $msg = USER_NOT_FOUND; break;
                case CODE_STATS_404        : $msg = MAIL_STATS_404; break;
                case CODE_ALREADY_CONFIRMED: $msg = MAIL_ALREADY_CONFIRMED; break;
-               case CODE_ERROR_MAILID     : if (EXT_IS_ACTIVE("mailid", true)) { $msg = ERROR_CONFIRMING_MAIL; } else { $msg = sprintf(EXTENSION_PROBLEM_NOT_INSTALLED, "mailid"); } break;
-               case CODE_EXTENSION_PROBLEM: $msg = sprintf(EXTENSION_PROBLEM_EXT_INACTIVE, "mailid"); break;
+
+               case CODE_ERROR_MAILID:
+                       if (EXT_IS_ACTIVE($ext, true)) { $msg = ERROR_CONFIRMING_MAIL; } else { $msg = sprintf(EXTENSION_PROBLEM_NOT_INSTALLED, "mailid"); }
+                       break;
+
+               case CODE_EXTENSION_PROBLEM:
+                       $msg = sprintf(EXTENSION_PROBLEM_EXT_INACTIVE, $ext);
+                       break;
+
                case CODE_COOKIES_DISABLED : $msg = LOGIN_NO_COOKIES; break;
                case CODE_BEG_SAME_AS_OWN  : $msg = BEG_SAME_UID_AS_OWN; break;
                case CODE_LOGIN_FAILED     : $msg = LOGIN_FAILED_GENERAL; break;
                default                    : $msg = UNKNOWN_MAILID_CODE_1.$_GET['msg'].UNKNOWN_MAILID_CODE_2; break;
-       }
+       } // END - switch
+
+       // Load message template
        LOAD_TEMPLATE("message", false, $msg);
-}
+} // END - if
 
 // Some of you needs this to be extracted into a template... ???
 LOAD_TEMPLATE("guest_menu_td");
 
 // When no what value is provided take the "home" value
-if (empty($GLOBALS['what'])) $GLOBALS['what'] = $CONFIG['index_home'];
+if (empty($GLOBALS['what'])) $GLOBALS['what'] = $_CONFIG['index_home'];
 
 // Adding the main content module here
-if (empty($GLOBALS['action']))
-{
+if (empty($GLOBALS['action'])) {
        // Get action value from what value
        $act = GET_ACTION("guest", $GLOBALS['what']);
-}
- else
-{
+} else {
        // Get action value directly from URL
        $act = COMPILE_CODE($GLOBALS['action']);
 }
 
 // Add the guest's menu here...
-if (($CONFIG['guest_menu'] == 'Y') || (!EXT_IS_ACTIVE("sql_patches", true)))
-{
+if (($_CONFIG['guest_menu'] == "Y") || (!EXT_IS_ACTIVE("sql_patches", true))) {
        // Show only when guest menu is active
        ADD_MENU("guest", $act, $GLOBALS['what']);
-}
+} // END - if
 
 // TDs between menu and content
 LOAD_TEMPLATE("guest_menu_content");
 
-$INC_ACTION = sprintf(PATH."inc/modules/guest/action-%s.php", $act);
-if ((file_exists($INC_ACTION)) && (is_readable($INC_ACTION)) && (VALIDATE_MENU_ACTION("guest", $act, $GLOBALS['what'])))
-{
+$INC_ACTION = sprintf("%sinc/modules/guest/action-%s.php", PATH, $act);
+if ((FILE_READABLE($INC_ACTION)) && (VALIDATE_MENU_ACTION("guest", $act, $GLOBALS['what']))) {
        // Requested module is available so we load it
        require_once($INC_ACTION);
-}
- else
-{
+} else {
        // Invalid module specified or not found...
-       LOAD_URL(URL."/modules.php?module=index");
+       LOAD_URL("modules.php?module=index");
 }
 
-if (($CONFIG['guest_menu'] == 'Y') || (!EXT_IS_ACTIVE("sql_patches", true)))
-{
-       // TDs between content and </table>
+if (($_CONFIG['guest_menu'] == "Y") || (!EXT_IS_ACTIVE("sql_patches", true))) {
+       // Right side of content (hint: a good place for 120x600 skyscraper banner!)
        LOAD_TEMPLATE("guest_content_footer");
 
        // Some advertising stuff?
@@ -131,7 +128,7 @@ if (($CONFIG['guest_menu'] == 'Y') || (!EXT_IS_ACTIVE("sql_patches", true)))
 
        // Goto TOP template
        LOAD_TEMPLATE("guest_goto_top");
-}
+} // END - if
 
 // Footer template (Thanx to Mr. Glaus!)
 LOAD_TEMPLATE("guest_footer");