... SnowCounter 1.0 ...
require "config.inc"; require "counter.inc"; $DataFile = "counter.data"; $AnalysisFile = "analysis.data"; if(file_exists($DataFile)) { $fp=fopen($DataFile,'r'); flock($fp,1); $buffer=fread($fp,filesize($DataFile)); flock($fp,3); fclose($fp); $Temp=explode("|",$buffer); $AllCount=intval($Temp[0]); $TodayCount=intval($Temp[1]); $YesterCount=intval($Temp[2]); $Max=intval($Temp[3]); $Min=intval($Temp[4]); $Remote=$Temp[5]; $LastDate=$Temp[6]; $Time=intval($Temp[7]); } else { $Max=0; $Min=0; $AllCount=0; $TodayCount=0; $YesterCount=0; $Time=0; } if(file_exists($AnalysisFile)) { $fp=fopen($AnalysisFile,'r'); flock($fp,1); $buffer=fread($fp,filesize($AnalysisFile)); flock($fp,3); fclose($fp); $Analysis=explode("|",$buffer); } else { $Analysis=array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); } $YourHost = $REMOTE_ADDR; $CurrentTime = time(); $AccessTime = $Time + 600; $CurrentDate = date("nj"); if (($CurrentTime>$AccessTime) || ($Remote !=$YourHost)) { $AllCount++; if ($LastDate!=$CurrentDate) { if ($TodayCount>$Max) { $Max=$TodayCount; } if ($TodayCount<$Min || $Min==0) { $Min=$TodayCount; } $YesterCount=$TodayCount; $TodayCount=1; $LastDate=$CurrentDate; } else $TodayCount++; if(ereg("MSIE",$HTTP_USER_AGENT)) { $Analysis[0]++; } else if (ereg("Mozilla",$HTTP_USER_AGENT)) { $Analysis[1]++; } else { $Analysis[2]++; } $Analysis[intval(date(H))+3]++; $Analysis[27]=$AllCount; } if ((($fp=fopen($DataFile,'w'))==NULL)||(($fp2=fopen($AnalysisFile,'w'))==NULL)) { echo "ÆÄÀÏÀ» »ý¼ºÇÒ ¼ö°¡ ¾ø½À´Ï´ç.."; exit; } $Data="${AllCount}|${TodayCount}|${YesterCount}|${Max}|${Min}|${YourHost}|${LastDate}|${CurrentTime}|\n"; flock($fp,2); fwrite($fp,$Data); flock($fp,3); fclose($fp); for ($i=0;$i<=27;$i++) { $Data2.=$Analysis[$i]; $Data2.="|"; } flock($fp2,2); fwrite($fp2,$Data2); flock($fp2,3); fclose($fp2); $Max=number_format($Max); $Min=number_format($Min); $YesterCount=number_format($YesterCount); $TodayCount=number_format($TodayCount); $AllCount=number_format($AllCount); echo "
ÃÖÀú : $Min
|
ÃÖ°í : $Max
|
¾îÁ¦ : $YesterCount
|
¿À´Ã : $TodayCount
|
ÃÑÇÕ : $AllCount
¢Æ Åë°èº¸±â ¢Æ
"; ?>