From 9afb6bced6e66683efe2ba570fccecbe754bfde7 Mon Sep 17 00:00:00 2001 From: Jacek Kowalski <Jacek@jacekk.info> Date: Mon, 10 Jun 2019 20:44:20 +0000 Subject: [PATCH] Check if data timestamps are recent before doing any DB changes --- parse.php | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/parse.php b/parse.php index 94a59d9..b3014b8 100644 --- a/parse.php +++ b/parse.php @@ -36,8 +36,18 @@ $logger->info('Loading data...'); $mapper = new Mapper(); + $mapper->loadTTSS($source['ttss_file']); + $timeDifference = time() - $mapper->getTTSSDate(); + if(abs($timeDifference) > 60) { + throw new Exception('TTSS timestamp difference ('.$timeDifference.'s) is too high, aborting!'); + } + $mapper->loadGTFSRT($source['gtfsrt_file']); + $timeDifference = time() - $mapper->getGTFSRTDate(); + if(abs($timeDifference) > 60) { + throw new Exception('GTFSRT timestamp difference ('.$timeDifference.'s) is too high, aborting!'); + } $db = new Database($source['database']); -- Gitblit v1.9.1