0

我的网站上有访问者计数脚本。

直到中午(ITC)它运行良好,但现在它无法运行,所有计数文件现在都没有任何文本,甚至没有单个字符。

我的代码:

<?php
if (file_exists('date.txt')) {     
date_default_timezone_set('Asia/Calcutta');
$cdatel = date('Y-m-d', time());

$dthandle = fopen("date.txt", "r"); //reads date
$date =  fread($dthandle,filesize("date.txt"));
fclose ($dthandle);
$tthandle = fopen("total.txt", "r"); //reads total count
$ttcounter =  fread($tthandle,filesize("total.txt"));
fclose ($tthandle);
$ttcounter++; //+1 for new count in total
$ttl = $ttcounter;
$tthandle = fopen("total.txt", "w" ); //write for total count
fwrite($tthandle,$ttcounter);
fclose ($tthandle);
if($cdatel == $date){ //checks whether date in file is same as current date
$handle = fopen("today.txt", "r"); //reads todays count
$counter =  fread($handle,filesize("today.txt"));
fclose ($handle);
$yhandle = fopen("yesterday.txt", "r"); //reads todays count
$yv =  fread($yhandle,filesize("yesterday.txt"));
fclose ($yhandle);
$counter++; //+1 for new count in todays
$tdy = $counter;
$handle = fopen("today.txt", "w" ); //write for todays count
fwrite($handle,$counter);
fclose ($handle); 
}
else{
$ttyhandle = fopen("date.txt", "w" );
fwrite($ttyhandle,$cdatel);
fclose ($ttyhandle);
$ttyhandle = fopen("today.txt", "r");
$tdycounter =  fread($ttyhandle,filesize("today.txt"));
fclose ($ttyhandle);
$zero = "0";
$tzhandle = fopen("today.txt", "w" );
fwrite($tzhandle,$zero);
fclose ($tzhandle); 
$ttyhandle = fopen("yesterday.txt", "w" );
fwrite($ttyhandle,$tdycounter);
fclose ($ttyhandle);
?>
<meta http-equiv="refresh" content="0; ./sitemap-generator.php">
<?php
}
} 
?>
4

0 回答 0