aboutsummaryrefslogtreecommitdiff
path: root/counter.php
diff options
context:
space:
mode:
authorTyler Hoang <tyler@tylerhoang.xyz>2026-05-26 00:33:22 -0700
committerTyler Hoang <tyler@tylerhoang.xyz>2026-05-26 00:33:22 -0700
commitb2827329a32d3fe627a62bd4ff4191b2a3e4407f (patch)
tree2d5ef329e579340d1e6b64b179a8d723c1da9b54 /counter.php
parent1c9ad19a5ff2e3c1463ba34ee5d707b93ebf8960 (diff)
redesign: frutiger aero faux-OS desktop
replaces the old enter/index pages with a draggable-windows desktop metaphor. wires last.fm now-playing, films.tylerhoang.xyz diary, and a php visitor counter; keeps background music via /mus/mmt.mp3. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Diffstat (limited to 'counter.php')
-rw-r--r--counter.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/counter.php b/counter.php
new file mode 100644
index 0000000..b8117e4
--- /dev/null
+++ b/counter.php
@@ -0,0 +1,27 @@
+<?php
+header('Content-Type: application/json');
+header('Cache-Control: no-store');
+
+$file = __DIR__ . '/counter.dat';
+
+// 24h cookie to dedupe reloads
+$cookieName = 'fun_seen';
+$shouldIncrement = !isset($_COOKIE[$cookieName]);
+
+if (!file_exists($file)) file_put_contents($file, '0');
+
+$fp = fopen($file, 'r+');
+if (!$fp) { echo json_encode(['count' => 0]); exit; }
+flock($fp, LOCK_EX);
+$count = (int) trim(stream_get_contents($fp));
+if ($shouldIncrement) {
+ $count++;
+ ftruncate($fp, 0);
+ rewind($fp);
+ fwrite($fp, (string) $count);
+ setcookie($cookieName, '1', time() + 86400, '/', '', true, true);
+}
+flock($fp, LOCK_UN);
+fclose($fp);
+
+echo json_encode(['count' => $count]);