1
0

getActivePublicPeers 624 B

123456789101112131415161718192021
  1. #!/usr/bin/env php
  2. <?php
  3. /**
  4. * Create list of active peers for cjdroute.conf file
  5. */
  6. define('FNAME', 'publicPeers.json');
  7. define('LAST_SEEN_DAYS', 7); // COMMENT: peer seen less than week ago
  8. if (!file_exists(FNAME)) die('Can not find '.FNAME."\n");
  9. $a = @json_decode(@file_get_contents(FNAME), true);
  10. foreach ($a as $k => $a)
  11. if (time() - @$a['lastseen'] < LAST_SEEN_DAYS*24*3600)
  12. {
  13. echo '"'.$k.'" : {'."\n";
  14. $x = 'publicKey'; echo "\t".'"'.$x.'": "'.$a[$x].'",'."\n";
  15. $x = 'password'; echo "\t".'"'.$x.'": "'.$a[$x].'",'."\n";
  16. $x = 'peerName'; echo "\t".'"'.$x.'": "'.$a[$x].'",'."\n";
  17. echo "},\n";
  18. }