initializing git repo
This commit is contained in:
commit
3df8fc53b8
86 changed files with 5649 additions and 0 deletions
60
includes/log.php
Executable file
60
includes/log.php
Executable file
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
$LogLineArray = array();
|
||||
$LogFirstLineWritten = 0;
|
||||
|
||||
function ErrorLog ($Msg)
|
||||
{
|
||||
global $LogLineArray;
|
||||
global $LogFirstLineWritten;
|
||||
$LogFirstLineWritten = 1;
|
||||
$LogLineArray[count($LogLineArray)]=LogFormatMessage($Msg);
|
||||
$Dbg=debug_backtrace();
|
||||
for ($i=0; $i<count($Dbg);$i++) $LogLineArray[count($LogLineArray)]= " - (Callstack $i) ".$Dbg[$i]['file'].":".$Dbg[$i]['line']."\n";
|
||||
}
|
||||
|
||||
function LogWriteToFile ()
|
||||
{
|
||||
global $LogLineArray;
|
||||
global $GlobalLogfile;
|
||||
global $LogFirstLineWritten;
|
||||
global $GlobalLogfileMaxLength;
|
||||
|
||||
if ($GlobalLogfile && $LogFirstLineWritten)
|
||||
{
|
||||
//read existing file
|
||||
$ExistingFileArray=array();
|
||||
if (file_exists($GlobalLogfile))
|
||||
$ExistingFileArray=file($GlobalLogfile);
|
||||
|
||||
//merge both line arrays
|
||||
$ExistingFileArray[count($ExistingFileArray)]="\n";
|
||||
foreach ($LogLineArray as $x)
|
||||
$ExistingFileArray[count($ExistingFileArray)]=$x;
|
||||
|
||||
//save to file
|
||||
$FileHandler=fopen($GlobalLogfile,'w');
|
||||
$Length=count($ExistingFileArray);
|
||||
for ($i= (($Length>$GlobalLogfileMaxLength) ? $Length-$GlobalLogfileMaxLength:0); $i<$Length;$i++)
|
||||
fputs($FileHandler,$ExistingFileArray[$i]);
|
||||
fclose($FileHandler);
|
||||
}
|
||||
}
|
||||
|
||||
function LogClose ()
|
||||
{
|
||||
LogWriteToFile();
|
||||
}
|
||||
|
||||
function LogFormatMessage ($Msg)
|
||||
{
|
||||
global $GlobalTimeZone;
|
||||
global $GlobalTimeFormat;
|
||||
date_default_timezone_set($GlobalTimeZone);
|
||||
$NewMsg = "";
|
||||
$NewMsg .= "[".date($GlobalTimeFormat,time())."]";
|
||||
$NewMsg .= $Msg . "\n";
|
||||
return $NewMsg;
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue