FormMail
V1.0 © 2001 Internet Express, Inc.
';
# Generic US-style date string
$date = strftime("%A, %B %d, %Y at %H:%M:%S");
# List of options used by the script.
$options = array('recipient','subject','email','realname','redirect','bgcolor',
'background','link_color','vlink_color','text_color',
'alink_color','title','sort','print_config','required',
'env_report','return_link_title','return_link_url',
'print_blank_fields','missing_fields_redirect');
# Read in the config file settings.
$config = read_config($conffile);
# If a referring URL was specified, make sure it matches one of the
# domains in our referer list.
$check_referer = false;
if ($_SERVER['HTTP_REFERER']) {
if (!is_array($config['referers'])) {
$config['referers'] = array($config['referers']);
}
foreach ($config['referers'] as $referer) {
if (eregi("^https?://([^/]*)$referer",
$_SERVER['HTTP_REFERER']))
{
$check_referer = true;
break;
}
}
} else {
$check_referer = true;
}
# If the HTTP_REFERER was invalid, send back an error.
if (!$check_referer) { local_error('bad_referer'); }
if ($_SERVER['REQUEST_METHOD'] !== 'POST'
&& $_SERVER['REQUEST_METHOD'] !== 'GET') {
local_error('request_method');
}
# Know which variables we're pulling from.
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$user_vars = $_POST;
} else {
$user_vars = $_GET;
}
$Field_Order = array();
$errors = array();
foreach ($user_vars as $name => $value) {
if (in_array($name,$options,true)) {
$config[$name] = $value;
} else {
if ($output[$name] && $value) {
$output[$name] = $output[$name] . ', ' . $value;
} else if ($value) {
array_push($Field_Order,$name);
$output[$name] = $value;
}
$output[$name] = $value;
}
}
# These three settings are lists of variable names. Turn them into
# arrays.
if (!is_array($config['required'])) {
$config['required'] = parse_array($config['required']);
}
if (!is_array($config['env_report'])) {
$config['env_report'] = parse_array($config['env_report']);
}
if (!is_array($config['print_config'])) {
$config['print_config'] = parse_array($config['print_config']);
}
if (!$config['recipient']) {
if (count($output) === 0) {
local_error('bad_referer');
} else {
local_error('no_recipient');
}
}
foreach ($config['required'] as $required) {
# If the required field is the email field, the syntax of the email
# address if checked to make sure it passes a valid syntax.
if ($required === 'email' && !check_email($config[$required])) {
array_push($errors,$required);
}
# Otherwise, if the required field is a configuration field and it
# has no value or has been filled in with a space, send an error.
else if (in_array($required,$options,true)) {
if (!$config[$required]) {
array_push($errors,$required);
}
}
# If it is a regular form field which has not been filled in or
# filled in with a space, flag it as an error field.
else if (!$output[$required]) {
array_push($errors,$required);
}
}
# If any error fields have been found, send error message to the user.
if (count($errors)) {
local_error('missing_fields', $errors);
}
if (is_array($config['recipient'])) {
$config['recipient'] = implode(", ", $config['recipient']);
}
# If redirect option is used, print the redirectional location header.
if ($config['redirect']) {
Header("Location: " . $config['redirect']);
} else {
# Otherwise, begin printing the response page.
?>
= $config['title'] ?>Thank You
>
= $config['title'] ?>
Thank You For Filling Out This Form
Below is what you submitted to = $config['recipient'] ?> on = $date ?>
= field ?>: = $output[$field] ?>
= $sorted_field ?>
= $output[$sorted_field] ?>
= $field ?>: = $output[$field] ?>
= $copyright; ?>
bgcolor="= $config['bgcolor'] ?>" background="= $config['background'] ?>" link="= $config['link_color'] ?>" vlink="= $config['vlink_color'] ?>" alink="= $config['alink_color'] ?>" text="= $config['text_color'] ?>"
Bad Referrer - Access Denied
| Bad Referrer - Access Denied |
| The form attempting to use
FormMail resides
at = $server ?>, which is not allowed to access this cgi script.
If you are attempting to configure FormMail to run with this form,
you need to add the following to referers list, explained in detail
in the README file.
Add '= $host ?>' to your referers list.
= $copyright ?>
|
Internet Express FormMail v1.0
| = $copyright ?>
Licensed for use by Internet Express customers. |
Error: Request Method
| The Request Method of the Form you submitted did not match
either GET or POST. Please check the form and make sure the
method= statement is in upper case and matches GET or POST.
= $copyright ?>
|
Error: No Recipient
No Recipient was specified in the data sent to FormMail. Please
make sure you have filled in the 'recipient' form field with an e-mail
address. More information on filling in recipient form fields can be
found in the README file.
= $copyright ?>
|
$missing_field\n";
}
?>
Error: Blank Fields
| The following fields were left blank in your submission form:
These fields must be filled in before you can successfully submit the form.
Please use your browser's back button to return to the form and try again.
= $copyright ?>
|