验证IP合法性,防止SQL注入

This commit is contained in:
mstxq17 2023-10-10 09:11:30 +08:00 committed by 六零
parent 393ddb6e05
commit 03a80ae8bf

View File

@ -181,7 +181,12 @@ function get_real_ip() {
} elseif (isset($_SERVER['REMOTE_ADDR'])) { } elseif (isset($_SERVER['REMOTE_ADDR'])) {
$real_ip = $_SERVER['REMOTE_ADDR']; $real_ip = $_SERVER['REMOTE_ADDR'];
} }
return $real_ip; if (filter_var($real_ip, FILTER_VALIDATE_IP)) {
return $real_ip;
} else {
return "";
}
// return $real_ip;
} }
function yan() { function yan() {
$filename = ROOT.'/assets/data/data.dat'; $filename = ROOT.'/assets/data/data.dat';