note 90040 added to function.gethostbyaddr
| From: | Anonymous at osu1 dot php dot net | Date: | Thu, 02 Apr 2009 19:39:01 +0000 |
| Subject: | note 90040 added to function.gethostbyaddr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-152769@lists.php.net to get a copy of this message | ||
The use of the shell command to speed things up seems to work very well, but I would suggest one
thing: you ARE executing a shell command, so it would seem to be a good idea to be absolutely sure
of your input. Something like this perhaps:
function gethost ($ip)
{
//Make sure the input is not going to do anything unexpected
//IPs must be in the form x.x.x.x with each x as a number
$testar = explode('.',$ip);
if (count($testar)!=4)
return $ip;
for ($i=0;$i<4;++$i)
if (!is_numeric($testar[$i]))
return $ip;
$host =
host $ip;
return (($host ? end ( explode (' ', $host)) : $ip));
}
----
Server IP: 208.69.120.35
Probable Submitter: 72.66.9.25
----
Manual Page -- http://www.php.net/manual/en/function.gethostbyaddr.php
Edit -- https://master.php.net/note/edit/90040
Del: integrated -- https://master.php.net/note/delete/90040/integrated
Del: useless -- https://master.php.net/note/delete/90040/useless
Del: bad code -- https://master.php.net/note/delete/90040/bad+code
Del: spam -- https://master.php.net/note/delete/90040/spam
Del: non-english -- https://master.php.net/note/delete/90040/non-english
Del: in docs -- https://master.php.net/note/delete/90040/in+docs
Del: other reasons-- https://master.php.net/note/delete/90040
Reject -- https://master.php.net/note/reject/90040
Search -- https://master.php.net/manage/user-notes.php