initial commit of new webpage
[silc.git] / public_html / html / counter.php
diff --git a/public_html/html/counter.php b/public_html/html/counter.php
new file mode 100644 (file)
index 0000000..e85d400
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+
+function Hits() {
+
+// $datafile has to be writable by http server user uid
+// else hits count will not be increased, only printed out
+
+  $datafile = "COUNTER";
+
+  if (Is_Writable($datafile)) {
+    $fp = FOpen($datafile, "r+");
+    $writable = "true";
+  }
+  else
+    if (Is_Readable($datafile)) $fp = FOpen($datafile,"r");
+    else return;
+  
+  $hits = FGets($fp,255) + 1;
+  if(!$hits) $hits = 1;
+
+  if($writable) {
+    Rewind($fp);
+    FPuts($fp, $hits);
+  }
+
+  FClose($fp);
+  echo $hits." hits";
+}
+
+Hits();
+
+?>