added check on ip sanity
This commit is contained in:
parent
d48a33cee6
commit
9d7ddd4f94
@ -87,8 +87,10 @@
|
||||
|
||||
}
|
||||
$arr['content'] = $_POST['content'];
|
||||
|
||||
$arr['ip-address'] = utils_ipget();
|
||||
|
||||
if ($v = utils_ipget()) {
|
||||
$arr['ip-address'] = $v;
|
||||
}
|
||||
|
||||
if (apply_filters('comment_validate', true, $arr))
|
||||
return $arr;
|
||||
|
@ -309,6 +309,9 @@ if (!function_exists('fnmatch')) {
|
||||
|
||||
// get client IP
|
||||
function utils_ipget() {
|
||||
|
||||
$ip = '';
|
||||
|
||||
if ( !empty ( $_SERVER[ 'HTTP_CLIENT_IP' ] ) ) {
|
||||
$ip = $_SERVER[ 'HTTP_CLIENT_IP' ];
|
||||
}
|
||||
@ -327,10 +330,14 @@ if (!function_exists('fnmatch')) {
|
||||
elseif ( getenv( "REMOTE_ADDR") ) {
|
||||
$ip = getenv( "REMOTE_ADDR" );
|
||||
}
|
||||
else {
|
||||
$ip = "UNKNOWN";
|
||||
|
||||
if (preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $ip)) {
|
||||
return $ip;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
return( $ip );
|
||||
|
||||
|
||||
}
|
||||
|
||||
function utils_nocache_headers() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user