<?php

header('Content-Type: application/json; charset=utf-8');

$file="counter.json";

if(!file_exists($file)){

$data=[

"today"=>385,

"total"=>9204187,

"date"=>date("Y-m-d")

];

file_put_contents($file,json_encode($data));

}

$data=json_decode(file_get_contents($file),true);

$today=date("Y-m-d");

if($data["date"]!=$today){

$data["date"]=$today;

$data["today"]=385;

}

$data["today"]++;

$data["total"]++;

file_put_contents(

$file,

json_encode($data)

);

echo json_encode([

"today"=>$data["today"],

"total"=>$data["total"]

]);

?>