SHARE
TWEET

getnodes.php

a guest Aug 17th, 2015 204 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /usr/bin/php -q
  2. <?php
  3.  
  4. // Get allstar database
  5. $url = "https://allstarlink.org/cgi-bin/allmondb.pl";
  6. $contents = '';
  7. $fh = fopen($url, 'r');
  8. if (!$fh) {
  9.     die('Failed to open URL.');
  10. }
  11. while (!feof($fh)) {
  12.   $contents .= fread($fh, 8192);
  13. }
  14. fclose($fh);
  15.  
  16. // Load private nodes if any
  17. $privatefile = "privatenodes.txt";
  18. if (file_exists($privatefile)) {
  19.     $contents .= file_get_contents($privatefile);
  20. }
  21.  
  22. // Save the data
  23. $db = "nodenames.txt";
  24. if (! $fh = fopen($db, 'w')) {
  25.     die("Cannot open $db.");
  26. }
  27. if (!flock($fh, LOCK_EX))  {
  28.     echo 'Unable to obtain lock.';
  29.     exit(-1);
  30. }
  31. if (fwrite($fh, $contents) === FALSE) {
  32.     die ("Cannot write $db.");
  33. }
  34. fclose($fh);
  35. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top