<?php
// This is an example script to demonstrate how to use the class ahostlookup.
// When run it displays information on the remote host.
// Enter any ip address in the form and submit to obtain information on that ip.
// You must edit one line to put in your own MySQL
// username, password and database name.
include "class.ahostlookup.php";
if (!empty($_GET['ip'])){
$ip = $_GET['ip'];
}else{
$ip=$REMOTE_HOST;
}
$hst= new ahostlookup();
// ****** edit next line to put your own username, password and database name.
$hst->SetUserPassDb("username","password","database_name");
if(!$rslt=$hst->GetHost($ip)){ //Try getting it from database
$rslt=$hst->GetArin($ip,true); //If not, then from Arin and add to database
} //(True=add to database, False=don't add to database)
//For both GetHost and GetArin functions:
//Returns array of 'host', 'upper', 'lower', 'zip'.
if(is_array($rslt)){ //If found, an array is returned
//If not, 'false' is returned
print "<H4>A demonstration of the AHostLookup Class with Remote Host Counter</h4>";
print "The IP address is $ip";
print "<table border='1'><tr align='center'>";
print "<td>Host</td><td>Lower IP</td><td>Upper IP</td><td>Zip Code</td>";
print "<td>Hit Count</td><td>Date</td><td>Time</td>";
print "</tr><tr align='center'>";
print "<td>".$rslt['host']."</td><td>".$rslt['lower']."</td>";
print "<td>".$rslt['upper']."</td><td>".$rslt['zip']."</td>";
print "<td>".$rslt['count']."</td><td>".$rslt['date']."</td>";
print "<td>".$rslt['time']."</td></tr></table>";
}else{
print "<br>No match for IP $ip";
}
print "<form action='$PHP_SELF' method='GET'>";
print "Enter an IP (0-255.0-255.0-255.0-255)<br>";
print "<input type='text' name='ip' size='20' value=$ip>";
print "<input type='submit' name='submit' value='submit'><br><br>";
print "<a href='/ahostlookup/ahostdisplay.php' target='_BLANK'>Display Hits</a>";
?>
|