-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathcctv.php
140 lines (121 loc) · 5.41 KB
/
cctv.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/include/main.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/include/camera.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/include/config.php');
$pagepath = array(array('CCTV CONTROL', $_SERVER['REQUEST_URI']));
$topbar = true;
include $_SERVER['DOCUMENT_ROOT'].'/include/header.php';
?>
<div class="panel panel-primary control-box">
<div class="panel-heading">RECORDING CONTROL</div>
<div class="panel-body">
<a class="btn btn-success" href="control.php?action=startall">START ALL</a>
<a class="btn btn-danger" href="control.php?action=stopall">STOP ALL</a>
<a class="btn btn-warning" href="control.php?action=reloadall">RELOAD ALL</a>
</div>
</div>
<div class="panel panel-primary control-box">
<div class="panel-heading">RECORDING DATA</div>
<div class="panel-body">
<a class="btn btn-primary" href="recording-video.php">VIDEO FILES</a>
<a class="btn btn-primary" href="recording-log.php">RECORDING LOG VIEWER</a>
</div>
</div>
<div class="panel panel-primary control-box">
<div class="panel-heading">FUNCTIONS</div>
<div class="panel-body">
<a class="btn btn-primary" href="/admin/">ADMIN SETTINGS</a>
</div>
</div>
<hr>
<p>DISK USAGE:</p>
<?php
$config = config::get_key_instances($database, 'recording_directory');
if ($config === false) {
echo '<p>Error getting [recording_directory] configuration key!</p>';
}
echo '<table border="1">';
$headers_shown = false;
foreach ($config as $c) {
$rec_path = preg_replace('/[^a-zA-Z0-9\-\/]/', '_', $c['value']);
$dev_ids = ($c['devices'] == '') ? '**DEFAULT**' : $c['devices'];
exec('df -h '.$rec_path.' | tr -s \' \'', $df);
$first = 1;
foreach ($df as $line) {
$word = explode(' ',$line);
if ($first == '1') {
if ($headers_shown === false) {
echo '<tr><td><b>Device IDs</b></td><td><b>'.$word[0].'</b></td><td><b>'.$word[1].'</b></td><td><b>'.$word[2].'</b></td><td><b>'.$word[3].'</b></td><td><b>'.$word[4].'</b></td><td><b>'.$word[5].'</b></td><td><b>% Used</b></td>';
$headers_shown = true;
}
$first = 0;
} else {
echo '<tr><td>'.$dev_ids.'</td><td>'.$word[0].'</td><td>'.$word[1].'</td><td>'.$word[2].'</td><td>'.$word[3].'</td><td>'.$word[4].'</td><td>'.$word[5].'</td>';
echo '<td><div class="percentbar" style="width: 100px;"><div style="width:'.$word[4].';"></div></div></td></tr>';
}
}
unset($df);
}
echo '</table>';
?>
<hr>
<p>DEVICE LIST:</p>
<p><a class="btn btn-primary" href="/camera-manager.php">EDIT CAMERAS</a></p>
<table class="table table-hover">
<tr>
<th>ID</th>
<th>NAME</th>
<th>IP ADDRESS</th>
<th>PROTOCOL</th>
<th>URL</th>
<th>USERNAME</th>
<th>PASSWORD</th>
<th>STATUS</th>
<th colspan=7>CONTROLS</th>
</tr>
<?php
//$result = $db->query("select `id`,`name`,`ip_address`,`protocol`,`url`,`username`,`password` from devices");
$database->query("select `id`,`name`,`ip_address`,`protocol`,`url`,`username`,`password` from devices");
//$highlight = 0;
if (isset($database->result[0])) {
$result = $database->result;
foreach ($result as $row) {
//echo ($highlight) ? '<tr bgcolor="#CCCCCC">' : '<tr>';
//$highlight = ($highlight) ? 0 : 1;
echo '<tr>';
echo '<td>'.$row['id'].' </td>';
echo '<td>'.$row['name'].' </td>';
echo '<td>'.$row['ip_address'].' </td>';
echo '<td>'.$row['protocol'].' </td>';
echo '<td>'.$row['url'].' </td>';
echo '<td>'.$row['username'].' </td>';
echo '<td>'.$row['password'].' </td>';
$config = new config($database, $row['id']);
$camera = new camera($database, $config->config_data, $row['id']);
//echo '<pre>'.print_r($camera,1).'</pre>';
if ($camera->has_pid()) {
if ($camera->is_running()) {
echo '<td>RUNNING PID: '.$camera->get_pid().'</td>';
} else {
echo '<td>PROCESS DIED PID: '.$camera->get_pid().'</td>';
}
} elseif ($camera->has_sleep_pid()) {
echo '<td>SLEEPING: '.$camera->get_sleep_pid().'</td>';
} else {
echo '<td>STOPPED</td>';
}
echo '<td><a class="btn btn-sm btn-success" href="control.php?action=start&camera='.$row['name'].'">START</a></td>';
echo '<td><a class="btn btn-sm btn-danger" href="control.php?action=stop&camera='.$row['name'].'">STOP</a></td>';
echo '<td><a class="btn btn-sm btn-warning" href="control.php?action=reload&camera='.$row['name'].'">RELOAD</a></td>';
echo '<td><a class="btn btn-sm btn-primary" href="javascript:var sfw=window.open(\'liveview.php?camera='.$row['name'].'\', \''.$row['name'].'\', \'height=500, menubar=no, status=no, toolbar=no, width=660, location=no, scrollbars=no\');">LIVE</a></td>';
echo '<td><a class="btn btn-sm btn-primary" href="javascript:var sfw=window.open(\'recording-viewer.php?camera='.$row['name'].'\', \''.$row['name'].'\', \'height=500, menubar=no, status=no, toolbar=no, width=660, location=no, scrollbars=yes\');">RECORDINGS</a></td>';
echo '<td><a class="btn btn-sm btn-primary" href="javascript:var sfw=window.open(\'viewlog.php?camera='.$row['name'].'\', \''.$row['name'].'\', \'height=700, menubar=no, status=no, toolbar=no, width=800, location=no, scrollbars=yes\');">LOG</a></td>';
echo '<td><a class="btn btn-sm btn-primary" href="http://'.$row['ip_address'].'/" target="_blank">WEB</a></td>';
echo '</tr>';
}
}
?>
</table>
<?php
include $_SERVER['DOCUMENT_ROOT'].'/include/footer.php';
?>