-
-
Save gioxx/34a8f0786b20d897b6ba3dc1afa6d8cb to your computer and use it in GitHub Desktop.
Una rapida occhiata a una parte del codice di My Information, il tool che mostra le informazioni della tua connessione, liberamente accessibile puntando il browser verso https://go.gioxx.org/ip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ip = $_SERVER['REMOTE_ADDR']; | |
$location = file_get_contents('http://api.ipstack.com/'.$ip.'?access_key=XXX&hostname=1'); | |
$ipstack = json_decode($location, true); | |
echo '<li id="Hostname" > | |
<div> | |
<strong>Hostname</strong>:<br /> | |
<textarea readonly rows="1" cols="30" style="font-size: 30px;">'.$ipstack['hostname'].'</textarea> | |
</div> | |
</li>'; | |
echo '<li id="Country" > | |
<div> | |
<strong>Country</strong>:<br /> | |
<textarea readonly rows="1" cols="30" style="font-size: 30px;">'.$ipstack['country_code'].' ('.$ipstack['country_name'].')</textarea> | |
</div> | |
</li>'; | |
echo '<li id="Location" > | |
<div> | |
<strong>Location</strong>:<br /> | |
<textarea readonly rows="2" cols="45" style="font-size: 20px;">'.$ipstack['zip'].', '.$ipstack['city'].' ('.$ipstack['region_name'].')</textarea> | |
</div> | |
</li>'; | |
echo '<li id="Map" > | |
<div> | |
<strong>Map</strong>:<br /> | |
<div id="mapid" style="width: 560px; height: 300px;"></div> | |
</div> | |
</li>'; | |
?> | |
<script> | |
var mymap = L.map('mapid').setView([<?php echo $ipstack['latitude'].', '.$ipstack['longitude'] ?>], 13); | |
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.XXX.XXX', { | |
maxZoom: 20, | |
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' + | |
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' + | |
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>', | |
id: 'mapbox.streets' | |
}).addTo(mymap); | |
L.marker([<?php echo $ipstack['latitude'].', '.$ipstack['longitude'] ?>]).addTo(mymap) | |
.bindPopup("<?php echo $ipstack['zip'].', '.$ipstack['city'] ?>"); | |
var popup = L.popup(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment