. * */ /** * Class for logging features * */ class OC_LOG { /** * array to define different log types * */ public static $TYPE = array ( 1=>'login', 2=>'logout', 3=>'read', 4=>'write', ); /** * log an event * * @param username $user * @param type $type * @param message $message */ public static function event($user,$type,$message){ $result = OC_DB::query('insert into log (timestamp,user,type,message) values ("'.time().'","'.addslashes($user).'","'.addslashes($type).'","'.addslashes($message).'")'); OC_DB::free_result($result); } /** * show the log entries in a web GUI * */ public static function show(){ global $CONFIG_DATEFORMAT; echo('
'); $result = OC_DB::query('select timestamp,user,type,message from log order by timestamp desc limit 20'); $count=OC_DB::numrows($result); for ($i=0; $i < $count;$i++) { $entry=OC_DB::fetch_assoc($result); echo(''); echo(''); echo(''); echo(''); echo(''); echo(''); } echo('
'.date($CONFIG_DATEFORMAT,$entry['timestamp']).''.OC_LOG::$TYPE[$entry['type']].''.$entry['user'].''.$entry['message'].'
'); OC_DB::free_result($result); } } ?>