isLoggedIn()) $message = "[" . $member->getDisplayName() . "] " . $message; $message = sql_real_escape_string($message); // add slashes $timestamp = date("Y-m-d H:i:s",time()); // format timestamp $query = "INSERT INTO " . sql_table('actionlog') . " (timestamp, message) VALUES ('$timestamp', '$message')"; sql_query($query); ACTIONLOG::trimLog(); } /** * (Static) Method to clear the whole action log */ function clear() { global $manager; $query = 'DELETE FROM ' . sql_table('actionlog'); $manager->notify('ActionLogCleared',array()); return sql_query($query); } /** * (Static) Method to trim the action log (from over 500 back to 250 entries) */ function trimLog() { static $checked = 0; // only check once per run if ($checked) return; // trim $checked = 1; $iTotal = quickQuery('SELECT COUNT(*) AS result FROM ' . sql_table('actionlog')); // if size > 500, drop back to about 250 $iMaxSize = 500; $iDropSize = 250; if ($iTotal > $iMaxSize) { $tsChop = quickQuery('SELECT timestamp as result FROM ' . sql_table('actionlog') . ' ORDER BY timestamp DESC LIMIT '.$iDropSize.',1'); sql_query('DELETE FROM ' . sql_table('actionlog') . ' WHERE timestamp < \'' . $tsChop . '\''); } } } ?>