Delete radar/update.php
This commit is contained in:
@@ -1,43 +0,0 @@
|
|||||||
<?php
|
|
||||||
// Alleen POST toestaan
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
|
||||||
http_response_code(405);
|
|
||||||
exit("Only POST allowed");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check of data bestaat
|
|
||||||
if (!isset($_POST['hoek']) || !isset($_POST['afstand'])) {
|
|
||||||
http_response_code(400);
|
|
||||||
exit("Missing data");
|
|
||||||
}
|
|
||||||
|
|
||||||
$hoek = intval($_POST['hoek']);
|
|
||||||
$afstand = intval($_POST['afstand']);
|
|
||||||
|
|
||||||
// Basis validatie
|
|
||||||
if ($hoek < 0 || $hoek > 180) {
|
|
||||||
http_response_code(400);
|
|
||||||
exit("Invalid angle");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bestand met radar data
|
|
||||||
$file = __DIR__ . "/radar.json";
|
|
||||||
|
|
||||||
// Bestaande data laden
|
|
||||||
$data = [];
|
|
||||||
if (file_exists($file)) {
|
|
||||||
$json = file_get_contents($file);
|
|
||||||
$data = json_decode($json, true);
|
|
||||||
if (!is_array($data)) $data = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Opslaan per hoek
|
|
||||||
$data[$hoek] = [
|
|
||||||
"afstand" => $afstand,
|
|
||||||
"tijd" => time()
|
|
||||||
];
|
|
||||||
|
|
||||||
// Terugschrijven
|
|
||||||
file_put_contents($file, json_encode($data));
|
|
||||||
|
|
||||||
echo "OK";
|
|
||||||
Reference in New Issue
Block a user