function log_hit($vhost, $remote_host, $remote_ip, $logged_user, $http_request, $rq_err, $sent_content_length, $http_referer, $http_user_agent) { global $conf; $logline = $remote_host . " - " . ($logged_user && $logged_user != " " ? $logged_user : "******") . " [" . date("d/M/Y:H:i:s O") . "] \"" . mod_stdlog::log_strfilter($http_request) . "\" " . $rq_err . " " . (int) $sent_content_length; switch (strtolower($conf[$vhost]["logtype"][0])) { case "common": case "clf": $logline .= "\n"; break; case "common-with-vhost": case "clf-vhost": $logline = $vhost . " " . $logline . "\n"; break; case "combined": default: $logline .= " \"" . ($http_referer ? mod_stdlog::log_strfilter($http_referer) : "-") . "\" \"" . ($http_user_agent ? mod_stdlog::log_strfilter($http_user_agent) : "-") . "\"\n"; break; } $srv_logline = "[" . $vhost . "] " . $logline; if ($conf["global"]["loghitstoconsole"][0] && !$GLOBALS["quiet"]) { echo $srv_logline; } log_srv($srv_logline, NW_EL_HIT); $fdir = $conf[$vhost]["logdir"][0]; if ($fn_ar = $conf[$vhost]["log"]) { foreach ($fn_ar as $fname) { if ($GLOBALS["os"] == "unix" ? $fname[0] == "/" : $fname[0] == "\\" || $fname[1] == ":") { $lfn = $fname; } else { $lfn = $fdir . DIRECTORY_SEPARATOR . $fname; } if ($lf = @fopen($lfn, NW_BSAFE_APP_OPEN)) { fputs($lf, $logline); fclose($lf); } else { techo("WARN: unable to write to log file '" . $lfn . "'", NW_EL_WARNING); } } } }
function techo($s, $level = NW_EL_NOTICE, $flush = false) { global $conf; static $srv_buf; $tl = date("Ymd:His") . " {$s}\n"; if (!$conf["_complete"] && !$flush) { $srv_buf[] = array($tl, $level); } else { if ($conf["global"]["servermode"][0] != "inetd" && !$GLOBALS["quiet"]) { if ($srv_buf) { foreach ($srv_buf as $sb_arr) { echo $sb_arr[0]; } } echo $tl; flush(); } if ($srv_buf) { foreach ($srv_buf as $sb_arr) { log_srv($sb_arr[0], $sb_arr[1]); } $srv_buf = array(); } log_srv($tl, $level); } }