-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpicture.php
54 lines (45 loc) · 1.34 KB
/
picture.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
<?php
// Replace this with a picture object someday!!!
if ($_GET['mode'] != "debug") error_reporting(0);
require("session.inc");
require("db.inc");
if ($_GET['mode'] != "debug") header("Content-type: image/jpeg");
switch ($_GET['mode']) {
case "debug":
echo "Fetching picture from: {$_SESSION['cam_src']}<br>\n";
case "capture":
if (isset( $_SESSION['cam_src'])) if ($_SESSION['cam_src'] != "") {
if (!isset($_SESSION['ca_pic'])) $_SESSION['ca_pic'] = array();
$_SESSION['ca_pic']['data'] = "";
$fp = fopen($_SESSION['cam_src'], "rb");
if ($fp) {
$starttime = time();
while (!feof($fp) && (time() < ($starttime + 5))) $_SESSION['ca_pic']['data'] .= fread($fp,8192);
fclose($fp);
}
$_SESSION['ca_pic']['dirty'] = true;
}
break;
case "reset":
unset($_SESSION['ca_pic']);
break;
}
if (!isset($_SESSION['ca_pic'])) {
$_SESSION['ca_pic'] = array();
$_SESSION['ca_pic']['dirty'] = false;
$db = new dbconn;
$return = $db->query("SELECT picture FROM pictures WHERE id=" . $_SESSION['ca_id']);
if ($db->row_count($return) > 0) {
$_SESSION['ca_pic']['in_db'] = true;
$arr = $db->fetch_row($return);
$_SESSION['ca_pic']['data'] = $arr[0];
}
else {
$_SESSION['ca_pic']['in_db'] = false;
$fp = fopen("unknown.jpg", "rb");
$_SESSION['ca_pic']['data'] = fread($fp,906240);
fclose($fp);
}
}
echo $_SESSION['ca_pic']['data'];
?>