summaryrefslogtreecommitdiff
path: root/localwebsite/handlers/MiscHandler.php
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2023-01-19 19:58:57 +0300
committerEvgeny Zinoviev <me@ch1p.io>2023-01-19 19:58:57 +0300
commitec1e287bf129b3c4b91b565e0334009b72f6e928 (patch)
treec34051d6268f16fc04f53a1f74b2cfe43e05fc76 /localwebsite/handlers/MiscHandler.php
parenta58f4ef5880f37c0e873a06a927d24cecb1efbe2 (diff)
lws: add ipcam_server stats
Diffstat (limited to 'localwebsite/handlers/MiscHandler.php')
-rw-r--r--localwebsite/handlers/MiscHandler.php15
1 files changed, 15 insertions, 0 deletions
diff --git a/localwebsite/handlers/MiscHandler.php b/localwebsite/handlers/MiscHandler.php
index 2c2eb76..4eeb9fb 100644
--- a/localwebsite/handlers/MiscHandler.php
+++ b/localwebsite/handlers/MiscHandler.php
@@ -108,6 +108,21 @@ class MiscHandler extends RequestHandler
$this->tpl->render_page('cams.twig');
}
+ public function GET_cams_stat() {
+ global $config;
+ list($ip, $port) = explode(':', $config['ipcam_server_api_addr']);
+ $body = jsonDecode(file_get_contents('http://'.$ip.':'.$port.'/api/timestamp/all'));
+
+ header('Content-Type: text/plain');
+ $date_fmt = 'd.m.Y H:i:s';
+
+ foreach ($body['response'] as $cam => $data) {
+ $fix = date($date_fmt, $data['fix']);
+ $motion = date($date_fmt, $data['motion']);
+ echo "$cam:\n motion: $motion\n\n";
+ }
+ }
+
public function GET_debug() {
print_r($_SERVER);
}