added fix so page isn't cached
[squirrelmail.git] / src / validate.php
CommitLineData
f740c049 1<?php
2 /**
3 ** validate.php
4 **
5 ** Copyright (c) 1999-2000 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
7 **
8 ** $Id$
9 **/
10
11 if (defined ('validate_php')) {
12 return;
13 } else {
14 define ('validate_php', true);
15 }
16
17 session_start();
6ee631f7 18 include ('../functions/auth.php');
19
20 // Everyone needs stuff from config, and config needs stuff from
21 // strings.php, so include them both here.
22 include ('../functions/strings.php');
23 include ('../config/config.php');
24
f740c049 25 is_logged_in();
26
27
28 // Remove all slashes for form values
29 if (get_magic_quotes_gpc())
30 {
31 global $REQUEST_METHOD;
32 if ($REQUEST_METHOD == "POST")
33 {
34 global $HTTP_POST_VARS;
35 RemoveSlashes($HTTP_POST_VARS);
36 }
37 elseif ($REQUEST_METHOD == "GET")
38 {
39 global $HTTP_GET_VARS;
40 RemoveSlashes($HTTP_GET_VARS);
41 }
42 }
43
44 // Auto-detection
45 //
46 // if $send (the form button's name) contains "\n" as the first char
47 // and the script is compose.php, then trim everything. Otherwise,
48 // we don't have to worry.
49 //
50 // This is for a RedHat package bug and a Konqueror (pre 2.1.1?) bug
51 global $send, $PHP_SELF;
52 if (isset($send) && substr($send, 0, 1) == "\n" &&
53 substr($PHP_SELF, -12) == '/compose.php')
54 {
55 if ($REQUEST_METHOD == "POST") {
56 global $HTTP_POST_VARS;
57 TrimArray($HTTP_POST_VARS);
58 } else {
59 global $HTTP_GET_VARS;
60 TrimArray($HTTP_GET_VARS);
61 }
62 }
63
64 //**************************************************************************
65 // Trims every element in the array
66 //**************************************************************************
67 function TrimArray(&$array) {
68 foreach ($array as $k => $v) {
69 global $$k;
70 if (is_array($$k)) {
71 foreach ($$k as $k2 => $v2) {
72 $$k[$k2] = substr($v2, 1);
73 }
74 } else {
75 $$k = substr($v, 1);
76 }
77 // Re-assign back to array
78 $array[$k] = $$k;
79 }
80 }
81
82
83 //**************************************************************************
84 // Removes slashes from every element in the array
85 //**************************************************************************
86 function RemoveSlashes(&$array)
87 {
88 foreach ($array as $k => $v)
89 {
90 global $$k;
91 if (is_array($$k))
92 {
93 foreach ($$k as $k2 => $v2)
94 {
95 $newArray[stripslashes($k2)] = stripslashes($v2);
96 }
97 $$k = $newArray;
98 }
99 else
100 {
101 $$k = stripslashes($v);
102 }
103 // Re-assign back to the array
104 $array[$k] = $$k;
105 }
106 }
107
108?>