action is mail\n"; break; case "T": # Action is Test form MakeHTMLtop($HTML,$SystemVariables); $HTML .= "

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

\n"; DisplayArrayVariables($FormVariables, $DisplayedVariables); $HTML .= $DisplayedVariables; $HTML .= "

System Variables

\n"; DisplayArrayVariables($SystemVariables, $DisplayedVariables); $HTML .= $DisplayedVariables; $HTML .= "

Environment Variables

\n"; DisplayArrayVariables($HTTP_ENV_VARS, $DisplayedVariables); $HTML .= $DisplayedVariables; MakeHTMLbottom($HTML,$SystemVariables); print $HTML; exit; case "A": echo "

action is acknowledgment\n"; break; default: echo "

invalid action\n"; } # End of switch ($Action) exit; MakeHTMLtop($HTML,$SystemVariables); print $HTML; $HTML=""; DisplayArrayVariables($FormVariables, $DisplayedVariables); foreach($SystemVariables as $Name=>$Value) { echo "
name=$Name value=$Value\n"; } echo "

The form used the $Method method\n"; echo "

Form Variables:\n

\n$DisplayedVariables"; MakeHTMLbottom($HTML,$SystemVariables); print $HTML; exit; # ****************************** Subprograms ********************************** # Function DisplayArrayVariables ############################################### function DisplayArrayVariables(&$FormVariables,&$HTMLVariables) { $HTMLVariables = ""; $LongestName = 0; foreach ($FormVariables as $Name=>$Value) { $HTMLVariables .= "$Name: \n"; if (gettype($Value) == "array") { $ArrayComponent = ""; foreach ($Value as $ArrayElement) { $ArrayComponents .= "$ArrayElement, "; } # End of foreach ($Value as $ArrayElement) $Value = substr($ArrayComponents,0,strlen($ArrayComponents)-2); } $HTMLVariables .= "$Value\n"; } # End of foreach ($FormVariables as $Name=>$Value) $HTMLVariables = "\n$HTMLVariables\n
\n"; } # End of function DisplayArrayVariables ###################################### # Function FixArrays ########################################################## function FixArrays(&$SystemVariables,&$FormVariables) { # 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 } # End of if (isset($SystemVariables[$TestKey])) } # End of foreach ($FormVariables as $Name=>$Value) } # 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 } # End of function GetFormData ############################################### # Function MakeHTMLbottom ##################################################### function MakeHTMLbottom(&$HTML,&$Variables) { $HTML.=<<

$Variables[title] by $Variables[organization]

$Variables[returnlinktitle] 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 StartUp ############################################################ function StartUp(&$SystemVariables) { # Define the SystemVariables associative array. # System variables can contain a default value by including it below. However, # default variables are averwritten if passed in hidden fields. $SystemVariables = array( # The action variable determines the script's role. # "M" is mail results to recipient # "T" test form by displaying form, system, and environment variables # "A" mail results to recipient and acknowledgment to submitter action=>"M", allownamealias=>True, # Allow name aliasing recipient=>"", # Email recipient - only required hidden field subject=>"Form Submission", # Email subject # Cosmetic properties bgcolor=>"WHITE", # Background color linkcolor=>"BLUE", # Link color vlinkcolor=>"RED", # Visited link color textcolor=>"BLACK", # Text Color alinkcolor=>"GREEN", # Active Link Color background=>"", # Background graphic email=>"", realname=>"", redirect=>"", # Destignation URL if no errors # Variables for HTML displayed pages organization=>"America's Town Square", title=>"Form Submission", returnlinkurl=>"", # Return link URL returnlinktitle=>"", # Return link prompt sort=>"", print_config=>"", required=>"", env_report=>"", print_blank_fields=>"", missing_fields_redirect=>""); } # End of Function StartUp ################################################### ?>