App Logs, functions/app_log.php). * Unlike logAudit(), it takes plain text and escapes it here. $type is the * level - info, warning, error or debug; anything else is put to the nearest, * as the column takes only those. */ function logApp($category, $type, $details) { global $mysqli; $type = strtolower(trim((string) $type)); if (!in_array($type, ['info', 'warning', 'error', 'debug'], true)) { $type = in_array($type, ['critical', 'fatal', 'alert', 'emergency'], true) ? 'error' : ($type === 'warn' ? 'warning' : 'info'); } // Cut by character, so a name or message with accents isn't cut through the middle of one $category = mb_substr((string) $category, 0, 200); $details = mb_substr((string) $details, 0, 1000); $category_sql = mysqli_real_escape_string($mysqli, $category); $details_sql = mysqli_real_escape_string($mysqli, $details); mysqli_query($mysqli, "INSERT INTO app_logs SET app_log_category = '$category_sql', app_log_type = '$type', app_log_details = '$details_sql'"); // On to a syslog server or SIEM, from the level picked (functions/log_forward.php) logForwardQueue('app', mysqli_insert_id($mysqli), $type, $category); }