-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsanitizePOSTGET.php
80 lines (64 loc) · 2.24 KB
/
sanitizePOSTGET.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
function sanitizePost($PostArrayFragment=null) {
if (!isset($_NEW_POST)) {
static $_NEW_POST=array();
}
if ($PostArrayFragment) {
$subArray=array();
$POST_ITEMS=$PostArrayFragment;
} else {
$POST_ITEMS=&$_POST;
}
foreach($POST_ITEMS as $key => $value) {
if (!is_array($_POST[$key])) {
if (!is_array($PostArrayFragment)) {
$_NEW_POST[htmlspecialchars($key)]=htmlspecialchars($value);
} else {
$subArray[htmlspecialchars($key)]=htmlspecialchars($value);
}
} else {
if (!is_array($PostArrayFragment)) {
$_NEW_POST[htmlspecialchars($key)]=htmlspecialchars($value);
} else {
$subArray[htmlspecialchars($key)]=htmlspecialchars($value);
}
}
}
if ($PostArrayFragment===null) {
$_POST=$_NEW_POST;
return;die();
} else {
return $subArray;
}
}
function sanitizeGet($GetArrayFragment=null) {
if (!isset($_NEW_GET)) {
static $_NEW_GET=array();
}
if ($GetArrayFragment) {
$subArray=array();
$GET_ITEMS=$GetArrayFragment;
} else {
$GET_ITEMS=&$_GET;
}
foreach($GET_ITEMS as $key => $value) {
if (!is_array($_GET[$key])) {
if (!is_array($GetArrayFragment)) {
$_NEW_GET[htmlspecialchars($key)]=htmlspecialchars($value);
} else {
$subArray[htmlspecialchars($key)]=htmlspecialchars($value);
}
} else {
if (!is_array($GetArrayFragment)) {
$_NEW_GET[htmlspecialchars($key)]=htmlspecialchars($value);
} else {
$subArray[htmlspecialchars($key)]=htmlspecialchars($value);
}
}
}
if ($GetArrayFragment===null) {
$_GET=$_NEW_GET;
return;die();
} else {
return $subArray;
}
}