visitor counters

nuel.pw

15941 — Last updated: May 04 2024 13:33:13 UTC

globoform.com

4957 — Last updated: May 04 2024 12:03:27 UTC

no trackers, just turnstiles

My visitor counters only increment a number in a text file and flip a bit in your session variables to lightly debounce script execution. Small data says enough. Big Data Does Not Speak
Show code
  1. <?php
  2. // Only allow the script to be run from nuel.pw
  3. header('Access-Control-Allow-Origin: https://nuel.pw');
  4. // Get the current value
  5. $fn = 'count.txt';
  6. $current = intval(file_get_contents($fn));
  7. // Only increment once per browsing session
  8. session_start();
  9. if ($_SESSION['count-nuel'] !== 1) {
  10. $_SESSION['count-nuel'] = 1;
  11. $current++;
  12. // Overwrite the text file with the new value
  13. $fp = fopen($fn, 'w');
  14. fwrite($fp, $current);
  15. fclose($fp);
  16. }
  17. // Return the updated value
  18. echo $current;