Hello:
This should be a simple form script: but getting the following error:
Parse error: parse error in /home/cabling/public_html/provider_app/mmex.php on line 426
The code is as follows for mmex.php:
Any help is appreciated!
Scott
The code on line 426 is (just above database functions area): } // end $send_type
#================================================= ==========
# Register Globals
#================================================= ==========
$settings = $_REQUEST['settings'];
$refresh = $_REQUEST['refresh'];
$phone = $_REQUEST['phone'];
$email = $_REQUEST['email'];
$state = $_REQUEST['state'];
$zip = $_REQUEST['zip'];
#================================================= ==========
# Check for Settings
#================================================= ==========
header("Cache-control: private");
if(!$settings)
{
exit ("No settings were found for this form.");
}
include($settings);
#================================================= ==========
# Set Output Style
#================================================= ==========
if (!$font_size)
$font_size = '11pt'; // Default
if (!$font_color)
$font_color = '#000000'; // Default
if (!$font_weight)
$font_weight = 'none'; // Default
if (!$font_family)
$font_weight = 'arial'; // Default
$style .= '<span style="margin-left:12px;font-family:'.$font_family.';font-size:'.$font_size.';color:'.$font_color.';font_wei ght:'.$font_weight.'">';
$divstyle .= '<div style="margin-left:12px;font-family:'.$font_family.';font-size:'.$font_size.';color:'.$font_color.';font_wei ght:'.$font_weight.'">';
#================================================= ==========
# Error Messages
#================================================= ==========
$msg['authorized'] = "This site is not authorized to use this script.";
$msg['ipblocked'] = "Your IP address has been blocked.";
$msg['recent'] = "Recent entry. New submissions are allowed every $interval minute(s).";
$msg['norecipient'] = "This email cannot be sent. No specified recipient.";
$msg['required'] = "The following field(s) are required to be filled in before submission:";
$msg['formatted'] = "The following field(s) are required to be filled in with valid format before submission:";
$msg['flooderr'] = "There is an error with your Flood Control File.\r\nEither, the file name in the settings is incorrect or permissions are not set to 666.\r\n\r\nMail Manage EX";
$msg['iperr'] = "There is an error with your IP Address File.\r\nEither, the file name in the settings is incorrect or the file does not exist.\r\n\r\nMail Manage EX";
$msg['csverr'] = "There is an error with your CSV File.\r\nEither, the file name in the settings is incorrect, the file does not exist or permissions are not set to 666.\r\nr\nMail Manage EX";
$msg['filerr'] = "There is an error with your Flat File.\r\nEither, the file name in the settings is incorrect, the file does not exist or permissions are not set to 666.\r\nr\nMail Manage EX";
#================================================= ==========
# Check User's IP Address and Last Submission
#================================================= ==========
if ($flood_control)
{
$user_ip = $_SERVER['REMOTE_ADDR'];
$stamp = mktime();
$secs = $interval * 60;
@ $get=fopen($floodfile_name,'r');
if (!$get and $senderrors == 'yes')
mail($recipient,"Form Error",$msg['flooderr'],"From: \"Mail Manage EX Notifier\" <MMEX_Notifier@domain.com>");
@ flock($get, LOCK_SH);
$flooddata = @ fread($get,999999);
$flooddata = explode("#",$flooddata);
for ($x=0;$x<count($flooddata);$x++)
{
$line = explode("|",$flooddata[$x]);
if ($user_ip == $line[0])
{
if (($stamp - $line[1]) < $secs)
exit ($style . $msg['recent'] . "</span>");
}
}
@ flock($get,LOCK_UN);
@ fclose($get);
}
#================================================= ==========
# Check if User's IP Address is Allowed
#================================================= ==========
if ($ip_block)
{
@ $read = fopen($ipfile_name,'r');
if (!$read and $senderrors == 'yes')
mail($recipient,"Form Error",$msg['iperr'],"From: \"Mail Manage EX Notifier\" <MMEX_Notifier@domain.com>");
@ flock($read,LOCK_SH);
@ $data = fread($read,filesize($ipfile_name));
@ flock($read,LOCK_UN);
@ fclose($read);
$user_ip = $_SERVER['REMOTE_ADDR'];
if(stristr($data,$user_ip))
exit ($style . $msg['ipblocked'] . '</span>');
}
#================================================= ==========
# Post Values Depending on Php Version
#================================================= ==========
if (isset($HTTP_POST_VARS))
$_FORM = $HTTP_POST_VARS;
if (isset($_POST))
$_FORM = $_POST;
unset ($HTTP_POST_VARS);
unset ($_POST);
if ($email)
$sendemail = $email;
if ($preview)
$keepsettings = $settings;
$_FILEFORM = $_FORM;
$_DBASE = $_FORM;
$_CSVFORM = $_FORM;
#================================================= ==========
# Display Preview
#================================================= ==========
if ($preview and !$refresh)
{
$form .="$divstyle<b>Form Results Preview</b><hr></div>
<form style=\"font-family:$font_family;font-size:$font_size;margin-left:12px\" method=\"post\" action=\"".$PHP_SELF."\">
<input type=\"hidden\" name=\"settings\" value=\"".$keepsettings."\">
<input type=\"hidden\" name=\"refresh\" value=\"yes\">";
while (list ($key, $val) = each ($_FORM))
{
if ($key != "settings" and $key != "refresh")
{
if ($val == "" and $no_answer > "")
$val = "[no answer]";
$key = stripslashes($key);
$val = stripslashes($val);
$form .= "<input type=\"hidden\" name=\"".$key."\" value=\"".$val."\"><span style=\"margin-left:-8px\"><b>$style $key</b>: $val</span><br>";
}
}
$form .= "<br>
<input type=\"button\" value=\"Back\" onclick=\"history.back()\" style=\"text-decoration:underline;font-family:$font_family;font-size:$font_size;background-color:#FFFFFF;border: solid #FFFFFF 1px; cursor:hand\">
<input type=\"submit\" value=\"Continue\" style=\"text-decoration:underline;font-family:$font_family;font-size:$font_size;background-color:#FFFFFF;border: solid #FFFFFF 1px; cursor:hand\"></form>";
exit($form);
}
#=======================================
# CHECK REQUIRED FIELDS
#=======================================
if ($req_fields)
{
$req_fields = explode(",",$req_fields);
for($i=0;$i<count($req_fields);$i++)
{
$Field = $req_fields[$i];
if(!$_FORM[$Field])
{
$Field = str_replace("_"," ",$Field);
$Emptyfields .= "<li>$Field</li>";
}
}
if ($Emptyfields)
$Errors = $divstyle . $msg['required'] . "<ul type=\"square\">" . $Emptyfields . "</ul></div><br><br>";
}
#=======================================
# CHECK FORMATTED FIELDS
#=======================================
if ($formatted)
{
$formatted = explode(",",$formatted);
for ($x=0;$x<count($formatted);$x++)
{
$Format = substr($formatted[$x],-1);
$Field = substr($formatted[$x],0,-1);
if ($Format == "@" and $_FORM[$Field] > "") // EMAIL FORMAT
{
if(!eregi('^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$',$_FORM[$Field]))
{
$Field = str_replace("_"," ",$Field);
$Incorrectfields .= "<li>$Field</li> <span style=\"font-size:8pt\">(EMAIL ADDRESS)</span>";
}
}
if ($Format == "*" and $_FORM[$Field] > "") // PHONE NUMBER FORMAT
{
if (!eregi('([0-9]{3})-([0-9]{3})-([0-9]{4})', $_FORM[$Field]) and !eregi('([0-9]{3})\.([0-9]{3})\.([0-9]{4})', $_FORM[$Field]) and !eregi('([0-9]{3}) ([0-9]{3}) ([0-9]{4})', $_FORM[$Field]) and !eregi('(\([0-9]{3}\))-([0-9]{3})-([0-9]{4})', $_FORM[$Field]) and !eregi('(\([0-9]{3}\))\.([0-9]{3})\.([0-9]{4})', $_FORM[$Field]) and !eregi('(\([0-9]{3}\)) ([0-9]{3}) ([0-9]{4})', $_FORM[$Field]))
{
$Field = str_replace("_"," ",$Field);
$Incorrectfields .= "<li>$Field</li> <span style=\"font-size:8pt\">(PHONE NUMBER)</span>";
}
}
if ($Format == "Z" and $_FORM[$Field] > "") // ZIP CODE FORMAT
{
if (!eregi('([0-9]{5})', $_FORM[$Field]))
{
$Field = str_replace("_"," ",$Field);
$Incorrectfields .= "<li>$Field</li> <span style=\"font-size:8pt\">(ZIP CODE)</span>";
}
}
if ($Format == "S" and $_FORM[$Field] > "") // STATE FORMAT
{
if (!eregi('([a-zA-Z]{2})', $_FORM[$Field]))
{
$Field = str_replace("_"," ",$Field);
$Incorrectfields .= "<li>$Field</li> <span style=\"font-size:8pt\">(STATE)</span>";
}
}
if ($Format == "#" and $_FORM[$Field] > "") // NUMERIC ONLY FORMAT
{
if (eregi('([a-zA-Z_\-)', $_FORM[$Field]))
{
$Field = str_replace("_"," ",$Field);
$Incorrectfields .= "<li>$Field</li> <span style=\"font-size:8pt\">(NUMERIC ONLY)</span>";
}
}
if ($Format == "A" and $_FORM[$Field] > "") // ALPHA ONLY FORMAT
{
if (eregi('([0-9])', $_FORM[$Field]))
{
$Field = str_replace("_"," ",$Field);
$Incorrectfields .= "<li>$Field</li> <span style=\"font-size:8pt\">(ALPHA ONLY)</span>";
}
}
}
if ($Incorrectfields)
$Errors .= $divstyle . $msg['formatted'] . "<ul type=\"square\">" . $Incorrectfields . "</ul></div>";
}
if ($Errors)
exit ($Errors);
################################################## #######################
# EMAIL FUNCTIONS #
################################################## #######################
if ($send_type == 'email' or $send_type == 'emailfile' or $send_type == 'emailcsv' or $send_type == 'emaildbase')
{
#================================================= ==========
# Get All Values from the Form Fields
#================================================= ==========
while (list ($key, $val) = each ($_FORM))
{
if ($key != "settings" and $key != "refresh")
{
$key = stripslashes($key);
$val = stripslashes($val);
if ($val == "" and $no_answer > "")
$val = "[no answer]";
$html .= "<b>$key</b>: $val<br>";
$content .= "$key: $val<br>";
$form .= "<b>$style $key</b>: $val </span><br>";
}
}
#================================================= ==========
# Check for Recipient
#================================================= ==========
if (!$recipient)
exit ($style . $msg['norecipient'] . '</span>');
#================================================= ==========
# Verify Subject
#================================================= ==========
if (!$subject)
$subject = 'Form submission';
#================================================= ==========
# Get User's IP Address
#================================================= ==========
if($ip_address)
{
$user_ip = $_SERVER['REMOTE_ADDR'];
$content .= "User's IP Address: $user_ip<br>";
}
#================================================= ==========
# Get User's Browser Agent
#================================================= ==========
if($browser)
{
$browser = $_SERVER['HTTP_USER_AGENT'];
$content .= "User's Browser: $browser<br>";
}
#================================================= ==========
# Get Date and Time of Submission
#================================================= ==========
if($getdate)
{
$getdate = date('M d, Y @ g:i:s a');
$content .= "Received: $getdate\n";
}
#================================================= ==========
# Put Header Information in Email
#================================================= ==========
if ($sendemail)
{
$header = "From: $sendemail\n";
$header .= "Reply-to: $sendemail\n";
}
else
$header = "From: $recipient\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: text/html; charset=iso-8859-1\n";
$header .= "Content-Transfer-Encoding: 8bit\n";
if ($htmlemail)
{
$handle = fopen($htmlemail_page,'r');
$data = fread($handle,99999);
fclose($handle);
$content = str_replace('[insert mmex]',$html,$data);
}
if ($cc)
$header .= "cc: $cc\n";
if ($bcc)
$header .= "bcc: $bcc\n";
#================================================= ==========
# Send It Off
#================================================= ==========
mail($recipient,$subject,$content,$header);
} // end $send_type
################################################## #######################
# CSV-FILE FUNCTIONS #
################################################## #######################
if ($send_type == 'csv' or $send_type == 'emailcsv')
{
$getdate = date('M d Y g:i:s a');
$user_ip = $_SERVER['REMOTE_ADDR'];
$content = '';
$form = '';
while (list ($key, $val) = each ($_CSVFORM))
{
if ($key != "settings" and $key != "refresh")
{
$key = stripslashes($key);
$val = stripslashes($val);
$val = str_replace(",","¸",$val);
if ($val == "" and $no_answer > "")
$val = "[no answer]";
$content .= "$val,";
$form .= "<b>$style $key</b>: $val </span><br>";
}
}
$content .= "$getdate,$user_ip\n";
@ $write = fopen($csvfile_name,'a');
if (!$write and $senderrors == 'yes')
@mail($recipient,"Form Error",$msg['csverr'],"From: \"Mail Manage EX Notifier\" <MMEX_Notifier@domain.com>");
@ flock($write,LOCK_EX);
@ fwrite($write,$content);
@ flock($write,LOCK_UN);
@ fclose($write);
} // end $send_type
################################################## #######################
# FLAT-FILE FUNCTIONS #
################################################## #######################
if ($send_type == 'file' or $send_type == 'emailfile')
{
$getdate = date('M d, Y g:i:s a');
$user_ip = $_SERVER['REMOTE_ADDR'];
$content = '';
$form = '';
while (list ($key, $val) = each ($_FILEFORM))
{
if ($key != "settings" and $key != "refresh")
{
$key = stripslashes($key);
$val = stripslashes($val);
if ($val == "" and $no_answer > "")
$val = "[no answer]";
$content .= "$key: $val\n";
$form .= "<b>$style $key</b>: $val </span><br>";
}
}
}
$data .= "Received: " . $getdate . "\nIP: " . $user_ip . "\n" . $content . "\n========================================\n\ n";
$write= @ fopen($flatfile_name,'a');
if (!$write and $senderrors == 'yes')
mail($recipient,"Form Error",$msg['fileerr'],"From: \"Mail Manage EX Notifier\" <MMEX_Notifier@domain.com>");
@ flock($write,LOCK_EX);
@ fwrite($write,$data);
@ flock($write,LOCK_UN);
@ fclose($write);
} // end $send_type
################################################## #######################
# DATABASE FUNCTIONS #
################################################## #######################
if ($send_type == 'dbase' or $send_type == 'emaildbase')
{
#================================================= ==========
# Connect to Database
#================================================= ==========
$db_connect = mysql_connect("localhost", "$db_user", "$db_pass");
mysql_select_db("$db_name",$db_connect);
#================================================= ==========
# Get Form Results
#================================================= ==========
while (list ($key, $val) = each ($_DBASE))
{
if ($key != "settings" and $key != "refresh")
{
$val = addslashes($val);
$key = addslashes($key);
$add .= $key . ',';
$values .= "'" . $val . "',";
$key = stripslashes($key);
$val = stripslashes($val);
$form .= "<b>$style $key</b>: $val </span><br>";
}
}
$timestamp = date('M d, Y g:i:s a');
$user_ip = $_SERVER['REMOTE_ADDR'];
if ($input_timeandIP)
{
$add .= "timestamp,user_ip";
$values .= "'" . $timestamp . "','" . $user_ip ."'";
}
else
{
$add = substr($add,0,-1);
$values = substr($values,0,-1);
}
#================================================= ==========
# Store Values into Database
#================================================= ==========
$sql = "INSERT INTO $table_name ($add) VALUES ($values)";
$result = mysql_query($sql);
mysql_close($db_connect);
} // end $send_type
################################################## #######################
# POST SUBMIT FUNCTIONS #
################################################## #######################
#================================================= ==========
# Add Plug-In Functionality (plugins may be used later)
#================================================= ==========
if ($runplugin)
{
if (file_exists($pluginfile))
include($pluginfile);
}
#================================================= ==========
# Saves IP Address and Time to Flood File
#================================================= ==========
if ($flood_control)
{
$flooddata = $user_ip . "|" . $stamp . "#";
@ $write=fopen($floodfile_name,'a');
@ flock($write,LOCK_EX);
@ fwrite($write,$flooddata);
@ flock($write,LOCK_UN);
@ fclose($write);
}
#================================================= ==========
# Auto Respond Information
#================================================= ==========
if ($auto_respond)
{
if (!$auto_subject)
$auto_subject = 'Thank you for your submission';
if (!$auto_content)
$auto_content = "Thank you for your submmission. We will contact you shortly.";
$auto_header = "From: $recipient";
if ($email)
mail($email,$auto_subject,"$auto_content",$auto_he ader);
}
#================================================= ==========
# Redirects or Outputs Thank You and Form Results
#================================================= ==========
if (!$redirect)
{
if (!$thankyou)
$thankyou = 'Thank you for your submission.';
if ($showresults == "yes")
exit ($divstyle . "$thankyou<hr></div><br>$form<br><br><img style=\"position:absolute; right:3px; bottom:3px\" src=\"http://www.arecaweb.com/php/mmex/small_mmex.jpg\" alt=\"Mail Manage EX\">");
else
exit ($divstyle . "$thankyou<img style=\"position:absolute; right:3px; bottom:3px\" src=\"http://www.arecaweb.com/php/mmex/small_mmex.jpg\" alt=\"Mail Manage EX\">");
}
else
header("Location: $redirect");
?>