} # # Allow formfields that are already set to override defaults # if (isset($formfields)) { while (list($field, $value) = each($formfields)) { $defaults[$field] = $formfields[$field]; } } SPITFORM($defaults, 0); PAGEFOOTER(); return; } # Make sure we got that formfields array! if (!isset($formfields)) { PAGEARGERROR(); } # # Okay, validate form arguments. # $errors = array(); # Some local variables. $nsfilelocale = 0; $thensfile = 0; $deletensfile = 0; # # Project: # if (!isset($formfields["pid"]) || $formfields["pid"] == "") { $errors["Project"] = "Not Selected"; } elseif (!TBvalid_pid($formfields["pid"])) {
function ValidateArgument($name, $arg) { switch ($name) { case PAGEARG_UID: case PAGEARG_PID: case PAGEARG_GID: case PAGEARG_EID: case PAGEARG_NODEID: case PAGEARG_PROJECT: case PAGEARG_GROUP: case PAGEARG_USER: case PAGEARG_EXPERIMENT: case PAGEARG_NODE: case PAGEARG_LOGFILE: if (preg_match("/^[-\\w]+\$/", "{$arg}")) { return 1; } PAGEARGERROR("Invalid argument for '{$name}': {$arg}"); break; case PAGEARG_IMAGEID: case PAGEARG_IMAGE: case PAGEARG_OSID: case PAGEARG_OSINFO: if (preg_match("/^[-\\w\\.\\+]+\$/", "{$arg}")) { return 1; } PAGEARGERROR("Invalid argument for '{$name}': {$arg}"); break; case PAGEARG_GUID: case PAGEARG_VERS: case PAGEARG_INSTANCE: if (preg_match("/^[\\d]+\$/", "{$arg}")) { return 1; } PAGEARGERROR("Invalid argument for '{$name}': {$arg}"); break; case PAGEARG_METADATA: if (preg_match("/^[\\d]+\\/[\\d]+\$/", "{$arg}")) { return 1; } PAGEARGERROR("Invalid argument for '{$name}': {$arg}"); break; case PAGEARG_INTEGER: case PAGEARG_NUMERIC: if (is_numeric($arg)) { return 1; } PAGEARGERROR("Invalid argument for '{$name}': {$arg}"); break; case PAGEARG_ARRAY: if (is_array($arg)) { return 1; } PAGEARGERROR("'{$name}' is not an array: {$arg}"); break; default: TBERROR("ValidateArgument: " . "Unknown argument type - {$name}", 1); } return 0; }
function GraphChange($action, $recursive = 0, $no_output = 0) { global $pid, $unix_gid, $eid, $uid, $guid, $TBSUEXEC_PATH, $TBADMINGROUP; global $template, $unix_pid; $html = ""; $reqarg = "-a "; $versarg = $template->vers(); if ($action == "zoomout" || $action == "zoomin") { $optarg = ""; if ($action == "zoomin") { $optarg = "-z in"; } else { $optarg = "-z out"; } # Need to update the template graph. SUEXEC($uid, "{$unix_pid},{$unix_gid}", "webtemplate_graph {$optarg} {$guid}", SUEXEC_ACTION_DIE); } else { $optarg = $recursive ? "-r" : ""; if ($action == "showtemplate") { $reqarg .= "show"; } elseif ($action == "hidetemplate") { $reqarg .= "hide"; } elseif ($action == "showhidden") { $reqarg .= "showhidden"; # Applies only to root template $versarg = "1"; } elseif ($action == "hidehidden") { $reqarg .= "hidehidden"; # Applies only to root template $versarg = "1"; } elseif ($action == "activate") { $reqarg .= "activate"; } elseif ($action == "inactivate") { $reqarg .= "inactivate"; } else { PAGEARGERROR("Invalid action {$action}"); return; } $reqarg .= " {$guid}/{$versarg}"; SUEXEC($uid, "{$unix_pid},{$unix_gid}", "webtemplate_control {$reqarg} {$optarg}", SUEXEC_ACTION_DIE); } $template->Refresh(); $html = ""; if (!$no_output) { $html = Show("graph", 0, 0); } return $html; }
# function SPITERROR($message = "", $death = 1) { header("Content-type: image/gif"); readfile("coming-soon-thumb.gif"); } $session_interactive = 0; $session_errorhandler = 'SPITERROR'; # # Verify page arguments. # $reqargs = RequiredPageArguments("template", PAGEARG_TEMPLATE); $optargs = OptionalPageArguments("zoom", PAGEARG_STRING); if (isset($zoom)) { if ($zoom != "in" && $zoom != "out") { PAGEARGERROR("Invalid characters in zoom factor!"); } } function SPITGRAPH($template) { $data = NULL; if ($template->GraphImage($data) != 0 || $data == NULL || $data == "") { SPITERROR(); } else { header("Content-type: image/png"); echo "{$data}"; } } # # If the request did not specify a zoom, return whatever we have. #
# We must get the redirection arguments, # $reqargs = RequiredPageArguments("redirect_to", PAGEARG_STRING); # # Check format. Also figure out the target. # if (!preg_match("/^http[s]?:\\/\\/([-\\w\\.]*)\\//", $redirect_to, $matches)) { PAGEARGERROR("Invalid redirection argument!"); } $redirect_host = $matches[1]; # # Right now all we allow is www.datapository.net, and that is really # nfs.emulab.net. # if ($redirect_host != "www.datapository.net" && $redirect_host != "nfs.emulab.net") { PAGEARGERROR("Invalid redirection host '{$redirect_host}'"); } # # Okay, now see if the user is logged in. If not, the user will be # be brought back here after logging in. # $this_user = CheckLoginOrDie(); $uid = $this_user->uid(); $isadmin = ISADMIN(); # # Generate a cookie. # $authhash = GENHASH(); # # Send it over to the server where it will save it. #
if (!isset($formfields)) { if (isset($prevsearch)) { $defaults = $root->SavedSearch(addslashes($prevsearch), $this_user); } else { $defaults = array(); $defaults["searchwhat"] = "this"; $defaults["searchwhich"] = "template"; $defaults["matchif"] = "any"; } SPITFORM($defaults, null); PAGEFOOTER(); return; } # Form submitted. if (!isset($formfields['clausecount']) || $formfields['clausecount'] <= 0 || $formfields['clausecount'] > 20) { PAGEARGERROR("Invalid form arguments."); } # # Old searches. Process a deletion request before generating new list. # if (isset($formfields['deletesearch']) && $formfields['deletesearch'] != "" && TBcheck_dbslot($formfields['deletesearch'], "experiment_template_searches", "name", TBDB_CHECKDBSLOT_WARN | TBDB_CHECKDBSLOT_ERROR)) { $root->DeleteSearch(addslashes($formfields['deletesearch']), $this_user); # # Lets clear the saved search stuff. # unset($formfields['savesearch']); unset($formfields['savename']); } # # Need to generate new clauses for any added previously, plus a new one # if the Add Clause button was pressed. But, have to watch for deleted
$template_vers = $template->vers(); if (!isset($metadata)) { PAGEARGERROR("Must provide a metadata guid"); } $metadata_guid = $metadata->guid(); $metadata_vers = $metadata->vers(); $metadata_type = $metadata->type(); } else { if (!isset($template)) { PAGEARGERROR("Must provide a template guid"); } $template_guid = $template->guid(); $template_vers = $template->vers(); if (isset($metadata_type) && $metadata_type != "") { if (!TBvalid_template_metadata_type($metadata_type)) { PAGEARGERROR("Invalid characters in metadata type!"); } } else { unset($metadata_type); } } # Perm check for add/modify to the template. if (!$template->AccessCheck($this_user, $TB_EXPT_MODIFY)) { USERERROR("You do not have permission to {$action} metadata in " . " template {$template_guid}!", 1); } # # Okay, validate form arguments. # $errors = array(); $command_opts = ""; #
# $this_user = CheckLoginOrDie(); $uid = $this_user->uid(); $isadmin = ISADMIN(); # # Verify page arguments. # $optargs = OptionalPageArguments("instance", PAGEARG_INSTANCE, "template", PAGEARG_TEMPLATE, "canceled", PAGEARG_BOOLEAN, "confirmed", PAGEARG_BOOLEAN, "referrer", PAGEARG_STRING, "runidx", PAGEARG_INTEGER, "tag", PAGEARG_STRING, "overwrite", PAGEARG_BOOLEAN, "spew", PAGEARG_BOOLEAN); # # An instance might be a current or historical. If its a template, use # the underlying experiment of the template. # if (isset($instance)) { $template = $instance->GetTemplate(); } elseif (!isset($template)) { PAGEARGERROR("Must provide a template or an instance to export"); } if (isset($canceled) && $canceled) { if (isset($instance)) { header("Location: " . CreateURL("template_show", $template)); } else { header("Location: " . CreateURL("template_show", $instance)); } return; } # Need these below. $guid = $template->guid(); $vers = $template->vers(); $pid = $template->pid(); $unix_gid = $template->UnixGID(); $project = $template->GetProject();
# $optargs = OptionalPageArguments("slice_idx", PAGEARG_INTEGER, "slice_uuid", PAGEARG_STRING, "download", PAGEARG_BOOLEAN); if (!isset($download)) { $download = 0; } # # Standard Testbed Header # if (!$download) { PAGEHEADER("Geni Slice Logs"); } if (!($isadmin || STUDLY())) { USERERROR("You do not have permission to view Geni slices!", 1); } if (!(isset($slice_idx) || isset($slice_uuid))) { PAGEARGERROR("Must provide a slice idx or UUID"); } $whereclause = isset($slice_idx) ? "where m.metakey='slice_idx' and m.metaval='{$slice_idx}'" : "where m.metakey='slice_uuid' and m.metaval='{$slice_uuid}'"; $urlarg = isset($slice_idx) ? "slice_idx={$slice_idx}" : "slice_uuid={$slice_uuid}"; # # 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' " . "{$whereclause} " . "order by l.date_created asc"); if ($query_result && mysql_num_rows($query_result)) { if ($download) { 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(); while ($row = mysql_fetch_array($query_result)) {
$gid = $experiment->gid(); $eid = $experiment->eid(); $idx = $experiment->idx(); $stats = $experiment->GetStats(); if (!$stats) { TBERROR("Could not load stats object for experiment {$pid}/{$eid}", 1); } $archive_idx = $stats->archive_idx(); # Permission if (!$isadmin && !$experiment->AccessCheck($this_user, $TB_EXPT_READINFO)) { USERERROR("You do not have permission to view this archive!", 1); } } elseif (isset($index)) { $stats = ExperimentStats::Lookup($index); if (!$stats) { PAGEARGERROR("Invalid experiment index: {$index}"); } # Need these below. $pid = $stats->pid(); $eid = $stats->eid(); $gid = $stats->gid(); $idx = $index; $archive_idx = $stats->archive_idx(); # Permission if (!$isadmin && !$stats->AccessCheck($this_user, $TB_PROJECT_READINFO)) { USERERROR("You do not have permission to view tags for " . "archive in {$pid}/{$eid}!", 1); } } # This gets scrubbed ... $query = escapeshellcmd($_SERVER["QUERY_STRING"]); #
} # Must be admin or project/group root. if (!$isadmin && !TBMinTrust(TBGrpTrust($uid, $pid, $pid), $TBDB_TRUST_GROUPROOT)) { USERERROR("You do not have permission to toggle {$type}!", 1); } $zapurl = CreateURL("showproject", $project); $project->SetCVSRepoPublic($value); $unix_pid = $project->unix_gid(); SUEXEC($uid, $unix_pid, "webcvsrepo_ctrl {$pid}", SUEXEC_ACTION_DIE); } elseif ($type == "workbench") { # Must validate the pid since we allow non-admins to do this. if (!TBvalid_pid($pid)) { PAGEARGERROR("Invalid characters in {$pid}"); } if (!($project = Project::Lookup($pid))) { PAGEARGERROR("Project {$pid} is not a valid project!"); } # Must be admin if (!$isadmin) { USERERROR("You do not have permission to toggle {$type}!", 1); } $zapurl = CreateURL("showproject", $project); $project->SetAllowWorkbench($value); } elseif ($type == "hiderun") { RequiredPageArguments("instance", PAGEARG_INSTANCE, "runidx", PAGEARG_INTEGER); if (!$instance->AccessCheck($this_user, $TB_EXPT_MODIFY)) { USERERROR("You do not have permission to modify this instance", 1); } $instance->SetRunHidden($runidx, $value); } else { USERERROR("Nobody has permission to toggle {$type}!", 1);
} # # Spit out the image with a content header. # $eid = $instance->eid(); $pid = $instance->pid(); $guid = $instance->guid(); $vers = $instance->vers(); $exptidx = $instance->exptidx(); $unix_gid = $template->UnixGID(); $which = "pps"; # # Default to pps if no graphtype. # if (isset($graphtype) && $graphtype != "") { if (!preg_match('/^[\\w]*$/', $graphtype)) { PAGEARGERROR("Invalid characters in graphtype!"); } $which = escapeshellarg($graphtype); } if ($fp = popen("{$TBSUEXEC_PATH} {$uid} {$unix_gid} webtemplate_linkgraph " . "-i {$exptidx} {$runarg} {$vnodes} {$guid}/{$vers} {$which}", "r")) { header("Content-type: image/gif"); fpassthru($fp); } else { # No Data. Spit back a stub image. header("Content-type: image/gif"); readfile("coming-soon-thumb.gif"); } # # No Footer! #