Afficher un message
Vieux 11/09/2007, 17h22   #2
GreyWyvern
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Finding abuse contact for IP address

And lo, Karl Groves didst speak in alt.www.webmaster:

> This is probably a more appropriate question for comp.lang.php but I like
> you guys better.
>
> I'm looking for a way - using PHP - to get *only* the abuse contact for
> an
> IP address. Anyone know how to do this?


Assuming a *nix server with shell access to the whois command, try this on
for size:


<?php

if (isset($_GET['ip']) && preg_match("/(\d{1,3}\.){3}\d{1,3}/",
$_GET['ip'])) {

echo "Checking {$_GET['ip']} . . .\n";

if (preg_match("/(abuse@[\S]+)/i", `whois {$_GET['ip']}`, $match)) {
$abuse = $match[1];
echo "Abuse email address: $abuse";

} else echo "No abuse email address found";

} else echo "Invalid IP or No IP Given";

?>


The script will accept IPs sent via HTTP in the form:
/abuse.php?ip=123.123.123.123 Modify as you see fit.

Note the IP regular expression is a simple one which will also allow IPs
like 999.999.999.999 to get through.

Grey

--
The technical axiom that nothing is impossible sinisterly implies the
pitfall corollary that nothing is ridiculous.
- http://www.greywyvern.com/orca#search - Orca Search: Full-featured
spider and site-search engine
  Réponse avec citation
 
Page generated in 0,05681 seconds with 9 queries