1# Core module 2# Copyright (C) 2009, AllWorldIT 3# Copyright (C) 2008, LinuxRulz 4# 5# This program is free software; you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation; either version 2 of the License, or 8# (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License along 16# with this program; if not, write to the Free Software Foundation, Inc., 17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 19 20package cbp::modules::Core; 21 22use strict; 23use warnings; 24 25 26use cbp::logging; 27use cbp::dblayer; 28use cbp::system; 29 30 31# User plugin info 32our $pluginInfo = { 33 name => "Core", 34 priority => 100, 35 cleanup => \&cleanup, 36}; 37 38 39# Cleanup function 40sub cleanup 41{ 42 my ($server) = @_; 43 44 # Get yesterday's time 45 my $yesterday = time() - 86400; 46 47 # Remove old tracking info from database 48 my $sth = DBDo(" 49 DELETE FROM 50 session_tracking 51 WHERE 52 Timestamp < ".DBQuote($yesterday)." 53 "); 54 if (!$sth) { 55 $server->log(LOG_ERR,"[CORE] Failed to remove old session tracking records: ".cbp::dblayer::Error()); 56 return -1; 57 } 58 $server->log(LOG_INFO,"[CORE] Removed ".( $sth ne "0E0" ? $sth : 0)." records from session tracking table"); 59} 60 61 621; 63# vim: ts=4 64