diff --git a/scripts/generate-monthly-downloads b/scripts/generate-monthly-downloads index 36abec49..12c93e28 100755 --- a/scripts/generate-monthly-downloads +++ b/scripts/generate-monthly-downloads @@ -11,10 +11,6 @@ $contentFiles = explode("\n", trim(shell_exec('find ' . escapeshellarg($webRoot $ebooksByMonth = []; $lastUpdatedTimestamps = []; -if(!is_dir(WEB_ROOT . '/patrons-circle/downloads')){ - mkdir(WEB_ROOT . '/patrons-circle/downloads'); -} - // Iterate over all ebooks and arrange them by publication month foreach($contentFiles as $path){ if($path == '') @@ -50,7 +46,7 @@ foreach($ebooksByMonth as $month => $ebooks){ $filename = 'se-ebooks-' . $month . '.zip'; $filePath = $webRoot . '/www/patrons-circle/downloads/' . $filename; - // If the file doesn't exist, or if the content.opf last updated time is newer than the file creation time + // If the file doesn't exist, or if the content.opf last updated time is newer than the file modification time if(!file_exists($filePath) || filemtime($filePath) < $lastUpdatedTimestamps[$month]){ print('Creating ' . $filePath . "\n"); diff --git a/www/patrons-circle/downloads/index.php b/www/patrons-circle/downloads/index.php index 1fbb8433..42a09abc 100644 --- a/www/patrons-circle/downloads/index.php +++ b/www/patrons-circle/downloads/index.php @@ -1,9 +1,18 @@ require_once('Core.php'); +use Safe\DateTime; +use function Safe\filemtime; +use function Safe\filesize; +use function Safe\glob; +use function Safe\gmdate; +use function Safe\rsort; + $ex = null; if(isset($_SERVER['PHP_AUTH_USER'])){ + // We get here if the user entered an invalid HTTP Basic Auth username, + // and this page was served as the 401 page. $ex = new Exceptions\InvalidPatronException(); } @@ -61,7 +70,7 @@ foreach($files as $file){
= Formatter::ToPlainText($year) ?>
+= Formatter::ToPlainText((string)$year) ?>
@@ -75,7 +84,7 @@ foreach($files as $file){ | = Formatter::ToPlainText($item->Month) ?> | = Formatter::ToPlainText(number_format($item->Count)) ?> | = Formatter::ToPlainText($item->Size) ?> | -= Formatter::ToPlainText($obj->Updated) ?> | += Formatter::ToPlainText($item->Updated) ?> | } ?>