2017-07-23 23:34:53 +00:00
|
|
|
<?php
|
|
|
|
// -------------------------------------------
|
|
|
|
// outdoor lights control -- server
|
|
|
|
// copyright: Jannik Beyerstedt | https://jannikbeyerstedt.de
|
|
|
|
// license: http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 License
|
|
|
|
// -------------------------------------------
|
|
|
|
|
|
|
|
include "functions.php";
|
|
|
|
|
|
|
|
$light = new LightStatus();
|
|
|
|
$light->update();
|
|
|
|
|
|
|
|
$error_string = "";
|
|
|
|
|
2017-08-23 12:43:13 +00:00
|
|
|
$lastSeenTimeStr = date("H:i:s, Y-m-d",($light->getClientLastSeen()));
|
|
|
|
$lastSeenTimeDiff = (time()-$light->getClientLastSeen());
|
|
|
|
|
2017-07-23 23:34:53 +00:00
|
|
|
// route actions
|
|
|
|
if (isset($_GET['action'])) {
|
|
|
|
if ($_GET['action'] == 'enlighten') {
|
|
|
|
// set off time to now + 15 minutes
|
|
|
|
$light->times['instant-on'] = time() + (15*60);
|
|
|
|
if ($light->saveTimes() === true) {
|
|
|
|
header('Location: index.php?success=true');
|
|
|
|
} else {
|
|
|
|
$error_string = "Error saving config file";
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if ($_GET['action'] == 'update') {
|
|
|
|
if (isset($_POST) && !empty($_POST)) {
|
|
|
|
// parse form data
|
|
|
|
$parse_state = checkTimesInput($_POST);
|
|
|
|
if ($parse_state === true) {
|
|
|
|
// change values of $times arrays
|
|
|
|
$light->times['time1']['on'] = $_POST['time1-start'];
|
|
|
|
$light->times['time1']['off'] = $_POST['time1-stop'];
|
|
|
|
$light->times['time2']['on'] = $_POST['time2-start'];
|
|
|
|
$light->times['time2']['off'] = $_POST['time2-stop'];
|
|
|
|
$light->times['time3']['on'] = $_POST['time3-start'];
|
|
|
|
$light->times['time3']['off'] = $_POST['time3-stop'];
|
|
|
|
|
|
|
|
// save new $times array
|
|
|
|
$light->saveTimes();
|
|
|
|
|
|
|
|
header('Location: index.php?success=true');
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$error_string = $parse_state;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$error_string = "ERROR: no form data received";
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
echo "invalid action\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="de">
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8" />
|
|
|
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
|
|
<meta name="format-detection" content="telephone=no">
|
|
|
|
<title>Lightscontrol Control Interface</title>
|
|
|
|
<meta name="robots" content="noindex, nofollow">
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
|
2017-08-23 12:43:13 +00:00
|
|
|
<link rel="stylesheet" href="style.css?v1.1">
|
2017-07-23 23:34:53 +00:00
|
|
|
|
|
|
|
</head>
|
2017-10-04 18:54:18 +00:00
|
|
|
<body class="container <?php echo ($light->isNight) ? 'dark' : 'light' ?> <?php echo ($light->state) ? 'on' : ''?>">
|
2017-08-02 20:58:44 +00:00
|
|
|
<h1>Garagenlicht</h1>
|
2017-07-23 23:34:53 +00:00
|
|
|
|
|
|
|
<?php if ($error_string != '') : ?>
|
|
|
|
<div class="alert alert-danger" role="alert"><?php echo $error_string ?></div>
|
|
|
|
<?php endif; ?>
|
|
|
|
|
2017-08-23 12:11:54 +00:00
|
|
|
<table class="big">
|
|
|
|
<tr>
|
|
|
|
<td>Licht:</td>
|
|
|
|
<td><?php echo ($light->state) ? '<span class="label label-success">EINGESCHALTET</span>'
|
|
|
|
: '<span class="label label-default">AUSGESCHALTET</span>';?></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Änderung in:</td>
|
|
|
|
<td><span class="label label-primary"><?php echo ($light->changeTime === 1) ? $light->changeTime." Minute" : $light->changeTime." Minuten" ?></span></td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
<a class="btn btn-primary" href="index.php?action=enlighten">Licht temporär an (15 Min)</a>
|
2017-07-23 23:34:53 +00:00
|
|
|
|
|
|
|
<h5>weitere Informationen:</h5>
|
2017-08-23 12:11:54 +00:00
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<td>Sonnenaufgang:</td><td><?php echo $light->sunrise ?></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Sonnenuntergang:</td><td><?php echo $light->sunset ?></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Aktuelle Zeit:</td><td><?php echo date("H:i, Y-m-d",time()) ?></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Nacht (ja/nein):</td><td><?php echo ($light->isNight) ? "ja" : "nein" ?></td>
|
|
|
|
</tr>
|
2017-08-23 12:43:13 +00:00
|
|
|
<tr>
|
|
|
|
<td>Client Last Seen:</td><td><?php echo $lastSeenTimeStr ?>;
|
|
|
|
vor <?php echo (int)($lastSeenTimeDiff/60).':'.($lastSeenTimeDiff - (int)($lastSeenTimeDiff/60) * 60) ?> Min:Sek</td>
|
|
|
|
</tr>
|
2017-08-23 12:11:54 +00:00
|
|
|
</table>
|
2017-07-23 23:34:53 +00:00
|
|
|
|
|
|
|
<h2>Einstellungen</h2>
|
|
|
|
<form class="form-horizontal" action="index.php?action=update" method="post">
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="time1-start" class="col-xs-3 col-sm-2 control-label">Zeit 1</label>
|
|
|
|
<div class="col-xs-9 col-sm-10">
|
|
|
|
<input type="time" class="form-control" name="time1-start" value="<?php echo $light->times['time1']['on'] ?>">
|
|
|
|
<input type="time" class="form-control" name="time1-stop" value="<?php echo $light->times['time1']['off'] ?>">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="time2-start" class="col-xs-3 col-sm-2 control-label">Zeit 2</label>
|
|
|
|
<div class="col-xs-9 col-sm-10">
|
|
|
|
<input type="time" class="form-control" name="time2-start" value="<?php echo $light->times['time2']['on'] ?>">
|
|
|
|
<input type="time" class="form-control" name="time2-stop" value="<?php echo $light->times['time2']['off'] ?>">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="time3-start" class="col-xs-3 col-sm-2 control-label">Zeit 3</label>
|
|
|
|
<div class="col-xs-9 col-sm-10">
|
|
|
|
<input type="time" class="form-control" name="time3-start" value="<?php echo $light->times['time3']['on'] ?>">
|
|
|
|
<input type="time" class="form-control" name="time3-stop" value="<?php echo $light->times['time3']['off'] ?>">
|
|
|
|
</div>
|
|
|
|
</div>
|
2017-08-23 12:43:13 +00:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-xs-9 col-xs-push-3 col-sm-10 col-sm-push-2"><button type="submit" class="btn btn-primary">Zeiten ändern</button></div>
|
|
|
|
</div>
|
2017-07-23 23:34:53 +00:00
|
|
|
</form>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|
|
|
|
<script src="bootstrap/jquery-2.2.4.min.js"></script>
|
|
|
|
<script src="bootstrap/js/bootstrap.min.js"></script>
|