$CounterFile="contents.dat"; $UniqueFileID="$SERVER_NAME--$DOCUMENT_URI"; $UniqueHash=bin2hex(md5($UniqueFileID)); $FilePointer=fopen($CounterFile,"r+"); flock($FilePointer,LOCK_EX); while ($FileCount = fscanf ($FilePointer, "%s\t%s\n")) { list($HashID,$Count)=$FileCount; $CountHash[$HashID]=$Count; } $CountHash[$UniqueHash]=$CountHash[$UniqueHash]+1; rewind($FilePointer); $CountKeys=array_keys($CountHash); foreach($CountKeys as $TheKey) { fwrite($FilePointer,"$TheKey {$CountHash[$TheKey]}\n"); } flock($FilePointer,LOCK_UN); fclose($FilePointer); print("
");
print("
"); print("
Number of times visited:
"); print("");
$hits = $CountHash[$UniqueHash];
$i=0;
while($i