Registriert seit: 11. Okt 2010
86 Beiträge
Delphi XE Starter
|
AW: PHP-Variablen wiederholt an Javascript übergeben
3. Jul 2012, 14:04
Code:
<?php
$badwords = Array('/(.*)(SELECT)( *?)(\*|\'?[a-z]\'? *?,? *?){1,}( *?)(FROM)(.*)/',
'/(.*)(DELETE)( *?)(\[[A-Z0-9]\],?){0,4}( *?)(FROM)(.*)/',
'/(.*)(DROP|ALTER)( *?)(\[[A-Z0-9]\],?){0,}( *?)(TABLE)( *?)(.*)/',
'/(.*)(UPDATE)( *?)([a-z0-9[]]*?)( *?)(SET)( *?)(.*)/',
'/(.*)(INSERT)( *?)(\[[A-Z0-9]\],?){0,4}( *?)(INTO)( *?)([A-Z0-9_\-]*)( *?)(VALUES)(.*)/',
'/(.*)( *?)([A-Z0-9]{1,})(\'|"| *?)(AND|OR)( *?)(\'?|"?)([A-Z0-9]*)(\'?|"?)( *?)([=<>]{1,2})(.*)/');
function anti_inject(&$array)
{
global $badwords;
foreach ($array as $key => $value)
{
$value = strtoupper($value);
foreach ($badwords as $bad)
{
$bad = strtoupper($bad);
if (preg_match($bad,$value))
{
return true;
}
}
}
unset($bad);
foreach ($array as $key => &$value)
{
$value = addslashes(stripslashes(mysql_real_escape_string($value)));
}
unset($value);
return false;
}
if ((anti_inject($_POST)) or (anti_inject($_GET)) or (anti_inject($_COOKIE)))
{
die('Injectionsversuch erkannt!');
}
?>
jetzt ist er sicher!
|
|
Zitat
|