Skip to content

Instantly share code, notes, and snippets.

@Brother-Lal
Created September 7, 2016 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Brother-Lal/e8330b64808cebef288aedb3b5407c62 to your computer and use it in GitHub Desktop.
Save Brother-Lal/e8330b64808cebef288aedb3b5407c62 to your computer and use it in GitHub Desktop.
<?php
/**
* Nodes.json von meshviewer laden (per web unter <meshviewerinstall>/nodes.json)
* jq nutzen:
* cat nodes.json| jq '.nodes | to_entries | map({key,seen:.value.firstseen}) ' > nodes.firstseen
* hopglass server stoppen
* Raw.json von hopglass laden (/etc/hopglass/default/raw.json)
* php convert.php
* scp rawer.json auf /etc/hopglass/default/raw.json
* hopglass server starten
* Done
*
*/
$input = json_decode(file_get_contents("nodes.firstseen"));
$output = json_decode(file_get_contents("raw.json"));
$sa=array();
foreach($input as $d)
{
$sa[$d->key] = $d->seen;
}
foreach($output as $key => &$d)
{
if(isset($sa[$key]))
{
$d->firstseen = $sa[$key] . ".503Z";
}
}
file_put_contents("rawer.json",json_encode($output));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment