\n"); function is_valid_ip($ip) { if ( !empty($ip) ) { $ipnum = ip2long($ip); if($ipnum !== -1 && $ipnum !== false && (long2ip($ipnum) === $ip)) { // PHP 4 and PHP 5 if( ($ipnum < 167772160 || $ipnum > 184549375) && // Not in 10.0.0.0/8 ($ipnum < -1408237568 || $ipnum > -1407188993) && // Not in 172.16.0.0/12 ($ipnum < -1062731776 || $ipnum > -1062666241) ) // Not in 192.168.0.0/16 { return true; } } } return false; } function get_ip() { if (is_valid_ip($_SERVER['HTTP_X_FORWARDED_FOR'])) return $_SERVER['HTTP_X_FORWARDED_FOR']; else if (is_valid_ip($_SERVER['HTTP_X_FORWARDED'])) return $_SERVER['HTTP_X_FORWARDED']; else if (is_valid_ip($_SERVER['HTTP_FORWARDED_FOR'])) return $_SERVER['HTTP_FORWARDED_FOR']; else if (is_valid_ip($_SERVER['HTTP_FORWARDED'])) return $_SERVER['HTTP_FORWARDED']; else if (is_valid_ip($_SERVER['HTTP_VIA'])) return $_SERVER['HTTP_VIA']; else if (is_valid_ip($_SERVER['HTTP_X_COMING_FROM'])) return $_SERVER['HTTP_X_COMING_FROM']; else if (is_valid_ip($_SERVER['HTTP_COMING_FROM'])) return $_SERVER['HTTP_COMING_FROM']; else return $_SERVER['REMOTE_ADDR']; } ?> Contact us - Universal Communication Systems

Contact Us