Source for file redirect.php

Documentation is available at redirect.php

  1. <?php
  2.  
  3. /**
  4.  * Prevents users from reposting their form data after a successful logout.
  5.  *
  6.  * Derived from webmail.php by Ralf Kraudelt <kraude@wiwi.uni-rostock.de>
  7.  *
  8.  * @copyright &copy; 1999-2006 The SquirrelMail Project Team
  9.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10.  * @version $Id: redirect.php,v 1.98 2006/09/18 11:30:00 tokul Exp $
  11.  * @package squirrelmail
  12.  */
  13. $sInitLocation 'redirect';
  14.  
  15. /**
  16.  * Include the SquirrelMail initialization file.
  17.  */
  18. require('../include/init.php');
  19.  
  20. /* SquirrelMail required files. */
  21. require_once(SM_PATH 'functions/imap_general.php');
  22. require_once(SM_PATH 'functions/strings.php');
  23.  
  24. header('Pragma: no-cache');
  25. $location get_location();
  26.  
  27. // session_set_cookie_params (0, $base_uri);
  28.  
  29. sqsession_unregister ('user_is_logged_in');
  30. sqsession_register ($base_uri'base_uri');
  31.  
  32. /* get globals we me need */
  33. sqGetGlobalVar('login_username'$login_username);
  34. sqGetGlobalVar('secretkey'$secretkey);
  35. if(!sqGetGlobalVar('squirrelmail_language'$squirrelmail_language|| $squirrelmail_language == ''{
  36.     $squirrelmail_language $squirrelmail_default_language;
  37. }
  38. if (!sqgetGlobalVar('mailto'$mailto)) {
  39.     $mailto '';
  40. }
  41.  
  42. /* end of get globals */
  43.  
  44. set_up_language($squirrelmail_languagetrue);
  45. /* Refresh the language cookie. */
  46. sqsetcookie('squirrelmail_language'$squirrelmail_languagetime()+2592000,
  47.           $base_uri);
  48.  
  49. if (!isset($login_username)) {
  50.     logout_error_("You must be logged in to access this page.") );
  51.     exit;
  52. }
  53.  
  54. if (!sqsession_is_registered('user_is_logged_in')) {
  55.     do_hook ('login_before');
  56.  
  57.     $onetimepad OneTimePadCreate(strlen($secretkey));
  58.     $key OneTimePadEncrypt($secretkey$onetimepad);
  59.  
  60.     /* remove redundant spaces */
  61.     $login_username trim($login_username);
  62.  
  63.     /* Verify that username and password are correct. */
  64.     if ($force_username_lowercase{
  65.         $login_username strtolower($login_username);
  66.     }
  67.  
  68.     $imapConnection sqimap_login($login_username$key$imapServerAddress$imapPort0);
  69.     /* From now on we are logged it. If the login failed then sqimap_login handles it */
  70.  
  71.     /* regenerate the session id to avoid session hyijacking */
  72.     /**
  73.      * The cookie part. session_start and session_regenerate_session normally set
  74.      * their own cookie. SquirrelMail sets another cookie which overwites the
  75.      * php cookies. The sqsetcookie function sets the cookie by using the header
  76.      * function which gives us full control how the cookie is set. We do that
  77.      * to add the HttpOnly cookie attribute which blocks javascript access on
  78.      * IE6 SP1.
  79.      * sqsetcookieflush is needed to send out the headers. sqsetcookie caches
  80.      * the cookies to be send. If we don't do that we only can send 1 single cookie
  81.      * which is not sufficient.
  82.      */
  83.     sqsetcookie(session_name(),session_id(),false,$base_uri);
  84.     sqsetcookie('key'$keyfalse$base_uri);
  85.     sqsetcookieflush();
  86.  
  87.     sqsession_register($onetimepad'onetimepad');
  88.  
  89.     $sqimap_capabilities sqimap_capability($imapConnection);
  90.  
  91.     /* Server side sorting control */
  92.     if (isset($sqimap_capabilities['SORT']&& $sqimap_capabilities['SORT'== true &&
  93.         isset($disable_server_sort&& $disable_server_sort{
  94.         unset($sqimap_capabilities['SORT']);
  95.     }
  96.  
  97.     /* Thread sort control */
  98.     if (isset($sqimap_capabilities['THREAD']&& $sqimap_capabilities['THREAD'== true &&
  99.         isset($disable_thread_sort&& $disable_thread_sort{
  100.         unset($sqimap_capabilities['THREAD']);
  101.     }
  102.  
  103.     sqsession_register($sqimap_capabilities'sqimap_capabilities');
  104.     $delimiter sqimap_get_delimiter ($imapConnection);
  105.  
  106.     sqimap_logout($imapConnection);
  107.     sqsession_register($delimiter'delimiter');
  108.  
  109.     $username $login_username;
  110.     sqsession_register ($username'username');
  111.     do_hook ('login_verified');
  112. }
  113.  
  114. /* Set the login variables. */
  115. $user_is_logged_in true;
  116. $just_logged_in true;
  117.  
  118. /* And register with them with the session. */
  119. sqsession_register ($user_is_logged_in'user_is_logged_in');
  120. sqsession_register ($just_logged_in'just_logged_in');
  121.  
  122. /* parse the accepted content-types of the client */
  123. $attachment_common_types array();
  124. $attachment_common_types_parsed array();
  125. sqsession_register($attachment_common_types'attachment_common_types');
  126. sqsession_register($attachment_common_types_parsed'attachment_common_types_parsed');
  127.  
  128. $debug false;
  129.  
  130. if sqgetGlobalVar('HTTP_ACCEPT'$http_acceptSQ_SERVER&&
  131.     !isset($attachment_common_types_parsed[$http_accept]) ) {
  132.     attachment_common_parse($http_accept$debug);
  133. }
  134.  
  135. /* Complete autodetection of Javascript. */
  136.  
  137. /* Compute the URL to forward the user to. */
  138. $redirect_url $location '/webmail.php';
  139.  
  140. if sqgetGlobalVar('session_expired_location'$session_expired_locationSQ_SESSION) ) {
  141.     sqsession_unregister('session_expired_location');
  142.     if strpos($session_expired_location'compose.php'!== FALSE {
  143.         $compose_new_win getPref($data_dir$username'compose_new_win'0);
  144.         if ($compose_new_win{
  145.             // do not prefix $location here because $session_expired_location is set to PHP_SELF
  146.             // of the last page
  147.                         $redirect_url $session_expired_location;
  148.         else {
  149.             $redirect_url $location.'/webmail.php?right_frame='.urldecode($session_expired_location);
  150.         }
  151.     }
  152.     unset($session_expired_location);
  153. }
  154.  
  155. if($mailto != ''{
  156.     $redirect_url  $location '/webmail.php?right_frame=compose.php&mailto=';
  157.     $redirect_url .= urlencode($mailto);
  158. }
  159.  
  160. /* Write session data and send them off to the appropriate page. */
  161. header("Location$redirect_url");
  162. exit;
  163.  
  164. /* --------------------- end main ----------------------- */
  165.  
  166. function attachment_common_parse($str$debug{
  167.     global $attachment_common_types$attachment_common_types_parsed;
  168.  
  169.     $attachment_common_types_parsed[$strtrue;
  170.  
  171.     /*
  172.      * Replace ", " with "," and explode on that as Mozilla 1.x seems to
  173.      * use "," to seperate whilst IE, and earlier versions of Mozilla use
  174.      * ", " to seperate
  175.      */
  176.  
  177.     $str str_replace', ' ',' $str );
  178.     $types explode(','$str);
  179.  
  180.     foreach ($types as $val{
  181.         // Ignore the ";q=1.0" stuff
  182.         if (strpos($val';'!== false)
  183.             $val substr($val0strpos($val';'));
  184.  
  185.         if (isset($attachment_common_types[$val])) {
  186.             $attachment_common_types[$valtrue;
  187.         }
  188.     }
  189.     sqsession_register($attachment_common_types'attachment_common_types');
  190. }

Documentation generated on Sat, 07 Oct 2006 16:13:15 +0300 by phpDocumentor 1.3.0RC6