Czy takie coś pozwoli mi się zabezpieczyć przed SQL Inj.. ?
<?php
function sqlesc($x) {
}
function strip_magic_quotes($arr)
{
foreach ($arr as $k => $v){
$arr[$k] = strip_magic_quotes($v);
}
else{
}
}
return $arr;
}
{
if (!empty($_GET)) { $_GET = strip_magic_quotes
($_GET); } if (!empty($_POST)) { $_POST = strip_magic_quotes
($_POST); } if (!empty($_COOKIE)) { $_COOKIE = strip_magic_quotes
($_COOKIE); } }
// addslashes to vars if magic_quotes_gpc is off
// this is a security precaution to prevent someone
// trying to break out of a SQL statement.
//
{
while( list
($k, $v) = each($_GET) ) { while( list
($k2, $v2) = each($_GET[$k]) ){ }
}
else {
}
}
}
while( list
($k, $v) = each($_POST) ){ while( list
($k2, $v2) = each($_POST[$k]) ){ }
}
else{
}
}
}
while( list
($k, $v) = each($_COOKIE) ){ while( list
($k2, $v2) = each($_COOKIE[$k]) ){ }
}
else{
}
}
}
}
?>
a dodawanie/update do bazy robić tak:
<?php
"UPDATE ...... SET `cos`='".sqlesc($_GET['blabla']."'..."
?>
wyświetlenie wyników już na stronę z
htmlspecialchars" title="Zobacz w manualu PHP" target="_manuali jak, takie coś może być?
Ten post edytował robos85 30.09.2008, 13:33:51