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 <[email protected]>
  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.72.2.13 2006/08/03 15:13:36 kink Exp $
  11.  * @package squirrelmail
  12.  */
  13.  
  14. /**
  15.  * Path for SquirrelMail required files.
  16.  * @ignore
  17.  */
  18. define('SM_PATH','../');
  19.  
  20. /* SquirrelMail required files. */
  21. require_once(SM_PATH 'functions/global.php');
  22. require_once(SM_PATH 'functions/i18n.php');
  23. require_once(SM_PATH 'functions/strings.php');
  24. require_once(SM_PATH 'config/config.php');
  25. require_once(SM_PATH 'functions/prefs.php');
  26. require_once(SM_PATH 'functions/imap.php');
  27. require_once(SM_PATH 'functions/plugin.php');
  28. require_once(SM_PATH 'functions/constants.php');
  29. require_once(SM_PATH 'functions/page_header.php');
  30.  
  31. /* Before starting the session, the base URI must be known. Assuming */
  32. /* that this file is in the src/ subdirectory (or something).        */
  33. if (!function_exists('sqm_baseuri')){
  34.     require_once(SM_PATH 'functions/display_messages.php');
  35. }
  36. $base_uri sqm_baseuri();
  37.  
  38. header('Pragma: no-cache');
  39. $location get_location();
  40.  
  41. session_set_cookie_params (0$base_uri);
  42.  
  43. sqsession_unregister ('user_is_logged_in');
  44. sqsession_register ($base_uri'base_uri');
  45.  
  46. /* get globals we me need */
  47. sqGetGlobalVar('login_username'$login_username);
  48. sqGetGlobalVar('secretkey'$secretkey);
  49. sqGetGlobalVar('js_autodetect_results'$js_autodetect_results);
  50. if(!sqGetGlobalVar('squirrelmail_language'$squirrelmail_language|| $squirrelmail_language == ''{
  51.     $squirrelmail_language $squirrelmail_default_language;
  52. }
  53.  
  54. if (!sqgetGlobalVar('mailto'$mailto)) {
  55.     $mailto '';
  56. }
  57.  
  58.  
  59. /* end of get globals */
  60.  
  61. set_up_language($squirrelmail_languagetrue);
  62. /* Refresh the language cookie. */
  63. setcookie('squirrelmail_language'$squirrelmail_languagetime()+2592000,
  64.           $base_uri);
  65.  
  66. if (!isset($login_username)) {
  67.     include_once(SM_PATH .  'functions/display_messages.php' );
  68.     logout_error_("You must be logged in to access this page.") );
  69.     exit;
  70. }
  71.  
  72. if (!sqsession_is_registered('user_is_logged_in')) {
  73.     do_hook ('login_before');
  74.  
  75.     $onetimepad OneTimePadCreate(strlen($secretkey));
  76.     $key OneTimePadEncrypt($secretkey$onetimepad);
  77.     sqsession_register($onetimepad'onetimepad');
  78.  
  79.     /* remove redundant spaces */
  80.     $login_username trim($login_username);
  81.  
  82.     /* Verify that username and password are correct. */
  83.     if ($force_username_lowercase{
  84.         $login_username strtolower($login_username);
  85.     }
  86.  
  87.     $imapConnection sqimap_login($login_username$key$imapServerAddress$imapPort0);
  88.  
  89.     $sqimap_capabilities sqimap_capability($imapConnection);
  90.     sqsession_register($sqimap_capabilities'sqimap_capabilities');
  91.     $delimiter sqimap_get_delimiter ($imapConnection);
  92.  
  93.     sqimap_logout($imapConnection);
  94.     sqsession_register($delimiter'delimiter');
  95.  
  96.     $username $login_username;
  97.     sqsession_register ($username'username');
  98.     setcookie('key'$key0$base_uri);
  99.     do_hook ('login_verified');
  100.  
  101. }
  102.  
  103. /* Set the login variables. */
  104. $user_is_logged_in true;
  105. $just_logged_in true;
  106.  
  107. /* And register with them with the session. */
  108. sqsession_register ($user_is_logged_in'user_is_logged_in');
  109. sqsession_register ($just_logged_in'just_logged_in');
  110.  
  111. /* parse the accepted content-types of the client */
  112. $attachment_common_types array();
  113. $attachment_common_types_parsed array();
  114. sqsession_register($attachment_common_types'attachment_common_types');
  115. sqsession_register($attachment_common_types_parsed'attachment_common_types_parsed');
  116.  
  117. $debug false;
  118.  
  119. if sqgetGlobalVar('HTTP_ACCEPT'$http_acceptSQ_SERVER&&
  120.     !isset($attachment_common_types_parsed[$http_accept]) ) {
  121.     attachment_common_parse($http_accept$debug);
  122. }
  123.  
  124. /* Complete autodetection of Javascript. */
  125. $javascript_setting getPref
  126.     ($data_dir$username'javascript_setting'SMPREF_JS_AUTODETECT);
  127. $js_autodetect_results (isset($js_autodetect_results?
  128.     $js_autodetect_results SMPREF_JS_OFF);
  129. /* See if it's set to "Always on" */
  130. $js_pref SMPREF_JS_ON;
  131. if ($javascript_setting != SMPREF_JS_ON){
  132.     if ($javascript_setting == SMPREF_JS_AUTODETECT{
  133.         if ($js_autodetect_results == SMPREF_JS_OFF{
  134.             $js_pref SMPREF_JS_OFF;
  135.         }
  136.     else {
  137.         $js_pref SMPREF_JS_OFF;
  138.     }
  139. }
  140. /* Update the prefs */
  141. setPref($data_dir$username'javascript_on'$js_pref);
  142.  
  143. /* Compute the URL to forward the user to. */
  144. $redirect_url 'webmail.php';
  145.  
  146. if sqgetGlobalVar('session_expired_location'$session_expired_locationSQ_SESSION) ) {
  147.     sqsession_unregister('session_expired_location');
  148.     if strpos($session_expired_location'compose.php'!== FALSE {
  149.         $compose_new_win getPref($data_dir$username'compose_new_win'0);
  150.         if ($compose_new_win{
  151.             $redirect_url $session_expired_location;
  152.         elseif strpos($session_expired_location'webmail.php'=== FALSE {
  153.             $redirect_url 'webmail.php?right_frame=compose.php';
  154.         }
  155.     else {
  156.         $redirect_url 'webmail.php?right_frame=' urldecode($session_expired_location);
  157.     }
  158.     unset($session_expired_location);
  159. }
  160.  
  161. if($mailto != ''{
  162.     $redirect_url  $location '/webmail.php?right_frame=compose.php&mailto=';
  163.     $redirect_url .= urlencode($mailto);
  164. }
  165.  
  166.  
  167.  
  168. /* Write session data and send them off to the appropriate page. */
  169. header("Location$redirect_url");
  170.  
  171. /* --------------------- end main ----------------------- */
  172.  
  173. function attachment_common_parse($str$debug{
  174.     global $attachment_common_types$attachment_common_types_parsed;
  175.  
  176.     $attachment_common_types_parsed[$strtrue;
  177.  
  178.     /*
  179.      * Replace ", " with "," and explode on that as Mozilla 1.x seems to
  180.      * use "," to seperate whilst IE, and earlier versions of Mozilla use
  181.      * ", " to seperate
  182.      */
  183.  
  184.     $str str_replace', ' ',' $str );
  185.     $types explode(','$str);
  186.  
  187.     foreach ($types as $val{
  188.         // Ignore the ";q=1.0" stuff
  189.         if (strpos($val';'!== false)
  190.             $val substr($val0strpos($val';'));
  191.  
  192.         if (isset($attachment_common_types[$val])) {
  193.             $attachment_common_types[$valtrue;
  194.         }
  195.     }
  196.     sqsession_register($attachment_common_types'attachment_common_types');
  197. }
  198.  
  199. ?>

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