diff --git a/dist/goatcounter.php b/dist/goatcounter.php index 739a9a1..5480f45 100644 --- a/dist/goatcounter.php +++ b/dist/goatcounter.php @@ -6,6 +6,12 @@ */ function goatcounter_record_hit(string $path) { + if (isset($_SERVER["HTTP_USER_AGENT"]) + && preg_match("/bot|crawl|slurp|spider|mediapartners/i", $_SERVER["HTTP_USER_AGENT"])) { + return; + } + + $token = file_get_contents(".goat.token"); $ch = curl_init(); @@ -17,7 +23,7 @@ function goatcounter_record_hit(string $path) "hits" => array(array( "path" => $path, "ip" => $_SERVER["REMOTE_ADDR"], - "ref" => $_SERVER["HTTP_REFERER"], + "ref" => $_SERVER["HTTP_REFERER"] ?? "", "user_agent" => $_SERVER["HTTP_USER_AGENT"] )) )) diff --git a/dist/index.php b/dist/index.php index ab8d3df..5ba4a26 100644 --- a/dist/index.php +++ b/dist/index.php @@ -107,7 +107,7 @@ if ($target != null && !$needs_confirmation) { $("#header").appendChild(header({title: "fwdkr.co"})); $("#footer").appendChild(footer({ vcsURL: "https://git.fwdekker.com/FWDekker/fwdkr.co/", - version: "v1.3.1" + version: "v1.3.2" })); });