validate.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. /* SquirrelMail required files. */
  29. require_once(SM_PATH . 'class/mime.class.php');
  30. require_once(SM_PATH . 'functions/strings.php');
  31. require_once(SM_PATH . 'config/config.php');
  32. /* set the name of the session cookie */
  33. if(isset($session_name) && $session_name) {
  34. ini_set('session.name' , $session_name);
  35. } else {
  36. ini_set('session.name' , 'SQMSESSID');
  37. }
  38. session_start();
  39. require_once(SM_PATH . 'functions/i18n.php');
  40. require_once(SM_PATH . 'functions/auth.php');
  41. require_once(SM_PATH . 'functions/global.php');
  42. is_logged_in();
  43. /**
  44. * Auto-detection
  45. *
  46. * if $send (the form button's name) contains "\n" as the first char
  47. * and the script is compose.php, then trim everything. Otherwise, we
  48. * don't have to worry.
  49. *
  50. * This is for a RedHat package bug and a Konqueror (pre 2.1.1?) bug
  51. */
  52. global $send, $PHP_SELF;
  53. if (isset($send)
  54. && (substr($send, 0, 1) == "\n")
  55. && (substr($PHP_SELF, -12) == '/compose.php')) {
  56. if ($REQUEST_METHOD == 'POST') {
  57. global $HTTP_POST_VARS;
  58. TrimArray($HTTP_POST_VARS);
  59. } else {
  60. global $HTTP_GET_VARS;
  61. TrimArray($HTTP_GET_VARS);
  62. }
  63. }
  64. /**
  65. * Everyone needs stuff from config, and config needs stuff from
  66. * strings.php, so include them both here. Actually, strings is
  67. * included at the top now as the string array functions have
  68. * been moved into it.
  69. *
  70. * Include them down here instead of at the top so that all config
  71. * variables overwrite any passed in variables (for security).
  72. */
  73. /**
  74. * Reset the $theme() array in case a value was passed via a cookie.
  75. * This is until theming is rewritten.
  76. */
  77. global $theme;
  78. unset($theme);
  79. $theme=array();
  80. require_once(SM_PATH . 'include/load_prefs.php');
  81. require_once(SM_PATH . 'functions/page_header.php');
  82. require_once(SM_PATH . 'functions/prefs.php');
  83. /* Set up the language (i18n.php was included by auth.php). */
  84. global $username, $data_dir;
  85. set_up_language(getPref($data_dir, $username, 'language'));
  86. $timeZone = getPref($data_dir, $username, 'timezone');
  87. /* Check to see if we are allowed to set the TZ environment variable.
  88. * We are able to do this if ...
  89. * safe_mode is disabled OR
  90. * safe_mode_allowed_env_vars is empty (you are allowed to set any) OR
  91. * safe_mode_allowed_env_vars contains TZ
  92. */
  93. $tzChangeAllowed = (!ini_get('safe_mode')) ||
  94. !strcmp(ini_get('safe_mode_allowed_env_vars'),'') ||
  95. preg_match('/^([\w_]+,)*TZ/', ini_get('safe_mode_allowed_env_vars'));
  96. if ( $timeZone != SMPREF_NONE && ($timeZone != "")
  97. && $tzChangeAllowed ) {
  98. putenv("TZ=".$timeZone);
  99. }
  100. ?>