-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
stats.php
41 lines (32 loc) · 834 Bytes
/
stats.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
if (!isset($_POST)) {
return;
}
if (!isset($_POST["action"]) || !isset($_POST["type"])) {
http_response_code(400);
return;
}
$action = $_POST["action"];
$type = $_POST["type"];
//$host = $_POST["host"];
$source = $_POST["source"];
$json = json_decode(file_get_contents("./stats.json"), true);
if (!isset($json["total"])) die();
$json["total"]++;
if ("javascript" === $source) {
$json["javascript"]++;
}
if ("iframe" === $source) {
$json["iframe"]++;
}
if (!isset($json["types"][$type]) && isset($type) && !empty($type)) {
$json["types"][$type] = 1;
} else {
$json["types"][$type]++;
}
//if (!isset($json["hosts"][$host]) && isset($host) && !empty($host)) {
// $json["hosts"][$host] = 1;
//} else {
// $json["hosts"][$host]++;
//}
file_put_contents("./stats.json", json_encode($json));