From 5feb044149fb981a61d7a1b2d4ffe47207f0739f Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Sat, 19 May 2018 00:51:58 -0600 Subject: [PATCH] Honor Do-Not-Track header --- lib/gatheranalytics.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/gatheranalytics.php b/lib/gatheranalytics.php index 92e4821..279eb66 100644 --- a/lib/gatheranalytics.php +++ b/lib/gatheranalytics.php @@ -14,8 +14,13 @@ use GeoIp2\Database\Reader; require_once __DIR__ . "/requiredpublic.php"; if (!$database->has("settings", ["AND" => ["siteid" => getsiteid(), "key" => "analytics", "value" => "off"]]) && !isset($_GET['edit'])) { + try { + if (isset($_SERVER['HTTP_DNT']) && $_SERVER['HTTP_DNT'] === "1") { + throw new Exception("Do-Not-Track header detected, skipping analytics"); + } + $time = date("Y-m-d H:i:s"); /** @@ -101,5 +106,8 @@ if (!$database->has("settings", ["AND" => ["siteid" => getsiteid(), "key" => "an } } catch (Exception $e) { // Silently fail so the rest of the site still works + if (DEBUG) { + echo ""; + } } } \ No newline at end of file