add another applicable cve ID to the changelog,
[squirrelmail.git] / include / init.php
index bfc36d8ae3e5d90c1114f2ddb5243bcb6664f5bc..28b9eb053156e70fbf2865dd1e6a1072b714d9ef 100644 (file)
@@ -49,9 +49,6 @@ if ((bool) ini_get('register_globals') &&
         case 'key':
         case 'value':
             break;
-        case 'sInitLocation':
-            // FIXME: variable must be set only in src/login.php
-            break;
         default:
             unset($GLOBALS[$key]);
         }
@@ -63,7 +60,8 @@ if ((bool) ini_get('register_globals') &&
 
 /**
  * Used as a dummy value, e.g., for passing as an empty
- * hook argument.
+ * hook argument (where the value is passed by reference,
+ * and therefore NULL itself is not acceptable).
  */
 global $null;
 $null = NULL;
@@ -203,6 +201,7 @@ if (!isset($session_name) || !$session_name) {
  * if session.auto_start is On then close the session
  */
 $sSessionAutostartName = session_name();
+$sCookiePath = null;
 if ((isset($sSessionAutostartName) || $sSessionAutostartName == '') &&
      $sSessionAutostartName !== $session_name) {
     $sCookiePath = ini_get('session.cookie_path');
@@ -222,16 +221,12 @@ ini_set('session.name' , $session_name);
 session_set_cookie_params (0, $base_uri);
 sqsession_is_active();
 
-/**
- * SquirrelMail version number -- DO NOT CHANGE
- */
-$version = '1.5.2 [SVN]';
-
 /**
  * SquirrelMail internal version number -- DO NOT CHANGE
  * $sm_internal_version = array (release, major, minor)
  */
-$SQM_INTERNAL_VERSION = array(1,5,2);
+$SQM_INTERNAL_VERSION = explode('.', SM_VERSION, 3);
+$SQM_INTERNAL_VERSION[2] = intval($SQM_INTERNAL_VERSION[2]);
 
 
 /* if plugins are disabled only for one user and
@@ -297,15 +292,12 @@ if (! sqgetGlobalVar('squirrelmail_language',$squirrelmail_language,SQ_COOKIE))
     $squirrelmail_language = '';
 }
 
-
 /**
- * @var $sInitlocation From where do we include.
+ * Do something special for some pages. This is based on the PAGE_NAME constand
+ * set at the top of every page.
  */
-if (!isset($sInitLocation)) {
-    $sInitLocation=NULL;
-}
-
-switch ($sInitLocation) {
+if ( !defined('PAGE_NAME') ) define('PAGE_NAME', NULL);
+switch (PAGE_NAME) {
     case 'style':
 
         // need to get the right template set up
@@ -420,8 +412,8 @@ switch ($sInitLocation) {
             // signout page will deal with users who aren't logged
             // in on its own; don't show error here
             //
-            if (strpos($PHP_SELF, 'signout.php') !== FALSE) {
-            return;
+            if ( PAGE_NAME == 'signout' ) {
+                return;
             }
 
             /**
@@ -571,7 +563,9 @@ if (empty($oTemplate)) {
 }
 
 // We want some variables to always be available to the template
-$oTemplate->assign('javascript_on', checkForJavascript());
+$oTemplate->assign('javascript_on', 
+    (sqGetGlobalVar('user_is_logged_in', $user_is_logged_in, SQ_SESSION)
+     ?  checkForJavascript() : 0));
 $oTemplate->assign('base_uri', sqm_baseuri());
 $always_include = array('sTemplateID', 'icon_theme_path');
 foreach ($always_include as $var) {
@@ -604,6 +598,7 @@ function checkForJavascript($reset = FALSE) {
   if ( !$reset && sqGetGlobalVar('javascript_on', $javascript_on, SQ_SESSION) )
     return $javascript_on;
 
+  $user_is_logged_in = FALSE;
   if ( ( $reset || !isset($javascript_setting) )
     // getPref() not defined (nor is it meaningful) when user not
     // logged in, but that begs the question if $javascript_on is