Skip to content

Instantly share code, notes, and snippets.

@JulienBreux
Created August 8, 2012 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JulienBreux/3294030 to your computer and use it in GitHub Desktop.
Save JulienBreux/3294030 to your computer and use it in GitHub Desktop.
IO prevent
<?php
function secure(&$value, $key)
{
if ((bool)preg_match('/^[0-9]+$/', $value))
$value = (int)$value;
elseif ((bool)preg_match('/^[0-9]+\.[0-9]+$/', $value))
$value = (float)$value;
else
$value = mysql_real_escape_string($value);
}
array_walk($_GET, 'secure');
array_walk($_POST, 'secure');
array_walk($_REQUEST, 'secure');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment