Advertisement
Guest User

Untitled

a guest
Apr 10th, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.71 KB | None | 0 0
  1. <?php
  2. ############################################################################
  3. #
  4. #  retrieves current ampr.org host list
  5. #  parses list and returns valid/invalid (including expired) callsigns
  6. #  It takes a few minutes to run. Change the "44.92." part in the
  7. #  following line below to select the portion of the list you want to
  8. #  parse  if (strstr($key, "44.92.")) {
  9. #
  10. ############################################################################
  11. $db = file('ftp://hamradio.ucsd.edu/pub/amprhosts');
  12.  
  13. $pattern = "/^";
  14. $pattern .= "([A-Z][0-9][A-Z]{1,3})|";
  15. $pattern .= "([A-Z]{2}[0-9][A-Z]{1,3})|";
  16. $pattern .= "([0-9][A-Z][0-9][A-Z]{3})|";
  17. $pattern .= "/";
  18.  
  19. $valid = "";
  20. $invalid = "";
  21. $today_date = time();
  22.  
  23. foreach($db as $key) {
  24.  if (strstr($key, "44.92.")) {
  25.   $record = explode("\t", $key);
  26.   $record_split = explode(" ", $record[1]);
  27.   $host = strtoupper(substr($record_split[0], 0, strlen($record_split[0]) - 9));
  28.   $host_split = explode(".", $host);
  29.   $isgood = FALSE;
  30.   foreach($host_split as $part) {
  31.    preg_match($pattern, $part, $preg);
  32. var_dump($preg);
  33.    if (strlen($preg[0]) != 0) {
  34.     $checkcall = file("http://callook.info/" . $preg[0] . "/text", FILE_IGNORE_NEW_LINES);
  35. var_dump($checkcall);
  36.     if (count($checkcall) > 4) {
  37.      foreach($checkcall as $search) {
  38.       if(strpos($search, "Expires:")) {
  39.        $expire = explode("Expires: ", $search);
  40.        $expire_date = strtotime($expire[1]);
  41.        break;
  42.       }
  43.      }
  44.      if ($expire_date > $today_date) {
  45.       $isgood = TRUE;
  46.      }
  47.     }
  48.    }
  49.   }
  50.   if($isgood) {
  51.    $valid .= $key;
  52.   } else {
  53.    $invalid .= $key;
  54.   }
  55.  }
  56. }
  57. echo "valid\n\n" . $valid . "\n\n\n";
  58. echo "invalid\n" . $invalid . "\n\n";
  59. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement