IPB

Welcome Guest ( Log In | Register )



Tags
This content has not been tagged yet
 
Reply to this topicStart new topic

Ip Info


dogtag
no avatar
Newbie [Level 1]
*
Group: Members
Posts: 23
Joined: 7-June 07
Member No.: 44,336



Post #1 post Jun 7 2007, 12:46 PM
Here is my 5th Code:
By this class you can have many informations about an IP address:


CODE
<?php
class ipinfo
{
    var $remote_addr;
    var $address;
    var $country;
    var $state;
    var $city;
    var $isp;
    var $organization;
    
    function ipinfo()
    {
        $this->remote_addr = $_SERVER["REMOTE_ADDR"];
    }
    
    function check($ip = false)
    {
        if ($ip == false)
        $ip = $this->remote_addr;

        $postfields = "custom_ip_address=".urlencode($ip)."&submit=".urlencode("lookup any ip");
        
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, 'http://www.ip-adress.com/index.php');
        curl_setopt($ch, CURLOPT_HEADER, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
        curl_setopt($ch, CURLOPT_REFERER, "http://www.ip-adress.com");
        //curl_setopt($ch, CURLOPT_PROXY, '211.233.74.24:80'); //To use proxy!
        $html = curl_exec($ch);
        curl_close($ch);
                
        if($html)
        {
            $start = strpos($html, '</form>');
            $end = strpos($html, '<p align="left"></p>') - $start;
            
            $html2 = trim(substr($html, $start, $end));
            $html2 = trim(ereg_replace("<([^>]+)>", "", $html2));
            $html2 = ereg_replace("\n", "<br>", $html2);
            
            $html3 = explode("<br>", $html2);
            
            /* //If you want to use arrays
            $ipinfo = array();
            $ipinfo["address"] = trim($html3[1]);
            $ipinfo["country"] = trim($html3[10]);
            $ipinfo["state"] = trim($html3[15]);
            $ipinfo["city"] = trim($html3[19]);
            $ipinfo["isp"] = trim($html3[31]);
            $ipinfo["organization"] = trim($html3[35]);
            $this->ipinfo = $ipinfo;
            */
            
            $this->address = trim($html3[1]);
            $this->country = trim($html3[10]);
            $this->state = trim($html3[15]);
            $this->city = trim($html3[19]);
            $this->isp = trim($html3[31]);
            $this->organization = trim($html3[35]);
        }
    }
}

$ipinfo = new ipinfo;

echo "<b>Check my IP:</b><br><br>";
$ipinfo->check();

echo    "IP Address: ".$ipinfo->address;
echo    "<br>Country: ".$ipinfo->country;
echo    "<br>State: ".$ipinfo->state;
echo    "<br>City: ".$ipinfo->city;
echo    "<br>ISP :".$ipinfo->isp;
echo    "<br> Organization :".$ipinfo->organization."<br><br><br>";

echo "<b>Check custom IP:</b><br><br>";
$ipinfo->check("72.14.221.99");

echo    "IP Address: ".$ipinfo->address;
echo    "<br>Country: ".$ipinfo->country;
echo    "<br>State: ".$ipinfo->state;
echo    "<br>City: ".$ipinfo->city;
echo    "<br>ISP :".$ipinfo->isp;
echo    "<br> Organization :".$ipinfo->organization;

?>
Go to the top of the page
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No New Posts   2 pr3dr49 3,753 2nd August 2004 - 10:45 AM
Last post by: OpaQue
No new   14 Chatz 1,288 22nd March 2007 - 06:52 AM
Last post by: Blessed
No new   16 fernan 4,387 11th September 2004 - 01:53 PM
Last post by: Lurk
No new   19 cyberoidx 5,669 15th October 2004 - 09:03 AM
Last post by: Lyubomyr
No New Posts   8 Mr Self Destruct 4,998 1st October 2004 - 02:00 PM
Last post by: Mr Self Destruct
No New Posts 2 rowita 3,144 5th October 2004 - 12:23 PM
Last post by: norbert
No New Posts 1 rowita 2,977 5th October 2004 - 12:18 PM
Last post by: norbert
No New Posts   5 -prodigy- 2,971 6th October 2004 - 06:37 AM
Last post by: -prodigy-
No New Posts 0 rowita 6,332 4th October 2004 - 10:48 PM
Last post by: rowita
No new 18 serverph 5,067 16th May 2005 - 02:06 PM
Last post by: Liquid-Fusion
No New Posts 10 rowita 7,252 3rd November 2004 - 10:40 PM
Last post by: rowita
No New Posts 5 rowita 3,967 13th October 2004 - 12:38 AM
Last post by: capeto
No New Posts   6 ICE-XG 5,679 13th October 2004 - 01:21 PM
Last post by: deejames
No New Posts 5 spawn_syxx9 3,290 22nd October 2004 - 06:25 AM
Last post by: Liquid Fire
No New Posts 4 rowita 3,038 16th May 2007 - 10:10 AM
Last post by: SamiFX


 



RSS Open Discussion Time is now: 4th July 2009 - 10:52 PM

Web Hosting Powered by ComputingHost.com.