Home / Geral / SQL Injection: função PHP para ajudar a filtrar ataques de injection
Geral

SQL Injection: função PHP para ajudar a filtrar ataques de injection

<?php
// Quote variable to make safe
function quote_smart($value)
{
    // Stripslashes
    if (get_magic_quotes_gpc()) {
        $value = stripslashes($value);
    }
    // Quote if not integer
    if (!is_numeric($value)) {
        $value = "'" . mysql_real_escape_string($value) . "'";
    }
    return $value;
}
?>
É interessante também adicionar no seu arquivo .htaccess as seguintes regras: RewriteCond %{QUERY_STRING} (\|%3E) [NC,OR] RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR] RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) RewriteCond %{QUERY_STRING} SELECT(=|\[|\%[0-9A-Z]{0,2}) [OR] RewriteCond %{QUERY_STRING} UNION(=|\[|\%[0-9A-Z]{0,2}) [OR]
A

Escrito por Admin

Autor e especialista em tecnologia publicando reflexões e conhecimentos sobre inovação e desenvolvimento.

← Post Anterior Iphone 4G: Rumores de supostas imagens do novo sucessor do Iphone 3Gs Próximo Post → Nexus One: Linus Torvalds compra o smartphone do Google e segundo blog ele amou o dispositivo