/
setstatus.php
executable file
·41 lines (35 loc) · 1.06 KB
/
setstatus.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
# CONFIG ##############################
$data_json_file_path = "data.json";
$config_json_file_path = "config.json";
#######################################
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$json_data = file_get_contents($data_json_file_path);
$data_data = json_decode($json_data, true);
$json_config = file_get_contents($config_json_file_path);
$data_config = json_decode($json_config,true);
$targets = array();
$targets = array_keys($data_config);
foreach ($targets as $var) {
if (isset($_GET[$var]) && $_GET[$var] >= -1 && $_GET[$var] <= 10) {
$$var = $_GET[$var]; // Dynamische Variable erstellen
} else {
if (isset($data_data['target'][$var])) {
$$var = $data_data['target'][$var];
}
else{
$$var = '0';
}
}
$target[$var] = $$var;
}
$data_data = array(
'status' => $data_data['status'],
'target' => $target,
);
$json_encoded = json_encode($data_data);
file_put_contents('data.json', $json_encoded);
print_r($json_encoded);
?>