function formbuilder_process_form_redirect($form, $fields) { global $_POST, $wpdb; $autoresponse_required = false; $source_email = ""; foreach ($fields as $field) { // Get source email address, if exists. Will use the first email address listed in the form results, as the source email address. if ($field['required_data'] == "email address" and !$source_email) { $source_email = $field['value']; } } // Set autoresponse information if required and send it out. if ($source_email and $form['autoresponse'] != false and $autoresponse_required == false) { $sql = "SELECT * FROM " . FORMBUILDER_TABLE_RESPONSES . " WHERE id = '" . $form['autoresponse'] . "';"; $results = $wpdb->get_results($sql, ARRAY_A); $response_details = $results[0]; $response_details['destination_email'] = $source_email; if ($response_details['from_email'] and $response_details['subject'] and $response_details['message'] and $response_details['destination_email']) { if ($response_details['from_name']) { $response_details['from_email'] = "\"" . $response_details['from_name'] . "\"<" . $response_details['from_email'] . ">"; } } $result = formbuilder_send_email($response_details['destination_email'], decode_html_entities($response_details['subject'], ENT_QUOTES, get_option('blog_charset')), $response_details['message'], "From: " . $response_details['from_email']); if ($result) { die($result); } } foreach ($fields as $field) { if ($field['field_type'] == "followup page") { echo "<meta HTTP-EQUIV='REFRESH' content='0; url=" . $field['field_value'] . "'>"; break; } } return false; }
function formbuilder_process_xml_email($form, $fields) { global $_POST, $wpdb, $formBuilderTextStrings; $xml_container = "form"; $email_msg = "<{$xml_container}>\r\n"; $autoresponse_required = false; $source_email = ""; // Iterate through the form fields to add values to the email sent to the recipient. foreach ($fields as $field) { // Add the comments to the email message, if they are appropriate. if ($field['field_type'] != "comments area" and $field['field_type'] != "followup page" and $field['field_type'] != "spam blocker" and $field['field_type'] != "page break" and $field['field_type'] != "submit button" and $field['field_type'] != "submit image" and $field['field_type'] != "captcha field") { $email_msg .= "<" . decode_html_entities($field['field_name'], ENT_QUOTES, get_option('blog_charset')) . ">" . decode_html_entities($field['value'], ENT_QUOTES, get_option('blog_charset')) . "</" . decode_html_entities($field['field_name'], ENT_QUOTES, get_option('blog_charset')) . ">\r\n"; } // Get source email address, if exists. Will use the first email address listed in the form results, as the source email address. if ($field['required_data'] == "email address" and !$source_email) { $source_email = $field['value']; } // Add IP if enabled. $ip_capture = get_option('formBuilder_IP_Capture'); if ($ip_capture == 'Enabled' and isset($_SERVER['REMOTE_ADDR'])) { $email_msg .= "<ip>" . $_SERVER['REMOTE_ADDR'] . "</ip>\r\n"; } // Add Page and Referer urls to the bottom of the email. if (isset($_POST['PAGE'])) { $email_msg .= "<page>" . $_POST['PAGE'] . "</page>\r\n"; } if (isset($_POST['REFERER'])) { $email_msg .= "<referer>" . $_POST['REFERER'] . "</referer>\r\n"; } } $email_msg .= "</{$xml_container}>"; // Set autoresponse information if required and send it out. if ($source_email and $form['autoresponse'] != false and $autoresponse_required == false) { $sql = "SELECT * FROM " . FORMBUILDER_TABLE_RESPONSES . " WHERE id = '" . $form['autoresponse'] . "';"; $results = $wpdb->get_results($sql, ARRAY_A); $response_details = $results[0]; $response_details['destination_email'] = $source_email; if ($response_details['from_email'] and $response_details['subject'] and $response_details['message'] and $response_details['destination_email']) { if ($response_details['from_name']) { $response_details['from_email'] = "\"" . $response_details['from_name'] . "\"<" . $response_details['from_email'] . ">"; } } $result = formbuilder_send_email($response_details['destination_email'], decode_html_entities($response_details['subject'], ENT_QUOTES, get_option('blog_charset')), $response_details['message'], "From: " . $response_details['from_email']); if ($result) { die($result); } } if (!$source_email) { $source_email = get_option('admin_email'); } $sendResult = formbuilder_send_email($form['recipient'], $form['subject'], $email_msg, "From: " . $source_email . "\n"); if (!$sendResult) { if (!$form['thankyoutext']) { $form['thankyoutext'] = "<h4>" . $formBuilderTextStrings['success'] . "</h4><p>" . $formBuilderTextStrings['send_success'] . "</p>"; } echo "\n<div class='formBuilderSuccess'>" . decode_html_entities($form['thankyoutext'], ENT_NOQUOTES, get_option('blog_charset')) . "</div>"; } return $sendResult; }
/** * Resend a specific email using the standard FB email module * using the data stored in the for this email. * @param $email_id * @return unknown_type */ function resend_email($email_id) { global $wpdb; $error = ''; // Check to ensure we have a valid looking email id. if (!preg_match('#^[0-9]+$#isU', $email_id)) { $error .= "Invalid email ID "; } // Load the details of the email from the DB. if (!$error) { $sql = "SELECT * FROM " . FORMBUILDER_TABLE_RESULTS . " WHERE id='{$email_id}' ORDER BY timestamp DESC LIMIT 0," . $this->result_limit . ";"; $result = $wpdb->get_row($sql, ARRAY_A); if ($result == false) { $error .= "No email found with that ID. "; } $form_data = $this->xmltoarray($result['xmldata']); $form_id = $result['form_id']; } // Resend the email in question using the standard FB controls. if (!$error) { $email_msg = ''; $email_from = ''; foreach ($form_data['form'] as $key => $value) { $email_msg .= strtoupper($key) . ": " . $value . "\n\n"; if ($key != 'FormSubject' && $key != 'FormRecipient' && !$email_from && preg_match('#' . FORMBUILDER_PATTERN_EMAIL . '#isU', $value)) { $email_from = $value; } } if (!$email_from) { $email_from = get_option('admin_email'); } $email_subject = $form_data['form']['FormSubject']; $email_to = $form_data['form']['FormRecipient']; $email_headers = 'From: ' . $email_from; $debg = array('$email_from' => $email_from, '$email_subject' => $email_subject, '$email_to' => $email_to, '$email_headers' => $email_headers); # echo '<pre>', htmlentities(print_r( $debg, true )), '</pre>'; $result = formbuilder_send_email($email_to, $email_subject, $email_msg, $email_headers); if ($result) { $error .= $result; } } if (!$error) { return true; } else { $this->resend_email_errors .= $error; return false; } }
function formbuilder_process_email($form, $fields) { global $_POST, $wpdb; $formBuilderTextStrings = formbuilder_load_strings(); $email_sub = $form['subject']; // mai - added $email_msg = ""; $autoresponse_required = false; $source_email = ""; // Iterate through the form fields to add values to the email sent to the recipient. foreach ($fields as $field) { // Add the comments to the email message, if they are appropriate. if (trim($field['field_name']) != "" and $field['field_type'] != "recipient selection" and $field['field_type'] != "comments area" and $field['field_type'] != "followup page" and $field['field_type'] != "spam blocker" and $field['field_type'] != "page break" and $field['field_type'] != "reset button" and $field['field_type'] != "submit button" and $field['field_type'] != "submit image" and $field['field_type'] != "captcha field") { $email_msg .= strtoupper(decode_html_entities($field['field_name'], ENT_QUOTES, get_option('blog_charset'))) . ": " . decode_html_entities($field['value'], ENT_QUOTES, get_option('blog_charset')) . "\r\n\r\n"; $field_values[$field['field_name']] = decode_html_entities($field['value'], ENT_QUOTES, get_option('blog_charset')); // Populate ~variable~ tags in the form subject with values submitted by the user $email_sub = str_replace("~" . $field['field_name'] . "~", $field_values[$field['field_name']], $email_sub); // mai - added } elseif ($field['field_type'] == "recipient selection") { // If we have a recipient selection field, change the form recipient to the selected value. if (preg_match('#' . FORMBUILDER_PATTERN_EMAIL . '#isU', trim($field['value']))) { $form['recipient'] = trim($field['value']); } else { $email_msg .= $formBuilderTextStrings['bad_alternate_email'] . " [" . trim($field['value']) . "]\n\n"; } } // Get source email address, if exists. Will use the first email address listed in the form results, as the source email address. if ($field['required_data'] == "email address" and !$source_email) { $source_email = $field['value']; } } // Add IP if enabled. $ip_capture = get_option('formBuilder_IP_Capture'); if ($ip_capture == 'Enabled' and isset($_SERVER['REMOTE_ADDR'])) { $email_msg .= "IP: " . $_SERVER['REMOTE_ADDR'] . "\r\n"; } $referrer_info = get_option('formBuilder_referrer_info'); if ($referrer_info == 'Enabled') { // Add Page and Referer urls to the bottom of the email. if (isset($_POST['PAGE'])) { $email_msg .= "PAGE: " . $_POST['PAGE'] . "\r\n"; } if (isset($_POST['REFERER'])) { $email_msg .= "REFERER: " . $_POST['REFERER'] . "\r\n"; } } // Set autoresponse information if required and send it out. if ($source_email and $form['autoresponse'] != false and $autoresponse_required == false) { $sql = "SELECT * FROM " . FORMBUILDER_TABLE_RESPONSES . " WHERE id='" . $form['autoresponse'] . "';"; $results = $wpdb->get_results($sql, ARRAY_A); $response_details = $results[0]; $response_details['destination_email'] = $source_email; if ($response_details['from_email'] and $response_details['subject'] and $response_details['message'] and $response_details['destination_email']) { if ($response_details['from_name']) { $response_details['from_email'] = '"' . $response_details['from_name'] . '"<' . $response_details['from_email'] . '>'; } } // Populate ~variable~ tags in the autoresponse with values submitted by the user. $txtAllFields = ""; foreach ($field_values as $key => $value) { $response_details['subject'] = str_replace("~" . $key . "~", $value, $response_details['subject']); $response_details['message'] = str_replace("~" . $key . "~", $value, $response_details['message']); $txtAllFields .= $key . ": " . $value . "\n"; } $response_details['subject'] = str_replace("~FullForm~", trim($txtAllFields), $response_details['subject']); $response_details['message'] = str_replace("~FullForm~", trim($txtAllFields), $response_details['message']); $result = formbuilder_send_email($response_details['destination_email'], decode_html_entities($response_details['subject'], ENT_QUOTES, get_option('blog_charset')), $response_details['message'], "From: " . $response_details['from_email'] . "\nReply-To: " . $response_details['from_email'] . "\n"); if ($result) { die($result); } } // James' addition to ensure no hacking is allowed. $email_sub = preg_replace('#[^a-z0-9_ -]#isU', '', $email_sub); if (!$source_email) { $source_email = get_option('admin_email'); } // Updated to force from address to use what is saved in settings. $formBuilder_Default_from = formbuilder_get_default_from(); // Allow for old style messaging. if (strtoupper($formBuilder_Default_from) == '[SENDER_EMAIL]') { $formBuilder_Default_from = $source_email; } return formbuilder_send_email($form['recipient'], decode_html_entities($email_sub, ENT_QUOTES, get_option('blog_charset')), $email_msg, "From: " . $formBuilder_Default_from . "\nReply-To: " . $source_email . "\n"); }
/** * Resend a specific email using the standard FB email module * using the data stored in the for this email. * @param $email_id * @return unknown_type */ function resend_email($email_id) { global $wpdb; $error = ''; // Check to ensure we have a valid looking email id. if (!eregi('^[0-9]+$', $email_id)) { $error .= "Invalid email ID "; } // Load the details of the email from the DB. if (!$error) { $sql = "SELECT * FROM " . FORMBUILDER_TABLE_RESULTS . " WHERE id='{$email_id}' ORDER BY timestamp DESC LIMIT 0," . $this->result_limit . ";"; $result = $wpdb->get_row($sql, ARRAY_A); if ($result == false) { $error .= "No email found with that ID. "; } $form_data = $this->xmltoarray($result['xmldata']); $form_id = $result['form_id']; } // Resend the email in question using the standard FB controls. if (!$error) { $email_msg = ''; foreach ($form_data['form'] as $key => $value) { $email_msg .= strtoupper($key) . ": " . $value . "\n\n"; } $email_subject = $form_data['form']['FormSubject']; $email_to = $form_data['form']['FormRecipient']; $email_headers = 'From: ' . get_option('admin_email'); $result = formbuilder_send_email($email_to, $email_subject, $email_msg, $email_headers); if ($result) { $error .= $result; } } if (!$error) { return true; } else { $this->resend_email_errors .= $error; return false; } }
function formbuilder_process_email($form, $fields) { global $_POST, $wpdb; $formBuilderTextStrings = formbuilder_load_strings(); $email_msg = ""; $autoresponse_required = false; $source_email = ""; // Iterate through the form fields to add values to the email sent to the recipient. foreach ($fields as $field) { // Add the comments to the email message, if they are appropriate. if (trim($field['field_name']) != "" and $field['field_type'] != "recipient selection" and $field['field_type'] != "comments area" and $field['field_type'] != "followup page" and $field['field_type'] != "spam blocker" and $field['field_type'] != "page break" and $field['field_type'] != "reset button" and $field['field_type'] != "submit button" and $field['field_type'] != "submit image" and $field['field_type'] != "captcha field") { $email_msg .= strtoupper(decode_html_entities($field['field_name'], ENT_QUOTES, get_option('blog_charset'))) . ": " . decode_html_entities($field['value'], ENT_QUOTES, get_option('blog_charset')) . "\r\n\r\n"; $field_values[$field['field_name']] = decode_html_entities($field['value'], ENT_QUOTES, get_option('blog_charset')); } elseif ($field['field_type'] == "recipient selection") { // If we have a recipient selection field, change the form recipient to the selected value. if (eregi(FORMBUILDER_PATTERN_EMAIL, trim($field['value']))) { $form['recipient'] = trim($field['value']); } else { $email_msg .= $formBuilderTextStrings['bad_alternate_email'] . " [" . trim($field['value']) . "]\n\n"; } } // Get source email address, if exists. Will use the first email address listed in the form results, as the source email address. if ($field['required_data'] == "email address" and !$source_email) { $source_email = $field['value']; } // Add the followup page redirect, if it exists. if ($field['field_type'] == "followup page" and trim($field['field_value']) != "") { echo "<meta HTTP-EQUIV='REFRESH' content='0; url=" . $field['field_value'] . "'>"; } } // Add IP if enabled. $ip_capture = get_option('formBuilder_IP_Capture'); if ($ip_capture == 'Enabled' and isset($_SERVER['REMOTE_ADDR'])) { $email_msg .= "IP: " . $_SERVER['REMOTE_ADDR'] . "\r\n"; } $referrer_info = get_option('formBuilder_referrer_info'); if ($referrer_info == 'Enabled') { // Add Page and Referer urls to the bottom of the email. if (isset($_POST['PAGE'])) { $email_msg .= "PAGE: " . $_POST['PAGE'] . "\r\n"; } if (isset($_POST['REFERER'])) { $email_msg .= "REFERER: " . $_POST['REFERER'] . "\r\n"; } } // Set autoresponse information if required and send it out. if ($source_email and $form['autoresponse'] != false and $autoresponse_required == false) { $sql = "SELECT * FROM " . FORMBUILDER_TABLE_RESPONSES . " WHERE id='" . $form['autoresponse'] . "';"; $results = $wpdb->get_results($sql, ARRAY_A); $response_details = $results[0]; $response_details['destination_email'] = $source_email; if ($response_details['from_email'] and $response_details['subject'] and $response_details['message'] and $response_details['destination_email']) { if ($response_details['from_name']) { $response_details['from_email'] = '"' . $response_details['from_name'] . '"<' . $response_details['from_email'] . '>'; } } // Populate ~variable~ tags in the autoresponse with values submitted by the user. foreach ($field_values as $key => $value) { $response_details['subject'] = str_replace("~" . $key . "~", $value, $response_details['subject']); $response_details['message'] = str_replace("~" . $key . "~", $value, $response_details['message']); } $result = formbuilder_send_email($response_details['destination_email'], decode_html_entities($response_details['subject'], ENT_QUOTES, get_option('blog_charset')), $response_details['message'], "From: " . $response_details['from_email'] . "\nReply-To: " . $response_details['from_email'] . "\n"); if ($result) { die($result); } } if (!$source_email) { $source_email = get_option('admin_email'); } return formbuilder_send_email($form['recipient'], decode_html_entities($form['subject'], ENT_QUOTES, get_option('blog_charset')), $email_msg, "From: " . $source_email . "\nReply-To: " . $source_email . "\n"); }