Skip to content

Instantly share code, notes, and snippets.

@ilyabrin
Created June 28, 2012 04:45
Show Gist options
  • Select an option

  • Save ilyabrin/3009151 to your computer and use it in GitHub Desktop.

Select an option

Save ilyabrin/3009151 to your computer and use it in GitHub Desktop.
xss protection
<?php
function clean($value)
{
if (get_magic_quotes_gpc()) $value = stripslashes($value);
if (!is_numeric($value)) $value = mysql_real_escape_string($value);
return $value;
}
array_walk($_GET,'clean');
array_walk($_POST,'clean');
array_walk($_COOKIE,'clean');
extract($_GET,EXTR_PREFIX_ALL,'get');
extract($_POST,EXTR_PREFIX_ALL,'post');
extract($_COOKIE,EXTR_PREFIX_ALL,'cookie');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment