Skip to content

Instantly share code, notes, and snippets.

@rotanid
Last active September 28, 2015 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rotanid/697ec181262400e7b012 to your computer and use it in GitHub Desktop.
Save rotanid/697ec181262400e7b012 to your computer and use it in GitHub Desktop.
<?php
if (!isset($_REQUEST['macadd'])) {
?>
<!DOCTYPE html>
<html>
<body>
<p>Suche nach der IPv6-Adresse eines Freifunk-Routers im Netz von Freifunk München anhand dessen MAC-Adresse</p>
<form method="POST">
<input type="text" name="macadd" value="MAC-Adresse" />
<input type="submit" value="IPv6 Adresse suchen" />
</form>
</body>
</html>
<?php
} else {
$arrContextOptions=array(
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);
$macadd = trim($_REQUEST['macadd']);
$macaddpure = str_replace(':', '', $macadd);
$json = file_get_contents('https://ffmuc.net/data/nodes.json', false, stream_context_create($arrContextOptions));
$json = json_decode($json, true);
$nodes = $json['nodes'];
foreach ($nodes as $nodekey => $nodeval) {
if ($nodekey == $macaddpure) {
foreach ($nodeval['nodeinfo']['network']['addresses'] as $addr) {
if (substr($addr, 0, 5) != "fe80:" && substr($addr, 0, 5) != "fdef:") {
echo $addr;
break;
}
}
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment