Files
scripts/Perl Ubiquiti mpower steuerung/control center/template/api.php
2024-10-14 00:08:40 +02:00

38 lines
783 B
PHP

<?php
require "func.php";
require "config.php";
if (isset($_GET["action"])) {
# Status lesen
if ($_GET["action"] === "getstatus") {
$state = load('state.php');
for ($i=0; $i<$switches; $i++) {
$j=$i+1;
echo "$j:'$state[$i]';";
}
}
# Last state change lesen
if ($_GET["action"] === "getchanged") {
if (file_exists("changed")) {
echo "changed";
} else {
echo "unchanged";
}
unlink ("changed");
}
if ($_GET["action"] === "setstatus") {
$a=['', '', '', '', '', ''];
for ($i=0; $i < $switches; $i++) {
$j=$i+1;
if ($_GET["oos$j"] === "on") {
$a[$i]="checked";
}
}
save("state.php", $a);
}
}