PHP Script To Geo Locate With Lat & Lon

View previous topic View next topic Go down

PHP Script To Geo Locate With Lat & Lon

Post by jamied_uk on Mon 6 Jun 2016 - 14:18

Geo locate By IP



Code:
<title>J~Net IP Geo Location Map</title>
<center>

<div style="clear:left; height:24px;"></div>

<div style="float:center; height:auto; width:580px;background:#EBEBEB; margin-left:25px; margin-right:5px; box-shadow: 1px 3px 4px #666;">

<p><br>

<?php

$ip = $_GET['ip'];

$process = shell_exec("geoiplookup -f /usr/share/GeoIP/GeoLiteCity.dat $ip");



$rem = array("GeoIP City Edition, Rev 1:", " N/A,");

$rep = "";

echo $process = str_replace($rem,$rep,$process);

echo "<p>";



$new = substr("$process",5,-7);

// print_r (explode(" ",$new)); // debugging

$test = (explode(" ",$new));

$dot_example = array('.');


echo "<p>";

if (strpos($test[0], '.') == true){

$out  = $test[0];

$out .= $test[1];

} else

if (strpos($test[1], '.') == true){

$out  = $test[1];

$out .= $test[2];
} else
if (strpos($test[2], '.') == true){

$out  = $test[2];

$out .= $test[3];
} else

if (strpos($test[3], '.') == true){

$out  = $test[3];

$out .= $test[4];

} else

if (strpos($test[4], '.') == true){

$out  = $test[4];

$out .= $test[5];

} else
if (strpos($test[5], '.') == true){
$out  = $test[5];

$out .= $test[6];

} else
if (strpos($test[6], '.') == true){

$out  = $test[6];

$out .= $test[7];

} else
if (strpos($test[7], '.') == true){
$out  = $test[7];

$out .= $test[8];
} else
if (strpos($test[8], '.') == true){
$out  = $test[8];

$out .= $test[9];
}
if (strpos($test[9], '.') == true){
$out  = $test[9];

$out .= $test[10];
}
$new = substr($out,0,-1);

echo '<p><br><a href="https://www.google.co.uk/maps/search/'.$new.'" target="_blank">Find On Map</a>';

echo "<p>";

?>

<p><br>

<div>

<STYLE TYPE="text/css">

BODY {
background-image: url('images/map.jpg');


}

</STYLE>

You will need the geo locate database

see this page

http://jnet.forumn.biz/t1224-linux-bash-lookup-geo-location-from-ip#1653

Code Update
https://app.box.com/s/q2h5yjtybtuf5fi2havbbz2po4p8dxdt
avatar
jamied_uk
Admin

Posts : 2022
Join date : 2010-05-09
Age : 34
Location : UK

http://address-shortner.co.uk

Back to top Go down

Re: PHP Script To Geo Locate With Lat & Lon

Post by jamied_uk on Tue 7 Jun 2016 - 2:49

Find Directions Or Distance

avatar
jamied_uk
Admin

Posts : 2022
Join date : 2010-05-09
Age : 34
Location : UK

http://address-shortner.co.uk

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum