function CheckLogFile ($Filename,$Delimiter,$Time,$TimeFTP,$Servo)
{
if(file_exists($Filename) AND file_exists(substr($Filename,0,-4)."Date".substr($Filename,-4)))
{
$Inc = include("Config/config.php");
$DateFilename = substr($Filename,0,-4)."Date".substr($Filename,-4);
$LogDate = fopen($DateFilename,"r");
$CreatedTime = fgets($LogDate);
fclose($LogDate);
if($Inc AND $Config["FTP"] AND $Config["TimeStamp"] - $CreatedTime >= $TimeFTP)
{
$Name = substr(substr($Filename,strrpos($Filename,"/")+1),0,-4);
File_ZIP (substr($Filename,0,-4),$Filename);
$FileZIP = substr($Filename,0,-4).".zip";
$FTPcon = ftp_connect($Config["FTPHost"],$Config["FTPPort"]) or die(Alert(4));
ftp_login($FTPcon,$Config["FTPUser"],$Config["FTPPassword"]) or die(Alert(5));
ftp_chdir($FTPcon,$Config["FTPFolder"]);
$NewFile = "$Config[Nameabbr]-$Name-".date("m.Y",$Config["TimeStamp"]).".zip";
$Upload = ftp_put($FTPcon,$NewFile,$FileZIP,FTP_BINARY);
ftp_chmod($FTPcon,0400,$NewFile);
ftp_quit($FTPcon) or die(Alert(6));
if($Upload)
{
unlink($FileZIP);
unlink($Filename);
unlink($DateFilename);
}
unset ($FileZIP); unset ($FTPcon); unset ($NewFile); unset ($Upload);
return true;
} elseif ($Inc AND !$Config["FTP"] AND $Config["TimeStamp"] - $CreatedTime >= $Time) {
$Finish = "";
$Stop = 0;
$Content = file_get_contents($Filename);
$FilePart = explode("\n",$Content);
$CountParts = count($FilePart);
for($i=0; $i < $CountParts; $i++)
{
$Part = explode("-",$FilePart[$i]);
if(false)
{
$FilePart[$i] = 0;
}
if($Config["TimeStamp"] - $Part[$Servo] > $Time AND $Stop == 0)
{
if($i < $CountParts-2)
{ $FilePart[$i] .= "\n"; }
$Finish .= $FilePart[$i];
} else { $Stop = 1; $i = $CountParts+1; }
}
file_put_contents($Filename,$Finish);
chmod($Filename, 0600);
unset($Stop);
unset($Content);
unset($FilePart);
unset($CountParts);
return true;
}
unset($CreatedTime);
} else { return false; }
}