[CODE] add client last seen time

This commit is contained in:
Jannik Beyerstedt 2017-08-23 14:43:13 +02:00
parent 153d48f8ef
commit 73b896c395
4 changed files with 23 additions and 2 deletions

View file

@ -136,6 +136,14 @@ class LightStatus {
} }
} }
public function setClientLastSeen() {
$this->times['clientLastSeen'] = time();
$this->saveTimes();
}
public function getClientLastSeen() {
return $this->times['clientLastSeen'];
}
private function readTimes() { private function readTimes() {

View file

@ -12,6 +12,9 @@ $light->update();
$error_string = ""; $error_string = "";
$lastSeenTimeStr = date("H:i:s, Y-m-d",($light->getClientLastSeen()));
$lastSeenTimeDiff = (time()-$light->getClientLastSeen());
// route actions // route actions
if (isset($_GET['action'])) { if (isset($_GET['action'])) {
if ($_GET['action'] == 'enlighten') { if ($_GET['action'] == 'enlighten') {
@ -66,7 +69,7 @@ if (isset($_GET['action'])) {
<meta name="robots" content="noindex, nofollow"> <meta name="robots" content="noindex, nofollow">
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="style.css?v1.1">
</head> </head>
<body class="container <?php echo ($light->isNight) ? 'dark' : 'light' ?>"> <body class="container <?php echo ($light->isNight) ? 'dark' : 'light' ?>">
@ -103,6 +106,10 @@ if (isset($_GET['action'])) {
<tr> <tr>
<td>Nacht (ja/nein):</td><td><?php echo ($light->isNight) ? "ja" : "nein" ?></td> <td>Nacht (ja/nein):</td><td><?php echo ($light->isNight) ? "ja" : "nein" ?></td>
</tr> </tr>
<tr>
<td>Client Last Seen:</td><td><?php echo $lastSeenTimeStr ?>;
vor&nbsp;<?php echo (int)($lastSeenTimeDiff/60).':'.($lastSeenTimeDiff - (int)($lastSeenTimeDiff/60) * 60) ?>&nbsp;Min:Sek</td>
</tr>
</table> </table>
<h2>Einstellungen</h2> <h2>Einstellungen</h2>
@ -128,7 +135,9 @@ if (isset($_GET['action'])) {
<input type="time" class="form-control" name="time3-stop" value="<?php echo $light->times['time3']['off'] ?>"> <input type="time" class="form-control" name="time3-stop" value="<?php echo $light->times['time3']['off'] ?>">
</div> </div>
</div> </div>
<button type="submit" class="btn btn-primary">Zeiten ändern</button> <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>
</form> </form>
</body> </body>

View file

@ -9,6 +9,7 @@ include "functions.php";
$light = new LightStatus(); $light = new LightStatus();
$light->update(); $light->update();
$light->setClientLastSeen();
echo $light; echo $light;
?> ?>

View file

@ -14,6 +14,9 @@ table {
margin-top: 1em; margin-top: 1em;
margin-bottom: 1em; margin-bottom: 1em;
} }
table tr td {
vertical-align: top;
}
table tr>td:first-child { table tr>td:first-child {
padding-right: 0.75em; padding-right: 0.75em;
text-align: right; text-align: right;