diff --git a/comments.php b/comments.php index c0a3417..e537a7e 100644 --- a/comments.php +++ b/comments.php @@ -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; diff --git a/fp-includes/core/core.utils.php b/fp-includes/core/core.utils.php index 012f7af..6381639 100644 --- a/fp-includes/core/core.utils.php +++ b/fp-includes/core/core.utils.php @@ -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() {