<?php function db_insert_log($dbconn, $log_category, $log_value, $log_text=false) { global $Config; $sql="INSERT INTO `{$Config->TableMapLog['common']}` (" ."`log_service`, `log_reporter`, `log_reporter_ip`, `log_remote_ip`, `log_category`, `log_value`, `log_text`, `log_time`" .") VALUES (" .$dbconn->escape($Config->SERVICE_NAME,true)."," .$dbconn->escape($Config->SERVER_DOMAIN,true)."," .$dbconn->escape($_SERVER['SERVER_ADDR'],true)."," .$dbconn->escape(REMOTE_ADDR(),true)."," .$dbconn->escape($log_category,true)."," .$dbconn->escape($log_value,true)."," .$dbconn->escape($log_text,true)."," ."UTC_TIMESTAMP())"; $dbconn->real_query($sql,"error.db.insertfail"); return $dbconn->insert_id(); } function db_log_load($dbconn,$log_category,$log_value=false,$timeascending=true,$limit=null,$offset=null) { global $Config; $sql="SELECT * " ."FROM `{$Config->TableMapLog['common']}` " ."WHERE " ."`log_service`=".$dbconn->escape($Config->SERVICE_NAME,true)." AND " ."`log_category`=".$dbconn->escape($log_category,true)." AND " .($log_value!==false?"`log_value`=".$dbconn->escape($log_value,true)." AND ":'') ."1 " ."ORDER BY `log_time` ".($timeascending?'ASC ':'DESC ') ._db_limit($limit,$offset); return $dbconn->query_allrows_assoc($sql); } ?>