Skip to content

Instantly share code, notes, and snippets.

@Lh4cKg
Last active August 29, 2015 14:06
Show Gist options
  • Save Lh4cKg/435dc6af274353e41375 to your computer and use it in GitHub Desktop.
Save Lh4cKg/435dc6af274353e41375 to your computer and use it in GitHub Desktop.
<?php
if(isset($_GET['lat'])) {
$lat = trim($_GET['lat']);
}
if(isset($_GET['lon'])) {
$lon = trim($_GET['lon']);
}
if(isset($_GET['acc'])) {
$acc = trim($_GET['acc']);
}
echo $lat . " " . $lon . " " . $acc;
$fp = fopen('hello.txt', 'w');
fwrite($fp, $lat . ", " . $lon . ", " . $acc);
fclose($fp);
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru" lang="ru" dir="ltr">
<head>
<title>Передача данных методом GET</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="ru" />
<script type="text/javascript">
function getXmlHttpRequest()
{
if (window.XMLHttpRequest)
{
try
{
return new XMLHttpRequest();
}
catch (e){}
}
else if (window.ActiveXObject)
{
try
{
return new ActiveXObject('Msxml2.XMLHTTP');
} catch (e){}
try
{
return new ActiveXObject('Microsoft.XMLHTTP');
}
catch (e){}
}
return null;
}
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var coords = position.coords;
showCoord(coords.latitude, coords.longitude, coords.accuracy)
}, function(error) {
var errorTypes = {
1: 'წვდომა აკრძალულია',
2: 'კოორდინატები ხელმისაწვდომია',
3: 'შეყოვნება'
};
alert(errorTypes[error.code] + ' შეუძლებელია დადგინდეს თქვენი ადგილმდებარეობა');
});
}
function showCoord(lat, lon, acc)
{
var req = getXmlHttpRequest();
req.onreadystatechange = function()
{
if (req.readyState != 4) return;
}
req.open("GET", "gettome.php?lat=" + lat + "&lon=" + lon + "&acc=" + acc, true);
req.send(null);
}
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment