1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
function fix_input_quotes() |
|
|
|
|
4
|
|
|
{ |
5
|
|
|
if (get_magic_quotes_gpc()) { |
6
|
|
|
array_stripslashes($_GET); |
7
|
|
|
array_stripslashes($_POST); |
8
|
|
|
array_stripslashes($_COOKIE); |
9
|
|
|
} |
10
|
|
|
} |
11
|
|
|
|
12
|
|
|
function array_stripslashes(&$array) |
13
|
|
|
{ |
14
|
|
|
if (!is_array($array)) { |
15
|
|
|
return; |
16
|
|
|
} |
17
|
|
|
foreach ($array as $k => $v) { |
18
|
|
|
if (is_array($array[$k])) { |
19
|
|
|
array_stripslashes($array[$k]); |
20
|
|
|
} else { |
21
|
|
|
$array[$k] = stripslashes($array[$k]); |
22
|
|
|
} |
23
|
|
|
} |
24
|
|
|
return $array; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
function clean($input) |
28
|
|
|
{ |
29
|
4 |
|
return trim(stripslashes(htmlentities($input, ENT_QUOTES, 'UTF-8'))); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
function strToASCII($str) |
33
|
|
|
{ |
34
|
|
|
$trans = array( |
35
|
|
|
'Š' => 'S', 'Ș' => 'S', 'š' => 's', 'ș' => 's', 'Ð' => 'Dj', 'Ž' => 'Z', 'ž' => 'z', 'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Ă' => 'A', |
36
|
|
|
'Å' => 'A', 'Æ' => 'A', 'Ç' => 'C', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', |
37
|
|
|
'Ï' => 'I', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'O', 'Ø' => 'O', 'Ù' => 'U', 'Ú' => 'U', 'Ț' => 'T', |
38
|
|
|
'Û' => 'U', 'Ü' => 'U', 'Ý' => 'Y', 'Þ' => 'B', 'ß' => 'Ss', 'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'a', 'ă' => 'a', |
39
|
|
|
'å' => 'a', 'æ' => 'a', 'ç' => 'c', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i', |
40
|
|
|
'ï' => 'i', 'ð' => 'o', 'ñ' => 'n', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ø' => 'o', 'ù' => 'u', |
41
|
|
|
'ú' => 'u', 'û' => 'u', 'ý' => 'y', 'ý' => 'y', 'þ' => 'b', 'ÿ' => 'y', 'ƒ' => 'f', 'ț' => 't'); |
42
|
|
|
return strtr($str, $trans); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
if (!function_exists('value')) { |
46
|
|
|
/** |
47
|
|
|
* Return the default value of the given value. |
48
|
|
|
* |
49
|
|
|
* @param mixed $value |
50
|
|
|
* @return mixed |
51
|
|
|
*/ |
52
|
|
|
function value($value) |
53
|
|
|
{ |
54
|
|
|
return $value instanceof Closure ? $value() : $value; |
55
|
|
|
} |
56
|
|
|
} |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: