aboutsummaryrefslogtreecommitdiff
path: root/includes/telemetry.php
diff options
context:
space:
mode:
authorMinteck <nekostarfan@gmail.com>2021-08-08 12:04:30 +0200
committerMinteck <nekostarfan@gmail.com>2021-08-08 12:04:30 +0200
commit95112b1eb06a4be531ded59563d53a63a8d614e8 (patch)
treefd3dc676227309c87a39feab9ca458985e327907 /includes/telemetry.php
parent87303b0d3540037fb94efdde24dbaacb2880d6cb (diff)
downloadmain-95112b1eb06a4be531ded59563d53a63a8d614e8.tar.gz
main-95112b1eb06a4be531ded59563d53a63a8d614e8.tar.bz2
main-95112b1eb06a4be531ded59563d53a63a8d614e8.zip
Opening!
Diffstat (limited to 'includes/telemetry.php')
-rw-r--r--includes/telemetry.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/includes/telemetry.php b/includes/telemetry.php
new file mode 100644
index 0000000..3988679
--- /dev/null
+++ b/includes/telemetry.php
@@ -0,0 +1,30 @@
+<?php
+
+$db = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/telemetry.json"), true);
+
+$ip = md5($_SERVER['REMOTE_ADDR']);
+$day = date('d');
+$month = date('m');
+$year = date('y');
+$url = "space:" .explode("?", $_SERVER['REQUEST_URI'])[0];
+
+if (!isset($db[$year]) && $_SERVER['PHP_SELF'] !== "/404.php") {
+ $db[$year] = [];
+}
+if (!isset($db[$year][$month]) && $_SERVER['PHP_SELF'] !== "/404.php") {
+ $db[$year][$month] = [];
+}
+if (!isset($db[$year][$month][$day]) && $_SERVER['PHP_SELF'] !== "/404.php") {
+ $db[$year][$month][$day] = [];
+}
+if (!isset($db[$year][$month][$day][$url]) && $_SERVER['PHP_SELF'] !== "/404.php") {
+ $db[$year][$month][$day][$url] = [];
+}
+
+if (!in_array($ip, $db[$year][$month][$day][$url]) && $_SERVER['PHP_SELF'] !== "/404.php") {
+ array_push($db[$year][$month][$day][$url], $ip);
+}
+
+if (trim(json_encode($db, JSON_PRETTY_PRINT)) !== "null") {
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/telemetry.json", json_encode($db, JSON_PRETTY_PRINT));
+} \ No newline at end of file