diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-06-25 19:58:14 -0700 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-06-25 19:58:14 -0700 |
commit | 5d4d87e957068b54e2b12abcea5c74bb4f3c012c (patch) | |
tree | a8592aa404505e97ad66e21073066e2f22de3336 /modules/digibug/controllers | |
parent | 93e4f14c855d3fe4c4e9cc5c7d6a58fb2e25fe99 (diff) |
Remove the digibug maintenance task. Expired imges will be removed when the
print_proxy is run.
Diffstat (limited to 'modules/digibug/controllers')
-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 |