Browse Source

Add cron script to prune thumbnail cache (close #2)

master
Skylar Ittner 3 years ago
parent
commit
5a9510bf7a
  1. 21
      cron.php

21
cron.php

@ -0,0 +1,21 @@
<?php
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// Remove old thumbnails
echo "Pruning thumbnail cache...\n";
$path = __DIR__ . '/cache/thumb/';
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if ((time() - filectime($path . $file)) > 60 * 60 * 24) {
if (preg_match('/\.jpg$/i', $file)) {
echo "Deleting $file\n";
unlink($path . $file);
}
}
}
}
Loading…
Cancel
Save