echo "emulab_status={$status}\n"; } # Required arguments $reqargs = RequiredPageArguments("IP", PAGEARG_STRING, "privkey", PAGEARG_STRING); $optargs = OptionalPageArguments("hostname", PAGEARG_STRING); # Must use https, if (!isset($_SERVER["SSL_PROTOCOL"])) { SPITSTATUS(WASTATUS_MUSTUSESSL); return; } if (!preg_match('/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/', $IP) || !preg_match('/^[\\w]+$/', $privkey) || isset($hostname) && !preg_match('/^[-\\w\\.]+$/', $hostname)) { SPITSTATUS(WASTATUS_INVALIDARGS); return; } # # Make sure this is a valid privkey before we invoke the backend. # $query_result = DBQueryFatal("select IP from widearea_nodeinfo where privkey='{$privkey}'"); if (!mysql_num_rows($query_result)) { SPITSTATUS(WASTATUS_BADPRIVKEY); return; } # # Invoke the backend and return the status. We send the IP since cause we # have to deal with nodes with dynamic IP addresses. # $retval = SUEXEC("nobody", $TBADMINGROUP, "webwanodecheckin " . (isset($hostname) ? "-h {$hostname} " : "") . "{$privkey} {$IP}", SUEXEC_ACTION_IGNORE); if ($retval) { SUEXECERROR(SUEXEC_ACTION_CONTINUE); } SPITSTATUS($retval);
function TemplateLookupByName($template, $name) { $metadata_name = addslashes($name); $template_guid = $template->guid(); $template_vers = $template->vers(); $query_result = DBQueryFatal("select i.guid,i.vers " . " from experiment_template_metadata as m " . "left join experiment_template_metadata_items as i on " . " i.guid=m.metadata_guid and i.vers=m.metadata_vers " . "where m.parent_guid='{$template_guid}' and " . " m.parent_vers='{$template_vers}' and " . " i.name='{$metadata_name}'"); if (!mysql_num_rows($query_result)) { return null; } $row = mysql_fetch_array($query_result); $metadata_guid = $row['guid']; $metadata_vers = $row['vers']; $foo = new TemplateMetadata($metadata_guid, $metadata_vers); if (!$foo->IsValid()) { return null; } $foo->template = $template; return $foo; }
header("Pragma: no-cache"); if (!$isadmin) { echo "unauthorized\n"; return; } # check args if (!isset($resource)) { echo "no resource specified\n"; return; } if (!in_array($resource, $resources)) { echo "invalid resource\n"; return; } # grab the data $qres = DBQueryFatal($queries[$resource]); if (mysql_num_rows($qres) == 0) { echo "no data\n"; return; } # print column headers echo "{$resource}"; foreach ($fields[$resource] as $f => $finfo) { echo "\t{$f}(" . $finfo["type"] . ")(" . $finfo["data"] . ")"; } echo "\n"; # print data while ($row = mysql_fetch_array($qres)) { echo $row[$resource]; foreach ($fields[$resource] as $f => $finfo) { echo "\t" . $row[$f] . "";
$manifest = $mrow["manifest"]; $stuff = GeneratePopupDiv("manifest{$idx}", $manifest); $popups[] = $stuff; $tablerow["manifest"] = "<a href='#' title='' " . "onclick='PopUpWindowFromDiv(\"manifest{$idx}\");'" . ">manifest</a>\n"; } else { $tablerow["Manifest"] = "Unknown"; } $rows[] = $tablerow; $myindex = $idx; } list($html, $button) = TableRender($table, $rows); echo $html; foreach ($popups as $i => $popup) { echo "{$popup}\n"; } $query_result = DBQueryFatal("select count(*) from aggregate_history as a " . "where `type`='Aggregate' and a.idx<{$myindex} {$clause} ", $dblink); $row = mysql_fetch_array($query_result); $remaining = $row[0]; if ($remaining) { $opts = ""; if ($ch) { $opts .= "&ch={$ch}"; } if (isset($search)) { $opts .= "&search=yes&searchfor=" . rawurlencode($searchfor); } echo "<center>" . "<a href='genihistory.php?index={$myindex}{$opts}'>" . "More Entries</a></center><br>\n"; } } } #
$manifestidx++; } else { $row["manifest"] = "Unknown"; } $rows[] = $row; } list($html, $button) = TableRender($table, $rows); echo $html; } foreach ($popups as $i => $popup) { echo "{$popup}\n"; } # # Find all logs associated with this slice. # $query_result = DBQueryFatal("select m.logidx,l.logid,l.date_created,m2.metaval " . " from logfile_metadata as m " . "left join logfiles as l on l.logidx=m.logidx " . "left join logfile_metadata as m2 on " . " m2.logidx=m.logidx and m2.metakey='Method' " . "where m.metakey='slice_idx' and m.metaval='{$slice_idx}' " . "order by l.date_created asc"); if ($query_result && mysql_num_rows($query_result)) { $table = array('#id' => 'logfiles', '#title' => "Log Files", '#headings' => array("idx" => "ID", "method" => "Op", "created" => "Created", "log" => "Link")); $rows = array(); $img = "<img border='0' src='greenball.gif' />"; while ($row = mysql_fetch_array($query_result)) { $logidx = $row["logidx"]; $logid = $row["logid"]; $op = $row["metaval"]; $date = $row["date_created"]; $url = CreateURL("spewlogfile", "logfile", $logid); $row = array("idx" => $logidx, "method" => $op, "created" => $date, "log" => "<a href='{$url}'>{$img}</a>"); $rows[] = $row; } list($html, $button) = TableRender($table, $rows); echo $html;
$fields = array(); # # Search either templates, instances, or runs. # $fields['searchwhat'] = array('#type' => 'radio', '#label' => 'Search which template versions', '#required' => TRUE, '#radios' => array('Template' => array('#label' => 'This Version', '#return_value' => "this"), 'Instance' => array('#label' => 'All Versions', '#return_value' => "all")), '#checkslot' => "/^(this|all)\$/"); $fields['searchwhich'] = array('#type' => 'radio', '#label' => 'What do you want to search', '#required' => TRUE, '#radios' => array('Template' => array('#label' => 'Templates', '#return_value' => "template"), 'Instance' => array('#label' => 'Instances', '#return_value' => "instance"), 'Run' => array('#label' => 'Runs', '#return_value' => "run")), '#checkslot' => "/^(template|instance|run)\$/"); $fields['matchif'] = array('#type' => 'radio', '#label' => 'Match on', '#description' => 'all clauses match or any clause matches', '#required' => TRUE, '#radios' => array('Any' => array('#label' => 'Any', '#return_value' => "any"), 'All' => array('#label' => 'All', '#return_value' => "all")), '#checkslot' => "/^(any|all)\$/"); # # User is given the option to save this search for later. # $fields['save'] = array('#type' => 'list', '#label' => 'Save this search', '#elements' => array('savesearch' => array('#type' => 'checkbox', '#label' => 'Yes', '#return_value' => 1), 'savename' => array('#type' => 'textfield', '#label' => 'Save Name', '#size' => 20, '#maxlength' => 64))); # # Grab a list of all parameters across all the templates and create # a list of input boxes. # $query_result = DBQueryFatal("select distinct name from experiment_template_parameters " . "where parent_guid='{$guid}' " . "order by name"); $index = 1; $paramselection = array(); while ($row = mysql_fetch_array($query_result)) { $paramselection[$index++] = $row['name']; } # # Start with a single clause. # $fields['clause1'] = array('#type' => 'list', '#label' => 'Clause 1', '#elements' => array('parameter1' => array('#type' => 'select', '#default' => 'Parameter', '#which' => 1, '#checkslot' => 'CheckParameter', '#options' => $paramselection), 'condition1' => array('#type' => 'select', '#default' => 'Cond', '#which' => 1, '#checkslot' => 'CheckCondition', '#options' => $clauseselection), 'value1' => array('#type' => 'textfield', '#which' => 1, '#checkslot' => 'CheckValue', '#size' => 30))); $fields['clausecount'] = array('#type' => 'hidden', '#required' => TRUE, '#value' => "1"); # # Spit the form out using the array of data. # function SPITFORM($formfields, $errors) {
function DeleteNodeLog($log_id) { $node_id = $this->node_id(); $safe_id = addslashes($log_id); DBQueryFatal("delete from nodelog where " . "node_id='{$node_id}' and log_id={$safe_id}"); return 0; }
# Standard Testbed Header # PAGEHEADER("USRP Preorder List"); # # Only known and logged in users allowed. # $this_user = CheckLoginOrDie(); $uid = $this_user->uid(); $isadmin = ISADMIN(); if (!$isadmin) { USERERROR("You do not have permission to view the USRP preorder list!", 1); } # # Get the list. Date order, most recent first. # $query_result = DBQueryFatal("select * from usrp_orders " . "order by order_date desc"); if (($count = mysql_num_rows($query_result)) == 0) { USERERROR("There are no USRP preorders!", 1); } # # Grab some totals for the top of the page. # $total_mobos = 0; $total_dboards = 0; while ($row = mysql_fetch_array($query_result)) { $num_mobos = $row["num_mobos"]; $num_dboards = $row["num_dboards"]; $total_mobos += $num_mobos; $total_dboards += $num_dboards; } mysql_data_seek($query_result, 0);
function ShowExperiments($user) { global $TBOPSPID; global $TB_EXPT_READINFO; $uid = $user->uid(); $pid = $this->pid(); $osname = $this->osname(); # # Due to the funny way we handle 'global' images in the emulab-ops # project, we have to treat its images specially - namely, we # have to make sure there is not an osname in that project, which # takes priority over the global ones. # if ($pid == $TBOPSPID) { $query_result = DBQueryFatal("select distinct v.pid, v.eid, e.state " . " from virt_nodes as v " . "left join os_info as o on " . " v.osname=o.osname and v.pid=o.pid " . "left join experiments as e on v.pid=e.pid and " . " v.eid=e.eid " . "where v.osname='{$osname}' and o.osname is NULL " . "order by v.pid, v.eid, e.state"); } else { $query_result = DBQueryFatal("select distinct v.pid, v.eid, e.state " . " from virt_nodes as v " . "left join experiments as e " . " on v.pid=e.pid and v.eid=e.eid " . "where v.pid='{$pid}' and v.osname='{$osname}' " . "order by v.pid, v.eid, e.state"); } if (mysql_num_rows($query_result) == 0) { echo "<h4 align='center'>No experiments are using this OS</h3>"; } else { $other_exps = 0; echo "<h3 align='center'>Experiments using this OS</h3>\n"; echo "<table align=center border=1>\n"; echo " <tr> \n\t\t <th>PID</th>\n \t\t <th>EID</th>\n\t\t <th>State</th>\n\t\t </tr>\n"; while ($row = mysql_fetch_array($query_result)) { $pid = $row[0]; $eid = $row[1]; $state = $row[2]; # # Gotta make sure that the user actually has the right to # see this experiment - summarize all the experiments that # he/she cannot see at the bottom # if (!($experiment = Experiment::LookupByPidEid($pid, $eid))) { continue; } if (!$experiment->AccessCheck($user, $TB_EXPT_READINFO)) { $other_exps++; continue; } $showexp_url = CreateURL("showexp", $experiment); echo "<tr>\n"; echo " <td>{$pid}</td>\n"; echo " <td><a href='{$showexp_url}'>{$eid}</td>\n"; echo " <td>{$state}</td>\n"; echo "</tr>\n"; } if ($other_exps) { echo "<tr><td colspan=3>\n {$other_exps} experiments in other projects</td></tr>\n"; } echo "</table>\n"; } }
function ExperimentList($listify = 1) { $pid = $this->pid(); $gid = $this->gid(); $query_result = DBQueryFatal("select idx from experiments " . "where pid='{$pid}' and gid='{$gid}'"); if (!$listify) { return mysql_num_rows($query_result); } # Else, create a list of the groups. $result = array(); while ($row = mysql_fetch_array($query_result)) { $idx = $row["idx"]; if (!($experiment = Experiment::Lookup($idx))) { TBERROR("Group::ExperimentList: " . "Could not load experiment {$idx}!", 1); } $result[] = $experiment; } return $result; }
function find_free_id($prefix) { global $ELABINELAB, $TBADMINGROUP, $interfaces; # # When inside an inner emulab, we have to ask the outer emulab for # our nodeid; we cannot just pick one out of a hat, at least not yet. # if ($ELABINELAB) { $arghash = array(); $arghash["mac"] = $interfaces[0]["mac"]; $results = XMLRPC("nobody", $TBADMINGROUP, "elabinelab.newnode_info", $arghash); if (!$results || !isset($results['nodeid'])) { echo "Could not get nodeid from XMLRPC server; quitting.\n"; exit; } elseif (preg_match("/^(.*[^\\d])(\\d+)\$/", $results['nodeid'], $matches)) { $base = $matches[1]; $number = $matches[2]; return array($base, intval($number)); } else { $nodeid = $results['nodeid']; echo "Improper nodeid ({$nodeid}) from XMLRPC server; quitting.\n"; exit; } } # # First, check to see if there's a recent entry in new_nodes we can name # this node after # $query_result = DBQueryFatal("select node_id from new_nodes " . "order by created desc limit 1"); if (mysql_num_rows($query_result)) { $row = mysql_fetch_array($query_result); $old_node_id = $row[0]; # # Try to figure out if this is in some format we can increment # if (preg_match("/^(.*[^\\d])(\\d+)\$/", $old_node_id, $matches)) { echo "Matches pcXXX format"; # pcXXX format $base = $matches[1]; $number = $matches[2]; $potential_name = $base . ($number + 1); if (!check_node_exists($potential_name)) { return array($base, $number + 1); } } elseif (preg_match("/^(.*)-([a-zA-Z])\$/", $old_node_id, $matches)) { # Something like WAIL's (type-rack-A) format $base = $matches[1]; $lastchar = $matches[2]; $newchar = chr(ord($lastchar) + 1); $potential_name = $base . '-' . $newchar; if (!check_node_exists($potential_name)) { return array($base . '-', $newchar); } } } # # Okay, that didn't work. # Just go through the nodes and new_nodes tables looking for one that # hasn't been used yet - put in a silly little guard to prevent an # infinite loop in case of bugs. # $node_number = 0; while ($node_number < 10000) { $node_number++; $potential_name = $prefix . $node_number; if (!check_node_exists($potential_name)) { break; } } return array($prefix, $node_number); }
include "defs.php3"; # No Pageheader since we spit out a redirection below. $this_user = CheckLoginOrDie(); $uid = $this_user->uid(); $isadmin = ISADMIN(); PAGEHEADER("Portal Login"); if (!($PORTAL_ENABLE && $PORTAL_ISPRIMARY)) { USERERROR("Not a Portal", 1); } # # Verify page arguments. project_title is the project to zap to. # $reqargs = RequiredPageArguments("peer", PAGEARG_STRING); $optargs = OptionalPageArguments("user", PAGEARG_USER); $safe_peer = addslashes($peer); $query_result = DBQueryFatal("select * from emulab_peers " . "where name='{$safe_peer}' or urn='{$safe_peer}'"); if (!mysql_num_rows($query_result)) { USERERROR("Unknown peer: {$peer}", 1); } $row = mysql_fetch_array($query_result); $urn = $row['urn']; $url = $row['weburl']; # # Allow admin to xlogin as another user. # if (isset($user) && !$this_user->SameUser($user)) { if ($isadmin) { $uid = $user->uid(); } else { USERERROR("Not allowed to login as another user", 1); }
# $query_result = DBQueryFatal("select phys_nodeid,count(phys_nodeid) as vcount " . " from reserved as r " . "left join nodes as n on n.node_id=r.node_id " . "where n.node_id!=n.phys_nodeid and " . " r.sharing_mode is not null " . "group by phys_nodeid"); while ($row = mysql_fetch_array($query_result)) { $node_id = $row["phys_nodeid"]; $count = $row["vcount"]; $counts[$node_id] = $count; } # # Get the distinct set of nodes using the shared nodes. # $query_result = DBQueryFatal("select r.node_id from reserved as r " . "left join nodes as n on n.node_id=r.node_id " . "left join reserved as r2 on r2.node_id=n.phys_nodeid " . "where n.node_id!=n.phys_nodeid and " . " r.sharing_mode is not null and " . " r2.pid='{$pid}' and " . " (r2.eid='{$eid}' or r2.eid='shared-pcpg') " . "order by node_id"); while ($row = mysql_fetch_array($query_result)) { $node_id = $row["node_id"]; $nodes[$node_id] = $node_id; } $query_result = DBQueryFatal("select ru.*,r.node_id,n.type,n.def_boot_osid,o.osname, " . " ns.status as nodestatus, " . " date_format(rsrv_time,\"%Y-%m-%d %T\") as rsrvtime " . "from reserved as r " . "left join nodes as n on n.node_id=r.node_id " . "left join node_types as nt on nt.type=n.type " . "left join node_status as ns on ns.node_id=r.node_id " . "left join node_rusage as ru on ru.node_id=r.node_id " . "left join os_info as o on o.osid=n.def_boot_osid " . "where r.pid='{$pid}' and (r.eid='{$eid}' or r.eid='shared-pcpg') " . "order BY rsrvtime"); $url = CreateURL("showexp", $experiment); echo "These are the nodes in the <a href='{$url}'>shared pool</a>. "; echo "Please see the <a href='{$WIKIDOCURL}/SharedNodes'>documentation</a> "; echo "on how to use shared nodes in your experiment.<br>"; echo "<table width=\"100%\" border=2 cellpadding=1 cellspacing=2 \n id='pooltable' align='center'>\n"; echo "<thead class='sort'>"; echo "<tr>\n <th>NodeID</th>\n\t <th>Type</th>\n <th>Reserved</th>\n <th>Default OSID</th>\n <th>Count</th>\n <th>Node<br>Status</th>\n <th>Load Avg<br>1min/5min</th>\n"; echo "</tr>\n"; echo "</thead>\n"; while ($row = mysql_fetch_array($query_result)) { $node_id = $row["node_id"]; $rsrvtime = $row["rsrvtime"]; $type = $row["type"]; $status = $row["nodestatus"]; $osname = $row["osname"];
} else { $clauses = array(); $clause = ""; if ($tag) { $clauses[] = "tag='{$tag}'"; } if ($datetime) { $clauses[] = "allocated>" . strtotime($datetime); } if ($record) { $clauses[] = "history_id>{$record}"; } if (count($clauses)) { $clause = "where " . join(" and ", $clauses); } $query_result = DBQueryFatal("select v.*,s.pid,s.eid, " . " from_unixtime(allocated) as allocated, " . " from_unixtime(released) as released " . " from vlantag_history as v " . "left join experiment_stats as s on s.exptidx=v.exptidx " . "{$clause} " . "order by history_id limit {$count}"); } if (mysql_num_rows($query_result)) { $num_records = mysql_num_rows($query_result); # Keep track of history record bounds, for paging through. $max_history_id = 0; # Build up table contents. $html = ""; while ($row = mysql_fetch_array($query_result)) { $thistag = $row["tag"]; $exptidx = $row["exptidx"]; $pid = $row["pid"]; $eid = $row["eid"]; $alloc = $row["allocated"]; $id = 0; $slice = "--";
function NSFile() { $input_data_idx = $this->input_data_idx(); if (!$input_data_idx) { return null; } $query_result = DBQueryFatal("select input from experiment_input_data " . "where idx='{$input_data_idx}'"); if (!mysql_num_rows($query_result)) { return null; } $row = mysql_fetch_array($query_result); return $row["input"]; }
if (!isset($sortby)) { $sortby = "created"; } $sortclause = ""; if ($sortby == "created") { $sortclause = "order by created"; } elseif ($sortby == "urn") { $sortclause = "order by urn"; } elseif ($sortby == "commonname") { $sortclause = "order by commonname"; } elseif ($sortby == "buildinfo") { $sortclause = "order by buildinfo"; } elseif ($sortby == "updated") { $sortclause = "order by updated"; } $sites_result = DBQueryFatal("SELECT * from emulab_sites {$sortclause}"); echo "<table width='100%' border=2 id='sitelist'\n cellpadding=2 cellspacing=2 align=center>\n"; echo "<tr>\n"; echo " <th><a href='showsite_list.php?sortby=urn'>URN</a></th>\n"; echo " <th><a href='showsite_list.php?sortby=created'>Created</a></th>\n"; echo " <th><a href='showsite_list.php?sortby=buildinfo'>Last Build</a></th>\n"; echo " <th>OS Vers</th>\n"; echo "</tr>\n"; echo "<tr>\n"; echo " <th><a href='showsite_list.php?sortby=commonname'>Boss Name</a></th>\n"; echo " <th><a href='showsite_list.php?sortby=updated'>Updated</a></th>\n"; echo " <th>Commit Hash</th>\n"; echo " <th>Perl Vers</th>\n"; echo "</tr>\n"; while ($row = mysql_fetch_array($sites_result)) { $urn = substr($row["urn"], strlen("urn:publicid:IDN+"));
function DoesXen($does) { $imageid = $this->imageid(); if ($does) { $parentosinfo = OSinfo::LookupByName("emulab-ops", "XEN41-64-STD"); if (!$parentosinfo) { return -1; } $parentosid = $parentosinfo->osid(); DBQueryFatal("update os_info set def_parentosid='{$parentosid}' " . "where osid='{$imageid}'"); DBQueryFatal("replace into os_submap set " . " osid='{$imageid}', parent_osid='{$parentosid}'"); DBQueryFatal("replace into osidtoimageid set " . " osid='{$imageid}', type='pcvm', imageid='{$imageid}'"); } else { DBQueryFatal("delete from osidtoimageid " . "where osid='{$imageid}' and type='pcvm'"); DBQueryFatal("delete from os_submap " . "where osid='{$imageid}'"); DBQueryFatal("update os_info set def_parentosid=NULL " . "where osid='{$imageid}'"); } return 0; }
function GetPubs($where_clause, $deleted_clause = '!`deleted`') { return DBQueryFatal("select p.*,m.month_name,if(category = '',1,0) as category_sort from emulab_pubs as p natural join emulab_pubs_month_map as m where {$where_clause} and {$deleted_clause} order by category_sort,category,year desc,month desc,title"); }
if (!count($match_targets)) { if ($check) { SPITMSG("update=no"); } else { SPITNOTHING(); } } else { if ($check) { SPITMSG("update=yes"); } } # # Now, for each target matched, grab the file-to-send info, and pack them up. # We just grab everything cause it's cheap and there's no better way. # $qres = DBQueryFatal("select of.type as type,of.path as path," . " of.dest as dest,of.file_idx as file_idx" . " from osconfig_targets as ot" . " left join osconfig_files as of" . " on ot.target_file_idx=of.file_idx" . " where ot.target_apply='" . addslashes($env) . "'" . " group by of.file_idx" . " order by of.prio desc"); $done = array(); $files = array(); $manifest_str = ""; $i = 0; while ($row = mysql_fetch_array($qres)) { if (in_array($row['file_idx'], $match_targets) && !in_array($row['file_idx'], $done)) { $files[$i++] = $row["path"]; $manifest_str .= $row["path"] . "\t" . $row["type"] . "\t" . $row["dest"] . "\n"; array_push($done, $row['file_idx']); } } # make a random dir for tar use. while (TRUE) { $randdir = "/tmp/osconfig." . rand(100, 10000); if (mkdir($randdir)) {
return; } # # Check the login table for the user, and see if the key is really # the md5 of the login hash. If so, do a login. # $target_uid = $user->uid(); $safe_key = addslashes($key); $query_result = DBQueryFatal("select * from login " . "where uid='{$target_uid}' and hashhash='{$safe_key}' and " . " timeout > UNIX_TIMESTAMP(now())"); if (!mysql_num_rows($query_result)) { # Short delay. sleep(1); PAGEERROR("Invalid peer login request"); } # Delete the entry so it cannot be reused, even on failure. DBQueryFatal("delete from login " . "where uid='{$target_uid}' and hashhash='{$safe_key}'"); # # Now do the login, which can still fail. # $dologin_status = DOLOGIN($user->uid(), "", 0, 1); if ($dologin_status == DOLOGIN_STATUS_WEBFREEZE) { # Short delay. sleep(1); PAGEHEADER("Login"); echo "<h3>\n Your account has been frozen due to earlier login attempt\n failures. You must contact {$TBMAILADDR} to have your account\n restored. <br> <br>\n Please do not attempt to login again; it will not work!\n </h3>\n"; PAGEFOOTER(); die(""); } else { if ($dologin_status != DOLOGIN_STATUS_OKAY) { # Short delay. sleep(1);
function SliverList($slice) { $result = array(); $dblink = GetDBLink("sa"); $slice_idx = $slice->idx(); if (!$dblink) { return null; } $query_result = DBQueryFatal("select idx from client_slivers " . "where slice_idx='{$slice_idx}'", $dblink); if (!($query_result && mysql_num_rows($query_result))) { return null; } while ($row = mysql_fetch_array($query_result)) { $idx = $row["idx"]; if (!($sliver = ClientSliver::Lookup($idx))) { TBERROR("ClientSliver::SliverList: " . "Could not load client sliver {$idx}!", 1); } $result[] = $sliver; } return $result; }
# $this_user = CheckLoginOrDie(); $uid = $this_user->uid(); $isadmin = ISADMIN(); if (!$isadmin && !STUDLY()) { USERERROR("You are not allowed to view this page!", 1); } # # Verify page arguments. # $optargs = OptionalPageArguments("type", PAGEARG_STRING); # # Standard Testbed Header # PAGEHEADER("Node Control Center"); $query_result = DBQueryFatal("select n.inception,util.*, " . " UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(n.inception) as age " . " from node_utilization as util " . "left join nodes as n on n.node_id=util.node_id " . "left join node_types as t on t.type=n.type " . "where n.inception is not null and t.class='pc' and " . " role='testnode'" . "order BY priority"); if (mysql_num_rows($query_result) == 0) { echo "<center>Oops, no nodes to show you!</center>"; PAGEFOOTER(); exit; } echo "<center>\n <table id='nodetable' align=center cellpadding=2 border=1>\n <thead class='sort'>\n <tr>\n <th>Node ID</th>\n <th>Inception Date</th>\n <th align=center>Age<br>(seconds)</th>\n <th align=center>Free<br>(seconds)</th>\n <th align=center>Free<br>(percent)</th>\n <th align=center>Alloc<br>(seconds)</th>\n <th align=center>Alloc<br>(percent)</th>\n <th align=center>Down<br>(seconds)</th>\n <th align=center>Down<br>(percent)</th>\n </tr>\n </thead>\n"; while ($row = mysql_fetch_array($query_result)) { $node_id = $row["node_id"]; $inception = $row["inception"]; $age = $row["age"]; $alloctime = $row["allocated"]; $downtime = $row["down"]; $freetime = $age - ($alloctime + $downtime); $allocpercent = sprintf("%.3f", $alloctime / $age * 100); $freepercent = sprintf("%.3f", $freetime / $age * 100);
include "table_defs.php"; # # # Only known and logged in users allowed. # $this_user = CheckLoginOrDie(); $uid = $this_user->uid(); $isadmin = ISADMIN(); # # Standard Testbed Header # PAGEHEADER("Node Type List"); # # Get the list. # $query_result = DBQueryFatal("select * from node_types order by class,type"); if ($isadmin) { SUBPAGESTART(); SUBMENUSTART("More Options"); WRITESUBMENUBUTTON("Create a PC type", "editnodetype.php3?new_type=1&node_class=pc"); WRITESUBMENUBUTTON("Create a Switch type", "editnodetype.php3?new_type=1&node_class=switch"); WRITESUBMENUBUTTON("Create a device type", "editnodetype.php3?new_type=1&node_class=device"); SUBMENUEND(); } echo "<br>"; echo "Note that many types in this list are not accessible to most users"; if ($isadmin) { SUBPAGEEND(); } if (mysql_num_rows($query_result)) { $table = array('#id' => 'nodetypelist', '#title' => "Node Type List", '#sortable' => "yes", '#headings' => array("class" => "Class", "type" => "Type", "isvirt" => "IsVirt", "isrem" => "IsRem", "isdyn" => "IsDyn", "isfed" => "IsFed", "issw" => "IsSwch", "isjail" => "IsJail", "issub" => "IsSub"));
function WebCamAllowed() { $uid_idx = $this->uid_idx(); $query_result = DBQueryFatal("select distinct class from group_membership as g " . "left join nodetypeXpid_permissions as p on " . " g.pid=p.pid " . "left join node_types as nt on nt.type=p.type " . "where g.uid_idx='{$uid_idx}' and class='robot'"); return mysql_num_rows($query_result); }
PAGEFOOTER(); } else { $update_list = array("last_edit = now()", "`last_edit_by` = {$uid_idx}"); $update_start = count($update_list); if (!isset($formfields['deleted'])) { $formfields['deleted'] = false; } # determine what changed foreach ($dbfields as $f) { if (isset($formfields[$f]) && $defaults[$f] != $formfields[$f]) { $dbname = $f; $value = @$formfields[$f]; array_push($update_list, "`" . $dbname . "` = \"" . mysql_escape_string($value) . '"'); } } if (count($update_list) > $update_start) { DBQueryFatal("update emulab_pubs set " . implode(",", $update_list) . " where idx = {$idx}"); if (!$formfields['deleted']) { echo "<p>The following publication was Updated:</p>\n"; ConfirmationCommon(); } else { echo "<p>The following publication was deleted. "; echo "To undelete simply edit it again and unclick \"Mark As Deleted\"</p>\n"; ConfirmationCommon(true); } } else { echo "<p>Nothing has changed for the following pub:</p>"; ConfirmationCommon(); } PAGEFOOTER(); }
function ShowStats() { $pid_idx = $this->pid_idx(); $query_result = DBQueryFatal("select * from project_stats " . "where pid_idx='{$pid_idx}'"); if (!mysql_num_rows($query_result)) { return; } $row = mysql_fetch_assoc($query_result); # # Not pretty printed yet. # echo "<table align=center border=1>\n"; foreach ($row as $key => $value) { echo "<tr>\n <td>{$key}:</td>\n <td>{$value}</td>\n </tr>\n"; } echo "</table>\n"; }