From eb0e77354015130ff44ec3a2b7f40d2090f0c61b Mon Sep 17 00:00:00 2001 From: Rob Vella Date: Mon, 11 Jan 2021 06:56:52 -0800 Subject: [PATCH] Check for outdated node database --- fetchData.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fetchData.php b/fetchData.php index a28ed35..92db654 100644 --- a/fetchData.php +++ b/fetchData.php @@ -81,7 +81,7 @@ function fetchNodeInfoIRLP($node) { function fetchAllStarDb() { $dbFile = __DIR__.'/storage/allstar.txt'; - if (!file_exists($dbFile)) { + if (!file_exists($dbFile) || outdatedFile($dbFile)) { $db = file_get_contents("http://allmondb.allstarlink.org"); file_put_contents($dbFile, $db); return $db; @@ -93,7 +93,7 @@ function fetchAllStarDb() { function fetchIRLPDb() { $dbFile = __DIR__.'/storage/irlp.txt'; - if (!file_exists($dbFile)) { + if (!file_exists($dbFile) || outdatedFile($dbFile)) { $db = file_get_contents("http://status.irlp.net/nohtmlstatus.txt.zip"); file_put_contents("${dbFile}.zip", $db); shell_exec("/usr/bin/unzip -p ${dbFile}.zip > ${dbFile}"); @@ -102,3 +102,7 @@ function fetchIRLPDb() { return file_get_contents($dbFile); } +function outdatedFile($path) +{ + return time() - filemtime($path) > 3600; +} \ No newline at end of file