15 define(
'SQ_INORDER',0);
18 define(
'SQ_SESSION',3);
19 define(
'SQ_COOKIE',4);
20 define(
'SQ_SERVER',5);
31 if ((
bool) ini_get(
'register_globals') &&
32 strtolower(ini_get(
'register_globals'))!=
'off') {
37 foreach ($GLOBALS as $key => $value) {
39 case 'HTTP_POST_VARS':
43 case 'HTTP_COOKIE_VARS':
45 case 'HTTP_SERVER_VARS':
49 case 'HTTP_POST_FILES':
52 case 'HTTP_SESSION_VARS':
59 unset($GLOBALS[$key]);
63 unset($GLOBALS[
'key']);
64 unset($GLOBALS[
'value']);
74 die(
'SquirrelMail 1.4.x is not compatible with PHP\'s session.auto_start setting. Please disable it at least for the location where SquirrelMail is installed.');
89 if (isset($_SERVER[
'PHP_SELF'])) {
90 $_SERVER[
'PHP_SELF'] = htmlspecialchars($_SERVER[
'PHP_SELF']);
97 if (isset($_SERVER[
'QUERY_STRING'])) {
98 $_SERVER[
'QUERY_STRING'] = htmlspecialchars($_SERVER[
'QUERY_STRING']);
103 if (isset($_SERVER[
'REQUEST_URI'])) {
104 $_SERVER[
'REQUEST_URI'] = htmlspecialchars($_SERVER[
'REQUEST_URI']);
113 require_once(
SM_PATH .
'functions/strings.php');
145 ini_set(
'session.name' ,
'SQMSESSID');
154 ini_set(
'magic_quotes_runtime',
'0');
163 if (!(
bool)ini_get(
'session.use_cookies') ||
164 ini_get(
'session.use_cookies') ==
'off') {
165 ini_set(
'session.use_cookies',
'1');
180 if (function_exists(
'get_magic_quotes_gpc') && @get_magic_quotes_gpc()) {
196 global $SQ_PHP_VERSION;
198 if(!isset($SQ_PHP_VERSION))
199 $SQ_PHP_VERSION = substr( str_pad( preg_replace(
'/\D/',
'', PHP_VERSION), 3,
'0'), 0, 3);
201 return $SQ_PHP_VERSION >= ($a.$b.$c);
237 if(count($array) > 0) {
238 foreach ($array as $index=>$value) {
239 if (is_array($array[$index])) {
243 $array[$index] = stripslashes($value);
276 $display_errors = ini_get(
'display_errors');
277 ini_set(
'display_errors',
'0');
278 $ret = call_user_func_array($function, $args);
279 ini_set(
'display_errors', $display_errors);
293 $_SESSION[$name] = $var;
305 unset($_SESSION[$name]);
320 return isset($_SESSION[$test_name]);
357 if( isset($_SESSION[$name]) ) {
358 $value = $_SESSION[$name];
365 if( isset($_POST[$name]) ) {
366 $value = $_POST[$name];
372 if ( isset($_GET[$name]) ) {
373 $value = $_GET[$name];
379 if ( isset($_COOKIE[$name]) ) {
380 $value = $_COOKIE[$name];
385 if ( isset($_SERVER[$name]) ) {
386 $value = $_SERVER[$name];
414 if (isset($_COOKIE[session_name()])) {
433 unset($_COOKIE[session_name()]);
434 unset($_GET[session_name()]);
435 unset($_POST[session_name()]);
437 $sessid = session_id();
438 if (!empty( $sessid )) {
472 session_set_cookie_params (0,
$base_uri);
475 $session_id = session_id();
509 function sqsetcookie($sName, $sValue=
'deleted', $iExpire=0, $sPath=
"", $sDomain=
"",
510 $bSecure=
false, $bHttpOnly=
true, $bReplace=
false) {
525 global $only_secure_cookies;
526 if (!isset($only_secure_cookies)) $only_secure_cookies =
true;
527 if (!$only_secure_cookies)
535 if (!empty($sDomain)) {
537 if (strtolower(substr($sDomain, 0, 4)) ==
'www.') $sDomain = substr($sDomain, 4);
538 $sDomain =
'.' . $sDomain;
541 $Port = strpos($sDomain,
':');
542 if ($Port !==
false) $sDomain = substr($sDomain, 0, $Port);
544 if (!$sValue) $sValue =
'deleted';
545 header(
'Set-Cookie: ' . rawurlencode($sName) .
'=' . rawurlencode($sValue)
546 . (empty($iExpire) ?
'' :
'; expires=' . gmdate(
'D, d-M-Y H:i:s', $iExpire) .
' GMT')
547 . (empty($sPath) ?
'' :
'; path=' . $sPath)
548 . (empty($sDomain) ?
'' :
'; domain=' . $sDomain)
549 . (!$bSecure ?
'' :
'; secure')
550 . (!$bHttpOnly ?
'' :
'; HttpOnly'), $bReplace);
586 global $sq_ignore_http_x_forwarded_headers, $sq_https_port;
587 $https_env_var = getenv(
'HTTPS');
588 if ($sq_ignore_http_x_forwarded_headers
590 $forwarded_proto =
'';
591 if (empty($sq_https_port))
592 $sq_https_port = 443;
593 if ((isset($https_env_var) && strcasecmp($https_env_var,
'on') === 0)
595 && strcasecmp($https,
'off') !== 0)
596 || (strcasecmp($forwarded_proto,
'https') === 0)
598 && $server_port == $sq_https_port))
619 while (!feof($FILE)) {
620 $buffer = fgets($FILE, 4096);
621 if (strlen($buffer) > $max_length) {