You are here:home»My M1nd#»class by me “SQL Security”

class by me “SQL Security”

On June 30, 2011, in My M1nd#, by securitymind

سلام عليكم

وانا جالس اراجع معلوماتي في البي اتش بي جائت في بالي كتابة كلاس بسيط لحماية المدخلات والمخرجات من الـ

SQL

// Full Code
class sql_securty{
function check_sql($vars,$type){
//  1 -> just numbric
if($type == 1){
$vars = intval($vars);
}
// 2 -> safe from sql injection ,, and add slashe
elseif($type == 2){
if(get_magic_quotes_gpc() == 0){
$vars = addslashes(htmlspecialchars($vars));
}
}
//3 -> remove any slashe
elseif($type == 3){
$vars = stripslashes($vars); } // Parst4 -> dont input HTML
elseif($type == 4){
$vars = htmlspecialchars($vars);
}
// 5 -> remove space
elseif($type == 5){
$vars = trim($vars);
}
// Pars6 -> remove some words
elseif($type == 6){
$vars = str_replace(“script”,””,$vars);
$vars= str_replace(“body”,””,$vars);
$vars = str_replace(“on”,””,$vars);
$vars= str_replace(“<“,”&l”,$vars);
$vars = str_replace(“>”,”&”,$vars);
}elseif($type == 7){
$vars = md5($vars);
}else{
$vars = $vars;
}
return $vars;
}
}

الكلاس واضح وبسيط لا يحتاج الى شرح

في امان الله

Security-Mind For Tech
about author

securitymind

 

Comments are closed.