Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Ip Info
dogtag
post Jun 7 2007, 12:46 PM
Post #1


Newbie [Level 1]
*

Group: Members
Posts: 23
Joined: 7-June 07
Member No.: 44,336



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

Topics Topics
  1. Need Info For Counter Strike 2 Pls(13)
  2. Warning: Virus Spreading Through Msn Messenger(12)
  3. I Am Offering Free Domain .org Or .info(21)
  4. Another Free .org Or .info Domain Offer(13)
  5. Dell Tech Support(22)
  6. Info On The Best Rpg's Coming From The Ps3(3)
  7. W810(7)
  8. Free .info Domains(22)
  9. Ptsd (post Traumatic Stress Disorder)(3)
  10. Website For Sale(1)
  11. The Book, Hanta Yo(0)
  12. Call Of Duty 4(8)
  13. Portable Application(6)
  14. My Mum Has Mynesthimia Gravis**(2)
  15. Shotokan Karate - Asking For Info And Reviews(4)
  1. New Rootkit Uses Old Trick To Hide(2)
  2. Macawmoney.info(6)
  3. My Website Is Down [resolved](4)
  4. The Reason Why .info Domains Aren't Liked- *scam Site*(2)
  5. Tray Info Message(7)
  6. Some Basic But Important Info About Cancer(3)
  7. Get User Info True Sessions Or Cookies(0)
  8. Yoga(1)
  9. Reset My Site Pelase(6)
  10. Rate An Operating System!(0)
  11. Enzymes And Health(0)
  12. Plants And Water Loss(0)
  13. Agent-principal Relationships(0)


 



- Lo-Fi Version Time is now: 27th July 2008 - 01:24 AM