쿼

소스좀 봐주세요...24시간이 지나면 0부터 다시시작하게...하고싶은데..

<?
function hitcount()
{
//$file_count = "count.txt";
$file_date = "./counter/count_date";
$dcount = 0;
if ( !file_exists($file_date)){
touch ($file_date);
$handle = fopen ($file_date, 'r+'); // Let's open for read and write
$dcount = 0;
}
else{
$handle = fopen ($file_date, 'rw'); // Let's open for read and write
$contents = fread($handle, filesize($file_date));
//settype ($count,"integer");
$contents = trim($contents,'|');
$content = split("\|",$contents);
$dcount = $content[0];
$omtime = $content[1];
$nmtime = date("m-d-Y", filemtime($file_date));
//echo "$count<br>$omtime<br>$nmtime";
if ($omtime != $nmtime)
$dcount = 0;
@fclose($handle);
}
//rewind ($handle); // Go back to the beginning
$contents = ++$dcount . "|" . $nmtime;// . "|";
//$contents = trim($contents,"[ |]");
$handle = fopen($file_date, 'w'); // Let's open for read and write
fwrite ($handle, $contents); // Don't forget to increment the counter
fclose ($handle); // Done

// return $count;
$file = fopen("./counter/count.txt", "r");
$count = fread($file, 1024);
fclose($file);
//Increasing the count
$count = explode("=", $count);
//$count[1] = $count[1]+1;
$count[1] = $dcount;
//Writing to file
$file = fopen("./counter/count.txt", "w+");
fwrite($file, "count=".$count[1]);
fclose($file);
//print "count=".$count[1];

}
hitcount();
?>

---------------------------------------------------------------------------------------

계속 저녁12시되면 카운트가 0으로 되서 시작하는게 아니라, 아무시간때나 자꾸 0으로 바껴서 다시 시작해 버립니다. 저녁 12시에 딱 0으로 시작하게끔 하고 싶은데... 소스에 문제가 있는거 아닌가요?어떻게 하면되나요..?;;

댓글 3개

실험해보진 않았지만

$nmtime = date("m-d-Y", filemtime($file_date)); 를

$nmtime = date("m-d-Y"); 이렇게 해야 하는것 같은데요.
청원님 댓글 감사하구요, 되면 바로 채택하도록 할게요.
댓글을 작성하시려면 로그인이 필요합니다.

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기 기존 게시물은 열람만 가능합니다.

+
제목 글쓴이 날짜 조회
10-06-24 조회 2,265
10-06-24 조회 4,651
10-06-24 조회 4,250
10-06-24 조회 1,604
10-06-24 조회 1,644
10-06-24 조회 1,378
10-06-24 조회 1,621
10-06-24 조회 1,647
10-06-24 조회 1,598
10-06-24 조회 1,675
10-06-24 조회 1,662
10-06-24 조회 1,625
10-06-23 조회 1,641
10-06-23 조회 1,726
10-06-23 조회 1,611
10-06-23 조회 1,633
10-06-23 조회 1,611
10-06-23 조회 2,095
10-06-23 조회 1,162
10-06-23 조회 1,615