Commit 846a98d6 authored by Kevin Atkinson's avatar Kevin Atkinson

If a known user (based on stored cookies) is not logged in than

redirect to the login page rather than printing a message with a link
to the page.  Otherwise send a "403 Forbidden" to keep robots from
indexing the page.  Also send appreciate HTTP responses on other
precheck errors to keep a robot from indexing the page.  In order to
do this the PAGEHEADER call needed to be moved to after
CheckLoginOrDie and Required/OptionalPageArguments on many pages.  A
warning will be printed if either CheckLoginOrDie or
Required/OptionalPageArguments detects that PAGEHEADER was already
called.

Also change the redirect in kb-show to be a permanent redirect (301)
rather than a temporary one (302) which is the default unless a status
code is given.
parent 2f8c0d21
...@@ -6,11 +6,6 @@ ...@@ -6,11 +6,6 @@
# #
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("New Project Approved");
# #
# Only known and logged in users can do this. # Only known and logged in users can do this.
# #
...@@ -26,11 +21,17 @@ $optargs = OptionalPageArguments("head_uid", PAGEARG_STRING, ...@@ -26,11 +21,17 @@ $optargs = OptionalPageArguments("head_uid", PAGEARG_STRING,
"silent", PAGEARG_BOOLEAN, "silent", PAGEARG_BOOLEAN,
"pcplab_okay", PAGEARG_BOOLEAN, "pcplab_okay", PAGEARG_BOOLEAN,
"ron_okay", PAGEARG_BOOLEAN); "ron_okay", PAGEARG_BOOLEAN);
$sendemail = 1; $sendemail = 1;
if (isset($silent) && $silent) { if (isset($silent) && $silent) {
$sendemail = 0; $sendemail = 0;
} }
#
# Standard Testbed Header
#
PAGEHEADER("New Project Approved");
# #
# Of course verify that this uid has admin privs! # Of course verify that this uid has admin privs!
# #
......
...@@ -6,11 +6,6 @@ ...@@ -6,11 +6,6 @@
# #
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("New Project Approval");
# #
# Only known and logged in users can do this. # Only known and logged in users can do this.
# #
...@@ -46,6 +41,11 @@ if (! ($this_project = $reqargs["project"])) { ...@@ -46,6 +41,11 @@ if (! ($this_project = $reqargs["project"])) {
$pid = $this_project->pid(); $pid = $this_project->pid();
$projleader = $this_project->GetLeader(); $projleader = $this_project->GetLeader();
#
# Standard Testbed Header
#
PAGEHEADER("New Project Approval");
echo "<center><h3>You have the following choices:</h3></center> echo "<center><h3>You have the following choices:</h3></center>
<table class=stealth align=center border=0> <table class=stealth align=center border=0>
<tr> <tr>
......
...@@ -6,11 +6,6 @@ ...@@ -6,11 +6,6 @@
# #
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("New Project Approval List");
# #
# Only known and logged in users can do this. uid came in with the URI. # Only known and logged in users can do this. uid came in with the URI.
# #
...@@ -30,6 +25,11 @@ if (! $isadmin) { ...@@ -30,6 +25,11 @@ if (! $isadmin) {
# #
$reqargs = RequiredPageArguments(); $reqargs = RequiredPageArguments();
#
# Standard Testbed Header
#
PAGEHEADER("New Project Approval List");
# #
# Look in the projects table to see which projects have not been approved. # Look in the projects table to see which projects have not been approved.
# Present a menu of options to either approve or deny the projects. # Present a menu of options to either approve or deny the projects.
......
...@@ -6,11 +6,6 @@ ...@@ -6,11 +6,6 @@
# #
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("New Users Approved");
# #
# Only known and logged in users. # Only known and logged in users.
# #
...@@ -22,6 +17,11 @@ $uid = $this_user->uid(); ...@@ -22,6 +17,11 @@ $uid = $this_user->uid();
# #
$reqargs = RequiredPageArguments(); $reqargs = RequiredPageArguments();
#
# Standard Testbed Header
#
PAGEHEADER("New Users Approved");
# Local used below. # Local used below.
$projectchecks = array(); $projectchecks = array();
......
...@@ -6,11 +6,6 @@ ...@@ -6,11 +6,6 @@
# #
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("New User Approval");
# #
# Only known and logged in users can be verified. # Only known and logged in users can be verified.
# #
...@@ -34,6 +29,11 @@ if (count($approvelist) == 0) { ...@@ -34,6 +29,11 @@ if (count($approvelist) == 0) {
USERERROR("You have no new project members who need approval.", 1); USERERROR("You have no new project members who need approval.", 1);
} }
#
# Standard Testbed Header
#
PAGEHEADER("New User Approval");
echo " echo "
<h2>Approve new users in your Project or Group</h2> <h2>Approve new users in your Project or Group</h2>
<p> <p>
......
...@@ -6,11 +6,6 @@ ...@@ -6,11 +6,6 @@
# #
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Widearea Accounts Approval Form");
# #
# Only known and logged in users can be verified. # Only known and logged in users can be verified.
# #
...@@ -109,6 +104,11 @@ while (list ($header, $value) = each ($HTTP_POST_VARS)) { ...@@ -109,6 +104,11 @@ while (list ($header, $value) = each ($HTTP_POST_VARS)) {
} }
} }
#
# Standard Testbed Header
#
PAGEHEADER("Widearea Accounts Approval Form");
reset($HTTP_POST_VARS); reset($HTTP_POST_VARS);
# #
......
...@@ -6,11 +6,6 @@ ...@@ -6,11 +6,6 @@
# #
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Widearea Accounts Approval Form");
# #
# Only admin types can use this page. # Only admin types can use this page.
# #
...@@ -22,6 +17,11 @@ if (! $isadmin) { ...@@ -22,6 +17,11 @@ if (! $isadmin) {
USERERROR("Only testbed administrators people can access this page!", 1); USERERROR("Only testbed administrators people can access this page!", 1);
} }
#
# Standard Testbed Header
#
PAGEHEADER("Widearea Accounts Approval Form");
echo " echo "
<h2>Approve local accounts on specific widearea nodes</h2> <h2>Approve local accounts on specific widearea nodes</h2>
......
...@@ -6,11 +6,6 @@ ...@@ -6,11 +6,6 @@
# #
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Commit and Tag");
# #
# Only known and logged in users can look at experiments. # Only known and logged in users can look at experiments.
# #
...@@ -37,6 +32,11 @@ if (!$isadmin && ...@@ -37,6 +32,11 @@ if (!$isadmin &&
"archive in $pid/$eid!", 1); "archive in $pid/$eid!", 1);
} }
#
# Standard Testbed Header
#
PAGEHEADER("Commit and Tag");
function SPITFORM($formfields, $errors) function SPITFORM($formfields, $errors)
{ {
global $experiment, $TBDB_ARCHIVE_TAGLEN, $referrer; global $experiment, $TBDB_ARCHIVE_TAGLEN, $referrer;
......
...@@ -6,11 +6,6 @@ ...@@ -6,11 +6,6 @@
# #
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Archive Tags");
# #
# Only known and logged in users can end experiments. # Only known and logged in users can end experiments.
# #
...@@ -92,6 +87,11 @@ else { ...@@ -92,6 +87,11 @@ else {
PAGEARGERROR("Must provide a current or former experiment index"); PAGEARGERROR("Must provide a current or former experiment index");
} }
#
# Standard Testbed Header
#
PAGEHEADER("Archive Tags");
# Show just the last N records unless request is different. # Show just the last N records unless request is different.
if (!isset($records)) { if (!isset($records)) {
$records = 100; $records = 100;
......
...@@ -8,8 +8,6 @@ chdir(".."); ...@@ -8,8 +8,6 @@ chdir("..");
require("defs.php3"); require("defs.php3");
chdir("buildui"); chdir("buildui");
PAGEHEADER("NetBuild");
# #
# Only known and logged in users can do this. # Only known and logged in users can do this.
# #
...@@ -32,6 +30,11 @@ if (isset($action) && $action == "modify") { ...@@ -32,6 +30,11 @@ if (isset($action) && $action == "modify") {
echo "<h3>Modifying $pid/$eid:</h3>"; echo "<h3>Modifying $pid/$eid:</h3>";
} }
#
# Standard Testbed Header
#
PAGEHEADER("NetBuild");
?> ?>
<applet code="Netbuild.class" width=800 height=600 MAYSCRIPT> <applet code="Netbuild.class" width=800 height=600 MAYSCRIPT>
......
...@@ -15,8 +15,6 @@ $view = array( ...@@ -15,8 +15,6 @@ $view = array(
'hide_copyright' => 1 'hide_copyright' => 1
); );
PAGEHEADER("Experiment Creation GUI", $view);
# #
# Only known and logged in users can do this. # Only known and logged in users can do this.
# #
...@@ -30,6 +28,8 @@ $isadmin = ISADMIN(); ...@@ -30,6 +28,8 @@ $isadmin = ISADMIN();
$optargs = OptionalPageArguments("experiment", PAGEARG_EXPERIMENT, $optargs = OptionalPageArguments("experiment", PAGEARG_EXPERIMENT,
"fallback", PAGEARG_BOOLEAN); "fallback", PAGEARG_BOOLEAN);
PAGEHEADER("Experiment Creation GUI", $view);
?> ?>
<h3>Note: See the Help menu for quickstart and tips</h3> <h3>Note: See the Help menu for quickstart and tips</h3>
......
...@@ -258,9 +258,14 @@ function TBERROR ($message, $death, $xmp = 0) { ...@@ -258,9 +258,14 @@ function TBERROR ($message, $death, $xmp = 0) {
} }
# #
# General user errors should print something warm and fuzzy # General user errors should print something warm and fuzzy. If a
# # header is not already printed and the dealth paramater is true, then
function USERERROR($message, $death = 1) { # assume the error is a precheck error and send an appropriate HTTP
# response to prevent robots from indexing the page. This currently
# defaults to a "400 Bad Request", but that may change in the future.
#
function USERERROR($message, $death = 1,
$status_code = HTTP_400_BAD_REQUEST) {
global $TBMAILADDR; global $TBMAILADDR;
global $session_interactive, $session_errorhandler; global $session_interactive, $session_errorhandler;
...@@ -286,7 +291,7 @@ function USERERROR($message, $death = 1) { ...@@ -286,7 +291,7 @@ function USERERROR($message, $death = 1) {
</font>\n"; </font>\n";
if ($death) { if ($death) {
PAGEERROR($msg); PAGEERROR($msg, $status_code);
} }
else else
echo "$msg\n"; echo "$msg\n";
...@@ -310,7 +315,7 @@ function PAGEARGERROR($msg = 0) { ...@@ -310,7 +315,7 @@ function PAGEARGERROR($msg = 0) {
if ($msg) { if ($msg) {
$default = "$default<br><br>$msg"; $default = "$default<br><br>$msg";
} }
USERERROR($default, 1); USERERROR($default, 1, HTTP_400_BAD_REQUEST);
} }
# #
......
...@@ -6,11 +6,6 @@ ...@@ -6,11 +6,6 @@
# #
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Delay Control");
# #
# Only known and logged in users can do this. # Only known and logged in users can do this.
# #
...@@ -32,6 +27,11 @@ $gid = $experiment->gid(); ...@@ -32,6 +27,11 @@ $gid = $experiment->gid();
$state = $experiment->state(); $state = $experiment->state();
$unix_gid = $experiment->UnixGID(); $unix_gid = $experiment->UnixGID();
#
# Standard Testbed Header
#
PAGEHEADER("Delay Control");
# #
# Look for transition and exit with error. # Look for transition and exit with error.
# #
......
...@@ -6,11 +6,6 @@ ...@@ -6,11 +6,6 @@
# #
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Delete a Group");
# #
# Only known and logged in users. # Only known and logged in users.
# #
...@@ -47,6 +42,11 @@ if (! $project->AccessCheck($this_user, $TB_PROJECT_DELGROUP)) { ...@@ -47,6 +42,11 @@ if (! $project->AccessCheck($this_user, $TB_PROJECT_DELGROUP)) {
1); 1);
} }
#
# Standard Testbed Header
#
PAGEHEADER("Delete a Group");
# #
# Check to see if there are any active experiments. Abort if there are. # Check to see if there are any active experiments. Abort if there are.
# #
......
...@@ -7,11 +7,6 @@ ...@@ -7,11 +7,6 @@
include("defs.php3"); include("defs.php3");
include("imageid_defs.php"); include("imageid_defs.php");
#
# Standard Testbed Header
#
PAGEHEADER("Delete an Image Descriptor");
# #
# Only known and logged in users can end experiments. # Only known and logged in users can end experiments.
# #
...@@ -38,6 +33,11 @@ if (! $image->AccessCheck($this_user, $TB_IMAGEID_DESTROY)) { ...@@ -38,6 +33,11 @@ if (! $image->AccessCheck($this_user, $TB_IMAGEID_DESTROY)) {
USERERROR("You do not have permission to destroy ImageID $imageid!", 1); USERERROR("You do not have permission to destroy ImageID $imageid!", 1);
} }
#
# Standard Testbed Header
#
PAGEHEADER("Delete an Image Descriptor");
# #
# Check to see if the imageid is being used in various places # Check to see if the imageid is being used in various places
# #
......
...@@ -7,11 +7,6 @@ ...@@ -7,11 +7,6 @@
include("defs.php3"); include("defs.php3");
include_once("node_defs.php"); include_once("node_defs.php");
#
# Standard Testbed Header
#
PAGEHEADER("Delete a Node Log Entry");
# #
# Only known and logged in users can end experiments. # Only known and logged in users can end experiments.
# #
...@@ -37,6 +32,11 @@ if (! ($isadmin || OPSGUY())) { ...@@ -37,6 +32,11 @@ if (! ($isadmin || OPSGUY())) {
# Need these below # Need these below
$node_id = $node->node_id(); $node_id = $node->node_id();
#
# Standard Testbed Header
#
PAGEHEADER("Delete a Node Log Entry");
# #
# We run this twice. The first time we are checking for a confirmation # We run this twice. The first time we are checking for a confirmation
# by putting up a form. The next time through the confirmation will be # by putting up a form. The next time through the confirmation will be
......
...@@ -7,11 +7,6 @@ ...@@ -7,11 +7,6 @@
include("defs.php3"); include("defs.php3");
include_once("osinfo_defs.php"); include_once("osinfo_defs.php");
#
# Standard Testbed Header
#
PAGEHEADER("Delete an OS Descriptor");
# #
# Only known and logged in users can end experiments. # Only known and logged in users can end experiments.
# #
...@@ -38,6 +33,11 @@ if (!$osinfo->AccessCheck($this_user, $TB_OSID_DESTROY)) { ...@@ -38,6 +33,11 @@ if (!$osinfo->AccessCheck($this_user, $TB_OSID_DESTROY)) {
USERERROR("You do not have permission to delete OS Descriptor $osid!", 1); USERERROR("You do not have permission to delete OS Descriptor $osid!", 1);
} }
#
# Standard Testbed Header
#
PAGEHEADER("Delete an OS Descriptor");
$conflicts = 0; $conflicts = 0;
# #
......
...@@ -6,11 +6,6 @@ ...@@ -6,11 +6,6 @@
# #
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Terminating Project and Remove all Trace");
# #
# Only known and logged in users can end experiments. # Only known and logged in users can end experiments.
# #
...@@ -36,6 +31,12 @@ $optargs = OptionalPageArguments("canceled", PAGEARG_BOOLEAN, ...@@ -36,6 +31,12 @@ $optargs = OptionalPageArguments("canceled", PAGEARG_BOOLEAN,
# Need these below. # Need these below.
$pid = $project->pid(); $pid = $project->pid();
#
# Standard Testbed Header
#
PAGEHEADER("Terminating Project and Remove all Trace");
# #
# Check to see if there are any active experiments. Abort if there are. # Check to see if there are any active experiments. Abort if there are.
# #
......
...@@ -6,11 +6,6 @@ ...@@ -6,11 +6,6 @@
# #
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Remove User");
# #
# Only known and logged in users allowed. # Only known and logged in users allowed.
# #
...@@ -32,6 +27,11 @@ $optargs = OptionalPageArguments("target_project", PAGEARG_PROJECT, ...@@ -32,6 +27,11 @@ $optargs = OptionalPageArguments("target_project", PAGEARG_PROJECT,
$target_dbuid = $target_user->uid(); $target_dbuid = $target_user->uid();
$target_uid = $target_user->uid(); $target_uid = $target_user->uid();
#
# Standard Testbed Header
#
PAGEHEADER("Remove User");
# #
# Requesting? Fire off email and we are done. # Requesting? Fire off email and we are done.
# #
......
...@@ -6,11 +6,6 @@ ...@@ -6,11 +6,6 @@
# #
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Edit Group Membership");
# #
# Only known and logged in users. # Only known and logged in users.
# #
...@@ -42,6 +37,11 @@ if (! $group->AccessCheck($this_user, $TB_PROJECT_EDITGROUP)) { ...@@ -42,6 +37,11 @@ if (! $group->AccessCheck($this_user, $TB_PROJECT_EDITGROUP)) {
"project $pid!", 1); "project $pid!", 1);
} }
#
# Standard Testbed Header
#
PAGEHEADER("Edit Group Membership");
# #
# See if user is allowed to add non-members to group. # See if user is allowed to add non-members to group.
# #
......
...@@ -9,11 +9,6 @@ include_once("osiddefs.php3"); ...@@ -9,11 +9,6 @@ include_once("osiddefs.php3");
include_once("imageid_defs.php"); include_once("imageid_defs.php");
include_once("osinfo_defs.php"); include_once("osinfo_defs.php");
#
# Standard Testbed Header
#
PAGEHEADER("Edit Image Descriptor");
# #
# Only known and logged in users. # Only known and logged in users.
# #
...@@ -38,6 +33,11 @@ if (!$image->AccessCheck($this_user, $TB_IMAGEID_MODIFYINFO)) { ...@@ -38,6 +33,11 @@ if (!$image->AccessCheck($this_user, $TB_IMAGEID_MODIFYINFO)) {
USERERROR("You do not have permission to access ImageID $imageid!", 1); USERERROR("You do not have permission to access ImageID $imageid!", 1);
} }
#
# Standard Testbed Header
#
PAGEHEADER("Edit Image Descriptor");
# #
# Need a list of node types. We join this over the nodes table so that # Need a list of node types. We join this over the nodes table so that
# we get a list of just the nodes that currently in the testbed, not # we get a list of just the nodes that currently in the testbed, not
......
...@@ -6,11 +6,6 @@ ...@@ -6,11 +6,6 @@
# #
include("defs.php3"); include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Edit Site Variables");
# #
# Only known and logged in users can do this. # Only known and logged in users can do this.
# #
...@@ -33,6 +28,11 @@ $optargs = OptionalPageArguments(# Edit greenballs pull up an Edit subform. ...@@ -33,6 +28,11 @@ $optargs = OptionalPageArguments(# Edit greenballs pull up an Edit subform.
"edited", PAGEARG_STRING, "edited", PAGEARG_STRING,
"canceled", PAGEARG_STRING); "canceled", PAGEARG_STRING);
#
# Standard Testbed Header
#
PAGEHEADER("Edit Site Variables");