forked from zyphlar/ip-camera-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnapshot.php
executable file
·173 lines (147 loc) · 3.79 KB
/
snapshot.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<?php
require("config.inc.php");
if($_GET['camera'] == 1)
{
$rand = rand(1000,9999);
$url = 'http://172.22.110.11/snapshot.cgi?'.$rand;
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl_handle,CURLOPT_URL,$url);
curl_setopt($curl_handle, CURLOPT_USERPWD, "$cam1user:$cam1pass");
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
if (empty($buffer))
{
print "";
}
elseif($buffer == "Can not get image.")
{
print "Can not get image.";
}
else
{
header("Content-Type: image/jpeg");
print $buffer;
}
}
elseif($_GET['camera'] == 2)
{
$rand = rand(1000,9999);
$url = "http://172.22.110.12:88/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=$cam2user&pwd=$cam2pass";
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl_handle,CURLOPT_URL,$url);
# curl_setopt($curl_handle, CURLOPT_USERPWD, "$cam2user:$cam2pass");
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
if (empty($buffer))
{
print "";
}
elseif($buffer == "Can not get image.")
{
print "Can not get image.";
}
else
{
header("Content-Type: image/jpeg");
print $buffer;
}
}
elseif($_GET['camera'] == 3)
{
$rand = rand(1000,9999);
$url = 'http://172.22.110.13/snapshot.cgi?'.$rand;
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl_handle,CURLOPT_URL,$url);
curl_setopt($curl_handle, CURLOPT_USERPWD, "$cam3user:$cam3pass");
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
if (empty($buffer))
{
print "";
}
elseif($buffer == "Can not get image.")
{
print "Can not get image.";
}
else
{
header("Content-Type: image/jpeg");
print $buffer;
}
}
elseif($_GET['camera'] == 4)
{
$rand = rand(1000,9999);
$url = 'http://172.22.110.14/snapshot.cgi?'.$rand;
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl_handle,CURLOPT_URL,$url);
curl_setopt($curl_handle, CURLOPT_USERPWD, "$cam4user:$cam4pass");
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
if (empty($buffer))
{
print "";
}
elseif($buffer == "Can not get image.")
{
print "Can not get image.";
}
else
{
header("Content-Type: image/jpeg");
print $buffer;
}
}
elseif($_GET['camera'] == 9)
{
# Used to separate multipart
$boundary = "IPCamBoundary";
# We start with the standard headers. PHP allows us this much
header("Cache-Control: no-cache");
header("Cache-Control: private");
header("Pragma: no-cache");
header("Content-type: image/jpeg");
# From here out, we no longer expect to be able to use the header() function
print "--$boundary\n";
# Set this so PHP doesn't timeout during a long stream
set_time_limit(0);
# Disable Apache and PHP's compression of output to the client
@apache_setenv('no-gzip', 1);
@ini_set('zlib.output_compression', 0);
# Set implicit flush, and flush all current buffers
@ini_set('implicit_flush', 1);
for ($i = 0; $i < ob_get_level(); $i++)
ob_end_flush();
ob_implicit_flush(1);
# The loop, producing one jpeg frame per iteration
// while (true) {
# Your function to get one jpeg image
$rand = rand(1000,9999);
$url = 'http://intranet.heatsynclabs.org:9001/GetData.cgi?'.$rand;
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl_handle,CURLOPT_URL,$url);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
if (!empty($buffer))
{
# Per-image header, note the two new-lines
print "Content-type: image/jpeg\n\n";
print $buffer;
}
else {
print "Content-type: text/html\n\n";
print "No image.";
}
# The separator
print "--$boundary\n";
// }
}
else {
print "Error: No camera requested.";
}
?>