note 40788 added to function.gethostbyaddr

From: Date: Mon, 15 Mar 2004 01:29:40 +0000
Subject: note 40788 added to function.gethostbyaddr
Groups: php.notes 
Request: Send a blank email to php-notes+get-66837@lists.php.net to get a copy of this message
Going through numerous tests, the following results are concluded: <? // If you're using a server on Windows, this is faster function getisp($ip='') { if ($ip=='') $ip = $_SERVER['REMOTE_ADDR']; $longisp = @gethostbyaddr($ip); $isp = explode('.', $longisp); $isp = array_reverse($isp); $tmp = $isp[1]; if (preg_match("/\<(org?|com?|net)\>/i", $tmp)) { $myisp = $isp[2].'.'.$isp[1].'.'.$isp[0]; } else { $myisp = $isp[1].'.'.$isp[0]; } if (preg_match("/[0-9]{1,3}\.[0-9]{1,3}/", $myisp)) return 'ISP lookup failed.'; return $myisp; } // If your server is on a *nix system, this is faster function gethost ($ip) { $host = host $ip; return (($host ? end ( explode (' ', $host)) : $ip)); } // be warned, however, that gethost() will issue a warning // if safe mode is on with the use of backticked variables ?> ---- Manual Page -- http://www.php.net/manual/en/function.gethostbyaddr.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40788 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40788&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40788&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#66837) next »