remove hardcoded $fontset.
[squirrelmail.git] / include / validate.php
1 <?php
2
3 /**
4 * validate.php
5 *
6 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
8 * @version $Id$
9 * @package squirrelmail
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
30 session_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 */
36 global $theme;
37 unset($theme);
38 $theme=array();
39
40 /* SquirrelMail required files. */
41 include_once(SM_PATH . 'class/mime.class.php');
42 include_once(SM_PATH . 'functions/global.php');
43 include_once(SM_PATH . 'functions/strings.php');
44
45 /* set the name of the session cookie */
46 if(isset($session_name) && $session_name) {
47 ini_set('session.name' , $session_name);
48 } else {
49 ini_set('session.name' , 'SQMSESSID');
50 }
51
52 sqsession_is_active();
53
54 include_once(SM_PATH . 'functions/i18n.php');
55 include_once(SM_PATH . 'functions/auth.php');
56
57 is_logged_in();
58
59 /**
60 * Auto-detection
61 *
62 * if $send (the form button's name) contains "\n" as the first char
63 * and the script is compose.php, then trim everything. Otherwise, we
64 * don't have to worry.
65 *
66 * This is for a RedHat package bug and a Konqueror (pre 2.1.1?) bug
67 */
68 global $send, $PHP_SELF;
69 if (isset($send)
70 && (substr($send, 0, 1) == "\n")
71 && (substr($PHP_SELF, -12) == '/compose.php')) {
72 if ($REQUEST_METHOD == 'POST') {
73 global $HTTP_POST_VARS;
74 TrimArray($HTTP_POST_VARS);
75 } else {
76 global $HTTP_GET_VARS;
77 TrimArray($HTTP_GET_VARS);
78 }
79 }
80
81 include_once(SM_PATH . 'functions/page_header.php');
82 include_once(SM_PATH . 'functions/prefs.php');
83 include_once(SM_PATH . 'config/config.php');
84 include_once(SM_PATH . 'include/load_prefs.php');
85
86 /* Set up the language (i18n.php was included by auth.php). */
87 global $username, $data_dir;
88 set_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
102 if ( $timeZone != SMPREF_NONE && ($timeZone != "")
103 && $tzChangeAllowed ) {
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 }
119 }
120
121 /* temporary sm_init section */
122
123 include_once(SM_PATH . 'class/template/template.class.php');
124 include_once(SM_PATH . 'class/error.class.php');
125 /*
126 * Initialize the template object
127 */
128 global $sTplDir;
129 $oTemplate = new Template($sTplDir);
130
131 /*
132 * Initialize our custom error handler object
133 */
134 $oErrorHandler = new ErrorHandler($oTemplate,'error_message.tpl');
135
136 /*
137 * Activate custom error handling
138 */
139 if (version_compare(PHP_VERSION, "4.3.0", ">=")) {
140 $oldErrorHandler = set_error_handler(array($oErrorHandler, 'SquirrelMailErrorhandler'));
141 } else {
142 $oldErrorHandler = set_error_handler('SquirrelMailErrorhandler');
143 }
144
145 ?>