From 1a474b85b18488a26f3306be437b443da9fd424a Mon Sep 17 00:00:00 2001 From: Gloria Law <32382348+glorialaw@users.noreply.github.com> Date: Mon, 15 Oct 2018 16:41:07 -0700 Subject: [PATCH] Update counter.php --- umpleonline/counter.php | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/umpleonline/counter.php b/umpleonline/counter.php index c71c48611f..d6a1287bc0 100644 --- a/umpleonline/counter.php +++ b/umpleonline/counter.php @@ -9,25 +9,22 @@ //opens countlog.txt to read the number of hits $dir = dirname(__FILE__); $logpath = $dir."/countlog.txt"; -if(!file_exists($logpath)){ +if(file_exists($logpath)){ + if(!is_writable($logpath)||!is_readable($logpath)) { + chmod($logpath, 0755); + } + $log = fopen($logpath, "r"); + $count = fgets($log,1000); + fclose($log); + $count=$count + 1 ; + echo "$count" ; + echo " visits since October 2018" ; + + // opens countlog.txt to change new hit number $log = fopen($logpath,"w"); - fwrite($log, 0); + fwrite($log, $count); fclose($log); } -if(!is_writable($logpath)||!is_readable($logpath)) { - chmod($logpath, 0755); -} -$log = fopen($logpath, "r"); -$count = fgets($log,1000); -fclose($log); -$count=$count + 1 ; -echo "$count" ; -echo " visits since October 2018" ; - -// opens countlog.txt to change new hit number -$log = fopen($logpath,"w"); -fwrite($log, $count); -fclose($log); ?>