diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 6bb3f3dfb4d..b63c5a02856 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -64,31 +64,38 @@ if (function_exists('get_magic_quotes_gpc')) // magic_quotes_* removed in PHP6 } /** - * Security: SQL Injection and XSS Injection (scripts) protection (Filters on GET, POST) + * Security: SQL Injection and XSS Injection (scripts) protection (Filters on GET, POST, PHP_SELF) * * @param string $val Value - * @param string $get 1=GET, 0=POST + * @param string $type 1=GET, 0=POST, 2=PHP_SELF * @return boolean true if there is an injection */ -function test_sql_and_script_inject($val, $get) +function test_sql_and_script_inject($val, $type) { $sql_inj = 0; - // For SQL Injection - $sql_inj += preg_match('/delete[\s]+from/i', $val); - $sql_inj += preg_match('/create[\s]+table/i', $val); - $sql_inj += preg_match('/update.+set.+=/i', $val); - $sql_inj += preg_match('/insert[\s]+into/i', $val); - $sql_inj += preg_match('/select.+from/i', $val); - $sql_inj += preg_match('/union.+select/i', $val); - $sql_inj += preg_match('/(\.\.%2f)+/i', $val); + // For SQL Injection (onyl GET and POST are used to be included into bad escaped SQL requests) + if ($type != 2) + { + $sql_inj += preg_match('/delete[\s]+from/i', $val); + $sql_inj += preg_match('/create[\s]+table/i', $val); + $sql_inj += preg_match('/update.+set.+=/i', $val); + $sql_inj += preg_match('/insert[\s]+into/i', $val); + $sql_inj += preg_match('/select.+from/i', $val); + $sql_inj += preg_match('/union.+select/i', $val); + $sql_inj += preg_match('/(\.\.%2f)+/i', $val); + } // For XSS Injection done by adding javascript with script $sql_inj += preg_match('/