added check on ip sanity

This commit is contained in:
real_nowhereman 2007-12-11 15:34:03 +00:00
parent d48a33cee6
commit 9d7ddd4f94
2 changed files with 14 additions and 5 deletions

View File

@ -87,8 +87,10 @@
} }
$arr['content'] = $_POST['content']; $arr['content'] = $_POST['content'];
$arr['ip-address'] = utils_ipget(); if ($v = utils_ipget()) {
$arr['ip-address'] = $v;
}
if (apply_filters('comment_validate', true, $arr)) if (apply_filters('comment_validate', true, $arr))
return $arr; return $arr;

View File

@ -309,6 +309,9 @@ if (!function_exists('fnmatch')) {
// get client IP // get client IP
function utils_ipget() { function utils_ipget() {
$ip = '';
if ( !empty ( $_SERVER[ 'HTTP_CLIENT_IP' ] ) ) { if ( !empty ( $_SERVER[ 'HTTP_CLIENT_IP' ] ) ) {
$ip = $_SERVER[ 'HTTP_CLIENT_IP' ]; $ip = $_SERVER[ 'HTTP_CLIENT_IP' ];
} }
@ -327,10 +330,14 @@ if (!function_exists('fnmatch')) {
elseif ( getenv( "REMOTE_ADDR") ) { elseif ( getenv( "REMOTE_ADDR") ) {
$ip = 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() { function utils_nocache_headers() {