Example #1
0
function EXPERROR()
{
    global $formfields, $errors;
    SPITFORM($formfields, $errors);
    PAGEFOOTER();
    die("");
}
Example #2
0
#
if (!isset($submit)) {
    SPITFORM($target_user, "", null);
    return;
}
# Sanity checks
$error = null;
if (!isset($new_uid) || $new_uid == "") {
    $error = "UID: Must supply a new UID";
} elseif (!TBvalid_uid($new_uid)) {
    $error = "UID: " . TBFieldErrorString();
} elseif (User::Lookup($new_uid) || posix_getpwnam($new_uid)) {
    $error = "UID: Already in use. Pick another";
}
if ($error) {
    SPITFORM($target_user, $new_uid, $error);
    return;
}
#
# Standard Testbed Header.
#
PAGEHEADER("Change login UID for user");
# Okay, call out to backend to change.
STARTBUSY("Changing UID");
#
# Run the backend script.
#
SUEXEC($uid, $TBADMINGROUP, "webchangeuid {$target_idx} {$new_uid}", SUEXEC_ACTION_USERERROR);
# Stop the busy indicator and zap to user page.
STOPBUSY();
PAGEREPLACE(CreateURL("showuser", $target_user));
    }
    if (!file_exists($thensfile)) {
        $errors["NS File"] = "Temp file no longer exists on server";
        SPITFORM($formfields, $errors);
        PAGEFOOTER();
        exit(1);
    }
    $deletensfile = 1;
} elseif ($nsfilelocale == "remote") {
    #
    # The NS file was uploaded to a temp file.
    #
    $thensfile = $_FILES['nsfile']['tmp_name'];
    if (!file_exists($thensfile)) {
        $errors["NS File"] = "Temp file no longer exists on server";
        SPITFORM($formfields, $errors);
        PAGEFOOTER();
        exit(1);
    }
    chmod($thensfile, 0666);
}
#
# Grab the unix GID for running scripts.
#
$unix_gid = $group->unix_gid();
$unix_pid = $project->unix_gid();
# Okay, we can spit back a header now that there is no worry of redirect.
PAGEHEADER("Create an Experiment Template");
echo "<script type='text/javascript' language='javascript' " . "        src='template_sup.js'>\n";
echo "</script>\n";
STARTBUSY("Starting template creation!");
    # Show stuff
    #
    $project->Show();
    $url = CreateURL("resendapproval", $project);
    echo "<br>";
    echo "<table align=center border=1>\n";
    echo "<form action='{$url}' method='post'>\n";
    echo "<tr>\n              <td>Use the text box (70 columns wide) to add a message to the\n                  email notification. </td>\n          </tr>\n";
    echo "<tr>\n             <td align=center class=left>\n                 <textarea name=message rows=15 cols=70></textarea>\n             </td>\n          </tr>\n";
    echo "<tr>\n              <td align=center>\n                  <b><input type='submit' value='Submit' name='submit'></td>\n          </tr>\n          </form>\n          </table>\n";
}
#
# On first load, display a virgin form and exit.
#
if (!isset($submit)) {
    SPITFORM($project, "", null);
    PAGEFOOTER();
    return;
}
# If there is a message in the text box, it is appended below.
if (!isset($message)) {
    $message = "";
}
if (!($leader = $project->GetLeader())) {
    TBERROR("Error getting leader for {$pid}", 1);
}
$headuid = $leader->uid();
$headuid_email = $leader->email();
$headname = $leader->name();
SendProjAdminMail($pid, "ADMIN", "{$headname} '{$headuid}' <{$headuid_email}>", "Project '{$pid}' Approval", "\n" . "This message is to notify you that your project '{$pid}'\n" . "has been approved.  We recommend that you save this link so that\n" . "you can send it to people you wish to have join your project.\n" . "Otherwise, tell them to go to {$TBBASE} and join it.\n" . "\n" . "    {$TBBASE}/joinproject.php3?target_pid={$pid}\n" . "\n" . ($message != "" ? "{$message}\n\n" : "") . "Thanks,\n" . "Testbed Operations\n");
echo "<center>\n      <h2>Done!</h2>\n      </center><br>\n";
    } elseif ($metadata_type == "parameter_description") {
        if (!TBvalid_template_parameter_description($formfields["value"])) {
            $errors["Description"] = TBFieldErrorString();
        }
    } elseif ($metadata_type == "instance_description") {
        if (!TBvalid_template_instance_description($formfields["value"])) {
            $errors["Description"] = TBFieldErrorString();
        }
    } elseif ($metadata_type == "run_description") {
        if (!TBvalid_experiment_run_description($formfields["value"])) {
            $errors["Description"] = TBFieldErrorString();
        }
    }
}
if (count($errors)) {
    SPITFORM($action, $formfields, $errors);
    PAGEFOOTER();
    exit(1);
}
#
# Generate a temporary file and write in the data.
#
if ($action != "delete") {
    list($usec, $sec) = explode(' ', microtime());
    srand((double) $sec + (double) $usec * 100000);
    $foo = rand();
    $datafile = "/tmp/{$uid}-{$foo}.txt";
    if (!($fp = fopen($datafile, "w"))) {
        TBERROR("Could not create temporary file {$datafile}", 1);
    }
    fwrite($fp, $formfields["value"]);
if ($retval) {
    CLEARBUSY();
} else {
    STOPBUSY();
}
#
# Fatal Error. Report to the user, even though there is not much he can
# do with the error. Also reports to tbops.
#
if ($retval < 0) {
    SUEXECERROR(SUEXEC_ACTION_CONTINUE);
}
# User error. Tell user and exit.
if ($retval) {
    if ($retval == 2) {
        SPITFORM("Export directory already exists! Use the overwrite option.");
        PAGEFOOTER();
        return;
    }
    SUEXECERROR(SUEXEC_ACTION_USERERROR);
    return;
}
if (!isset($referrer)) {
    $referrer = CreateURL("template_show", $template);
}
# Zap back to template page.
PAGEREPLACE($referrer);
#
# Standard Testbed Footer
#
PAGEFOOTER();
                TBERROR("Could not create temp file {$parameter_xmlfile}", 1);
            }
            fwrite($fp, "<template_parameters>\n");
            reset($parameter_masterlist);
            while (list($name, $default_value) = each($parameter_masterlist)) {
                if (isset($parameters[$name])) {
                    $value = $parameters[$name];
                } else {
                    $value = $default_value;
                }
                fwrite($fp, " <parameter name=\"{$name}\">");
                fwrite($fp, "<value>{$value}</value></parameter>\n");
            }
            fwrite($fp, "</template_parameters>\n");
            fclose($fp);
            chmod($parameter_xmlfile, 0666);
        }
    }
    $command_options .= " -x {$parameter_xmlfile}";
}
if (count($errors)) {
    SPITFORM($action, $instance, $formfields, $parameters, $errors);
    PAGEFOOTER();
    exit(1);
}
# Run the backend script.
DOIT($instance, $action, $command_options);
#
# Standard Testbed Footer
#
PAGEFOOTER();
    }
    # Modify the arguments
    if (isset($formfields[$args_name]) && $formfields[$args_name] != "{$args}") {
        $newargs = $formfields[$args_name];
        if (!TBcheck_dbslot($newargs, 'eventlist', 'arguments', TBDB_CHECKDBSLOT_WARN | TBDB_CHECKDBSLOT_ERROR)) {
            $errors["{$vname} time"] = TBFieldErrorString();
        } else {
            if (!isset($changes[$vname])) {
                $changes[$vname] = array();
            }
            $changes[$vname]["arguments"] = $newargs;
        }
    }
}
if (count($errors)) {
    SPITFORM($template, $formfields, $errors);
    PAGEFOOTER();
    exit(1);
}
#
# Do the deletes and changes.
#
reset($eventlist);
while (list($index, $dbrow) = each($eventlist)) {
    $vname = $dbrow["vname"];
    if (isset($deletes[$vname])) {
        $template->DeleteEvent($vname);
        continue;
    }
    if (isset($changes[$vname])) {
        $template->ModifyEvent($vname, $changes[$vname]);
if (isset($formfields["replay_instance_idx"]) && $formfields["replay_instance_idx"] != "") {
    if (!preg_match("/^[\\d]+\$/", $formfields["replay_instance_idx"])) {
        $errors["Replay Instance"] = "Invalid replay instance";
    } else {
        $command_options .= " -r " . $formfields["replay_instance_idx"];
    }
    if (isset($formfields["replay_run_idx"]) && $formfields["replay_run_idx"] != "") {
        if (!preg_match("/^[\\d]+\$/", $formfields["replay_run_idx"])) {
            $errors["Replay Run"] = "Invalid replay run";
        } else {
            $command_options .= ":" . $formfields["replay_run_idx"];
        }
    }
}
if (count($errors)) {
    SPITFORM($template, $formfields, $parameters, $errors);
    PAGEFOOTER();
    exit(1);
}
#
# Avoid SIGPROF in child.
#
set_time_limit(0);
# Okay, we can spit back a header now that there is no worry of redirect.
PAGEHEADER("Instantiate Experiment Template");
echo $template->PageHeader();
echo "<font size=+2>, Instance <b>" . MakeLink("project", "pid={$pid}", $pid) . "/" . MakeLink("experiment", "pid={$pid}&eid={$eid}", $eid) . "</b></font>";
echo "<br><br>\n";
echo "<script type='text/javascript' language='javascript' " . "        src='template_sup.js'>\n";
echo "</script>\n";
STARTBUSY("Starting template instantiation!");