| 
<?require_once("bbIPtoCountry.class.php");
 
 // call this script with 'update' get-variable
 // for update database from ip-to-country CSV file.
 if ( isset($_GET['update']) )
 UpdateDB();
 
 $ip = $_GET['ip'];
 
 getIPInfo($ip);
 ?>
 <form name="iptocountry" method="get" action="<?=$_SERVER['SCRIPT_NAME']?>">
 IP Adresi: <input type="text" value="<?=$ip?>" name="ip">
 </form>
 <?
 
 function getIPInfo($ip) {
 
 if ( empty($ip) ) return false;
 
 $ipc = new bbIPtoCountry($ip);
 
 if ( empty($ipc->error) ) {
 echo "  $ipc->code2, $ipc->code3, $ipc->country<br>\n";
 echo "     ".$ipc->ip_from." - ".$ipc->ip_to."\n";
 echo "<br><br>\n\n";
 }
 
 if ( !empty($ipc->error) )
 echo '<br><font color="#770000">'.$ipc->error.'</font><br>';
 }
 
 
 function UpdateDB() {
 
 $ipc   = new bbIPtoCountry();
 $count = $ipc->updateDatas();
 
 if ( empty($ipc->error) ) {
 // echo "$count items.<br>\n";
 Header('Location: '.$_SERVER['SCRIPT_NAME']);
 exit;
 }
 
 echo '<br><font color="#770000">'.$ipc->error.'</font>';
 exit;
 }
 ?>
 
 |