validate.php 3.1 KB

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