/** * Get the PDF URL (the validity of the URL is checked) */ public function getMenuURL() { $PDFURL = $this->getPDFURL(); $UrlValid = false; if (!is_null($PDFURL) && URLExists($PDFURL)) { return $PDFURL; } return null; }
function preCheck($url) { global $weekEndText, $websiteNotAvailable; if (isWeekend()) { return $weekEndText; } if (!URLExists($url)) { return $websiteNotAvailable; } return null; }
/** * Performs data and time validity pre-checks * Return string if problem, null otherwise */ private function preChecks() { global $weekEndText, $websiteNotAvailable; if (isWeekend()) { return $weekEndText; } if (!(is_a($this, 'TextFileParser') || is_a($this, 'TextFileFixedPDFParser'))) { if (!URLExists($this->getBaseMenuURL())) { return $websiteNotAvailable; } } return null; }
echo "{$filename} - Uploading to {$bucket}...\n"; if (ArchiveFile("{$baseDir}/{$filename}", $bucket)) { $downloads[$filename] = array('url' => "{$download_path}{$bucket}/{$filename}", 'size' => $size, 'modified' => $modified, 'verified' => false, 'bucket' => $bucket); $updated = true; } } } } if ($updated) { file_put_contents("{$baseDir}/archived.json", json_encode($downloads)); } $updated = false; foreach ($downloads as $filename => &$download) { if (!$download['verified']) { echo "{$filename} - Checking {$download['url']}..."; if (URLExists($download['url'])) { echo "exists\n"; $download['verified'] = true; $updated = true; } else { echo "missing\n"; } } if ($download['verified'] && is_file("{$baseDir}/{$filename}")) { // only delete the local copy after 3 months $modified = filemtime("{$baseDir}/{$filename}"); if (!$modified || $modified < $now && $now - $modified > 7776000) { echo "{$filename} is in archive, deleting...\n"; unlink("{$baseDir}/{$filename}"); } }