Created
November 20, 2020 15:13
-
-
Save codenift/a8bf37a5bb5faffba35c557f4fb5406f to your computer and use it in GitHub Desktop.
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 | |
$login = 'admin'; | |
$password = 'your-password'; | |
$mount = '/live'; | |
$server = 'sndo.net:8000'; | |
$url = "http://$server/admin/listclients?mount=$mount"; | |
$opts = array('http' => array( | |
'method' => 'GET', | |
'header' => 'Authorization: Basic '.base64_encode("$login:$password")."\r\n" | |
)); | |
$context = stream_context_create($opts); | |
$xml = @file_get_contents($url, false, $context); | |
if( !$xml ) { | |
echo "<p>Sorry, no mountpoint found.</p>\n"; | |
exit(); | |
} | |
$listeners = new SimpleXMLElement($xml); | |
$unknown = 'Unknown'; | |
$bycity = array(); | |
$bycountry = array(); | |
foreach( $listeners->source->listener as $listener ) { | |
$l = array(); | |
$l['ip'] = (string)$listener->IP; | |
$l['time'] = (string)$listener->Connected; | |
//Test: print_r($l) | |
//Output on test would be: Array ( [ip] => 64.xxx.xx.xxx [time] => 183 ) | |
// Example using https://ipinfodb.com API | |
$location = $location->ip ($l['ip']); | |
// Values returned | |
$location['country']; | |
$location['country_code']; | |
$location['state']; | |
$location['city']; | |
$location['post_code']; | |
$location['latitude']; | |
$location['longitude']; | |
//then you can use this info for the map | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment