So I have a text file with a number inside. This text file is saved on the server. When ever someone downloads a file of mine, I have the number increase one. I know earlier today, the total count was 87. But I just checked minutes ago and it showed up at 11.
Anyone know what can be the cause of this and how I can avoid the number being inaccurate? Here is the php code I used so that the number in the text file increases.
<html>
<head>
<title>Downloading False Logics</title>
</head>
<body onload="SendFile()">
<script language="JavaScript">
window.name = 'main';
function SendFile() {
window.location.href = "Downloadable/False%20Logics.exe";
}
</script>
<?
define("HITCOUNT", "fldownloadcount.txt");
/*design by Mark Le Roy @ http://www.helpvid.net*/
function addOne() {
$fh = fopen(HITCOUNT, "r");
$count = fread($fh, filesize(HITCOUNT));
fclose($fh);
$count = $count +1;
$fh = fopen(HITCOUNT, "w");
fwrite($fh, $count);
fclose($fh);
}
/* count Variables */
function getcount() {
$fh = fopen(HITCOUNT, "r");
$count = fread($fh, filesize(HITCOUNT));
fclose($fh);
/* display Variables */
return $count;
}
addOne();
echo "This has been downloaded ";
echo getCount();
echo " times now since 1/16/2016."
?>
</body>