Started building wrapper

This commit is contained in:
Josh Sherman 2012-05-09 22:13:47 -04:00
parent e4c358980b
commit f49a0e7de2
2 changed files with 62 additions and 0 deletions

42
ProjectHoneyPot.php Normal file
View file

@ -0,0 +1,42 @@
<?php
class ProjectHoneyPot
{
private $api_key = '';
public function __construct($api_key)
{
if (preg_match('/^[a-z]{12}$/', $api_key))
{
$this->api_key = $api_key;
}
else
{
throw new Exception('Y U No Supply Valid API Key?!');
}
}
public function query($ip_address)
{
if (filter_var($ip_address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE))
{
// Flip tha script
$octets = explode('.', $ip_address);
krsort($octets);
$reversed_ip = implode('.', $octets);
$results = dns_get_record($this->api_key . '.' . $reversed_ip . '.dnsbl.httpbl.org');
$results = explode('.', $results);
if ($results[0] == 127)
{
$last_activity = $results[1];
$threat_sore = $results[2];
}
}
return array('error' => 'Invalid IP Address');
}
}
?>

20
example.php Normal file
View file

@ -0,0 +1,20 @@
<?php
require_once 'ProjectHoneyPot.php';
$php = new ProjectHoneyPot('YOUR_KEY');
/*
var_dump($php->query('127.0.0.1'));
var_dump($php->query('127.1.1.0'));
var_dump($php->query('127.1.1.1'));
var_dump($php->query('127.1.1.2'));
var_dump($php->query('127.1.1.3'));
var_dump($php->query('127.1.1.4'));
var_dump($php->query('127.1.1.5'));
var_dump($php->query('127.1.1.6'));
var_dump($php->query('127.1.1.7'));
*/
var_dump($php->query('60.169.75.161'));
?>