PHP not working
Here is the submitform.php script I am using. Is it set up right?
<?
$strMailServer="smtp.myplanamerica.com";
$arrAllowedSites=array("http://www.myplanamerica.com/",
"http://myplanamerica.com/");
$strEmailComponent="CDONTS";
$strDefaultFromAddress="
[email protected]";
$strDefaultToAddress="
[email protected]";
$blnDefaultToEmail=true;
if (${"Required"}!="")
{
$strMissing="The following fields need to be filled out:<ul type=disc>";
$arrRequired=$Split[trim(${"Required"})][","];
foreach ($arrRequired as $strRequired)
{
if (trim(${$strRequired})=="")
{
switch (strtoupper($strRequired))
{
case "FROMEMAIL":
$strRequired="Your email address";
break;
}
$strMissing=$strMissing."<li>".$strRequired."<br>";
$intMissing=1;
}
} $strMissing=$strMissing."</ul>";
if ($intMissing==1)
{
ReportError($strMissing,"Required fields not filled out");
}
}
$strReferer=strtoupper(${"HTTP_REFERER"});
$blnBadReferer=true;
if ($strReferer=="")
{
if ($blnDefaultToEmail)
{
$blnBadReferer=false;
$blnUseDefault=true;
}
}
for ($Index=0; $Index<=count($arrAllowedSites); $Index=$Index+1)
{
if (strtoupper(substr($strReferer,0,strlen($arrAllowedSites[$Index])))==strtoupper($arrAllowedSites[$Index]))
{
$blnBadReferer=false;
}
}
if ($blnBadReferer)
{
$strMessage="The site which refered you to this script is not allowed access to this script.";
$strMessage=$strMessage."<br>A possible solution is lowering the privacy levels on your ";
$strMessage=$strMessage."firewall, or stopping it, while you fill in this form.";
$strMessage=$strMessage."<br>Please contact the webmaster of the site.";
ReportError($strMessage,"Bad Referer");
}
$strNeedEmail=${"NeedEmail"};
if ($strNeedEmail=="")
{
$strNeedEmail="No";
}
switch (strtoupper($strNeedEmail))
{
case "YES":
if (strlen(${"FromEmail"})==0)
{
$strMessage="You must supply an email address.<br><br>Please use the Back button on your browser to return and correct this.";
ReportError ($strMessage,"Invalid Email Address");
}
CheckEmail(${"FromEmail"});
$strFromEmail=${"FromEmail"};
break;
case "NO":
if (strlen(${"FromEmail"})==0)
{
$strFromEmail=$strDefaultFromAddress;
}
else
{
$strFromEmail=${"FromEmail"};
}
break;
}
$strToEmail=${"ToEmail"};
if (strlen($strToEmail)==0)
{
$strToEmail=$strDefaultToAddress;
}
if ($blnUseDefault)
{
$strToEmail=$strDefaultToAddress;
}
if (strlen($strToEmail)==0)
{
$strMessage="The email address to send this information to is missing.<br>Please inform the administrator of this website.";
ReportError($strMessage,"No email address");
}
$strRedirectTo=${"RedirectURL"};
if (strlen($strRedirectTo)==0)
{
$strMessage="A redirection URL was not supplied.<br>Please inform the webmaster of this site.";
ReportError($strMessage,"No email address")($strMessage,"Need Redirection URL");
}
SendForm();
function SendForm()
{
global extract($GLOBALS);
switch (substr(strtoupper(${"Print_Blank"}),0,1))
{
case "Y":
$blnPrintBlank=true;
break;
default:
$blnPrintBlank=false;
break;
}
if (${"Print_Config"}!="")
{
$arrConfig=$Split[${"Print_Config"}][","];
foreach ($arrConfig as $strConfig)
{
$strBody=$strBody.trim($strConfig).": ".trim(${$strConfig})."\r\n";
} }
$strHowSort=${"Sort"};
if (strlen($strHowSort)==0)
{
$strHowSort="Formorder";
}
if (strtoupper($strHowSort)=="ALPHABETICAL")
{
$arrUnsorted=$Split[$HTTP_POST_VARS]["&"];
for ($I=0; $I<=count($arrUnsorted); $I=$I+1)
{
$strElement=$arrUnsorted[$I];
$intDelimiter=(strpos($strElement,"=") ? strpos($strElement,"=")+1 : 0);
if ($intDelimiter==0)
{
$intDelimiter=strlen($strElement);
}
$arrSorted[$I]=substr($strElement,0,$intDelimiter-1);
}
QuickSort($arrSorted,0,count($arrSorted));
for ($I=0; $I<=count($arrSorted); $I=$I+1)
{
$strItem=strtoupper($arrSorted[$I]);
$strValue=${$strItem};
if (((strlen($strValue)!=0 || $blnPrintBlank) && $strItem!="FROMEMAIL")
{
$And$strItem<>"TOEMAIL"&$strItem<>"FROMNAME"&$strItem<>"TONAME"
&$strItem<>"PRINT_CONFIG"&$strItem<>"REDIRECTURL"&$strItem<>"PRINT_BLANK"
&$strItem<>"ENV_REPORT"&$strItem<>"EMAILSUBJECT"&$strItem<>"SORT"
&$strItem<>"REQUIRED"&$strItem<>"NEEDEMAIL"&$strItem<>"SUBMIT")$Then;
}
$strBody=$strBody.$strItem.": ".Canonize($strValue)."\r\n";
}
if ()
{
}
}
else
if (strtoupper($strHowSort)!="ALPHABETICAL" && strtoupper($strHowSort)!="FORMORDER")
{
$arrSorted=$Split[${"Sort"}][","];
foreach ($arrSorted as $strData)
{
$strBody=$strBody.strtoupper(trim($strData)).": ".trim(${$strData})."\r\n";
}
}
else
{
$arrUnsorted=$Split[$HTTP_POST_VARS]["&"];
for ($I=0; $I<=count($arrUnsorted); $I=$I+1)
{
$strElement=$arrUnsorted[$I];
$intDelimiter=(strpos($strElement,"=") ? strpos($strElement,"=")+1 : 0);
$strItem=strtoupper(substr($strElement,0,$intDelimiter-1));
$strValue=substr($strElement,$intDelimiter+1-1,);
if (((strlen($strValue)!=0 || $blnPrintBlank) && $strItem!="FROMEMAIL")
{
$And$strItem<>"TOEMAIL"&$strItem<>"FROMNAME"&$strItem<>"TONAME"
&$strItem<>"PRINT_CONFIG"&$strItem<>"REDIRECTURL"&$strItem<>"PRINT_BLANK"
&$strItem<>"ENV_REPORT"&$strItem<>"EMAILSUBJECT"&$strItem<>"SORT"
&$strItem<>"REQUIRED"&$strItem<>"NEEDEMAIL"&$strItem<>"SUBMIT")$Then;
}
$strBody=$strBody.$strItem.": ".Canonize($strValue)."\r\n";
}
if ()
{
}
}
if (substr(strtoupper(trim(${"Env_Report"})),0,1)=="Y")
{
$strBody=$strBody."\r\n"."-- Enviroment Variables"."\r\n";
$strBody=$strBody."Remote Address: ".${"REMOTE_ADDR"}."\r\n";
$strBody=$strBody."Remote Host: ".${"REMOTE_HOST"}."\r\n";
$strBody=$strBody."Referring URL: ".${"HTTP_REFERER"}."\r\n";
$strBody=$strBody."User Name: ".${"REMOTE_USER"}."\r\n";
$strBody=$strBody."Browser Type: ".${"HTTP_USER_AGENT"}."\r\n";
}
if (strtoupper($strToEmail)=="USER1")
{
$strToEmail="
[email protected]";
}
else
if (strtoupper($strToEmail)=="USER2")
{
$strToEmail="
[email protected]";
}
switch (strtoupper($strEmailComponent))
{
case "JMAIL":
// $objMail is of type "JMail.SMTPMail"
$objmail_sender=$strFromEmail;
$objmail_charset="UTF-8";
$objmail_sendername=${"FromName"};
$objmail_addrecipientex= ${"ToName"}
$objmail_subject=${"EmailSubject"};
$objmail_lazysend=true;
$objmail_serveraddress=$strMailServer;
$objmail_body=$strBody;
$objmail_headers=$objmail_headers."From: ".$objmail_sender;
mail($objmail_recipient,$objmail_subject,$objmail_body,$objmail_headers);
break;
case "JMAIL4":
// $objMail is of type "JMail.Message"
$objMail->Charset="UTF-8";
$objMail->Logging=false;
$objMail->Silent=true;
$objMail->From=$strFromEmail;
$objMail->FromName=${"FromName"};
$objMail->Subject=${"EmailSubject"};
$objMail->Body=$strBody;
$objMail->AddRecipient$sToEmail${"ToName"}
$objMail->Send($strMailServer);
break;
case "ASPEMAIL":
// $objMail is of type "Persits.MailSender"
$objMail->Host=$strMailServer;
$objMail->From=$strFromEmail;
$objMail->FromName=${"FromName"};
$objMail->AddAddress$strToEmail${"ToName"}
$objMail->Subject=${"EmailSubject"};
$objMail->Body=$strBody;
$objMail->Send;
break;
case "CDONTS":
// $objMail is of type "CDONTS.NewMail"
mail( $objMail=null;
,$Case"CDOSYS",// $objMail is of type "CDO.Message"
,"From: ".$Send);
mail($objMail->From=$strFromEmail,$objMail->To=$strToEmail,$objMail->Subject=${"EmailSubject"},"From: ".$Body=$strBody);
mail($objMail->TextBody=$strBody,$objMail->Send, $objMail=null;
,"From: ".$Subject=${"EmailSubject"});
;
}
;
}
mail(,$Response->Redirect$strRedirectTo,,"From: ".=$strToEmail);
mail($SubReportError($strMessage,$strTitle),,,"From: ".$From=$strFromEmail);
mail(,,,"From: ".$SetLocaleIDs[65001]);
mail(,,,"From: ".$MailFormat=0);
?>
<html>
<head>
<title><? echo $strTitle; ?></title>
<!--#include file="error.inc" -->
<? echo $strMessage; ?>
<br>
<!--#include file="error2.inc" -->
<?
exit();
break;
case :
function CheckEmail($strEmailToCheck)
{
global extract($GLOBALS);
$blnValidated=true;
if ((strpos($strEmailToCheck,"@") ? strpos($strEmailToCheck,"@")+1 : 0)==1)
{
//(the '@' is in the first position)
}
$blnValidated=false;
$strWhatsWrong="The '@' in the address you specified is in the first position.<br><br>Please use the Back button of your browser to return and correct this.";
return $function_ret;
}
if ($blnValidated)
{
if ((strpos($strEmailToCheck,"@") ? strpos($strEmailToCheck,"@")+1 : 0)==strlen($strEmailToCheck))
{
//(The '@' is in the last position)
}
$blnValidated=false;
$strWhatsWrong="The '@' in the address you specified is in the last position.<br><br>Please use the Back button of your browser to return and correct this.";
}
break;
case :
if ($blnValidated)
{
$J=0;
for ($I=1; $I<=strlen($strEmailToCheck); $I=$I+1)
{
if (substr($strEmailToCheck,$I-1,1)=="@")
{
//there is a '@' in the address at this position
}
$J=$J+1;
$K=$I;
}
if ()
{
}
switch ($J)
{
case 0:
$blnValidated=false;
$strWhatsWrong="There is no '@' in the address you specified.<br><br>Please use the Back button of your browser to return and correct this.";
break;
case 1:
//Need to have this otherwise the Case Else includes J = 1
$strWhatsWrong=$strWhatsWrong;
break;
default:
$blnValidated=false;
$strWhatsWrong="There are too many '@' symbols in the address you supplied.<br><br>Please use your browser's back button to correct this.";
break;
}
}
if ($blnValidated)
{
$J=0;
for ($I=1; $I<=strlen($strEmailToCheck)'K is the position of the '$@'[$from$above$check]; $I=$I+1)
{
if (substr($strEmailToCheck,$I-1,1)==".")
{
//there is a period after the '@'
}
$J=1;
}
if ()
{
}
if ($J==0)
{
$blnValidated=false;
$strWhatsWrong="There is no period after the '@' in the address you specified.<br><br>Please use the Back button of your browser to return and correct this.";
}
}
if ($blnValidated)
{
for ($I=$K; $I<=strlen($strEmailToCheck); $I=$I+1)
{
if (substr($strEmailToCheck,$I-1,1)==".")
{
//there is a period at this spot
$J=$I;
}
}
$L=strlen($strEmailToCheck)-2;
if ($J>$L)
{
//the last period is less than two places before the end of the address
$blnValidated=false;
$strWhatsWrong="The extension after the last period in the email address you specified is less than 2 letters long.<br><br>Please use the Back button of your browser to return and correct this.";
}
}
if ($blnValidated)
{
$K=$K+1;
if (substr($strEmailToCheck,$K-1,1)==".")
{
//there is a period immediately after the '@'
}
$blnValidated=false;
$strWhatsWrong="The first character after the '@' in the email address you specified is a period.<br><br>Please use the Back button on your browser to return and correct this.";
}
break;
case :
if (!$blnValidated)
{
ReportErrorK($strWhatsWrong,"Invalid Email Address"); }
break;
case :
function QuickSort($vArray,$LowBound,$HighBound)
{
global extract($GLOBALS);
$lTmpLow=intval($LowBound);
$lTmpHi=intval($HighBound);
if ($HighBound<=$LowBound || !is_array($vArray))
{
return $function_ret;
}
$iMiddlePos=($LowBound+$HighBound)$\2;
$vTempVal=$vArray[$iMiddlePos];
while(($lTmpLow<=$lTmpHi))
{
while(($vArray[$lTmpLow]<$vTempVal && $lTmpLow<$HighBound))
{
$lTmpLow=$lTmpLow+1;
}
while(($vTempVal<$vArray[$lTmpHi] && $lTmpHi>$LowBound))
{
$lTmpHi=$lTmpHi-1;
}
if (($lTmpLow<=$lTmpHi))
{
$vTmpHold=$vArray[$lTmpLow];
$vArray[$lTmpLow]=$vArray[$lTmpHi];
$vArray[$lTmpHi]=$vTmpHold;
$lTmpLow=$lTmpLow+1;
$lTmpHi=$lTmpHi-1;
}
}
if (($LowBound<$lTmpHi))
{
QuickSortP($vArray,$LowBound,$lTmpHi); }
if (($lTmpLow<$HighBound))
{
QuickSortP($vArray,$LowBound,$lTmpHi)($vArray,$lTmpLow,$HighBound); }
return $function_ret;
}
function Canonize($strValue)
{
global extract($GLOBALS);
if (strlen($strValue)==0 || !isset($strValue))
{
return $function_ret;
}
$strResult=str_replace("+"," ",$strValue);
$intStart=1;
while(((strpos($intStart,$strResult,"%") ? strpos($intStart,$strResult,"%")+1 : 0)))
{
$intPos=(strpos($intStart,$strResult,"%") ? strpos($intStart,$strResult,"%")+1 : 0);
$Char1=substr($strResult,$intPos+1-1,1);
$Char2=substr($strResult,$intPos+2-1,1);
$intValue=16*HexToDec($Char1);
$intValue=$intValue+HexToDec($Char2);
$strResult=str_replace("%".$Char1.$Char2,char($intValue),$strResult);
$intStart=$intPos+1;
}
$function_ret=$strResult;
return $function_ret;
}
function HexToDec($strChar)
{
global extract($GLOBALS);
if (is_numeric($strChar))
{
$intResult=intval($strChar);
}
else
{
$uChar=strtoupper($strChar);
switch ($uChar)
{
case "A":
$intResult=10;
break;
case "B":
$intResult=11;
break;
case "C":
$intResult=12;
break;
case "D":
$intResult=13;
break;
case "E":
$intResult=14;
break;
case "F":
$intResult=15;
break;
}
}
$function_ret=$intResult;
return $function_ret;
}
?>
<html>
<head>
<title>Submission successful!</title>
<meta http-equiv="refresh" content="0;url=<? echo $strRedirectTo; ?>">
</head>
<body>
Thank you for your submission.
<br>
If you are not redirected automatically, please click <a href="<? echo $strRedirectTo; ?>">here</a>.
</body>
</html> break;
} return $function_ret;
}