Page 1 of 1

source code

PostPosted: Wed Nov 16, 2005 7:51 am
by fireblade
Hi,

I installed the hostip database in my mysql database with the hostip_current.sql file. I would like now to get the source code to get ip from this database. I tried svn co svn://hostip.info/hostip/api/trunk hostip but I just received some files. There are no README file, the ruby, perl, asp directories are empty. The php directory contains only dbase.php iplookup.php states.php ipRoughLookup.php and getip.php. It does not seems to be enough to request the database.

Do I forget somethings?

Thank you.

Re: source code

PostPosted: Thu Nov 17, 2005 8:01 am
by bfolkens
fireblade wrote:Hi,

I installed the hostip database in my mysql database with the hostip_current.sql file. I would like now to get the source code to get ip from this database. I tried svn co svn://hostip.info/hostip/api/trunk hostip but I just received some files. There are no README file, the ruby, perl, asp directories are empty. The php directory contains only dbase.php iplookup.php states.php ipRoughLookup.php and getip.php. It does not seems to be enough to request the database.

Do I forget somethings?

Thank you.


I'm working on the readme as well as some other files for it - we're still migrating the repo over to the new host.

Basically, the PHP libraries you see are all you need to call and reference the database (in fact, those are the same libraries that are used throughout the website for lookups, and also at api.hostip.info for the HTTP based services)

Hope that helps a bit...

Short readme!!

PostPosted: Sun Mar 19, 2006 5:12 pm
by Mister
Get the files via svn I used (TortoiseSVN) (google to find)
Connect to svn://hostip.info/hostip/api/trunk/php/
These are the files:
    dbase.php
    getip.php
    iplookup.php
    ipRoughLookup.php
    states.php


Open file dbase.php and you see on line 3
require_once("/home/hostip/hostip.conf.php");
That file doesnt exist so just creat that on later. also set path like this
require_once("hostip.conf.php"); (that way can you have the file in same dir as the others)

Still open dbase.php > remove all code (i just make connection dont use the functions) Insert this code
Code: Select all
<?php

require_once("hostip.conf.php");
$db  = mysql_pconnect($db_server, $db_user, $db_passwd) || die("Cannot connect to the database");
mysql_select_db($db_dbase) ||    die("Cannot select database '$db_dbase'");
?>


Now creat/open the file hostip.conf.php > insert code
Code: Select all
$db_server = "localhost"; //Server your database is on
$db_user = "root"; //User who connects to db
$db_passwd = ""; //Password
$db_dbase = "geoip"; //Name of your database

Save and close
Creat a file (any name ex: index.php) and open insert code >>
Code: Select all
<?
Echo "<h3>Output from iplookup.php</h3>";
include_once("host_inc/dbase.php");
require_once("host_inc/getip.php");
require_once("host_inc/iplookup.php");
require_once("host_inc/ipRoughLookup.php");
echo "<b>Function getIp()</b><br>";
$ip = getIp();
echo "$ip";
echo "<p><b>Function ipLocate( )</b><br>";
$info = ipLocate($ip);
echo "<pre>";
print_r($info);
echo "</pre>";
echo "<p><b>Function ipFastCoord( )</b><br>";
$info2 = ipFastCoord($ip);
echo "<pre>";
print_r($info2);
echo "</pre>";
echo "<p><b>Function getLocation( )</b><br>";
$location = getLocation($info);
echo "<pre>";
print_r($location);
echo "</pre>";
Echo "<h3>Output from ipRoughLookup.php</h3>";
echo "<p><b>Function ipRoughLocate( ip )</b><br>";
$info3 = ipRoughLocate($ip);
echo "<pre>";
print_r($info3);
echo "</pre>";
?>


This file will show you how they fetch info from DB and so. You need to know php to later on use this information but as I said this is a short readme to get started... :wink: