# Only known and logged in users ... # $this_user = CheckLoginOrDie(); $uid = $this_user->uid(); $isadmin = ISADMIN(); # # Verify page arguments. # $reqargs = RequiredPageArguments("instance", PAGEARG_INSTANCE); $optargs = OptionalPageArguments("runidx", PAGEARG_INTEGER, "srcvnode", PAGEARG_STRING, "dstvnode", PAGEARG_STRING, "graphtype", PAGEARG_STRING); $template = $instance->template(); # Optional runidx for graphing just a specific run. $runarg = ""; $vnodes = ""; if (isset($runidx) && $runidx != "") { if (!TBvalid_integer($runidx)) { PAGEARGERROR("Invalid characters in run index!"); } else { $runarg = "-r {$runidx}"; } } # Optional src and dst arguments. if (isset($srcvnode) && $srcvnode != "") { if (!preg_match("/^[-\\w\\/]*\$/", $srcvnode)) { PAGEARGERROR("Invalid characters in src vnode!"); } else { $vnodes .= " -s " . escapeshellarg($srcvnode); } } if (isset($dstvnode) && $dstvnode != "") { if (!preg_match("/^[-\\w\\/]*\$/", $dstvnode)) {
function Show($which, $zoom, $detail) { global $pid, $eid, $uid, $TBSUEXEC_PATH, $TBADMINGROUP; global $template, $isadmin; $html = ""; if ($which == "vis") { if ($zoom == 0) { # Default is whatever we have; to avoid regen of the image. list($zoom, $detail) = $template->CurrentVisDetails(); } else { # Sanity check but lets not worry about throwing an error. if (!TBvalid_float($zoom)) { $zoom = 1.25; } if (!TBvalid_integer($detail)) { $detail = 1; } } ob_start(); $template->ShowVis($zoom, $detail); $html = ob_get_contents(); ob_end_clean(); $zoomout = sprintf("%.2f", $zoom / 1.25); $zoomin = sprintf("%.2f", $zoom * 1.25); $html .= "<button name=viszoomout type=button value={$zoomout}"; $html .= " onclick=\"VisChange('{$zoomout}', {$detail});\">"; $html .= "Zoom Out</button>\n"; $html .= "<button name=viszoomin type=button value={$zoomin}"; $html .= " onclick=\"VisChange('{$zoomin}', {$detail});\">"; $html .= "Zoom In</button>\n"; if ($detail) { $html .= "<button name=hidedetail type=button value=0"; $html .= " onclick=\"VisChange('{$zoom}', 0);\">"; $html .= "Hide Details</button>\n"; } else { $html .= "<button name=showdetail type=button value=1"; $html .= " onclick=\"VisChange('{$zoom}', 1);\">"; $html .= "Show Details</button>\n"; } } elseif ($which == "graph") { ob_start(); $template->ShowGraph(); $html = ob_get_contents(); ob_end_clean(); if (!$template->IsRoot()) { if ($template->IsHidden()) { $html .= "<button name=showtemplate type=button value=Show"; $html .= " onclick=\"GraphChange('showtemplate');\">"; $html .= "Show Template</button> "; } else { $html .= "<button name=hidetemplate type=button value=Hide"; $html .= " onclick=\"GraphChange('hidetemplate');\">"; $html .= "Hide Template</button> "; } $html .= "<input id=showexp_recursive type=checkbox value=Yep> "; $html .= "Recursive?         "; } $root = Template::LookupRoot($template->guid()); # We overload the hidden bit on the root. if ($root->IsHidden()) { $html .= "<button name=showhidden type=button value=showhidden"; $html .= " onclick=\"GraphChange('showhidden');\">"; $html .= "Show Hidden Templates</button>        "; } else { $html .= "<button name=hidehidden type=button value=hidehidden"; $html .= " onclick=\"GraphChange('hidehidden');\"> "; $html .= "Hide Hidden Templates</button>        "; } $html .= "<button name=zoomout type=button value=out"; $html .= " onclick=\"GraphChange('zoomout');\">Zoom Out</button>\n"; $html .= "<button name=zoomin type=button value=in"; $html .= " onclick=\"GraphChange('zoomin');\">Zoom In</button>\n"; # A delete button with a confirm box right there. if ($isadmin) { $html .= "<br><br>\n"; $html .= "<button name=deletetemplate type=button value=Delete"; $html .= " onclick=\"DeleteTemplate();\">"; $html .= "<font color=red>Delete</font></button> "; $html .= "<input id=confirm_delete type=checkbox value=Yep> "; $html .= "Confirm"; } } elseif ($which == "nsfile") { $nsdata = ""; $input_list = $template->InputFiles(); for ($i = 0; $i < count($input_list); $i++) { $nsdata .= htmlentities($input_list[$i]); $nsdata .= "\n\n"; } $html = "<pre><div align=left class=\"showexp_codeblock\">" . "{$nsdata}</div></pre>\n"; $html .= "<button name=savens type=button value=1"; $html .= " onclick=\"SaveNS();\">"; $html .= "Save</button>\n"; } return $html; }
$defaults["exp_autoswap_timeout"] = TBGetSiteVar("general/autoswap_threshold"); # # Optional replay instance/run. # unset($replay_instance); if (isset($replay_instance_idx)) { if (!TBvalid_integer($replay_instance_idx)) { PAGEARGERROR("Invalid characters in replay instance IDX!"); } $replay_instance = TemplateInstance::LookupByExptidx($replay_instance_idx); if (!$replay_instance) { USERERROR("No such instance {$replay_instance_idx} in template!", 1); } $defaults["replay_instance_idx"] = $replay_instance_idx; if (isset($replay_run_idx)) { if (!TBvalid_integer($replay_run_idx)) { PAGEARGERROR("Invalid characters in replay run IDX!"); } $replay_instance->RunBindings($parameters); $defaults["replay_run_idx"] = $replay_run_idx; } else { $replay_instance->Bindings($parameters); } } else { # # Look for formal parameters that the user can specify. # $template->FormalParameters($parameters); } # # Allow formfields that are already set to override defaults