[CODE] add client last seen time
This commit is contained in:
parent
153d48f8ef
commit
73b896c395
|
@ -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() {
|
||||
|
|
13
index.php
13
index.php
|
@ -12,6 +12,9 @@ $light->update();
|
|||
|
||||
$error_string = "";
|
||||
|
||||
$lastSeenTimeStr = date("H:i:s, Y-m-d",($light->getClientLastSeen()));
|
||||
$lastSeenTimeDiff = (time()-$light->getClientLastSeen());
|
||||
|
||||
// route actions
|
||||
if (isset($_GET['action'])) {
|
||||
if ($_GET['action'] == 'enlighten') {
|
||||
|
@ -66,7 +69,7 @@ if (isset($_GET['action'])) {
|
|||
<meta name="robots" content="noindex, nofollow">
|
||||
|
||||
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<link rel="stylesheet" href="style.css?v1.1">
|
||||
|
||||
</head>
|
||||
<body class="container <?php echo ($light->isNight) ? 'dark' : 'light' ?>">
|
||||
|
@ -103,6 +106,10 @@ if (isset($_GET['action'])) {
|
|||
<tr>
|
||||
<td>Nacht (ja/nein):</td><td><?php echo ($light->isNight) ? "ja" : "nein" ?></td>
|
||||
</tr>
|
||||
<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>
|
||||
</table>
|
||||
|
||||
<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'] ?>">
|
||||
</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>
|
||||
|
||||
</body>
|
||||
|
|
|
@ -9,6 +9,7 @@ include "functions.php";
|
|||
|
||||
$light = new LightStatus();
|
||||
$light->update();
|
||||
$light->setClientLastSeen();
|
||||
|
||||
echo $light;
|
||||
?>
|
||||
|
|
Reference in a new issue