validate.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * validate.php
  4. *
  5. * Copyright (c) 1999-2004 The SquirrelMail Project Team
  6. * Licensed under the GNU GPL. For full terms see the file COPYING.
  7. *
  8. * @version $Id$
  9. * @package squirrelmail
  10. */
  11. /** include the mime class before the session start ! otherwise we can't store
  12. * messages with a session_register.
  13. *
  14. * From http://www.php.net/manual/en/language.oop.serialization.php:
  15. * In case this isn't clear:
  16. * In 4.2 and below:
  17. * session.auto_start and session objects are mutually exclusive.
  18. *
  19. * We need to load the classes before the session is started,
  20. * except that the session could be started automatically
  21. * via session.auto_start. So, we'll close the session,
  22. * then load the classes, and reopen the session which should
  23. * make everything happy.
  24. *
  25. * ** Note this means that for the 1.3.2 release, we should probably
  26. * recommend that people set session.auto_start=0 to avoid this altogether.
  27. */
  28. session_write_close();
  29. /**
  30. * Reset the $theme() array in case a value was passed via a cookie.
  31. * This is until theming is rewritten.
  32. */
  33. global $theme;
  34. unset($theme);
  35. $theme=array();
  36. /* SquirrelMail required files. */
  37. require_once(SM_PATH . 'class/mime.class.php');
  38. require_once(SM_PATH . 'functions/global.php');
  39. require_once(SM_PATH . 'functions/strings.php');
  40. require_once(SM_PATH . 'config/config.php');
  41. /* set the name of the session cookie */
  42. if(isset($session_name) && $session_name) {
  43. ini_set('session.name' , $session_name);
  44. } else {
  45. ini_set('session.name' , 'SQMSESSID');
  46. }
  47. sqsession_is_active();
  48. require_once(SM_PATH . 'functions/i18n.php');
  49. require_once(SM_PATH . 'functions/auth.php');
  50. is_logged_in();
  51. /**
  52. * Auto-detection
  53. *
  54. * if $send (the form button's name) contains "\n" as the first char
  55. * and the script is compose.php, then trim everything. Otherwise, we
  56. * don't have to worry.
  57. *
  58. * This is for a RedHat package bug and a Konqueror (pre 2.1.1?) bug
  59. */
  60. global $send, $PHP_SELF;
  61. if (isset($send)
  62. && (substr($send, 0, 1) == "\n")
  63. && (substr($PHP_SELF, -12) == '/compose.php')) {
  64. if ($REQUEST_METHOD == 'POST') {
  65. global $HTTP_POST_VARS;
  66. TrimArray($HTTP_POST_VARS);
  67. } else {
  68. global $HTTP_GET_VARS;
  69. TrimArray($HTTP_GET_VARS);
  70. }
  71. }
  72. require_once(SM_PATH . 'include/load_prefs.php');
  73. require_once(SM_PATH . 'functions/page_header.php');
  74. require_once(SM_PATH . 'functions/prefs.php');
  75. /* Set up the language (i18n.php was included by auth.php). */
  76. global $username, $data_dir;
  77. set_up_language(getPref($data_dir, $username, 'language'));
  78. $timeZone = getPref($data_dir, $username, 'timezone');
  79. /* Check to see if we are allowed to set the TZ environment variable.
  80. * We are able to do this if ...
  81. * safe_mode is disabled OR
  82. * safe_mode_allowed_env_vars is empty (you are allowed to set any) OR
  83. * safe_mode_allowed_env_vars contains TZ
  84. */
  85. $tzChangeAllowed = (!ini_get('safe_mode')) ||
  86. !strcmp(ini_get('safe_mode_allowed_env_vars'),'') ||
  87. preg_match('/^([\w_]+,)*TZ/', ini_get('safe_mode_allowed_env_vars'));
  88. if ( $timeZone != SMPREF_NONE && ($timeZone != "")
  89. && $tzChangeAllowed ) {
  90. putenv("TZ=".$timeZone);
  91. }
  92. ?>