nodeinfo.php3 2.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002, 2004, 2005 University of Utah and the Flux Group.
# All rights reserved.
#
chdir("..");
include("defs.php3");

#
# Only known and logged in users can watch LEDs
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);

#
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
# Verify page arguments. Allow user to optionally specify building/floor.
#
if (isset($building) && $building != "") {
    # Sanitize for the shell.
    if (!preg_match("/^[-\w]+$/", $building)) {
	PAGEARGERROR("Invalid building argument.");
    }
    # Optional floor argument. Sanitize for the shell.
    if (isset($floor) && !preg_match("/^[-\w]+$/", $floor)) {
	PAGEARGERROR("Invalid floor argument.");
    }
}
else {
    $building = "MEB-ROBOTS";
    $floor    = 4;
}
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

# Initial goo.
header("Content-Type: text/plain");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
flush();

#
# Clean up when the remote user disconnects
#
function SPEWCLEANUP()
{
    exit(0);
}
register_shutdown_function("SPEWCLEANUP");

# Get the robot information. Actually, this includes motes.
$query_result =
52 53
    DBQueryFatal("select loc.node_id,r.pid,r.eid,r.vname,n.type,nt.class, ".
		 "       loc.loc_x,loc.loc_y,loc.loc_z,loc.orientation ".
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
		 "  from location_info as loc ".
		 "left join reserved as r on r.node_id=loc.node_id ".
		 "left join nodes as n on n.node_id=loc.node_id ".
		 "left join node_types as nt on nt.type=n.type ".
		 "where loc.building='$building' and ".
		 "      loc.floor='$floor' $stamp_clause ".
		 "order by n.type,n.node_id");

while ($row = mysql_fetch_array($query_result)) {
    $pname  = $row["node_id"];
    $vname  = $row["vname"];
    $pid    = $row["pid"];
    $eid    = $row["eid"];
    $type   = $row["type"];
    $class  = $row["class"];
69 70 71 72
    $loc_x  = $row["loc_x"];
    $loc_y  = $row["loc_y"];
    $loc_z  = $row["loc_z"];
    $or     = $row["orientation"];
73 74
    $mobile = ($class == "robot" ? 1 : 0);
    # In meters.
75 76 77 78 79 80 81 82 83 84 85 86
    if ($class == "robot") {
	$size   = 0.27;
	$radius = 0.18;
    }
    elseif ($class == "pc" || $class == "pcwireless") {
	$size   = 1.0;
	$radius = 0.5;
    }
    else {
	$size   = 0.07;
	$radius = 0.04;
    }
87 88 89 90
    $alloc  = (isset($pid) ? 1 : 0);

    if (!isset($vname))
	$vname = $pname;
91 92 93 94
    if (!isset($loc_z))
	$loc_z = "";
    if (!isset($or))
	$or = "";
95
							      
96 97 98 99
    echo "$pname, ";
    if (!isset($selector)) {
	echo "$vname, ";
    }
100 101
    echo "$type, $alloc, $mobile, $size, $radius, ";
    echo "$loc_x, $loc_y, $loc_z, $or";
102
    echo "\n";
103 104 105
}

?>