Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ############################################################################
- #
- # retrieves current ampr.org host list
- # parses list and returns valid/invalid (including expired) callsigns
- # It takes a few minutes to run. Change the "44.92." part in the
- # following line below to select the portion of the list you want to
- # parse if (strstr($key, "44.92.")) {
- #
- ############################################################################
- $db = file('ftp://hamradio.ucsd.edu/pub/amprhosts');
- $pattern = "/^";
- $pattern .= "([A-Z][0-9][A-Z]{1,3})|";
- $pattern .= "([A-Z]{2}[0-9][A-Z]{1,3})|";
- $pattern .= "([0-9][A-Z][0-9][A-Z]{3})|";
- $pattern .= "/";
- $valid = "";
- $invalid = "";
- $today_date = time();
- foreach($db as $key) {
- if (strstr($key, "44.92.")) {
- $record = explode("\t", $key);
- $record_split = explode(" ", $record[1]);
- $host = strtoupper(substr($record_split[0], 0, strlen($record_split[0]) - 9));
- $host_split = explode(".", $host);
- $isgood = FALSE;
- foreach($host_split as $part) {
- preg_match($pattern, $part, $preg);
- var_dump($preg);
- if (strlen($preg[0]) != 0) {
- $checkcall = file("http://callook.info/" . $preg[0] . "/text", FILE_IGNORE_NEW_LINES);
- var_dump($checkcall);
- if (count($checkcall) > 4) {
- foreach($checkcall as $search) {
- if(strpos($search, "Expires:")) {
- $expire = explode("Expires: ", $search);
- $expire_date = strtotime($expire[1]);
- break;
- }
- }
- if ($expire_date > $today_date) {
- $isgood = TRUE;
- }
- }
- }
- }
- if($isgood) {
- $valid .= $key;
- } else {
- $invalid .= $key;
- }
- }
- }
- echo "valid\n\n" . $valid . "\n\n\n";
- echo "invalid\n" . $invalid . "\n\n";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement