Fixes for stripped HTML tags, and false warnings in debug log
[mailer.git] / inc / header.php
index 4f3f2a4e754f7253abd633148d289deb21ff7671..723933c17985a7ec672ef9d9051dc3d6bdc868dc 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);
 }
 
-// Initialize variables
-if (!isset($header)) $header = 0;
-
-if (($header != "1") && ($header != "2")) {
+// Is the header already sent?
+if (($GLOBALS['header_sent'] != "1") && ($GLOBALS['header_sent'] != "2")) {
        // If not in CSS mode generate the header
-       if (($CSS != "1")) {
+       if (($GLOBALS['output_mode'] != "1")) {
                // Generate header
                $TITLE = "";
 
                // Add title decorations? (left)
-               if ((!empty($CONFIG)) && (isset($link)) && (isset($db))) {
-                       if (($CONFIG['title_decoration'] == 'Y') && (trim(!empty($CONFIG['title_left'])))) $TITLE .= trim($CONFIG['title_left'])." ";
-                       $TITLE .= MAIN_TITLE;
-
-                       // Add title of module? (middle decoration will also be added!)
-                       if (($CONFIG['title_mod_show'] == 'Y') || ((empty($GLOBALS['what'])) && (empty($GLOBALS['action']))) || ($GLOBALS['module'] == "admin")) $TITLE .= " ".trim($CONFIG['title_middle'])." ".ADD_MODULE_TITLE($GLOBALS['module']);
-
-                       // Add title from what file
-                       $MODE = "";
-                       if ($GLOBALS['module'] == "login") $MODE = "member";
-                        elseif ($GLOBALS['module'] == "index") $MODE = "guest";
-                       if ((!empty($MODE)) && ($CONFIG['title_what_show'] == 'Y')) $TITLE .= " ".trim($CONFIG['title_middle'])." ".GET_MOD_DESCR($MODE, $GLOBALS['what']);
-
-                       // Add title decorations? (right)
-                       if (($CONFIG['title_decoration'] == 'Y') && (!empty($CONFIG['title_right']))) $TITLE .= " ".trim($CONFIG['title_right']);
-
-                       // Remember title in constant for the template
-                       define('__PAGE_TITLE', html_entity_decode($TITLE));
-               } elseif ((!mxchange_installed) || (!admin_registered)) {
-                       // Load language file because it was missing in installation finalizer step... *sigh*
-                       require_once(sprintf("%sinc/language/install_%s.php",
-                               PATH,
-                               GET_LANGUAGE()
-                       ));
-
-                       // Installation mode
-                       define('__PAGE_TITLE', INSTALLATION_OF_MXCHANGE);
-               } else {
-                       // Configuration not found!
-                       define('__PAGE_TITLE', NO_CONFIG_FOUND_TITLE);
-                       ADD_FATAL(NO_CONFIG_FOUND);
-               }
+               if (!defined('__PAGE_TITLE')) {
+                       // Config and database connection valid?
+                       if ((isset($_CONFIG)) && (is_array($_CONFIG)) && (count($_CONFIG) > 1) && (SQL_IS_LINK_UP())) {
+                               // Title decoration enabled?
+                               if ((getConfig('enable_title_deco') == "Y") && (getConfig('title_left') != "")) $TITLE .= trim(getConfig('title_left'))." ";
+
+                               // Do we have some extra title?
+                               if (!empty($EXTRA_TITLE)) {
+                                       // Then prepent it
+                                       $TITLE .= $EXTRA_TITLE." by ";
+                               } // END - if
+
+                               // Add main title
+                               $TITLE .= constant('MAIN_TITLE');
+
+                               // Add title of module? (middle decoration will also be added!)
+                               if ((getConfig('enable_mod_title') == "Y") || ((empty($GLOBALS['what'])) && (empty($GLOBALS['action']))) || ($GLOBALS['module'] == "admin")) $TITLE .= " ".trim(getConfig('title_middle'))." ".ADD_MODULE_TITLE($GLOBALS['module']);
+
+                               // Add title from what file
+                               $MODE = "";
+                               if ($GLOBALS['module'] == "login") $MODE = "member";
+                                elseif ($GLOBALS['module'] == "index") $MODE = "guest";
+                               if ((!empty($MODE)) && (getConfig('enable_what_title') == "Y")) $TITLE .= " ".trim(getConfig('title_middle'))." ".GET_MOD_DESCR($MODE, $GLOBALS['what']);
+
+                               // Add title decorations? (right)
+                               if ((getConfig('enable_title_deco') == "Y") && (getConfig('title_right') != "")) $TITLE .= " ".trim(getConfig('title_right'));
+
+                               // Remember title in constant for the template
+                               define('__PAGE_TITLE', $TITLE);
+                       } elseif ((!isBooleanConstantAndTrue('mxchange_installed')) || (!isBooleanConstantAndTrue('admin_registered'))) {
+                               // Installation mode
+                               define('__PAGE_TITLE', getMessage('INSTALLATION_OF_MXCHANGE'));
+                       } else {
+                               // Configuration not found!
+                               define('__PAGE_TITLE', getMessage('NO_CONFIG_FOUND_TITLE'));
+
+                               // Do not add the fatal message in installation mode
+                               if (basename($_SERVER['PHP_SELF']) != "install.php") addFatalMessage(getMessage('NO_CONFIG_FOUND'));
+                       }
+               } // END - if
 
                // Save some little memory
                unset($TITLE);
@@ -88,39 +94,39 @@ if (($header != "1") && ($header != "2")) {
                // Output page header code
                LOAD_TEMPLATE("page_header");
 
-               // Include meta data here
-               LOAD_TEMPLATE("metadata");
+               // Include meta data in "guest" module
+               if ($GLOBALS['module'] == "index") {
+                       // Load meta data template
+                       LOAD_TEMPLATE("metadata");
 
-               // Add meta description to header
-               if ((mxchange_installed) && (admin_registered) && ($GLOBALS['module'] != "admin") && ($GLOBALS['module'] != "login") && (isset($db)) && (isset($link))) {
-                       // Add meta description not in admin and login module and when the script is installed
-                       META_DESCRIPTION($GLOBALS['module'], $GLOBALS['what']);
-               }
+                       // Add meta description to header
+                       if ((isBooleanConstantAndTrue('mxchange_installed')) && (isBooleanConstantAndTrue('admin_registered')) && (SQL_IS_LINK_UP())) {
+                               // Add meta description not in admin and login module and when the script is installed
+                               META_DESCRIPTION($GLOBALS['module'], $GLOBALS['what']);
+                       } // END - if
+               } // END - if
 
                // Include more header data here
                LOAD_TEMPLATE("header");
 
                // Include stylesheet
-               include (PATH."inc/stylesheet.php");
-       }
+               LOAD_INC_ONCE("inc/stylesheet.php");
+       } // END - if
 
        // Closing HEAD tag
-       if ($CSS != "1") OUTPUT_HTML("</HEAD>");
-       $header = 1;
-}
-
-// Set unsetted variables
-if (empty($_GET['frame'])) $_GET['frame'] = "";
+       if ($GLOBALS['output_mode'] != "1") OUTPUT_HTML("</head>");
+       $GLOBALS['header_sent'] = 1;
+} // END - if
 
 // Load body or not
-if ((($GLOBALS['module'] != "frametester")) || (($header == "1") && ($GLOBALS['module'] == "frametester") && (!empty($_GET['frame']))) && ($CSS != "1")) {
+if (($GLOBALS['module'] != "frametester") || (($GLOBALS['module'] == "frametester") && (REQUEST_ISSET_GET(('frame')))) || (($GLOBALS['header_sent'] == "1") && (REQUEST_ISSET_GET(('frame')))) && ($GLOBALS['output_mode'] != "1")) {
        // Is the header sent and the script is not the mail confirmation script and not a CSS?
-       if (($header == "1") && (basename($_SERVER['PHP_SELF']) != "mailid.php") && ($CSS != "1")) {
+       if (($GLOBALS['header_sent'] == "1") && (basename($_SERVER['PHP_SELF']) != "mailid.php") && ($GLOBALS['output_mode'] != "1")) {
                // Add BODY tag
                LOAD_TEMPLATE("page_body");
-               $header = 2;
-       }
-}
+               $GLOBALS['header_sent'] = 2;
+       } // END - if
+} // END - if
 
 //
 ?>