move global include earlier..
[squirrelmail.git] / include / validate.php
... / ...
CommitLineData
1<?php
2
3/**
4* validate.php
5*
6* Copyright (c) 1999-2003 The SquirrelMail Project Team
7* Licensed under the GNU GPL. For full terms see the file COPYING.
8*
9* $Id$
10*/
11
12/* include the mime class before the session start ! otherwise we can't store
13 * messages with a session_register.
14 *
15 * From http://www.php.net/manual/en/language.oop.serialization.php:
16 * In case this isn't clear:
17 * In 4.2 and below:
18 * session.auto_start and session objects are mutually exclusive.
19 *
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.
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.
28 */
29
30session_write_close();
31
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
40/* SquirrelMail required files. */
41require_once(SM_PATH . 'class/mime.class.php');
42require_once(SM_PATH . 'functions/global.php');
43require_once(SM_PATH . 'functions/strings.php');
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}
52
53session_start();
54
55require_once(SM_PATH . 'functions/i18n.php');
56require_once(SM_PATH . 'functions/auth.php');
57
58is_logged_in();
59
60/**
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*/
69global $send, $PHP_SELF;
70if (isset($send)
71 && (substr($send, 0, 1) == "\n")
72 && (substr($PHP_SELF, -12) == '/compose.php')) {
73 if ($REQUEST_METHOD == 'POST') {
74 global $HTTP_POST_VARS;
75 TrimArray($HTTP_POST_VARS);
76 } else {
77 global $HTTP_GET_VARS;
78 TrimArray($HTTP_GET_VARS);
79 }
80}
81
82require_once(SM_PATH . 'include/load_prefs.php');
83require_once(SM_PATH . 'functions/page_header.php');
84require_once(SM_PATH . 'functions/prefs.php');
85
86/* Set up the language (i18n.php was included by auth.php). */
87global $username, $data_dir;
88set_up_language(getPref($data_dir, $username, 'language'));
89
90$timeZone = getPref($data_dir, $username, 'timezone');
91
92/* Check to see if we are allowed to set the TZ environment variable.
93 * We are able to do this if ...
94 * safe_mode is disabled OR
95 * safe_mode_allowed_env_vars is empty (you are allowed to set any) OR
96 * safe_mode_allowed_env_vars contains TZ
97 */
98$tzChangeAllowed = (!ini_get('safe_mode')) ||
99 !strcmp(ini_get('safe_mode_allowed_env_vars'),'') ||
100 preg_match('/^([\w_]+,)*TZ/', ini_get('safe_mode_allowed_env_vars'));
101
102if ( $timeZone != SMPREF_NONE && ($timeZone != "")
103 && $tzChangeAllowed ) {
104 putenv("TZ=".$timeZone);
105}
106?>