Advertisement
Guest User

getnodes.php

a guest
Aug 17th, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  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. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement