Commit e3bde0ea authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

New web cameras are a lot easier to deal with! I've removed the

grabwebcams startup since it is no longer needed.

The new version of the webcam page connects directly to the cameras
using a URL stored in the DB (webcams table). The URL includes the
user (elabman) and the password, which is fine; not likely to leak
out the password and even if we did, no biggie since its on the private
network and no one can get to it anyway.

I have reduced the frame rate to 5fps (compression 50%) as specified
in the URL, and even thats a lot of bandwidth.

I will work on providing mpeg feeds later!
parent b5e03567
......@@ -76,10 +76,10 @@ case "$1" in
if [ -x @prefix@/sbin/grabwebcams ]; then
echo -n " grabwebcams"
#if [ -x @prefix@/sbin/grabwebcams ]; then
# echo -n " grabwebcams"
# @prefix@/sbin/grabwebcams
# Could trigger experiment creation, so make sure everything
......@@ -57,9 +57,8 @@ echo "<table cellpadding='0' cellspacing='0' border='0' class='stealth'>\n";
while ($row = mysql_fetch_array($query_result)) {
$id = $row["id"];
$updated = $row["last_update"];
echo "<tr><td align=center>Web Cam $id. Last Update: $updated</td></tr>
echo "<tr><td align=center>Web Cam $id</td></tr>
<tr><td align=center class='stealth'>
<img src='webcamimg.php3?webcamid=$id' align=center></td></tr>
......@@ -35,21 +35,22 @@ if (!isset($webcamid) ||
MyError("You must provide a WebCam ID.");
# The ID is really just a filename. Make sure it looks okay.
if (! preg_match("/^[\d]+$/", $webcamid)) {
MyError("Invalid characters in WebCam ID.");
# And check for the filename in the webcam directory.
# And check for entry in webcams table, which tells us the server name
# where we open the connection to.
$filename = "$TBDIR/webcams/camera-${webcamid}.jpg";
$query_result =
DBQueryFatal("select * from webcams where id='$webcamid'");
if (!file_exists($filename)) {
MyError("Camera image file is missing!");
if (!$query_result || !mysql_num_rows($query_result)) {
MyError("No such webcam ID: '$webcamid'");
$row = mysql_fetch_array($query_result);
$URL = $row["URL"];
# Check sitevar to make sure mere users are allowed to peek at us.
......@@ -58,7 +59,7 @@ $anyone_can_view = TBGetSiteVar("webcam/anyone_can_view");
$admins_can_view = TBGetSiteVar("webcam/admins_can_view");
if (!$admins_can_view || (!$anyone_can_view && !$isadmin)) {
USERERROR("Webcam Views are currently disabled!", 1);
MyError("Webcam Views are currently disabled!");
......@@ -68,9 +69,45 @@ if (!$isadmin && !TBWebCamAllowed($uid)) {
MyError("Not enough permission to view the robot cameras!");
# Spit back the image
header("Content-type: image/gif");
$socket = fopen($URL, "r");
if (!$socket) {
TBERROR("Error opening URL $URL", 0);
MyError("Error opening URL");
# So, the webcam spits out its own HTTP headers, which includes this
# content-type line, but all those headers are basically lost cause
# of the interface we are using (fopen). No biggie, but we have to
# spit them out ourselves so the client knows what to do.
header("Content-type: multipart/x-mixed-replace; boundary=--myboundary");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
# Clean up when the remote user disconnects
function SPEWCLEANUP()
global $socket;
if (!$socket || !connection_aborted()) {
# ignore_user_abort(1);
# Spit back the image. The webcams include all the necessary headers,
# so do not spit any headers here.
# No Footer!
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment