私は自分のメインページをframework_ui.phpと呼んでいます。私はフィルタ関数があるところにauth.phpが必要です。
function filter($data)
{
// normalize $data because of get_magic_quotes_gpc
$dataNeedsStripSlashes = get_magic_quotes_gpc();
if ($dataNeedsStripSlashes) {
$data = stripslashes($data);
}
// normalize $data because of whitespace on beginning and end
$data = trim($data);
// strip tags
$data = strip_tags($data);
// replace characters with their HTML entitites
$data = htmlentities($data);
// mysql escape string
$data = mysql_real_escape_string($data);
return $data;
}
そして、get 変数と post 変数を含むすべてのページで、次のことを行います (そして、framework.php を呼び出します)。
// filter GET values
foreach ($_GET as $key => $value) {
$get[$key] = filter($value);
}
// filter post
foreach ($_POST as $key => $value) {
$post[$key] = filter($value);
}
上記を関数にして、代わりにすべてのページで呼び出すと、関数は正しく動作しますか?
function filter_all() {
// filter GET values
foreach ($_GET as $key => $value) {
$get[$key] = filter($value);
}
// filter post
foreach ($_POST as $key => $value) {
$post[$key] = filter($value);
}
}
これが最も安全な方法ではないことは理解していますが、この種のことが可能であり、コードに悪影響を及ぼさないかどうか疑問に思っていました.