Ejemplo n.º 1
0
        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 a redirect
#
if (isset($HTTP_REFERER) && $HTTP_REFERER != "" && strpos($HTTP_REFERER, $_SERVER["SCRIPT_NAME"]) === false) {
    # Make sure the referer is not me!
    header("Location: {$HTTP_REFERER}");
} elseif ($zapurl) {
    header("Location: {$zapurl}");
} else {
    header("Location: {$TBBASE}/showuser.php3");
}
Ejemplo n.º 2
0
$isadmin = ISADMIN();
#
# Verify page arguments.
#
$reqargs = RequiredPageArguments("instance", PAGEARG_INSTANCE, "runidx", PAGEARG_INTEGER);
$template = $instance->GetTemplate();
# Need these below.
$guid = $template->guid();
$vers = $template->vers();
$pid = $template->pid();
$eid = $instance->eid();
if (!$template->AccessCheck($this_user, $TB_EXPT_READINFO)) {
    USERERROR("You do not have permission to view experiment template " . "{$guid}/{$version}!", 1);
}
if (!$instance->ValidRun($runidx)) {
    USERERROR("The run {$runidx} is not a valid experiment run!", 1);
}
#
# For the Sajax Interface
#
function ModifyAnno($newtext)
{
    global $this_user, $template, $instance, $runidx;
    $instance->SetRunAnnotation($this_user, $runidx, $newtext);
    return 0;
}
#
# See if this request is to the above function. Does not return
# if it is. Otherwise return and continue on.
#
sajax_handle_client_request();
Ejemplo n.º 3
0
        } else {
            echo "<tr>\n                   <td class='pad4'>Your auto-generated NS file: &nbsp</td>\n                       <input type=hidden name=\"formfields[nsref]\"\n                              value={$nsref}>\n                   <td class='pad4'>\n                       <a target=_blank href=spitnsdata.php3?nsref={$nsref}>\n                       View NS File</a></td>\n                 </tr>\n";
        }
    } else {
        echo "<tr>\n                  <td class='pad4'>Your NS file: </td>\n                  <td><table cellspacing=0 cellpadding=0 border=0>\n                    <tr>\n                      <td class='pad4'>Upload<br>\n\t\t\t<font size='-1'>(500k&nbsp;max)</font></td>\n                      <td class='pad4'>\n                        <input type=hidden name=MAX_FILE_SIZE value=512000>\n\t                <input type=file\n                               name=nsfile\n                               value=\"" . $formfields["nsfile"] . "\"\n\t                       size=30>\n                      </td>\n                    </tr><tr>\n                    <td>&nbsp;&nbsp;<b>or</b></td><td></td>\n                    </tr><tr>\n                      <td class='pad4'>On Server<br>\n                              <font size='-1'>({$TBVALIDDIRS_HTML})</font></td>\n                      <td class='pad4'>\n\t                <input type=text\n                               name=\"formfields[localnsfile]\"\n                               value=\"" . $formfields["localnsfile"] . "\"\n\t                       size=40>\n                      </td>\n                     </tr>\n                     </table>\n                   </td>\n               </tr>\n";
    }
    echo "<tr>\n              <td colspan=2>\n               Use this text area to describe your template:\n              </td>\n          </tr>\n          <tr>\n              <td colspan=2 align=center class=left>\n                  <textarea name=\"formfields[description]\"\n                    rows=10 cols=80>" . str_replace("\r", "", $formfields["description"]) . "</textarea>\n              </td>\n          </tr>\n";
    echo "<tr>\n              <td class='pad4' align=center colspan=2>\n                <b><input type=submit name=create value='Create Template'></b>\n              </td>\n         </tr>\n        </form>\n        </table>\n";
    echo "<blockquote><blockquote>\n          <ol>\n            <li> Please read this\n                <a href='{$WIKIDOCURL}/kb112'>KB entry</a>\n                to see what NS extensions are available for templates.\n          </ol>\n          </blockquote></blockquote>\n";
}
#
# See what projects the uid can create experiments in. Must be at least one.
#
$projlist = $this_user->ProjectAccessList($TB_PROJECT_CREATEEXPT);
if (!count($projlist)) {
    USERERROR("You do not appear to be a member of any Projects in which " . "you have permission to create new experiment templates.", 1);
}
#
# On first load, display virgin form and exit.
#
if (!isset($create)) {
    $defaults = array();
    $defaults["pid"] = "";
    $defaults["gid"] = "";
    $defaults["tid"] = "";
    $defaults["pid"] = "";
    $defaults["description"] = "";
    $defaults["localnsfile"] = "";
    $defaults["nsfile"] = "";
    # Multipart data.
    #
Ejemplo n.º 4
0
#
# A cleanup function to keep the child from becoming a zombie, since
# the script is terminated, but the children are left to roam.
#
$fp = 0;
function SPEWCLEANUP()
{
    global $fp;
    if (!$fp || !connection_aborted()) {
        exit;
    }
    pclose($fp);
    exit;
}
register_shutdown_function("SPEWCLEANUP");
if ($fp = popen("{$TBSUEXEC_PATH} {$uid} {$unix_pid} webspewevents -w {$pid} {$eid}", "r")) {
    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 (!feof($fp)) {
        $string = fgets($fp, 1024);
        echo "{$string}";
        flush();
    }
    pclose($fp);
    $fp = 0;
} else {
    USERERROR("Experiment {$pid}/{$eid} is no longer in transition!", 1);
}
Ejemplo n.º 5
0
echo "</center>\n";
foreach ($showtypes as $type) {
    if ($type == "cm" && isset($query) && $query != $defaultsearchstring) {
        $slicelist = array();
        $uuidlist = array();
        $safe_query = escapeshellarg($query);
        $fp = popen("{$TBSUEXEC_PATH} {$uid} nobody " . "webmaptoslice -w {$safe_query}", "r");
        if (!$fp) {
            TBERROR("Could not start maptoslice: {$safe_query}", 1);
        }
        while ($line = fgets($fp)) {
            $uuidlist[] = rtrim($line);
        }
        $status = pclose($fp);
        if ($status > 0 || !count($uuidlist)) {
            USERERROR("No slices matching your search term", 1);
        } elseif ($status < 0) {
            TBERROR("Could not run maptoslice: {$safe_query}", 1);
        }
        foreach ($uuidlist as $uuid) {
            $slicelist[] = GeniSlice::Lookup($type, $uuid);
        }
    } else {
        $slicelist = GeniSlice::AllSlices($type);
    }
    $which = $type == "cm" ? "Component Manager" : ($type == "sa" ? "Slice Authority" : "Clearing House");
    if (!$slicelist || !count($slicelist)) {
        continue;
    }
    # The form attributes:
    $table = array('#id' => $type, '#title' => $which, '#sortable' => 1, '#headings' => array("idx" => "ID", "hrn" => "HRN", "created" => "Created", "expires" => "Expires"));
Ejemplo n.º 6
0
     }
     if (isset($search) && isset($searchfor)) {
         $safe_searchfor = addslashes($searchfor);
         if (preg_match("/^\\w+\\-\\w+\\-\\w+\\-\\w+\\-\\w+\$/", $searchfor)) {
             $clause = "{$clause} and a.slice_uuid='{$safe_searchfor}' ";
         } elseif (preg_match("/^urn:publicid:IDN\\+[-\\w\\.]+\\+slice\\+[-\\w]*\$/", $searchfor)) {
             $clause = "{$clause} and a.slice_urn='{$safe_searchfor}' ";
         } elseif (preg_match("/^urn:publicid:IDN\\+[-\\w\\.]+\\+user\\+[-\\w]*\$/", $searchfor)) {
             $clause = "{$clause} and a.creator_urn='{$safe_searchfor}' ";
         } elseif (strtotime($searchfor)) {
             $ts = strtotime($searchfor);
             $clause = "{$clause} and ({$ts} >= UNIX_TIMESTAMP(a.created) && " . "(a.destroyed is null or {$ts} <= UNIX_TIMESTAMP(a.destroyed)))";
         } elseif ($searchfor == $searchbox) {
             # Just a press of the ch box, so dump out the CH records.
         } else {
             USERERROR("Invalid search specification", 1);
         }
     }
 }
 $query_result = DBQueryFatal("select a.*,s.idx as slice_idx " . "  from aggregate_history as a " . "left join geni_slices as s on s.uuid=a.slice_uuid " . "where a.type='Aggregate' {$clause} " . "order by a.idx desc limit 20", $dblink);
 $table = array('#id' => 'aggregate', '#title' => "Aggregate History", '#headings' => array("idx" => "ID", "slice_hrn" => "Slice HRN/URN", "creator_hrn" => "Creator HRN/URN", "created" => "Created", "Destroyed" => "Destroyed", "Manifest" => "Manifest"));
 $rows = array();
 $popups = array();
 if (mysql_num_rows($query_result)) {
     while ($row = mysql_fetch_array($query_result)) {
         $idx = $row["idx"];
         $slice_idx = $row["slice_idx"];
         $uuid = $row["uuid"];
         $slice_hrn = $row["slice_hrn"];
         $slice_uuid = $row["slice_uuid"];
         $creator_hrn = $row["creator_hrn"];
Ejemplo n.º 7
0
if (!isset($showtype)) {
    $showtype = 'sa';
}
#
# Standard Testbed Header
#
PAGEHEADER("Geni Slice");
if (!($isadmin || STUDLY())) {
    USERERROR("You do not have permission to view Geni slices!", 1);
}
if (!($showtype == "sa" || $showtype == "cm" || $showtype == "ch")) {
    USERERROR("Improper argument: showtype={$showtype}", 1);
}
$slice = GeniSlice::Lookup($showtype, $slice_idx);
if (!$slice) {
    USERERROR("No such slice {$slice_idx}", 1);
}
function GeneratePopupDiv($id, $text)
{
    return "<div id=\"{$id}\" " . "style='display:none;width:700;height:400;overflow:auto;'>\n" . "{$text}\n" . "</div>\n";
}
$manifestidx = 0;
# The table attributes:
$table = array('#id' => 'form1', '#title' => "Slice {$slice_idx} ({$showtype})");
$rows = array();
$popups = array();
$rows[] = array("idx" => $slice->idx());
$rows[] = array("hrn" => $slice->hrn());
$urn = $slice->urn();
if ($urn) {
    $rows[] = array("urn" => $slice->urn());
Ejemplo n.º 8
0
$isadmin = ISADMIN();
#
# Verify Page Arguments.
#
$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");
Ejemplo n.º 9
0
#
$reqargs = RequiredPageArguments("instance", PAGEARG_INSTANCE);
$optargs = OptionalPageArguments("action", PAGEARG_STRING, "exprun", PAGEARG_STRING, "parameters", PAGEARG_ARRAY, "formfields", PAGEARG_ARRAY);
$template = $instance->GetTemplate();
# Need these below.
$guid = $template->guid();
$vers = $template->vers();
$pid = $template->pid();
$eid = $instance->eid();
$unix_gid = $template->UnixGID();
$exptidx = $instance->exptidx();
$experiment = $instance->GetExperiment();
$project = $template->GetProject();
$unix_pid = $project->unix_gid();
if (!$template->AccessCheck($this_user, $TB_EXPT_MODIFY)) {
    USERERROR("You do not have permission to export in template " . "{$guid}/{$vers}!", 1);
}
#
# Run the script backend
#
function DOIT($instance, $action, $command_options)
{
    global $guid, $vers, $pid, $unix_pid, $unix_gid, $eid, $uid;
    global $deletexmlfile, $parameter_xmlfile;
    $message = "";
    $template = $instance->GetTemplate();
    $experiment = $instance->GetExperiment();
    $command_options = "-e {$eid} " . $command_options;
    if ($action == "start") {
        PAGEHEADER("Start new Run");
        $message = "Starting new experiment run";
Ejemplo n.º 10
0
include_once "template_defs.php";
#
# Only known and logged in users.
#
$this_user = CheckLoginOrDie();
$uid = $this_user->uid();
$isadmin = ISADMIN();
#
# Verify page arguments.
#
$reqargs = RequiredPageArguments("template", PAGEARG_TEMPLATE);
# Need these below.
$guid = $template->guid();
$vers = $template->vers();
if (!$template->AccessCheck($this_user, $TB_EXPT_UPDATE)) {
    USERERROR("You do not have permission to instantiate experiment template " . "{$guid}/{$vers}!", 1);
}
#
# Spit the form out using the array of data.
#
function SPITFORM($template, $formfields, $errors)
{
    PAGEHEADER("Edit Template Events");
    if ($template->EventList($eventlist) != 0) {
        TBERROR("Could not get eventlist for template!", 1);
    }
    $guid = $template->guid();
    $vers = $template->vers();
    echo $template->PageHeader();
    echo "<br>\n";
    echo "<center>\n";
Ejemplo n.º 11
0
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);
echo "<center>\n       <font size=+1>There are {$count} USRP preorders</font><br><br>\n";
echo "<table align=center border=2 cellpadding=5 cellspacing=2>\n      <tr>\n         <td>Total Motherboards:</td>\n         <td align=left>{$total_mobos}</td>\n      </tr>\n      <tr>\n         <td>Total Daughterboards:</td>\n         <td align=left>{$total_dboards}</td>\n      </tr>\n      </table>\n";
Ejemplo n.º 12
0
$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);
    }
}
STARTBUSY("Contacting peer");
#
# Do the xlogin, which gives us back a hash to stick in the redirect URL.
#
SUEXEC($uid, "nobody", "webmanageremote xlogin " . escapeshellarg($urn) . " {$uid}", SUEXEC_ACTION_DIE);
STOPBUSY();
if (!preg_match("/^(\\w*)\$/", $suexec_output, $matches)) {
    TBERROR($suexec_output, 1);
}
$hash = $matches[1];
PAGEREPLACE("{$url}/peer_login.php?user={$uid}&key={$hash}");
Ejemplo n.º 13
0
# Verify page arguments.
#
$reqargs = RequiredPageArguments("instance", PAGEARG_INSTANCE, "runidx", PAGEARG_INTEGER);
$optargs = OptionalPageArguments("submit", PAGEARG_STRING, "referrer", PAGEARG_STRING, "formfields", PAGEARG_ARRAY);
$template = $instance->GetTemplate();
# Need these below.
$pid = $instance->pid();
$eid = $instance->eid();
$gid = $instance->gid();
$project = $instance->Project();
$unix_pid = $project->unix_gid();
$group = Group::LookupByPidGid($pid, $gid);
$unix_gid = $group->unix_gid();
# Permission
if (!$isadmin && !$instance->AccessCheck($this_user, $TB_EXPT_MODIFY)) {
    USERERROR("You do not have permission to change this record!", 1);
}
#
# Standard Testbed Header
#
PAGEHEADER("Revise Run Record");
function SPITFORM($formfields, $errors)
{
    global $instance, $runidx, $TBDB_ARCHIVE_TAGLEN, $referrer;
    $iid = $instance->id();
    $runid = $instance->GetRunID($runidx);
    echo $instance->RunPageHeader($runidx);
    echo "<br><br><center>\n          Revise Record {$runid} in Instance {$iid} </center><br>\n";
    if ($errors) {
        echo "<table class=nogrid\n                     align=center border=0 cellpadding=6 cellspacing=0>\n              <tr>\n                 <th align=center colspan=2>\n                   <font size=+1 color=red>\n                      &nbsp;Oops, please fix the following errors!&nbsp;\n                   </font>\n                 </td>\n              </tr>\n";
        while (list($name, $message) = each($errors)) {
Ejemplo n.º 14
0
{
    global $fp;
    if (connection_aborted() && $fp) {
        pclose($fp);
    }
    exit;
}
register_shutdown_function("SPEWCLEANUP");
ignore_user_abort(1);
# Pass the tag through.
$options = isset($tag) ? "-t " . escapeshellarg($tag) : "";
$options .= " -q {$query} ";
$options .= isset($file) ? " -i " . escapeshellarg($file) : "";
$fp = popen("{$TBSUEXEC_PATH} {$uid} " . "   {$pid},{$gid} webarchive_list {$options} {$archive_idx} {$idx}", "r");
if (!$fp) {
    USERERROR("Archive listing failed!", 1);
}
#
# Yuck. Since we cannot tell php to shut up and not print headers, we have to
# 'merge' headers from the backend with PHPs.
#
while ($line = fgets($fp)) {
    # This indicates the end of headers
    if ($line == "\n") {
        break;
    }
    header(rtrim($line));
}
flush();
fpassthru($fp);
$fp = 0;
Ejemplo n.º 15
0
    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 = "";
#
# Name
#
if (!isset($formfields["name"]) || $formfields["name"] == "") {
    $errors["Metadata Name"] = "Missing Field";
} elseif (!TBvalid_template_metadata_name($formfields["name"])) {
    $errors["Metadata Name"] = TBFieldErrorString();
}
if ($action == "add") {
Ejemplo n.º 16
0
#
# Only known and logged in users can do this.
#
$this_user = CheckLoginOrDie();
$uid = $this_user->uid();
$isadmin = ISADMIN();
#
# Verify page arguments
#
$optargs = OptionalPageArguments("sortby", PAGEARG_STRING);
#
# Standard Testbed Header
#
PAGEHEADER("Emulab Site List");
if (!($isadmin || OPSGUY() || STUDLY())) {
    USERERROR("Cannot view site list.", 1);
}
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";
Ejemplo n.º 17
0
    header("Location: " . CreateURL("template_show", $template));
    return;
}
# Need these below.
$guid = $template->guid();
$vers = $template->vers();
$pid = $template->pid();
$eid = $instance->eid();
$unix_gid = $template->UnixGID();
$project = $template->GetProject();
$unix_pid = $project->unix_gid();
#
# Check permission.
#
if (!$template->AccessCheck($this_user, $TB_EXPT_MODIFY)) {
    USERERROR("You do not have permission to commit experiment template " . "{$guid}/{$vers}!", 1);
}
#
# Confirm
#
if (!isset($confirmed)) {
    PAGEHEADER("Create Template from Instance");
    echo $instance->ExpPageHeader();
    echo "<center><br><font size=+1>\n          Create new Template from instance {$eid} \n             in Template {$guid}/{$vers}?</font>\n";
    $template->Show();
    echo "<br>";
    $instance->Show(0);
    $url = CreateURL("template_commit", $instance);
    echo "<form action='{$url}' method=post>\n";
    echo "<br>\n";
    echo "<br>\n";
Ejemplo n.º 18
0
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
require "defs.php3";
#
# Verify page arguments.
#
$reqargs = RequiredPageArguments("user", PAGEARG_USER, "key", PAGEARG_STRING);
$optargs = OptionalPageArguments("redirected", PAGEARG_BOOLEAN);
if (!$PORTAL_ENABLE) {
    USERERROR("No Portal", 1);
}
#
# Need this extra redirect so that the cookies get set properly.
#
if (!isset($redirected) || $redirected == 0) {
    $uri = $_SERVER['REQUEST_URI'] . "&redirected=1";
    header("Location: https://{$WWWHOST}" . $uri);
    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);
Ejemplo n.º 19
0
$this_user = CheckLoginOrDie();
$uid = $this_user->uid();
$isadmin = ISADMIN();
#
# Verify page arguments.
#
$reqargs = RequiredPageArguments("experiment", PAGEARG_EXPERIMENT);
$optargs = OptionalPageArguments("showevents", PAGEARG_BOOLEAN);
# Need these below.
$pid = $experiment->pid();
$eid = $experiment->eid();
#
# Verify permission.
#
if (!$experiment->AccessCheck($this_user, $TB_EXPT_READINFO)) {
    USERERROR("Not enough permission to view experiment {$pid}/{$eid}", 1);
}
$output = array();
$retval = 0;
if (isset($showevents) && $showevents) {
    $flags = "-v";
} else {
    # Show event summary and firewall info.
    $flags = "-b -e -f";
}
$result = exec("{$TBSUEXEC_PATH} {$uid} {$TBADMINGROUP} webtbreport {$flags} {$pid} {$eid}", $output, $retval);
header("Content-Type: text/plain");
for ($i = 0; $i < count($output); $i++) {
    echo "{$output[$i]}\n";
}
echo "\n";
Ejemplo n.º 20
0
#
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
include "defs.php3";
include_once "node_defs.php";
#
# Only known and logged in users can do this.
#
$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;
}
Ejemplo n.º 21
0
# }}}
#
include "pub_defs.php";
include "form_defs.php";
#
# Only known and logged in users.
#
$this_user = CheckLoginOrDie();
$uid = $this_user->uid();
$uid_idx = $this_user->uid_idx();
$isadmin = ISADMIN();
#
# Verify feature is enabled
#
if (!$PUBSUPPORT) {
    USERERROR("Publication support not enabled.");
}
#
# Verify page arguments.
#
$optargs = OptionalPageArguments("submit", PAGEARG_STRING, "idx", PAGEARG_INTEGER, "formfields", PAGEARG_ARRAY);
#
# Standard Testbed Header
#
PAGEHEADER("Submit Publication");
$also_required = array();
$also_required['article'] = array('conf', 'month');
$typelist = array('article', 'phd thesis', 'masters thesis', 'bachelors thesis', 'techreport', 'unpublished', 'talk', 'software', 'service');
$submit_url = isset($idx) ? CreateURL("submitpub", 'idx', $idx) : CreateURL("submitpub");
#
# Make Month List
Ejemplo n.º 22
0
        header("Content-Type: application/x-tar");
        header("Content-Encoding: x-gzip");
        header("Content-Disposition: attachment; filename={$exptidx}.tgz");
        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
        header("Cache-Control: no-cache, must-revalidate");
        header("Pragma: no-cache");
        flush();
        while (!feof($fp)) {
            $string = fgets($fp, 1024);
            echo "{$string}";
            flush();
        }
        pclose($fp);
        $fp = 0;
    } else {
        USERERROR("Could not export", 1);
    }
    return;
}
#
# Standard mode ...
#
$retval = SUEXEC($uid, "{$unix_pid},{$unix_gid}", "webtemplate_export {$export_args}", SUEXEC_ACTION_IGNORE);
/* Clear the 'loading' indicators above */
if ($retval) {
    CLEARBUSY();
} else {
    STOPBUSY();
}
#
# Fatal Error. Report to the user, even though there is not much he can
Ejemplo n.º 23
0
function VerifyPageArguments($argspec, $required)
{
    global $drewheader;
    if ($drewheader) {
        trigger_error("PAGEHEADER called before VerifyPageArguments " . "(called by RequiredPageArguments or OptionalPageArguments). " . "Won't be able to return proper HTTP status code on Error " . "in " . $_SERVER['SCRIPT_FILENAME'] . ",", E_USER_WARNING);
    }
    $result = array();
    while ($argspec and count($argspec) > 1) {
        $name = array_shift($argspec);
        $type = array_shift($argspec);
        $yep = 0;
        unset($object);
        switch ($type) {
            case PAGEARG_EXPERIMENT:
                if (isset($_REQUEST[URL_EXPERIMENT])) {
                    $idx = $_REQUEST[URL_EXPERIMENT];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_EXPERIMENT, $idx)) {
                        $object = Experiment::Lookup($idx);
                    }
                } elseif (isset($_REQUEST[URL_EXPTIDX])) {
                    $idx = $_REQUEST[URL_EXPTIDX];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_EXPERIMENT, $idx)) {
                        $object = Experiment::Lookup($idx);
                    }
                } elseif (isset($_REQUEST[URL_PID]) && isset($_REQUEST[URL_EID])) {
                    $pid = $_REQUEST[URL_PID];
                    $eid = $_REQUEST[URL_EID];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_PID, $pid) && ValidateArgument(PAGEARG_EID, $eid)) {
                        $object = Experiment::LookupByPidEid($pid, $eid);
                    }
                }
                break;
            case PAGEARG_TEMPLATE:
                if (isset($_REQUEST[URL_GUID]) && isset($_REQUEST[URL_VERS])) {
                    $guid = $_REQUEST[URL_GUID];
                    $vers = $_REQUEST[URL_VERS];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_GUID, $guid) && ValidateArgument(PAGEARG_VERS, $vers)) {
                        $object = Template::Lookup($guid, $vers);
                    }
                } elseif (isset($_REQUEST[URL_TEMPLATE])) {
                    $guidvers = $_REQUEST[URL_TEMPLATE];
                    $yep = 1;
                    if (preg_match("/^([\\d]+)\\/([\\d]+)\$/", $guidvers, $matches)) {
                        $guid = $matches[1];
                        $vers = $matches[2];
                        $object = Template::Lookup($guid, $vers);
                    } else {
                        PAGEARGERROR("Invalid argument for '{$type}': {$guidvers}");
                    }
                }
                break;
            case PAGEARG_INSTANCE:
                if (isset($_REQUEST[URL_INSTANCE])) {
                    $idx = $_REQUEST[URL_INSTANCE];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_INSTANCE, $idx)) {
                        $object = TemplateInstance::LookupByExptidx($idx);
                    }
                }
                break;
            case PAGEARG_METADATA:
                if (isset($_REQUEST[URL_METADATA])) {
                    $guidvers = $_REQUEST[URL_METADATA];
                    $yep = 1;
                    if (preg_match("/^([\\d]+)\\/([\\d]+)\$/", $guidvers, $matches)) {
                        $guid = $matches[1];
                        $vers = $matches[2];
                        $object = TemplateMetadata::Lookup($guid, $vers);
                    } else {
                        PAGEARGERROR("Invalid argument for '{$type}': {$guidvers}");
                    }
                }
                break;
            case PAGEARG_PROJECT:
                if (isset($_REQUEST[URL_PROJECT])) {
                    $idx = $_REQUEST[URL_PROJECT];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_PROJECT, $idx)) {
                        $object = Project::Lookup($idx);
                    }
                } elseif (isset($_REQUEST[URL_PID])) {
                    $pid = $_REQUEST[URL_PID];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_PID, $pid)) {
                        $object = Project::Lookup($pid);
                    }
                }
                break;
            case PAGEARG_GROUP:
                if (isset($_REQUEST[URL_GROUP])) {
                    $idx = $_REQUEST[URL_GROUP];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_GROUP, $idx)) {
                        $object = Group::Lookup($idx);
                    }
                } elseif (isset($_REQUEST[URL_PID]) && isset($_REQUEST[URL_GID])) {
                    $pid = $_REQUEST[URL_PID];
                    $gid = $_REQUEST[URL_GID];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_PID, $pid) && ValidateArgument(PAGEARG_GID, $gid)) {
                        $object = Group::LookupByPidGid($pid, $gid);
                    }
                }
                break;
            case PAGEARG_NODE:
                if (isset($_REQUEST[URL_NODE])) {
                    $idx = $_REQUEST[URL_NODE];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_NODE, $idx)) {
                        $object = Node::Lookup($idx);
                    }
                } elseif (isset($_REQUEST[URL_NODEID])) {
                    $nodeid = $_REQUEST[URL_NODEID];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_NODEID, $nodeid)) {
                        $object = Node::Lookup($nodeid);
                    }
                } elseif (isset($_REQUEST[URL_NODEID_ALT])) {
                    $nodeid = $_REQUEST[URL_NODEID_ALT];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_NODEID, $nodeid)) {
                        $object = Node::Lookup($nodeid);
                    }
                }
                break;
            case PAGEARG_USER:
                if (isset($_REQUEST[URL_USER])) {
                    $idx = $_REQUEST[URL_USER];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_USER, $idx)) {
                        $object = User::Lookup($idx);
                    }
                } elseif (isset($_REQUEST[URL_UID])) {
                    $uid = $_REQUEST[URL_UID];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_UID, $uid)) {
                        $object = User::Lookup($uid);
                    }
                }
                break;
            case PAGEARG_IMAGE:
                if (isset($_REQUEST[URL_IMAGEID])) {
                    $imageid = $_REQUEST[URL_IMAGEID];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_IMAGE, $imageid)) {
                        $object = Image::Lookup($imageid);
                    }
                } elseif (isset($_REQUEST[$name]) && $_REQUEST[$name] != "") {
                    $imageid = $_REQUEST[$name];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_IMAGE, $imageid)) {
                        $object = Image::Lookup($imageid);
                    }
                }
                break;
            case PAGEARG_OSINFO:
                if (isset($_REQUEST[URL_OSID])) {
                    $osid = $_REQUEST[URL_OSID];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_OSINFO, $osid)) {
                        $object = OSinfo::Lookup($osid);
                    }
                }
                break;
            case PAGEARG_BOOLEAN:
                if (isset($_REQUEST[$name]) && $_REQUEST[$name] != "") {
                    $object = $_REQUEST[$name];
                    $yep = 1;
                    if (strcasecmp("{$object}", "yes") == 0 || strcasecmp("{$object}", "1") == 0 || strcasecmp("{$object}", "true") == 0 || strcasecmp("{$object}", "on") == 0) {
                        $object = True;
                    } elseif (strcasecmp("{$object}", "no") == 0 || strcasecmp("{$object}", "0") == 0 || strcasecmp("{$object}", "false") == 0 || strcasecmp("{$object}", "off") == 0) {
                        $object = False;
                    }
                }
                break;
            case PAGEARG_INTEGER:
            case PAGEARG_NUMERIC:
            case PAGEARG_ARRAY:
                if (isset($_REQUEST[$name]) && $_REQUEST[$name] != "") {
                    $object = $_REQUEST[$name];
                    $yep = 1;
                    if (!ValidateArgument($type, $object)) {
                        unset($object);
                    }
                }
                break;
            case PAGEARG_ANYTHING:
                if (isset($_REQUEST[$name])) {
                    $object = $_REQUEST[$name];
                    $yep = 1;
                    # Anything allowed, caller BETTER check it.
                }
                break;
            case PAGEARG_ALPHALIST:
                if (isset($_REQUEST[$name])) {
                    $object = $_REQUEST[$name];
                    if (!preg_match("/^[\\d\\w\\-\\ \\,]+\$/", $object)) {
                        unset($object);
                    } else {
                        $object = preg_split("/[\\,\\;]+\\s*/", $_REQUEST[$name]);
                    }
                }
                break;
            case PAGEARG_STRING:
            default:
                if (isset($_REQUEST[$name])) {
                    $object = $_REQUEST[$name];
                    $yep = 1;
                    # Pages never get arguments with special chars. Check.
                    if (preg_match("/[\\'\"]/", $object)) {
                        $object = htmlspecialchars($object);
                        PAGEARGERROR("Invalid characters in '{$name}': {$object}");
                    }
                }
                break;
            case PAGEARG_PASSWORD:
            default:
                if (isset($_REQUEST[$name])) {
                    $object = $_REQUEST[$name];
                    $yep = 1;
                    # Only printable chars.
                    if (!preg_match("/^[ -~]+\$/", $object)) {
                        PAGEARGERROR("Invalid characters in '{$name}'");
                    }
                }
                break;
            case PAGEARG_LOGFILE:
                if (isset($_REQUEST[URL_LOGFILE])) {
                    $logid = $_REQUEST[URL_LOGFILE];
                    $yep = 1;
                    if (ValidateArgument(PAGEARG_LOGFILE, $logid)) {
                        $object = Logfile::Lookup($logid);
                    }
                }
                break;
        }
        if (isset($object)) {
            $result[$name] = $object;
            $GLOBALS[$name] = $object;
        } elseif ($yep) {
            #
            # Value supplied but could not be mapped to object.
            # Lets make that clear in the error message.
            #
            USERERROR("Could not map page arguments to '{$name}'", 1);
        } elseif ($required) {
            PAGEARGERROR("Must provide '{$name}' page argument");
        } else {
            unset($GLOBALS[$name]);
        }
    }
    return $result;
}
Ejemplo n.º 24
0
        echo "\n";
    }
    return;
}
#
# Standard Testbed Header (do this after checking getdata so we do not spit
# headers if getdata=1 -- of course, if any args are bad, the error msgs will
# be screwed up!)
#
PAGEHEADER("Resource Usage Visualization");
#
# Pull in some style sheets.
#
echo "<link type=text/css rel=stylesheet href={$TBBASE}/rusage_viz.css />\n";
if (!$isadmin) {
    USERERROR("You do not have permission to view the resource usage viz!", 1);
}
#
# Dump some Emulab auth vars for the xmlhttprequests
#
$auth = $HTTP_COOKIE_VARS[$TBAUTHCOOKIE];
echo "<script language=javascript type=text/javascript>\n";
echo "var tbuid = \"{$uid}\";\n";
echo "var tbauth = \"{$auth}\";\n";
#
# Dump the resource, if set
#
if (isset($resource)) {
    echo "var resource = \"{$resource}\";\n";
} else {
    echo "var resource = \"{$defResource}\";\n";
Ejemplo n.º 25
0
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
include "defs.php3";
#
# Only known and logged in users can do this.
#
$this_user = CheckLoginOrDie();
$uid = $this_user->uid();
$isadmin = ISADMIN();
if (!$isadmin) {
    USERERROR("You do not have permission to access this page!", 1);
}
#
# Verify form arguments.
#
$reqargs = RequiredPageArguments("project", PAGEARG_PROJECT);
$optargs = OptionalPageArguments("submit", PAGEARG_STRING, "message", PAGEARG_ANYTHING);
$pid = $project->pid();
PAGEHEADER("Resend Project Approval Message");
#
# Form to allow text input.
#
function SPITFORM($project, $message, $errors)
{
    global $this_user;
    $message = CleanString($message);
Ejemplo n.º 26
0
# Verify page arguments.
#
$optargs = OptionalPageArguments("printable", PAGEARG_BOOLEAN);
#
# Allow for a site specific hardware page. Hopefully this is where the
# bulk of the site specific stuff can go, otherwise we need to get more
# clever about this.
#
$sitefile = "hardware-" . strtolower($THISHOMEBASE) . ".html";
if (!file_exists($sitefile)) {
    if ($TBMAINSITE) {
        header("Location: {$WIKIDOCURL}/UtahHardware");
        return;
    }
    PAGEHEADER("Hardware Overview");
    USERERROR("This Emulab has not established a site-specific hardware page.", 1);
}
if (!isset($printable)) {
    $printable = 0;
}
#
# Standard Testbed Header
#
if (!$printable) {
    PAGEHEADER("Hardware Overview");
}
if (!$printable) {
    echo "<b><a href={$REQUEST_URI}?printable=1>\n             Printable version of this document</a></b><br>\n";
}
readfile("{$sitefile}");
#
Ejemplo n.º 27
0
# Need these below
$guid = $template->guid();
$vers = $template->vers();
$pid = $template->pid();
$eid = $template->eid();
$tid = $template->tid();
$exptidx = $experiment->idx();
$unix_gid = $experiment->UnixGID();
$this_url = CreateURL("template_show", $template);
$project = $template->GetProject();
$unix_pid = $project->unix_gid();
#
# Verify Permission.
#
if (!$template->AccessCheck($this_user, $TB_EXPT_READINFO)) {
    USERERROR("You do not have permission to view experiment " . "template {$guid}/{$vers}", 1);
}
#
# For the Sajax Interface
#
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.
Ejemplo n.º 28
0
#
# Only known and logged in users can look at experiments.
#
$this_user = CheckLoginOrDie();
$uid = $this_user->uid();
$isadmin = ISADMIN();
#
# Verify page arguments.
#
$reqargs = RequiredPageArguments("template", PAGEARG_TEMPLATE);
$optargs = OptionalPageArguments("expand", PAGEARG_INTEGER);
if (!isset($expand)) {
    $expand = 0;
}
#
# Standard Testbed Header after argument checking.
#
PAGEHEADER("Experiment Template History");
#
# Check permission.
#
if (!$template->AccessCheck($this_user, $TB_EXPT_READINFO)) {
    USERERROR("You do not have permission to view experiment template " . "{$guid}/{$version}!", 1);
}
echo $template->PageHeader();
echo "<br><br>\n";
$template->ShowHistory($expand);
#
# Standard Testbed Footer
#
PAGEFOOTER();
Ejemplo n.º 29
0
#
$this_user = CheckLoginOrDie();
$uid = $this_user->uid();
$isadmin = ISADMIN();
if (!$isadmin) {
    USERERROR("You do not have permission to change login names!", 1);
}
#
# Verify page/form arguments.
#
$reqargs = RequiredPageArguments("target_user", PAGEARG_USER);
$optargs = OptionalPageArguments("submit", PAGEARG_STRING, "new_uid", PAGEARG_STRING);
$target_uid = $target_user->uid();
$target_idx = $target_user->uid_idx();
if ($target_user->status() != TBDB_USERSTATUS_UNAPPROVED) {
    USERERROR("The user {$target_uid} must be " . "unapproved (but verified) to change!", 1);
}
function SPITFORM($target_user, $new_uid, $error)
{
    global $TBDB_UIDLEN;
    $target_uid = $target_user->uid();
    $target_webid = $target_user->webid();
    $new_uid = CleanString($new_uid);
    #
    # Standard Testbed Header.
    #
    PAGEHEADER("Change login UID for user");
    if ($error) {
        # XSS prevention.
        $error = CleanString($error);
        echo "<center>\n              <font size=+1 color=red>{$error}</font>\n              </center><br>\n";
Ejemplo n.º 30
0
#
include "defs.php3";
#
# Only known and logged in users allowed.
#
$this_user = CheckLoginOrDie();
if (!ISADMIN()) {
    USERERROR("You do not have permission to do this!", 1);
}
#
# Verify arguments.
#
$reqargs = RequiredPageArguments("target_user", PAGEARG_USER);
$target_uid = $target_user->uid();
if (DOLOGIN_MAGIC($target_user->uid(), $target_user->uid_idx()) < 0) {
    USERERROR("Could not log you in as {$target_uid}", 1);
}
# So the menu and headers get spit out properly.
$_COOKIE[$TBNAMECOOKIE] = $target_uid;
PAGEHEADER("SU as User");
echo "<center>";
echo "<br><br>";
echo "<font size=+2>You are now logged in as <b>{$target_uid}</b></font>\n";
echo "<br><br>";
echo "<font size=+1>Be Careful!</font>\n";
echo "</center>";
sleep(2);
PAGEREPLACE($TBBASE);
#
# Standard Testbed Footer
#