There has been a new submission from our Website form. Here is the info submitted:';
$bodystart = "There has been a new submission from our Website form. Here is the info submitted:";
$htmlbodyend = 'Please review and act accordingly.';
$bodyend = "Please review and act accordingly.";
$include_ip ="Yes";
$include_browser = "Yes";
$include_datetime = "Yes";
$auto_mode = "HTML";
$autorespondersubject = "Contact Confirmation";
$autoresponderfrom = "no_reply@harvilledesign.com ";
$autorespondernamefrom = "My Site Title";
$htmlautoresponderstart= 'Hello, this email is to confirm that your info has been received.';
$autoresponderstart = "Hello, this email is to confirm that your info has been received.";
$htmlautoresponderend = 'Thank you for contacting us!';
$autoresponderend = "Thank you for contacting us!";
$auto_include_datetime = "Yes";
$auto_attach = "";
$file_ext = "jpg, gif, png, bmp, mp3, pdf, html, htm";
$filesize = "1024";
$uploadfolder = "uploads";
$add_prefix = "Yes";
$max_attach_size = "10";
$csvFile = "fomdata.csv";
$csvType = "CSV for Excel";
$db_host = "localhost";
$db_name = "database_name";
$db_user = "username";
$db_password = "password";
$db_table = "table_name";
$create_table = "Yes";
$add_columns = "Yes";
$mail_engine = "SMTP";
$SMTPSecure = "No";
if($SMTPSecure == "No"){
$SMTPSecure = "";
}
$SMTPHost = "mymail.brinkster.com";
$SMTPPort = "25";
$SMTPUser = "info@harvilledesign.com";
$SMTPPass = "corona85";
if (trim($SMTPPort) == "") {
$SMTPPort = 25;
}
$start_of_script_include = "";
$before_formdata_include = "";
$after_formdata_include = "";
$after_filedata_include = "";
$before_error_include ="";
$before_admin_mail_include = "";
$before_auto_mail_include = "";
$end_of_script_include = "";
$allowed_extensions = explode(",",$file_ext);
for($i = 0; $i < count($allowed_extensions); $i++){
$allowed_extensions[$i] = trim($allowed_extensions[$i]);
}
$auto_attachments = explode(",",$auto_attach);
for($i = 0; $i < count($auto_attachments); $i++){
$auto_attachments[$i] = trim($auto_attachments[$i]);
}
$excludedfields = explode(",",$excluded_fields);
for($i = 0; $i < count($excludedfields); $i++){
$excludedfields[$i] = strtolower(trim($excludedfields[$i]));
}
if(trim($timezone) != ""){
if (function_exists(date_default_timezone_set)) {
date_default_timezone_set($timezone);
}
else{
putenv ($timezone);
mktime(0,0,0,1,1,1970);
}
}
$separator =";";
if ($csvType == "CSV") {
$separator =",";
}
$formid = isset($_POST['formid']) ? $_POST['formid'] : "";
if (($form_id != "" and $form_id == $formid) or $formid == "" ){
$includefile = $before_formdata_include;
if (!empty($includefile) and file_exists($includefile)) {
include $includefile;
}
//----Find Date and Time, Browser, IP address------------------
$date = date("l jS F Y, g:i A");
$browser =$_SERVER['HTTP_USER_AGENT'];
$ip = $_SERVER['REMOTE_ADDR'];
// Add timestamp and IP address in the fields list
$dbfieldname[0] = "Submission Date"; $logdata['Submission Date'] = date("Y-m-d H:i:s");
$dbfieldname[1] = "Timestamp"; $logdata['Timestamp'] = time();
$dbfieldname[2] = "IP Address"; $logdata['IP Address'] = $ip;
if ($copy_from_session == "Yes") {
$POST = $SESSION;
}
while (list ($key, $val) = each ($_POST)) {
$POST[$key] = $val;
}
$includefile = $after_formdata_include;
if (!empty($includefile) and file_exists($includefile)) {
include $includefile;
}
// -------- RECEIVIMG FIELDNAMES VALUES AND VALIDATION DETAILS------
reset($POST);
$i = 0;
$internalfields = array ("submit", "send", "captcha_code", "count", "formid", "username", "recaptcha_challenge_field", "recaptcha_response_field");
while (list ($key, $val) = each ($POST)) {
if (!in_array(strtolower($key), $internalfields)) {
$fieldname[$i] = ucwords(str_replace("_", " ", $key));
$dbfieldname[$i + 3] = ucwords(strtolower(str_replace("_", "", $fieldname[$i])));
$dbfieldname[$i + 3] = str_replace("-", "_", $dbfieldname[$i + 3]);
if (!is_array($val))
{
$fieldvalue[$i] = $val;
$logvalue = stripslashes(str_replace(";", ",",$val));
$logdata[$dbfieldname[$i+3]] = $logvalue;
}
else
{
$fieldvalue[$i] = implode(",", $val);
$logdata[$dbfieldname[$i+3]] = stripslashes(str_replace(";", ",", implode("|", $val)));
}
if ($allow_urls == "Yes") {
$fieldvalue[$i] = allowurls($fieldvalue[$i]);
}
if (strtolower($fieldname[$i]) == 'email')
{
$fieldvalue[$i] = ''.$fieldvalue[$i]."";
}
$i++;
}
}
// ------RECEIVING FILE VARIABLES--------------------
$prefix = rand(100000, 1000000);
reset ($_FILES);
$k = 0;
while (list ($key, $val) = each ($_FILES)) {
if ($_FILES[$key]['name']!="" and $_FILES[$key]['size'] > 0) {
$upload_Name[$k] = $_FILES[$key]['name'];
$filename[$k] = $_FILES[$key]['name'];
if ($add_prefix == "Yes") {
$upload_Name[$k] = $prefix."_".$upload_Name[$k];
}
$upload_Size[$k] = ($_FILES[$key]['size']);
$upload_Temp[$k] = ($_FILES[$key]['tmp_name']);
$uploadlink[$k] = $uploadfolder."/".$upload_Name[$k]."\n";
$fieldname[$i] = ucwords(str_replace("_", " ", $key));
$dbfieldname[$i+3] = ucwords(strtolower(str_replace("_", "", $fieldname[$i])));
$dbfieldname[$i+3] = str_replace("-", "_", $dbfieldname[$i+3]);
$fieldvalue[$i] = allowurls("http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME'])."/".$uploadlink[$k]);
$logdata[$dbfieldname[$i+3]]= "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME'])."/".$uploadlink[$k];
$total_attach_size += $upload_Size[$k];
$i++;
$k++;
}
}
if ($copy_in_session == "Yes") {
$_SESSION['POST'] = $POST;
}
//Captcha Verification
if ($captcha_rewrite == "Yes") {
$script = basename($_SERVER['PHP_SELF']);
rewrite_captcha($script);
}
if (isset($_POST['captcha_code'])) {
if (isset($_POST['captcha_code'],$_SESSION['random_txt']) && md5($_POST['captcha_code']) == $_SESSION['random_txt'])
{
unset($_POST['captcha_code'],$_SESSION['random_txt']);
}
else
{
$error .= $captcha_error."
";
report_error($error, $error_url);
}
}
// Recaptcha Verification
if ($force_recaptcha == "Yes") {
require_once('dbts_includes/recaptchalib.php');
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
$error .= $captcha_error." / reCAPTCHA Error: ". $resp->error ."
";
report_error($error, $error_url);
}
}
$includefile = $after_filedata_include;
if (!empty($includefile) and file_exists($includefile)) {
include $includefile;
}
// Set Total size of attachments
$total_attach_size = $total_attach_size/(1024*1000);
//Finding out if there are more than one email addresses to receive the admin email
$email = $POST['email'];
$mailtos = explode(",", $mailto);
$mailfrom = !empty($email) ? $email : $from_email;
$mailfrom = !empty($mailfrom) ? $mailfrom : $mailtos[0];
// Email validation
if (!empty($email)){
if (!ValidateEmail($email))
{
$error .= "The specified email address is invalid!\n
";
}
}
// ------------CHECKING FOR MAX UPLOADED FILE SIZE ----------------------
for ($i = 0; $i < count($upload_Name); $i++) {
if ($upload_Name[$i] != "" ) {
$ext = explode(".", $filename[$i]);
$file_ext = $ext[count($ext) - 1];
if (count($allowed_extensions) > 0) {
if (!in_array($file_ext, $allowed_extensions)) {
$error .= "The file type of $filename[$i] is not allowed!\n";
}
}
if ($upload_Size[$i] >= $filesize*1024) {
$error .= "The size of $upload_Name[$i] is bigger than the allowed $filesize Kb !\n";
}
}
}
$includefile = $before_error_include;
if (!empty($includefile) and file_exists($includefile)) {
include $includefile;
}
if (!empty($error))
{
report_error($error, $error_url);
}
if($csvStore == "Yes"){
WriteToFile($csvFile, $csvType, $logdata, $dbfieldname);
}
if ($dbStore == "Yes") {
$record_id = WriteToMySQL($db_name, $db_host, $db_user, $db_password, $db_table, $logdata, $dbfieldname, $create_table, $add_columns);
}
//Creating the Image code
if ($logo_image_url != "") {
$image_code = '';
}
if ($logo_link != "") {
$image_code = ''.$image_code.'';
}
if ($admin_mail == "Yes") {
require_once 'dbts_includes/admin_email.php';
$includefile = $before_admin_mail_include;
if (!empty($includefile) and file_exists($includefile)) {
include $includefile;
}
// Send email in html format
require_once 'dbts_includes/class.phpmailer.php';
// Set Generic Details
$mail = new PHPMailer();
if ($mail_engine == "Sendmail") {
$mail->IsSendmail(); // set mailer to use Sendmail
}
if ($mail_engine == "Qmail") {
$mail->IsQmail(); // set mailer to use Sendmail
}
if ($mail_engine == "SMTP") {
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = $SMTPHost; // specify main and backup server
$mail->Port = $Port; // specify smtp port
if ($SMTPAuth == "Yes") {
$mail->SMTPAuth = true; // turn on SMTP authentication
}
else {
$mail->SMTPAuth = false;
}
$mail->Username = $SMTPUser; // SMTP username
$mail->Password = $SMTPPass; // SMTP password
}
$mail->Subject = stripslashes($subject);
$mail->From = $mailfrom;
$mail->FromName = stripslashes($namefrom);
for ($i = 0; $i < count($mailtos); $i++){
$mail->AddAddress($mailtos[$i],"Webmaster");
}
if ($email != "") {
$mail->AddReplyTo($mailfrom);
}
$mail->WordWrap = 70;
if ($admin_mode == "HTML") {
$mail->IsHTML(true);
$mail->AltBody = $ALTmessage;
}
else {
$mail->IsHTML(false);
} // set word wrap to 70 characters
$mail->MsgHTML($MAILbody);
// optional, comment out and test
//$mail->MsgHTML($MAILbody);
// Lets add the attachments if so set
if($attach_files =="Yes" and $total_attach_size <= $max_attach_size){
if (!empty($_FILES))
{ $k = 0;
foreach ($_FILES as $key => $value)
{
if ($_FILES[$key]['error'] == 0 && $_FILES[$key]['size'] <= $filesize*1024)
{ $mail->AddAttachment($upload_Temp[$k], $filename[$k]);
$k++;
}
}
}
}
if (!$mail->Send()) {
$report .=" EMAIL FAILED Mailer Error: " . $mail->ErrorInfo." \r\n";
report_error($report,$error_url);
}
}
//--------- Move the files to destination----------------
// We cant do this earlier as we need to add the files to the email body
if ($store_uploaded == "Yes") {
$uploadfolder1 = basename($uploadfolder);
for ($i = 0; $i < count($upload_Name); $i++) {
if ($upload_Size[$i] >0)
{
$uploadFile = "$uploadfolder1/".$upload_Name[$i];
if (!is_dir(dirname($uploadFile)))
{
@RecursiveMkdir(dirname($uploadFile));
}
else
{
@chmod(dirname($uploadFile), 0777);
}
@move_uploaded_file( $upload_Temp[$i] , $uploadFile);
chmod($uploadFile, 0644);
}
}
}
if ($autoresponder == "Yes" and $email != "")
{
require_once 'dbts_includes/auto_email.php';
$includefile = $before_auto_mail_include;
if (!empty($includefile) and file_exists($includefile)) {
include $includefile;
}
// Send email in html format
require_once 'dbts_includes/class.phpmailer.php';
// Set Generic Details
$mail = new PHPMailer();
if ($mail_engine == "Sendmail") {
$mail->IsSendmail(); // set mailer to use Sendmail
}
if ($mail_engine == "Qmail") {
$mail->IsQmail(); // set mailer to use Sendmail
}
if ($mail_engine == "SMTP") {
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = $SMTPHost; // specify main and backup server
$mail->Port = $Port; // specify smtp port
if ($SMTPAuth == "Yes") {
$mail->SMTPAuth = true; // turn on SMTP authentication
}
else {
$mail->SMTPAuth = false;
}
if ($SMTPSecure == "Yes") {
$mail->SMTPSecure = "ssl"; // turn on SMTP authentication
}
$mail->Username = $SMTPUser; // SMTP username
$mail->Password = $SMTPPass; // SMTP password
}
$mail->Subject = stripslashes($autorespondersubject);
$mail->From = stripslashes($autoresponderfrom);
$mail->FromName = stripslashes($autorespondernamefrom);
$mail->AddAddress($mailfrom);
$mail->AddReplyTo(stripslashes($autoresponderfrom));
$mail->WordWrap = 70;
if ($auto_mode == "HTML") {
$mail->IsHTML(true);
$mail->AltBody = $ALTmessage;
}
else{
$mail->IsHTML(false);
}
// set word wrap to 70 characters
$mail->MsgHTML($MAILbody);
// Lets add the attachments if so set
foreach ($auto_attachments as $attachment)
{
if (file_exists($attachment))
{ $mail->AddAttachment($attachment);
}
}
if (!$mail->Send()) {
$report .=" EMAIL FAILED Mailer Error: " . $mail->ErrorInfo." \r\n";
report_error($report,$error_url);
}
}
extract($POST, EXTR_OVERWRITE);
$includefile = $end_of_script_include;
if (!empty($includefile) and file_exists($includefile)) {
include $includefile;
}
if($afterprocessing == "Include" and file_exists($end_include)){
include $end_include;
exit;
}
if($clear_session == "Yes"){
unset($_SESSION['POST']);
}
if($afterprocessing == "Redirect"){
header("Location: $success_url");
}
}
}
?>



