PHP Classes

Localization class: Detect user location using HTML 5 API or GeoIP API

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 1,076 This week: 2All time: 3,458 This week: 50Up
Version License PHP version Categories
local-class 2GNU General Publi...5PHP 5, Web services, Geography
Description 

Author

This class can detect user location using HTML 5 API or GeoIP API.

It can generate HTML with JavaScript code to detect the user location using Google Maps API on a browser that implements the HTML 5 geo-location API.

The class can also determine the user location by sending a HTTP request to the GeoIP API Web server to retrieve the location associated to the current use IP address.

Picture of Tiago André
Name: Tiago André <contact>
Classes: 4 packages by
Country: Portugal Portugal
Age: ???
All time rank: 120314 in Portugal Portugal
Week rank: 57 Up2 in Portugal Portugal Up

Recommendations

What is the best PHP mobile location finder class?
Find mobile user location

User location using an API
Search user location with an API

Detect user's location at the street level
Web site user's location

Tracking object at a distance
I need the PHP code for tracking object

Example

<?php
include('geoip.class.php');
$geoip=new geoIP();
$js_code_to_location = $geoip->location_html5("$('#city').text(place);");
$country=$geoip->get_location();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
    <title>untitled</title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <meta name="generator" content="Geany 0.21" />
    <script type='text/javascript' src='http://maps.googleapis.com/maps/api/js?sensor=false'></script>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
    <script>
    <?php echo $js_code_to_location; ?>
</script>
</head>

<body>
    <b>City via IP API</b>
    <pre>
    <?php print_r($country); ?>
</pre>
    <b>city via HTML5 geolocalisation</b>
    <div id='city'></div>
</body>

</html>


  Files folder image Files  
File Role Description
Accessible without login Plain text file demo.php Example demo file
Plain text file geo.class.php Class main file

 Version Control Unique User Downloads Download Rankings  
 0%
Total:1,076
This week:2
All time:3,458
This week:50Up