#!/usr/bin/env php $a) if (time() - @$data[$k]['updated'] > CACHE) { $ip = publicKey2ipv6($a['publicKey']); echo "Ping $ip... "; exec("ping -c3 -6 -W5 $ip", $out, $res); $res = $res === 0 ? true : false; echo $res ? '[ OK ]' : '[FAIL]'; echo "\n"; update($k, $a, $res); } } function update($k, $a, $res) { global $data; $a['updated'] = time(); if ($res) $a['lastseen'] = time(); $data[$k] = $a; $st = json_encode($data); $st = str_replace('},"', "},\n\"", $st); if ($st) file_put_contents(FNAME, $st); }