Ну попробуй так
CODE:
<?
$file="count.txt";
$cy = date("Y");//текущий год
$cm = date("n");//месяц
$cd = date("j");//день
if ( $newfile = fopen($file,'r') )
{
if (flock($newfile,LOCK_SH)){
list($num,$fy,$fm,$fd) = fscanf($newfile, "%d:%d/%d/%d"); }
@fclose($newfile);
}
if (isset($num) && isset($fy) && isset($fm) && isset($fd))
{
if ($fy!=$cy || $fm!=$cm || $fd!=$cd)
$num = 1;
else
$num++;
}else{
$num = 1; }
if ( $newfile = fopen($file,"w"))
{
if (flock($newfile,LOCK_EX)) {
fwrite($newfile, "$num:$cy/$cm/$cd"); }
@fclose($newfile);
}
echo "document.write('$num');";
?>
|