Acknowledgement Successfully Sent to $AcknowledgementSent\n": "
Acknowledgement Not Successfully Sent to $AcknowledgementSent\n"; $HTML.="

The following are the name/value pairs of data submitted\n"; DisplayArrayVariables($FormVariables, $HTML); } break; case "T": # Action is Test form # Check for data entry errors Check4Errors($SystemVariables,$FormVariables,$Errors); if ($Errors) { # If there were errors, process them. ProcessErrors($HTML,$Errors); } # End of if ($Errors) $HTML .= "

Form Variables\n"; $HTML .= "submitted using the \"$Method\" method.

\n"; DisplayArrayVariables($FormVariables, $HTML); #$Display variables); $HTML .= "

System Variables

\n"; DisplayArrayVariables($SystemVariables, $HTML); #$Display variables); $HTML .= "

Environment Variables

\n"; DisplayArrayVariables($HTTP_ENV_VARS, $HTML); #$Display variables); break; default: $HTML .= "

Invalid Action

\n"; } # End of switch ($Action) MakeHTMLbottom($HTML,$SystemVariables); print $HTML; exit; # ****************************** Subprograms ********************************** # Function Check4Errors ####################################################### function Check4Errors(&$SystemVariables,&$FormVariables,&$Errors) { # Call validation because at least Recipient must be checked ValidateRequired($SystemVariables,$FormVariables,$Errors); # Call email validation because at least Recipient must be checked ValidateEmail($SystemVariables,$FormVariables,$Errors); if ($SystemVariables[checknumeric]) # Numeric validations required? ValidateNumeric($SystemVariables,$FormVariables,$Errors); if ($SystemVariables[checkzipcode]) # Zip code validation required? ValidateZipCode($SystemVariables,$FormVariables,$Errors); } # End of function Check4Errors ############################################# # Function DisplayArrayVariables ############################################### function DisplayArrayVariables(&$FormVariables,&$HTMLVariables) { $Temp = ""; foreach ($FormVariables as $Name=>$Value) { $Value = stripslashes($Value); $Name = trim($Name); if (eregi("H[0-9]{1,3}",$Name)) { $Temp.=<< $Value Heading; } else { $Temp .=<< $Name:  $Value   TEMP; } # End of if (eregi("H[0-9]{1,3}",$Name)) } # End of foreach ($FormVariables as $Name=>$Value) $HTMLVariables .= "\n$Temp
\n"; } # End of function DisplayArrayVariables ###################################### # Function FixArrays ########################################################## function FixArrays(&$SystemVariables,&$FormVariables,&$LongestName) { # The function has a two fold purpose, to replace any default value in the # $SystemVariables array with values passed as hidden form field. The second # purpose is to remove system variables from the $FormVariables array. foreach ($FormVariables as $Name=>$Value) { # Traverse $FormVariables array # Check to see if name aliases are allowed $TestKey = NameAlias($Name,$SystemVariables["allownamealias"]); if (isset($SystemVariables[$TestKey])) { # Is it a system variable? $SystemVariables[$TestKey] = $Value; # Use it's value if yes unset($FormVariables[$Name]); # Remove it from $FormVariables } else { $NameSize = strlen($Name); if($NameSize > $LongestName) $LongestName = $NameSize; } # End of if (isset($SystemVariables[$TestKey])) } # End of foreach ($FormVariables as $Name=>$Value) $Acknowledge = strtolower($SystemVariables[sendacknowledgement]); if($Acknowledge=="no") $SystemVariables[sendacknowledgement] = ""; } # End of function FixArrays ################################################# # Function GetFormData ######################################################## function GetFormData(&$Method,&$FormVariables) { # Determine if the form used the POST or GET method and return in $Method # Return the form's variables as an associative array containing the # set of Name - Value pairs. global $HTTP_POST_VARS, $HTTP_GET_VARS; # POST or GET method used when submitting the form? $Method = (isset($HTTP_POST_VARS)) ? "Post" : "Get"; # Load the $FormVariables associative array from appropriate array $FormVariables = ($Method == "Post") ? $HTTP_POST_VARS : # Post Method Used $HTTP_GET_VARS; # Get Method Used foreach ($FormVariables as $Name=>$Value) { if (is_array($Value)) $FormVariables[$Name] = join(",",$Value); } # End of foreach ($FormVariables as $Name=>$Value) } # End of function GetFormData ############################################### # Function LegalDomain ######################################################## function LegalDomain(&$HTML,&$AcceptableDomains,$SystemVariables) { global $HTTP_REFERER; $URLparts = parse_url($HTTP_REFERER); $Domain = strtolower($URLparts[host]); foreach($AcceptableDomains as $GoodDomain) { if($Domain == strtolower($GoodDomain)) return TRUE; } # End foreach($AcceptableDomains as $GoodDomain) $HTML.=<<

