From d79162a8892c5fcc872a582fd577af8e7850f76b Mon Sep 17 00:00:00 2001 From: atomaka Date: Sat, 5 Nov 2011 16:10:30 -0400 Subject: [PATCH] Clean out the viewers table every 5 minutes. --- application/controllers/view.php | 9 ++++++++- application/models/viewer.php | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/application/controllers/view.php b/application/controllers/view.php index 2823db3..ce9e886 100644 --- a/application/controllers/view.php +++ b/application/controllers/view.php @@ -1,10 +1,17 @@ load->model('viewer'); + $this->viewer->clean_viewers(5 * 60); + } + public function index() { } - + public function specific() { $this->load->model('fileupload'); diff --git a/application/models/viewer.php b/application/models/viewer.php index aa58400..c1c1c18 100644 --- a/application/models/viewer.php +++ b/application/models/viewer.php @@ -23,6 +23,12 @@ class Viewer extends CI_Model { return false; } } + + function clean_viewers($duration) { + $clean_time = time() - $duration; + + $this->db->query("DELETE FROM viewers WHERE timestamp < $clean_time"); + } } ?> \ No newline at end of file