dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: ip by country

  1. #1
    Junior Member
    Join Date
    Dec 2006
    Posts
    17

    Talking ip by country

    hii can anyone help me i want 2 make on my mc wen user enters my site the user 2 seehis/her ip adress and show from wich country is entering ?

    if there is annywy like this would be cool

  2. #2
    Junior Member
    Join Date
    Aug 2004
    Location
    usa
    Posts
    19
    I use hostip.info for this (a free service): http://www.hostip.info
    It's not always 100% but it works well. All you have to do is pass their site the IP of your visitor, and it returns city/state/country, or whichever you specify.

    I use PHP and wanted the city/state, so my code looks like this:

    Code:
    <?
    function getLocation($ip){
    	$NetGeoURL = "http://api.hostip.info/get_html.php?ip=" . $ip;
    	if($NetGeoFP = fopen($NetGeoURL,r)){ 
    		ob_start();
    		fpassthru($NetGeoFP);
            $NetGeoHTML = ob_get_contents();
            ob_end_clean();
    		fclose($NetGeoFP);
    	}
    	preg_match ("/City:(.*)/i", $NetGeoHTML, $temp) or die("Site temporarily down. Check back later.");
    	$location = $temp[1];
    	return $location;
    }
    $ip = $_SERVER['REMOTE_ADDR'];
    $location = getLocation($ip);
    ?>
    Then you just pass Flash the data through the querystring:

    Code:
    <embed src="myMovie.swf?ip=<?php echo $ip;?>&location=<?php echo $location;?>">
    Last edited by holodog; 12-14-2006 at 12:53 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center