blob: 314920a28b02da25d504250e41d68b6096ddaf46 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
<?php
class MiscHandler extends RequestHandler
{
public function GET_main() {
$this->tpl->set_title('Главная');
$this->tpl->render_page('index.twig');
}
public function GET_phpinfo() {
phpinfo();
exit;
}
public function GET_sensors_page() {
global $config;
$clients = [];
foreach ($config['si7021d_servers'] as $key => $params) {
$cl = new Si7021dClient(...$params);
$clients[$key] = $cl;
$cl->readSensor();
}
$this->tpl->set(['sensors' => $clients]);
$this->tpl->set_title('Датчики');
$this->tpl->render_page('sensors.twig');
}
public function GET_pump_page() {
global $config;
list($set) = $this->input('set');
$client = new GPIORelaydClient($config['pump_host'], $config['pump_port']);
if ($set == GPIORelaydClient::STATUS_ON || $set == GPIORelaydClient::STATUS_OFF) {
$client->setStatus($set);
redirect('/pump/');
}
$status = $client->getStatus();
$this->tpl->set([
'status' => $status
]);
$this->tpl->set_title('Насос');
$this->tpl->render_page('pump.twig');
}
public function GET_cams() {
global $config;
$this->tpl->add_external_static('js', 'https://cdn.jsdelivr.net/npm/hls.js@latest');
$this->tpl->set([
'hls_host' => $config['cam_hls_host'],
'cams' => $config['cam_list']
]);
$this->tpl->set_title('Камеры');
$this->tpl->render_page('cams.twig');
}
}
|