#! /usr/bin/php -q 0) { if ($seconds > 60) { print "Sleeping for $seconds seconds...\n"; sleep(60); $seconds = $seconds - 60; } else { print "Sleeping for $seconds seconds...\n"; sleep($seconds); $seconds = 0; } } } while (true) { // Open AllStar db URL and retrieve file. $contents2 = @file_get_contents($url); // Test size. $size = strlen($contents2); if ($size < 300000) { #if ($retries >= 2) # $url = $url2; if ($retries >= 5) die ("astdb.txt: Retries exceeded!! $size bytes - Invalid: file too small, bailing out.\n"); $retries++; print "Retry $retries of 5. Will retry $url\n"; sleep (5); } else { break; } } } // End private node check $contents = $Pcontents; $contents .= $contents2; // Added to strip non printing characters. $contents = preg_replace('/[\x00-\x09\x0B-\x0C\x0E-\x1F\x7F-\xFF]/', '', $contents); // Save the data if (! ($fh = fopen($db, 'w'))) { die("Cannot open $db."); } if (!flock($fh, LOCK_EX)) { echo 'Unable to obtain lock.'; exit(-1); } if (fwrite($fh, $contents) === FALSE) { die ("Cannot write $db."); } fclose($fh); $size = strlen($contents); print "Success: astdb.txt $size bytes\n"; ?>