diff options
Diffstat (limited to 'modules/digibug/controllers/digibug.php')
-rw-r--r-- | modules/digibug/controllers/digibug.php | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php index 72b57242..25a9912a 100644 --- a/modules/digibug/controllers/digibug.php +++ b/modules/digibug/controllers/digibug.php @@ -76,6 +76,8 @@ class Digibug_Controller extends Controller { // We don't need to save the session for this request Session::abort_save(); + $this->_clean_expired(); + // Dump out the image header("Content-Type: $proxy->item->mime_type"); Kohana::close_buffers(false); @@ -92,4 +94,19 @@ class Digibug_Controller extends Controller { public function close_window() { print "<script type=\"text/javascript\">window.close();</script>"; } + + private function _clean_expired() { + $expired = ORM::factory("digibug_proxy") + ->where("request_date <= (CURDATE() - INTERVAL 10 DAY)") + ->find_all(); + + // Delete as many as we can in a second, so as to not slow up the request. + $start = microtime(true); + foreach ($expired as $proxy) { + if (microtime(true) - $start > 1.0) { + break; + } + $proxy->delete(); + } + } }
\ No newline at end of file |