Web Hosting Info

Search:

featured partner

The IP to Country Database

  Forum Topics : Development / Soap Application
Submitted by ruturajv on Wed, 11/24/2004 - 03:48.
Why don't U guys start off a Soap Server which accepts an IP and returns the country name, its code, and the flag urls..
:D
Comment viewing options:
Select your preferred way to display the comments and click 'Save settings' to submit your changes.
Just a work around for the webservice
Posted by ruturajv on Fri, 11/26/2004 - 08:35.
This is a sample PHP script which you can use, You won't have to download the dB ;)
<?php
$ip = $_GET['ip'];

function get_country($ip)
{
    $f = fsockopen('ip-to-country.webhosting.info', 80);
    if (!$f)
    {
        return false;
    }

    $postdata = "ip_address=".urlencode($ip)."&submit=".urlencode('Find Country');


    $request = '';
    $request .= "POST /node/view/36 HTTP/1.1\r\n";
    $request .= "Host: ip-to-country.webhosting.info\r\n";
    $request .= "User-Agent: Its me again\r\n";
    $request .= "Content-Length: ".strlen($postdata)."\r\n";
    $request .= "Content-Type: application/x-www-form-urlencoded\r\n";
    $request .= "\r\n";
    $request .= "$postdata\r\n";
    
    fwrite($f, $request);
    $response = '';
    while (!feof($f)) 
    {
           $response .= fgets($f, 128);
    }

    $pos1 = strpos ( $response , '</from>');

    $pos2 = strpos ( $response , '<br><br><img' , $pos1 );

    $parse_from = substr( $response, $pos1+21, ($pos2-$pos1) );
    $pattern = "/<b>([^\/]*)<\/b>/si";
    preg_match_all($pattern, $parse_from, $matches);

    return $matches[1][1];
}

echo (get_country($ip));
 ?>
Ruturaj's Home Page
 
Not SOAP
Posted by Daath on Sat, 01/15/2005 - 20:13.
This has nothing at all to do with SOAP ;)

-
Any technology distinguishable from magic, is insufficiently advanced.