webcam.php3 1.53 KB
Newer Older
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
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2005 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");

#
# Standard Testbed Header
#
PAGEHEADER("Robot Web Cams");

#
# Only known and logged in users can end experiments.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid);

# Helper function.
function MyError($msg)
{
    # No Data. Spit back a stub image.
    USERERROR($msg, 1);
    exit(0);
}

#
# Check sitevar to make sure mere users are allowed to peek at us.
#
$anyone_can_view = TBGetSiteVar("webcam/anyone_can_view");
$admins_can_view = TBGetSiteVar("webcam/admins_can_view");

if (!$admins_can_view || (!$anyone_can_view && !$isadmin)) {
    MyError("Webcam Views are currently disabled!", 1);
}

#
# Now check permission.
#
42
if (!$isadmin && !TBWebCamAllowed($uid)) {
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
    MyError("Not enough permission to view the robot cameras!");
}

#
# Get the set of webcams, and present a simple table of images, with titles.
#
$query_result =
    DBQueryFatal("select * from webcams");

if (!$query_result || !mysql_num_rows($query_result)) {
    MyError("There are no webcams to view!");
}

echo "<table cellpadding='0' cellspacing='0' border='0' class='stealth'>\n";

while ($row = mysql_fetch_array($query_result)) {
    $id      = $row["id"];

61
    echo "<tr><td align=center>Web Cam $id</td></tr>
62 63 64 65 66 67 68 69 70 71 72
          <tr><td align=center class='stealth'>
                <img src='webcamimg.php3?webcamid=$id' align=center></td></tr>
          <tr><tr>\n";
}
echo "</table>\n";

#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>