-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathon-http-notify.php
75 lines (67 loc) · 2.24 KB
/
on-http-notify.php
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
66
67
68
69
70
71
72
73
74
75
<?php
/**
* @file on-http-notify.php
* @brief Генерирует уведомление
*
*/
/* need for auth */
require_once('lib/config.inc.php');
require('../lib/get_cams_params.inc.php');
/**
* Send http headers
*/
// Don't use cache (required for Opera)
$now = gmdate('D, d M Y H:i:s') . ' GMT';
header('Expires: ' . $now);
header('Last-Modified: ' . $now);
header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
header('Pragma: no-cache'); // HTTP/1.0
// Define the charset to be used
header('Content-Type: text/html; charset=ISO-8859-1');
echo "<html><body>\r\n";
/* lookup camera's number from database */
unset($AVREG_CAMS_NR);
/* Массив номеров камер, найденных по InetCam_IP
Массив, потому что для ip-видеосервера
мы можем найти несколько камер с одним InetCam_IP */
$AVREG_CAMS_NR=array();
$cams_params = get_cams_params(array(
'work',
'video_src',
'text_left',
'InetCam_IP'));
$cams_nbr = count($cams_params) - 1;
if ($cams_nbr <= 0) {
die('There are no available cameras!');
}
if (isset($cams_params) && is_array($cams_params)) {
reset($cams_params);
each($cams_params); // skip template camera
while (list($_cam_nr, $CAM_PARAMS) = each($cams_params)) {
if (($CAM_PARAMS['video_src']['v'] === 'rtsp' ||
$CAM_PARAMS['video_src']['v'] === 'http') &&
$CAM_PARAMS['InetCam_IP']['v'] === $_SERVER["REMOTE_ADDR"]) {
/* define CAM_NR var */
$AVREG_CAMS_NR[] = (int)$_cam_nr;
break;
}
}
}
if (isset($AVREG_CAMS_NR)) {
print_syslog(
LOG_NOTICE,
sprintf(
'received http notify, query string - "%s", AVReg\'s camera(s) number(s) - [%s]',
$_SERVER['QUERY_STRING'],
implode(',', $AVREG_CAMS_NR)
)
);
} else {
print_syslog(LOG_ERR, sprintf('received http notify, query string - "%s"', $_SERVER['QUERY_STRING']));
}
/* include user scripts */
if (!empty($conf['on-http-notify'])) {
@include ($conf['on-http-notify']);
}
echo "<h1>Received!</h1>\r\n</body></html>\r\n";
/* vim: set expandtab smartindent tabstop=4 shiftwidth=4: */