"$Domain" is not an allowable domain

BadDomain; MakeHTMLbottom($HTML,$SystemVariables); print $HTML; exit; } # End of function LegalDomain ############################################### # Function MakeHTMLbottom ##################################################### function MakeHTMLbottom(&$HTML,&$Variables) { $Title = stripslashes($Variables[returnlinktitle]); $HTML.=<<
$Variables[title] by $Variables[organization]

$Title

MakeBottom; } # End of function MakeHTMLbottom ############################################ # Function MakeHTMLtop ######################################################## function MakeHTMLtop(&$HTML,&$Variables) { $HTML=<< $Variables[title] - $Variables[organization]

$Variables[title]

$Variables[organization]

MakeTop; } # End of function MakeHTMLtop ############################################### # Function NameAlias ########################################################## function NameAlias($Value,$AllowAlias="1") { if (!$AllowAlias) return $Value; # Replace blanks, dashes, and underscores with nothing. $TestKey = preg_replace("/( |-|_)/","",$Value); $TestKey = strtolower($TestKey); return $TestKey; } # End of subroutine NameAlias ############################################### # Function ProcessErrors ###################################################### function ProcessErrors(&$HTML,&$Errors) { global $HTTP_REFERER; $Count = count($Errors); $IsAre = ($Count==1) ? "is" : "are"; $Plural = ($Count==1) ? "" : "s"; $HTML.=<< ErrorHeading; foreach ($Errors as $Error) { $HTML.= "
  • $Error
  • \n"; } $HTML.=<<

    to the Form Page page to change your data.

    Or go back to a blank form

    ErrorEnd; } # End of function ProcessErrors ############################################# # Function SendEmail ########################################################## function SendEmail(&$HTML,&$Result,&$SystemVariables, $FormVariables,&$AcknowledgementSent,$LongestName) { global $SCRIPT_NAME,$HTTP_REFERER,$HTTP_HOST,$REMOTE_ADDR,$HTTP_USER_AGENT; $To = $SystemVariables[recipient]; $From = $SystemVariables[fromemail]; $UserEmail = $FormVariables[TestEmailAddress]; $Date = date("l F j, Y") . " at " . date("h:i A"); if($UserEmail) { $To = $UserEmail; $SystemVariables[recipient] = $UserEmail; } # End of if($UserEmail) $Subject = $SystemVariables[subject] . " from $SystemVariables[organization]"; $ENVfields=<<$Value) { if (is_array($Value)) $Value = join(",",$Value); if (eregi("H[0-9]{1,3}",$Name)) { $MailMessage .= "$Value\n"; } else { $Tab = substr($Dashes,0,$LongestName-strlen($Name)); $MailMessage .= "$Tab$Name: $Value\n"; } # End of if (eregi("H[0-9]{1,3}",$Name)) } # End of foreach ($FormVariables as $Name=>$Value) $MailMessage .= "-------------- End of Passed Fields -----------------------\n"; $OutgoingMessage=<<