<?php
$key='yxfLsxWlfTcqyZwQ';
$f=__DIR__."/.visits.json";
$d=is_file($f)?json_decode(file_get_contents($f),true):array();
if(!is_array($d))$d=array();
if(isset($_GET["stats"])){
  if(hash_equals($key,(string)$_GET["stats"])){
    header("Content-Type: application/json");
    echo json_encode($d);
  } else { http_response_code(403); echo "{}"; }
  exit;
}
$d["total"]=(isset($d["total"])?$d["total"]:0)+1;
$day=date("Y-m-d");
if(!isset($d["days"]))$d["days"]=array();
$d["days"][$day]=(isset($d["days"][$day])?$d["days"][$day]:0)+1;
@file_put_contents($f,json_encode($d),LOCK_EX);
header("Content-Type: image/gif");
header("Cache-Control: no-store, no-cache, must-revalidate");
echo base64_decode("R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7");
