. * */ /** * 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){ global $CONFIG_DBTABLEPREFIX; $result = OC_DB::query('INSERT INTO `' . $CONFIG_DBTABLEPREFIX . 'log` (`timestamp`,`user`,`type`,`message`) VALUES ('.time().',\''.addslashes($user).'\','.addslashes($type).',\''.addslashes($message).'\');'); } /** * show the log entries in a web GUI * */ public static function show(){ global $CONFIG_DATEFORMAT; global $CONFIG_DBTABLEPREFIX; echo('
'); if(OC_USER::ingroup($_SESSION['username_clean'],'admin')){ $result = OC_DB::select('select `timestamp`,`user`,`type`,`message` from '.$CONFIG_DBTABLEPREFIX.'log order by timestamp desc limit 20'); }else{ $user=$_SESSION['username_clean']; $result = OC_DB::select('select `timestamp`,`user`,`type`,`message` from '.$CONFIG_DBTABLEPREFIX.'log where user=\''.$user.'\' order by timestamp desc limit 20'); } foreach($result as $entry){ echo(''); echo(''); echo(''); echo(''); echo(''); echo(''); } echo('
'.date($CONFIG_DATEFORMAT,$entry['timestamp']).''.OC_LOG::$TYPE[$entry['type']].''.$entry['user'].''.$entry['message'].'
'); } } ?>