copyright update
[squirrelmail.git] / include / validate.php
CommitLineData
f740c049 1<?php
895905c0 2
35586184 3/**
4b4abf93 4 * validate.php
5 *
47ccfad4 6 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
4b4abf93 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
8 * @version $Id$
9 * @package squirrelmail
10 */
f740c049 11
2b646597 12/** include the mime class before the session start ! otherwise we can't store
fffe7fb2 13 * messages with a session_register.
de702cb8 14 *
15 * From http://www.php.net/manual/en/language.oop.serialization.php:
16 * In case this isn't clear:
91e0dccc 17 * In 4.2 and below:
de702cb8 18 * session.auto_start and session objects are mutually exclusive.
19 *
91e0dccc 20 * We need to load the classes before the session is started,
21 * except that the session could be started automatically
22 * via session.auto_start. So, we'll close the session,
23 * then load the classes, and reopen the session which should
24 * make everything happy.
de702cb8 25 *
26 * ** Note this means that for the 1.3.2 release, we should probably
27 * recommend that people set session.auto_start=0 to avoid this altogether.
fffe7fb2 28 */
ebabf3f5 29
de702cb8 30session_write_close();
31
a1a4a6e4 32/**
33 * Reset the $theme() array in case a value was passed via a cookie.
34 * This is until theming is rewritten.
35 */
36global $theme;
37unset($theme);
38$theme=array();
39
86725763 40/* SquirrelMail required files. */
41require_once(SM_PATH . 'class/mime.class.php');
ccbe63ba 42require_once(SM_PATH . 'functions/global.php');
67b73d65 43require_once(SM_PATH . 'functions/strings.php');
ebabf3f5 44require_once(SM_PATH . 'config/config.php');
45
46/* set the name of the session cookie */
47if(isset($session_name) && $session_name) {
48 ini_set('session.name' , $session_name);
49} else {
50 ini_set('session.name' , 'SQMSESSID');
51}
fffe7fb2 52
748ba6c0 53sqsession_is_active();
cab99c3a 54
86725763 55require_once(SM_PATH . 'functions/i18n.php');
56require_once(SM_PATH . 'functions/auth.php');
f740c049 57
cab99c3a 58is_logged_in();
f740c049 59
cab99c3a 60/**
4b4abf93 61 * Auto-detection
62 *
63 * if $send (the form button's name) contains "\n" as the first char
64 * and the script is compose.php, then trim everything. Otherwise, we
65 * don't have to worry.
66 *
67 * This is for a RedHat package bug and a Konqueror (pre 2.1.1?) bug
68 */
cab99c3a 69global $send, $PHP_SELF;
70if (isset($send)
71 && (substr($send, 0, 1) == "\n")
72 && (substr($PHP_SELF, -12) == '/compose.php')) {
5be9f195 73 if ($REQUEST_METHOD == 'POST') {
cab99c3a 74 global $HTTP_POST_VARS;
75 TrimArray($HTTP_POST_VARS);
76 } else {
77 global $HTTP_GET_VARS;
78 TrimArray($HTTP_GET_VARS);
f7b1b3b1 79 }
cab99c3a 80}
f7b1b3b1 81
08185f2a 82require_once(SM_PATH . 'include/load_prefs.php');
86725763 83require_once(SM_PATH . 'functions/page_header.php');
84require_once(SM_PATH . 'functions/prefs.php');
d4e84069 85
cab99c3a 86/* Set up the language (i18n.php was included by auth.php). */
87global $username, $data_dir;
88set_up_language(getPref($data_dir, $username, 'language'));
5be9f195 89
7bcc8f54 90$timeZone = getPref($data_dir, $username, 'timezone');
31afdbff 91
92/* Check to see if we are allowed to set the TZ environment variable.
91e0dccc 93 * We are able to do this if ...
31afdbff 94 * safe_mode is disabled OR
95 * safe_mode_allowed_env_vars is empty (you are allowed to set any) OR
91e0dccc 96 * safe_mode_allowed_env_vars contains TZ
31afdbff 97 */
98$tzChangeAllowed = (!ini_get('safe_mode')) ||
91e0dccc 99 !strcmp(ini_get('safe_mode_allowed_env_vars'),'') ||
100 preg_match('/^([\w_]+,)*TZ/', ini_get('safe_mode_allowed_env_vars'));
31afdbff 101
91e0dccc 102if ( $timeZone != SMPREF_NONE && ($timeZone != "")
31afdbff 103 && $tzChangeAllowed ) {
2d3a630b 104
105 // get time zone key, if strict or custom strict timezones are used
106 if (isset($time_zone_type) &&
107 ($time_zone_type == 1 || $time_zone_type == 3)) {
108 /* load time zone functions */
109 require_once(SM_PATH . 'include/timezones.php');
110 $realTimeZone = sq_get_tz_key($timeZone);
111 } else {
112 $realTimeZone = $timeZone;
113 }
114
115 // set time zone
116 if ($realTimeZone) {
117 putenv("TZ=".$realTimeZone);
118 }
7bcc8f54 119}
bb7173fa 120
121?>