Bahram0110
سه شنبه 02 مرداد 1386, 22:49 عصر
سلام
من ورودی های متنی را با تابع زیر چک می کنم و بعد از آنها استفاده می کنم
<?php
function secureit($inputstring)
{
$str = $inputstring;
$str = strtolower($str);
//replacing a single quote with a two single quotes -
//the way to escape single quotes in SQL.
$str = str_replace("'", "''", $str);
//script attack
$str = str_replace("<script", " ", $str);
$str = str_replace("<?", " ", $str);
//reject input that contains the following characters
$str = str_replace(";", " ", $str);
$str = str_replace("--", " ", $str);
$str = str_replace("/*", " ", $str);
$str = str_replace("*/", " ", $str);
$str = str_replace("*/", " ", $str);
//Note that if you are using a LIKE clause, wildcard
//characters still need to be escaped:
$str = str_replace("[", "[[]", $str);
$str = str_replace("%", "[%]", $str);
$str = str_replace("_", "[_]", $str);
//dang. words!
$str = str_replace("union", "_union", $str);
$str = str_replace("having", "_having", $str);
$str = str_replace("shutdown", "_shutdown", $str);
$str = str_replace("insert", "_insert", $str);
$str = str_replace("select", "_select", $str);
$str = str_replace("delete", "_delete", $str);
$str = str_replace("update", "_update", $str);
$str = str_replace("drop", "_drop", $str);
$str = str_replace("exec", "_exec", $str);
$str = str_replace("sp_", "_sp_", $str);
return $str;
}
?>
ولی مشکلم اینه که وقتی توی یه تکست باکس می نویسم :
<?php echo "string here"; ?>
کد اجرا می شه و "> به بیرون از تکست باکس می ره (عکس ضمیمه رو ببینید)
به نظر شما کد من (من نه دوستان) مشکلی داره؟ :متفکر:
من ورودی های متنی را با تابع زیر چک می کنم و بعد از آنها استفاده می کنم
<?php
function secureit($inputstring)
{
$str = $inputstring;
$str = strtolower($str);
//replacing a single quote with a two single quotes -
//the way to escape single quotes in SQL.
$str = str_replace("'", "''", $str);
//script attack
$str = str_replace("<script", " ", $str);
$str = str_replace("<?", " ", $str);
//reject input that contains the following characters
$str = str_replace(";", " ", $str);
$str = str_replace("--", " ", $str);
$str = str_replace("/*", " ", $str);
$str = str_replace("*/", " ", $str);
$str = str_replace("*/", " ", $str);
//Note that if you are using a LIKE clause, wildcard
//characters still need to be escaped:
$str = str_replace("[", "[[]", $str);
$str = str_replace("%", "[%]", $str);
$str = str_replace("_", "[_]", $str);
//dang. words!
$str = str_replace("union", "_union", $str);
$str = str_replace("having", "_having", $str);
$str = str_replace("shutdown", "_shutdown", $str);
$str = str_replace("insert", "_insert", $str);
$str = str_replace("select", "_select", $str);
$str = str_replace("delete", "_delete", $str);
$str = str_replace("update", "_update", $str);
$str = str_replace("drop", "_drop", $str);
$str = str_replace("exec", "_exec", $str);
$str = str_replace("sp_", "_sp_", $str);
return $str;
}
?>
ولی مشکلم اینه که وقتی توی یه تکست باکس می نویسم :
<?php echo "string here"; ?>
کد اجرا می شه و "> به بیرون از تکست باکس می ره (عکس ضمیمه رو ببینید)
به نظر شما کد من (من نه دوستان) مشکلی داره؟ :متفکر: