Move getSig, which can produce error output, after the point where the template syste...
[squirrelmail.git] / include / init.php
index 26e43e4e92ce151c32621e2dec66510ce95325d2..d0709d1603ce137480186b81a9800389a24fb4a3 100644 (file)
@@ -85,6 +85,7 @@ if (!(bool)ini_get('session.use_cookies') ||
     ini_set('session.use_cookies','1');
 }
 
+
 /**
  * calculate SM_PATH and calculate the base_uri
  * assumptions made: init.php is only called from plugins or from the src dir.
@@ -92,27 +93,29 @@ if (!(bool)ini_get('session.use_cookies') ||
  *
  */
 if (isset($_SERVER['SCRIPT_NAME'])) {
-    $a = explode('/',$_SERVER['SCRIPT_NAME']);
+    $a = explode('/', $_SERVER['SCRIPT_NAME']);
 } elseif (isset($HTTP_SERVER_VARS['SCRIPT_NAME'])) {
-    $a = explode('/',$HTTP_SERVER_VARS['SCRIPT_NAME']);
+    $a = explode('/', $HTTP_SERVER_VARS['SCRIPT_NAME']);
 } else {
-    $error = 'Unable to detect script environment. '
-       .'Please test your PHP settings and send PHP core config, $_SERVER '
-       .'and $HTTP_SERVER_VARS to SquirrelMail developers.';
+    $error = 'Unable to detect script environment. Please test your PHP '
+           . 'settings and send your PHP core configuration, $_SERVER and '
+           . '$HTTP_SERVER_VARS contents to the SquirrelMail developers.';
     die($error);
 }
 $sSM_PATH = '';
-for($i = count($a) -2;$i > -1; --$i) {
+for($i = count($a) -2; $i > -1; --$i) {
     $sSM_PATH .= '../';
     if ($a[$i] === 'src' || $a[$i] === 'plugins') {
         break;
     }
 }
 
-$base_uri = implode('/',array_slice($a,0,$i)). '/';
+$base_uri = implode('/', array_slice($a, 0, $i)). '/';
 
 define('SM_PATH',$sSM_PATH);
 define('SM_BASE_URI', $base_uri);
+
+
 /**
  * global var $bInit is used to check if initialisation took place.
  * At this moment it's a workarounf for the include of addrbook_search_html
@@ -250,6 +253,13 @@ if (PAGE_NAME == 'login') {
 
     sqsession_is_active();
     session_regenerate_id();
+
+    // put session restore data back into session if necessary
+    if (!empty($sel)) {
+        sqsession_register($sel, 'session_expired_location');
+        if (!empty($sep))
+            sqsession_register($sep, 'session_expired_post');
+    }
 }
 
 /**
@@ -383,13 +393,6 @@ switch (PAGE_NAME) {
         require(SM_PATH . 'functions/page_header.php');
         require(SM_PATH . 'functions/html.php');
 
-        // put session restore data back into session if necessary
-        if (!empty($sel)) {
-            sqsession_register($sel, 'session_expired_location');
-            if (!empty($sep))
-                sqsession_register($sep, 'session_expired_post');
-        }
-
         // reset template file cache
         //
         $sTemplateID = Template::get_default_template_set();