Adding template for error box.
[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. */
7442e064 41include_once(SM_PATH . 'class/mime.class.php');
42include_once(SM_PATH . 'functions/global.php');
43include_once(SM_PATH . 'functions/strings.php');
ebabf3f5 44
45/* set the name of the session cookie */
46if(isset($session_name) && $session_name) {
47 ini_set('session.name' , $session_name);
48} else {
49 ini_set('session.name' , 'SQMSESSID');
50}
fffe7fb2 51
748ba6c0 52sqsession_is_active();
cab99c3a 53
7442e064 54include_once(SM_PATH . 'functions/i18n.php');
55include_once(SM_PATH . 'functions/auth.php');
f740c049 56
cab99c3a 57is_logged_in();
f740c049 58
cab99c3a 59/**
4b4abf93 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 */
cab99c3a 68global $send, $PHP_SELF;
69if (isset($send)
70 && (substr($send, 0, 1) == "\n")
71 && (substr($PHP_SELF, -12) == '/compose.php')) {
5be9f195 72 if ($REQUEST_METHOD == 'POST') {
cab99c3a 73 global $HTTP_POST_VARS;
74 TrimArray($HTTP_POST_VARS);
75 } else {
76 global $HTTP_GET_VARS;
77 TrimArray($HTTP_GET_VARS);
f7b1b3b1 78 }
cab99c3a 79}
f7b1b3b1 80
7442e064 81include_once(SM_PATH . 'functions/page_header.php');
82include_once(SM_PATH . 'functions/prefs.php');
83include_once(SM_PATH . 'config/config.php');
84include_once(SM_PATH . 'include/load_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
7442e064 106 if (isset($time_zone_type) &&
2d3a630b 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
7442e064 121/* temporary sm_init section */
122
123include_once(SM_PATH . 'class/template/template.class.php');
124include_once(SM_PATH . 'class/error.class.php');
125/*
126 * Initialize the template object
127 */
963894c4 128global $sTplDir;
7442e064 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 */
139if (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
bb7173fa 145?>