Cookie защита

В този раздел ще се поместват уроците, свързани с програмирането и дизайна.
Post Reply
User avatar
Necrosis
Banned
Banned
Posts: 116
Joined: 24 Apr 2009, 19:24

Cookie защита

Post by Necrosis »

Code: Select all

<?
$IE = array_keys($_GET); $i=0;
while($i<count($IE)) { $_GET[$IE[$i]]= protect($_GET[$IE[$i]]); $i++; }
$IE = array_keys($_POST); $i=0;
while($i<count($IE)) { $_POST[$IE[$i]]= protect($_POST[$IE[$i]]); $i++; }
$IE = array_keys($_REQUEST); $i=0;
while($i<count($IE)) { $_REQUEST[$IE[$i]]= protect($_REQUEST[$IE[$i]]); $i++; }
$IE = array_keys($_COOKIE); $i=0;
while($i<count($IE)) { $_COOKIE[$IE[$i]]= protect($_COOKIE[$IE[$i]]); $i++; }
$IE = array_keys($_SESSION); $i=0;
while($i<count($IE)) { $_SESSION[$IE[$i]]= protect($_SESSION[$IE[$i]]); $i++; }
function protect($var)
{
$newvar = @preg_replace('/[^a-zA-Z0-9\_\-\.@]/','',$var);
if(strpos(str_replace("''",""," $newvar"),"'")!=false)
return str_replace("'", "''", $newvar);
else return $newvar;
}
?>
Post Reply

Return to “Учебни теми”