-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathincsan.php
More file actions
30 lines (25 loc) · 744 Bytes
/
incsan.php
File metadata and controls
30 lines (25 loc) · 744 Bytes
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
<?php
function sanV(&$var, $file=1, $html=1, $mysql=1) //sanitize variable depending on use
{
if (!$var) return $var;
if (get_magic_quotes_gpc()) $var = stripslashes($var);
if ($file)
{
$var=preg_replace("/\.{2,}/","",$var); //allow only 1 consecutive dot
$var=preg_replace("/[^0-9a-zA-Z\.\-\s_]/","",$var); //do not allow special characters
}
if ($html&&!$file)
{
$var=strip_tags($var);
$forbidden=array("<", ">");
foreach ($forbidden as $search) $var=str_replace($search,"",$var);
}
if ($mysql&&!$file)
{
$forbidden=array("'", "\"", "´", "`", "\\", "%");
foreach ($forbidden as $search) $var=str_replace($search,"",$var);
$var=mysql_real_escape_string($var);
}
return $var;
}
?>