/** * Log Message * * Writes a new log entry * * @param string $type Type of log entry (notice, warning, error, critical, or security) * @param string $module Where (in the code) this message is coming from * @param string $message Log message */ function log_message($type, $module, $message) { // Construct a LogDBO $logdbo = new LogDBO(); $logdbo->setType($type); $logdbo->setModule($module); $logdbo->setText($message); $logdbo->setUsername(!empty($_SESSION['client']['userdbo']) ? $_SESSION['client']['userdbo']->getUsername() : null); $logdbo->setRemoteIP(ip2long($_SERVER['REMOTE_ADDR'])); $logdbo->setDate(DBConnection::format_datetime(time())); // Write the log message add_LogDBO($logdbo); }
/** * Load multiple Log DBO's from database * * @param string $filter A WHERE clause * @param string $sortby Field name to sort results by * @param string $sortdir Direction to sort in (ASEC or DESC) * @param integer $limit Limit the number of results * @param integer $start Record number to start the results at * @return array Array of LogDBO's */ function &load_array_LogDBO($filter = null, $sortby = null, $sortdir = null, $limit = null, $start = null) { $DB = DBConnection::getDBConnection(); // Build query $sql = $DB->build_select_sql("log", "*", $filter, $sortby, $sortdir, $limit, $start); // Run query if (!($result = @mysql_query($sql, $DB->handle()))) { // Query error throw new DBException(mysql_error($DB->handle())); } if (mysql_num_rows($result) == 0) { // No rows found throw new DBNoRowsFoundException(); } // Build an array of DBOs from the result set $dbo_array = array(); while ($data = mysql_fetch_array($result)) { // Create and initialize a new DBO with the data from the DB $dbo = new LogDBO(); $dbo->load($data); // Add DomainServiceDBO to array $dbo_array[] = $dbo; } return $dbo_array; }