<?php
/*<OutSCIRT>
Date: 20181007
</OutSCIRT>*/

function O__logger($O__logFilename,$O__page,$O__status,$O__user,$O__notes){
	global $O__DBpath,$O__logPath,$O__logFileMax;
	$O_logFile = $O__logPath . $O__logFilename;
	
	if(isset($_SERVER["REMOTE_ADDR"])){
		$O__IPaddress = $_SERVER["REMOTE_ADDR"];
	} else {
		$O__IPaddress = "127.0.0.1 (most likely)";
	}
	
	$O_logLine = "\n" . "Date: " . date("Y-m-d") . "\tTime: " . date("h:i:s") . "\tPage: " . $O__page . "\tStatus: " . $O__status . "\tUser: " . $O__user . "\tIP: " . $O__IPaddress . "\tNotes: " . $O__notes;
	
	if((filesize($O_logFile)/1024) >= $O__logFileMax){
		rename($O_logFile, $O_logFile . "_" . date("Y-m-d") . "_" . date("h-i-s"));
		O__dataWrite($O_logFile,$O_logLine); // Create new log file
	} else { // Write to existing file
		$O_logOpen = fopen($O_logFile, "a") or die("Unable to open log file.");
		fwrite($O_logOpen, $O_logLine);
		fclose($O_logOpen);
	}
}
?>
