";
$TBMAIL_WWW = "Testbed WWW <$TBMAILADDR_WWW>";
$TBMAIL_APPROVAL = "Testbed Approval <$TBMAILADDR_APPROVAL>";
$TBMAIL_LOGS = "Testbed Logs <$TBMAILADDR_LOGS>";
$TBMAIL_AUDIT = "Testbed Audit <$TBMAILADDR_AUDIT>";
#
# This just spits out an email address in a page, so it does not need
# to be configured per development tree. It could be though ...
#
$TBMAILADDR = "
Testbed Operations ($TBMAILADDR_OPS)";
# So subscripts always know ...
putenv("HTTP_SCRIPT=1");
#
# Database constants and the like.
#
include("dbdefs.php3");
#
# Control how error messages are returned to the user. If the session is
# not actually "interactive" then do not send any output to the browser.
# Just save it up and let the page deal with it.
#
$session_interactive = 1;
$session_errorhandler = 0;
#
# Wrap up the mail function so we can prepend a tag to the subject
# line that indicates what testbed. Useful when multiple testbed
# email to the same list.
#
#
function TBMAIL($to, $subject, $message, $headers = 0)
{
global $THISHOMEBASE;
global $SCRIPT_NAME;
$subject = strtoupper($THISHOMEBASE) . ": $subject";
$tag = "X-NetBed: " . basename($SCRIPT_NAME);
if ($headers) {
$headers = "$headers\n" . $tag;
}
else {
$headers = $tag;
}
return mail($to, $subject, $message, $headers);
}
#
# Internal errors should be reported back to the user simply. The actual
# error information should be emailed to the list for action. The script
# should then terminate if required to do so.
#
function TBERROR ($message, $death, $xmp = 0) {
global $TBMAIL_WWW, $TBMAIL_OPS, $TBMAILADDR, $TBMAILADDR_OPS;
global $session_interactive, $session_errorhandler;
$script = urldecode($_SERVER['REQUEST_URI']);
TBMAIL($TBMAIL_OPS,
"WEB ERROR REPORT",
"\n".
"In $script\n\n".
"$message\n\n".
"Thanks,\n".
"Testbed WWW\n",
"From: $TBMAIL_OPS\n".
"Errors-To: $TBMAIL_WWW");
if ($death) {
if ($session_interactive)
PAGEERROR("Could not continue. Please contact $TBMAILADDR");
elseif ($session_errorhandler) {
$session_errorhandler("Could not continue. ".
"Please contact $TBMAILADDR_OPS", $death);
}
exit(1);
}
return 0;
}
#
# General user errors should print something warm and fuzzy
#
function USERERROR($message, $death) {
global $TBMAILADDR;
global $session_interactive, $session_errorhandler;
if (! $session_interactive) {
if ($session_errorhandler)
$session_errorhandler($message, $death);
else
echo "$message";
if ($death)
exit(1);
return;
}
$msg = "
$message
Please contact $TBMAILADDR if you feel this message is an error.
\n";
if ($death) {
PAGEERROR($msg);
}
else
echo "$msg\n";
}
#
# A form error.
#
function FORMERROR($field) {
USERERROR("Missing field; ".
"Please go back and fill out the \"$field\" field!", 1);
}
#
# A page argument error.
#
function PAGEARGERROR($msg = 0) {
$default = "Invalid page arguments: " . $_SERVER['REQUEST_URI'];
if ($msg) {
$default = "$default
$msg";
}
USERERROR($default, 1);
}
#
# SUEXEC stuff.
#
# Save this stuff so we can generate better error messages and such.
#
$suexec_cmdandargs = "";
$suexec_retval = 0;
$suexec_output = "";
$suexec_output_array;
#
# Actions for suexec.
#
define("SUEXEC_ACTION_CONTINUE", 0);
define("SUEXEC_ACTION_DIE", 1);
define("SUEXEC_ACTION_USERERROR", 2);
define("SUEXEC_ACTION_IGNORE", 3);
define("SUEXEC_ACTION_DUPDIE", 4);
#
# An suexec error.
#
function SUEXECERROR($action)
{
global $suexec_cmdandargs, $suexec_retval;
global $suexec_output, $suexec_output_array;
$foo = "Shell Program Error. Exit status: $suexec_retval\n";
$foo .= " '$suexec_cmdandargs'\n";
$foo .= "\n";
$foo .= $suexec_output;
switch ($action) {
case SUEXEC_ACTION_CONTINUE:
TBERROR($foo, 0, 1);
break;
case SUEXEC_ACTION_DIE:
TBERROR($foo, 1, 1);
break;
case SUEXEC_ACTION_USERERROR:
USERERROR("