visitor counters

nuel.pw

21654 — Last updated: December 05 2024 06:34:52 UTC

globoform.com

5992 — Last updated: December 05 2024 06:39:38 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;