From fc85c087509c29f19ada4ca0ad4a25f4ee17b617 Mon Sep 17 00:00:00 2001 From: John Hodge <tpg@ucc.asn.au> Date: Sun, 8 Nov 2020 17:02:23 +0800 Subject: [PATCH] Support zip compressed month/days --- archive.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/archive.php b/archive.php index bbdd5e1..e646d09 100644 --- a/archive.php +++ b/archive.php @@ -53,6 +53,36 @@ passthru($cmd); exit(); } + + $zipfile_day = $month_folder . $timestamp->format("Ymd").".zip"; + if( is_readable($zipfile_day) ) { + $zip = new ZipArchive; + $zip->open($zipfile_day); + $iname = $timestamp->format("d/H/i").".jpg"; + $c = $zip->getFromName($iname); + if($c !== false) { + header("Content-Type: image/jpeg"); + header("Content-Length: ".strlen($c)); + header("Last-Modified: ".gmdate("D, d M Y H:i:s", filectime($zipfile_day))." GMT"); + echo $c; + exit(); + } + } + + $zipfile_month = "archive/" . $camera . "/" . $timestamp->format("Ym").".zip"; + if( is_readable($zipfile_month) ) { + $zip = new ZipArchive; + $zip->open($zipfile_month); + $c = $zip->getFromName($timestamp->format("Ym/d/H/i").".jpg"); + if($c !== false) { + header("Content-Type: image/jpeg"); + header("Content-Length: ".strlen($c)); + header("Last-Modified: ".gmdate("D, d M Y H:i:s", filectime($zipfile_month))." GMT"); + echo $c; + exit(); + } + } + $file = $month_folder . $timestamp->format("d/H/") . $timestamp->format("i").".jpg"; //header("X-WebcamFile: {$file}"); } -- GitLab