static function validate($text) { // Wordpress will call this function when the settings form is submitted // $text contains the POST options array from the form global $fscf_special_slugs; // List of reserved slug names self::$global_options = FSCF_Util::get_global_options(); self::$form_defaults = FSCF_Util::set_defaults(); if (!isset(self::$form_options)) { self::$form_options = FSCF_Util::get_form_options(self::$current_form, false); } // See if 'donated' status has changed. If so, update global settings. // if the POST variable fs_contact_donated exists, then the checkbox was checked $donated = isset($_POST['fs_contact_donated']) ? 'true' : 'false'; if ($donated != self::$global_options['donated']) { self::$global_options['donated'] = $donated; } if (isset($_POST['fs_dismiss_import_msg'])) { self::$global_options['import_msg'] = false; } // Update global options array based on value of enable_php_sessions // if the POST variable enable_php_session, then the checkbox was checked $php_sessions = isset($_POST['enable_php_sessions']) ? 'true' : 'false'; if ($php_sessions != self::$global_options['enable_php_sessions']) { self::$global_options['enable_php_sessions'] = $php_sessions; } // vcita_auto_install if (!empty($_POST['vcita_auto_install']) && ($_POST['vcita_auto_install'] == 'true' || $_POST['vcita_auto_install'] == 'false')) { self::$global_options['vcita_auto_install'] = $_POST['vcita_auto_install']; } // vcita_dismiss if (!empty($_POST['vcita_dismiss']) && ($_POST['vcita_dismiss'] == 'true' || $_POST['vcita_dismiss'] == 'false')) { self::$global_options['vcita_dismiss'] = $_POST['vcita_dismiss']; } update_option('fs_contact_global', self::$global_options); // Trim trailing spaces FSCF_Util::trim_array($text); // Special processing for certain form fields if ('' == $text['email_to']) { $text['email_to'] = self::$form_defaults['email_to']; } // use default if empty $text['redirect_seconds'] = is_numeric($text['redirect_seconds']) && $text['redirect_seconds'] < 61 ? absint($text['redirect_seconds']) : self::$form_defaults['redirect_seconds']; if ('' == $text['redirect_url']) { $text['redirect_url'] = self::$form_defaults['redirect_url']; } // use default if empty if (!preg_match('/^[0-6]?$/', $text['cal_start_day'])) { $text['cal_start_day'] = self::$form_defaults['cal_start_day']; } $text['attach_types'] = str_replace('.', '', $text['attach_types']); if ('' == $text['attach_size'] || !preg_match('/^([[0-9.]+)([kKmM]?[bB])?$/', $text['attach_size'])) { $text['attach_size'] = self::$form_defaults['attach_size']; } if ('' == $text['auto_respond_from_name']) { $text['auto_respond_from_name'] = self::$form_defaults['auto_respond_from_name']; } // use default if empty if ('' == $text['auto_respond_from_email'] || !FSCF_Util::validate_email($text['auto_respond_from_email'])) { $text['auto_respond_from_email'] = self::$form_defaults['auto_respond_from_email']; } // use default if empty if ($text['auto_respond_reply_to'] == '' || !FSCF_Util::validate_email($text['auto_respond_reply_to'])) { $text['auto_respond_reply_to'] = self::$form_defaults['auto_respond_reply_to']; } // use default if empty // $text['field_size'] = ( is_numeric( $text['field_size'] ) && $text['field_size'] > 14 ) ? absint( $text['field_size'] ) : self::$form_defaults['field_size']; // use default if empty //$text['captcha_field_size'] = ( is_numeric( $text['captcha_field_size'] ) && $text['captcha_field_size'] > 4 ) ? absint( $text['captcha_field_size'] ) : self::$form_defaults['captcha_field_size']; //$text['text_cols'] = absint( $text['text_cols'] ); //$text['text_rows'] = absint( $text['text_rows'] ); if (!empty($text['domain_protect_names'])) { $text['domain_protect_names'] = self::clean_textarea($text['domain_protect_names']); } if (!empty($text['email_to'])) { $text['email_to'] = self::clean_textarea($text['email_to']); } // Use default style settings if styles are empty if (!isset(self::$style_defaults)) { self::$style_defaults = FSCF_Util::set_style_defaults(); } foreach (self::$style_defaults as $key => $val) { //if ( '' == $text[$key] ) // caused error on import settings from some older versions if (!isset($text[$key]) || empty($text[$key])) { $text[$key] = $val; } } // Do we need to reset all styles top this form? if (isset($_POST['fscf_reset_styles'])) { // reset styles feature $text = FSCF_Action::copy_styles(self::$form_defaults, $text); } if (isset($_POST['fscf_reset_styles_top'])) { $style_resets_arr = array('form_style' => 'width:99%; max-width:555px;', 'left_box_style' => 'float:left; width:55%; max-width:270px;', 'right_box_style' => 'float:left; width:235px;', 'clear_style' => 'clear:both;', 'field_left_style' => 'clear:left; float:left; width:99%; max-width:550px; margin-right:10px;', 'field_prefollow_style' => 'clear:left; float:left; width:99%; max-width:250px; margin-right:10px;', 'field_follow_style' => 'float:left; padding-left:10px; width:99%; max-width:250px;', 'title_style' => 'text-align:left; padding-top:5px;', 'field_div_style' => 'text-align:left;', 'captcha_div_style_sm' => 'width:175px; height:50px; padding-top:2px;', 'captcha_div_style_m' => 'width:250px; height:65px; padding-top:2px;', 'captcha_image_style' => 'border-style:none; margin:0; padding:0px; padding-right:5px; float:left;', 'captcha_reload_image_style' => 'border-style:none; margin:0; padding:0px; vertical-align:bottom;', 'submit_div_style' => 'text-align:left; clear:both; padding-top:15px;', 'border_style' => 'border:1px solid black; width:99%; max-width:550px; padding:10px;'); // reset left styles feature foreach ($style_resets_arr as $key => $val) { $text[$key] = $val; } } // end reset styles top if (isset($_POST['fscf_reset_styles_left'])) { $style_resets_arr = array('form_style' => 'width:655px;', 'left_box_style' => 'float:left; width:450px;', 'right_box_style' => 'float:left; width:235px;', 'clear_style' => 'clear:both;', 'field_left_style' => 'clear:left; float:left; margin-right:10px;', 'field_prefollow_style' => 'clear:left; float:left; margin-right:10px;', 'field_follow_style' => 'float:left; padding-left:10px;', 'title_style' => 'width:138px; float:left; clear:left; text-align:right; padding-top:8px; padding-right:10px;', 'field_div_style' => 'text-align:left; float:left; padding-top:10px;', 'captcha_div_style_sm' => 'float:left; width:162px; height:50px; padding-top:5px;', 'captcha_div_style_m' => 'float:left; width:362px; height:65px; padding-top:5px;', 'captcha_image_style' => 'border-style:none; margin:0; padding:0px; padding-right:5px; float:left;', 'captcha_reload_image_style' => 'border-style:none; margin:0; padding:0px; vertical-align:bottom;', 'submit_div_style' => 'padding-left:146px; float:left; clear:left; text-align:left; padding-top:15px;', 'border_style' => 'border:1px solid black; width:99%; max-width:450px; padding:10px;'); // reset left styles feature foreach ($style_resets_arr as $key => $val) { $text[$key] = $val; } } // end reset styles left if (isset($_POST['fscf_reset_styles_labels'])) { $style_resets_arr = array('border_enable' => 'false', 'required_style' => 'text-align:left;', 'required_text_style' => 'text-align:left;', 'hint_style' => 'font-size:x-small; font-weight:normal;', 'error_style' => 'text-align:left; color:red;', 'redirect_style' => 'text-align:left;', 'fieldset_style' => 'border:1px solid black; width:97%; max-width:500px; padding:10px;', 'label_style' => 'display:inline;', 'option_label_style' => 'display:inline;', 'field_style' => 'text-align:left; margin:0; width:99%; max-width:250px;', 'captcha_input_style' => 'text-align:left; margin:0; width:50px;', 'textarea_style' => 'text-align:left; margin:0; width:99%; max-width:250px; height:120px;', 'select_style' => 'text-align:left;', 'checkbox_style' => 'width:13px;', 'radio_style' => 'width:13px;', 'placeholder_style' => 'opacity:0.6; color:#333333;', 'button_style' => 'cursor:pointer; margin:0;', 'reset_style' => 'cursor:pointer; margin:0;', 'vcita_button_style' => 'text-decoration:none; display:block; text-align:center; background:linear-gradient(to bottom, #ed6a31 0%, #e55627 100%); color:#fff !important; padding:10px;', 'vcita_div_button_style' => 'border-left:1px dashed #ccc; margin-top:25px; height:50px; padding:8px 20px;', 'powered_by_style' => 'font-size:x-small; font-weight:normal; padding-top:5px; text-align:center;'); // reset label styles feature foreach ($style_resets_arr as $key => $val) { $text[$key] = $val; } } // end reset styles left // List of all checkbox settings names (except for checkboxes in fields) $checkboxes = array('email_from_enforced', 'preserve_space_enable', 'double_email', 'name_case_enable', 'sender_info_enable', 'domain_protect', 'email_check_dns', 'email_html', 'akismet_disable', 'captcha_enable', 'akismet_send_anyway', 'captcha_small', 'email_hide_empty', 'email_keep_attachments', 'print_form_enable', 'captcha_perm', 'honeypot_enable', 'redirect_enable', 'redirect_query', 'redirect_email_off', 'silent_email_off', 'export_email_off', 'ex_fields_after_msg', 'email_inline_label', 'textarea_html_allow', 'enable_areyousure', 'enable_submit_oneclick', 'auto_respond_enable', 'auto_respond_html', 'req_field_indicator_enable', 'req_field_label_enable', 'border_enable', 'anchor_enable', 'aria_required', 'auto_fill_enable', 'enable_reset', 'enable_credit_link'); // Set missing checkbox values to 'false' because these boxes were unchecked // html form checkboxes do not return anything in POST if unchecked // $text = array_merge($unchecked, $text); foreach ($checkboxes as $checkbox) { if (!isset($text[$checkbox])) { $text[$checkbox] = 'false'; } } // Sanitize settings fields $html_fields = array('welcome', 'after_form_note', 'req_field_indicator', 'text_message_sent', 'success_page_html'); if ('true' == $text['auto_respond_html']) { $html_fields[] = 'auto_respond_message'; } foreach ($text as $key => $value) { if (is_string($value)) { if (in_array($key, $html_fields)) { //$text[$key] = wp_filter_kses( $value ); //strips too much $text[$key] = $value; } else { $text[$key] = strip_tags($value); } } } // Process contact form fields $slug_list = $fscf_special_slugs; // The $special_slugs list is also used in FSCF_Display::get_query_parms() // $special_slugs = array( 'f_name', 'm_name', 'mi_name', 'l_name', 'email2', 'mailto_id', 'subject_id' ); $select_type_fields = array('checkbox-multiple', 'select', 'select-multiple', 'radio'); // none of the field slugs can be the same as a post type rewrite_slug // or you will get "page not found" when posting the form with that field filled in self::get_post_types_slugs(); $slug_list = array(); if (isset(self::$form_options) && !empty(self::$form_options['fields'])) { foreach (self::$form_options['fields'] as $key => $field) { $slug_list[] = $field['slug']; } } $bad_slugs = array(); foreach (self::$post_types_slugs as $key => $slug) { if (in_array(strtolower($slug), $slug_list)) { $bad_slugs[] = $slug; } } foreach ($text['fields'] as $key => $field) { if (isset($field['delete']) && "true" == $field['delete']) { // Delete the field unset($text['fields'][$key]); } else { unset($text['fields']['$key']['delete']); // Don't need to keep this // Add 'false' to any missing checkboxes for fields if (!isset($field['req'])) { $text['fields'][$key]['req'] = 'false'; } if (!isset($field['disable'])) { $text['fields'][$key]['disable'] = 'false'; } if (!isset($field['follow'])) { $text['fields'][$key]['follow'] = 'false'; } if (!isset($field['inline'])) { $text['fields'][$key]['inline'] = 'false'; } if (!isset($field['hide_label'])) { $text['fields'][$key]['hide_label'] = 'false'; } if (!isset($field['placeholder'])) { $text['fields'][$key]['placeholder'] = 'false'; } // Sanitize html in form field settings foreach ($field as $k => $v) { if (is_string($v)) { //if ( 'notes' == $k || 'notes_after' == $k ) $text['fields'][$key][$k] = wp_filter_kses( $v ); //strips too much if ('notes' == $k || 'notes_after' == $k) { $text['fields'][$key][$k] = $v; } else { $text['fields'][$key][$k] = strip_tags($v); } // strip html tags } } // Make sure the field name is not blank if (empty($field['label'])) { $text['fields'][$key]['label'] = sprintf(__('Field %s', 'si-contact-form'), $key); $temp = sprintf(__('Field label cannot be blank. Label set to "Field %s". To delete a field, use the delete option.', 'si-contact-form'), $key); add_settings_error('fscf_field_settings', 'missing-label', $temp); } // Sanitize the slug $slug_changed = false; if (!empty($field['slug']) && in_array(strtolower($field['slug']), $bad_slugs)) { $slug_changed = true; } if (empty($field['slug'])) { // no slug, so make one from the label // the sanitize title function encodes UTF-8 characters, so we need to undo that // this line croaked on some chinese characters //$field['slug'] = substr( urldecode(sanitize_title_with_dashes(remove_accents($field['label']))), 0, FSCF_MAX_SLUG_LEN ); $field['slug'] = remove_accents($field['label']); $field['slug'] = preg_replace('~([^a-zA-Z\\d_ .-])~', '', $field['slug']); $field['slug'] = substr(urldecode(sanitize_title_with_dashes($field['slug'])), 0, FSCF_MAX_SLUG_LEN); if ($field['slug'] == '') { $field['slug'] = 'na'; } if ('-' == substr($field['slug'], strlen($field['slug']) - 1, 1)) { $field['slug'] = substr($field['slug'], 0, strlen($field['slug']) - 1); } $slug_changed = true; } else { if (empty(self::$form_options['fields'][$key]['slug']) || $field['slug'] != self::$form_options['fields'][$key]['slug']) { // The slug has changed, so sanitize it // this line croaked on some chinese characters //$field['slug'] = substr( urldecode(sanitize_title_with_dashes(remove_accents($field['slug']))), 0, FSCF_MAX_SLUG_LEN ); $field['slug'] = remove_accents($field['slug']); $field['slug'] = preg_replace('~([^a-zA-Z\\d_ .-])~', '', $field['slug']); $field['slug'] = substr(urldecode(sanitize_title_with_dashes($field['slug'])), 0, FSCF_MAX_SLUG_LEN); if ($field['slug'] == '') { $field['slug'] = 'na'; } $slug_changed = true; } } // Make sure the slug is unique if ($slug_changed) { $text['fields'][$key]['slug'] = self::check_slug($field['slug'], $slug_list); } } $slug_list[] = $text['fields'][$key]['slug']; // If a select type field, make sure the select options list is not empty if (in_array($field['type'], $select_type_fields)) { // remove blank lines and trim options if (!empty($text['fields'][$key]['options'])) { $text['fields'][$key]['options'] = self::clean_textarea($text['fields'][$key]['options']); } if (empty($field['options'])) { $temp = sprintf(__('Select options are required for the %s field.', 'si-contact-form'), $field['label']); add_settings_error('fscf_field_settings', 'missing-options', $temp); } } // If date type field, check format of default (if any) if ('date' == $field['type'] && '' != $field['default']) { if ($field['default'] != '[today]' && !FSCF_Process::validate_date($field['default'], self::$current_form)) { $cal_date_array = array('mm/dd/yyyy' => esc_html(__('mm/dd/yyyy', 'si-contact-form')), 'dd/mm/yyyy' => esc_html(__('dd/mm/yyyy', 'si-contact-form')), 'mm-dd-yyyy' => esc_html(__('mm-dd-yyyy', 'si-contact-form')), 'dd-mm-yyyy' => esc_html(__('dd-mm-yyyy', 'si-contact-form')), 'mm.dd.yyyy' => esc_html(__('mm.dd.yyyy', 'si-contact-form')), 'dd.mm.yyyy' => esc_html(__('dd.mm.yyyy', 'si-contact-form')), 'yyyy/mm/dd' => esc_html(__('yyyy/mm/dd', 'si-contact-form')), 'yyyy-mm-dd' => esc_html(__('yyyy-mm-dd', 'si-contact-form')), 'yyyy.mm.dd' => esc_html(__('yyyy.mm.dd', 'si-contact-form'))); $temp = sprintf(__('Default date for %s is not correctly formatted. Format should be %s.', 'si-contact-form'), $field['label'], $cal_date_array[$text['date_format']]); add_settings_error('fscf_field_settings', 'invalid-date', $temp); } } } // end foreach (Process fields) $text = self::vcita_update_details($text); FSCF_Util::unencode_html($text); // Update the query args if necessary if (!isset($_POST['ctf_action']) && isset($_REQUEST['_wp_http_referer'])) { // Set the current tab in _wp_http_referer so that we go there after the save $wp_referer = remove_query_arg('fscf_tab', $_REQUEST['_wp_http_referer']); $wp_referer = add_query_arg('fscf_tab', $_POST['current_tab'], $wp_referer); if (isset($text['akismet_check'])) { // Request Akismet check on page reload $wp_referer = add_query_arg('akismet_check', 'true', $wp_referer); unset($text['akismet_check']); // Don't save this in database } else { $wp_referer = remove_query_arg('akismet_check', $wp_referer); } $_REQUEST['_wp_http_referer'] = $wp_referer; } return $text; }
static function import_old_version($force = '') { // global $fscf_special_slugs; // List of reserve slug names // ***** Import global options ***** // upgrade import only back to version 2.5.6, because before that, there was no 'si_contact_form_gb' setting self::$old_global_options = get_option('si_contact_form_gb'); if (empty(self::$old_global_options)) { return; } //print_r(self::$old_global_options)."<br>\n"; self::$global_options = FSCF_Util::get_global_options(); // import a few global options $copy_fields = array('donated', 'vcita_dismiss'); foreach ($copy_fields as $field) { if (!empty(self::$old_global_options[$field])) { self::$global_options[$field] = self::$old_global_options[$field]; } } // import this global option // Highest form ID (used to assign ID to new form) // When forms are deleted, the remaining forms are NOT renumberd, so max_form_num might be greater than // the number of existing forms if (!empty(self::$old_global_options['max_forms'])) { self::$global_options['max_form_num'] = self::$old_global_options['max_forms']; } //print 'max_form_num:'.self::$global_options['max_form_num']."<br>\n"; // ***** Import form options ***** $max_fields_shim = 8; if ($force == 'force') { // force is when they pressed the button import from 3.xx, they are warned this replaces the 4.xx forms self::$global_options['form_list'] = array(); // delete current form list // delete current 4.xx forms delete_option('fs_contact_global'); // delete up to 100 forms (a unique configuration for each contact form) for ($i = 1; $i <= 100; $i++) { delete_option("fs_contact_form{$i}"); } } for ($frm = 1; $frm <= self::$global_options['max_form_num']; $frm++) { //print 'importing form:'.$frm."<br>\n"; $old_opt_name = 'si_contact_form'; $old_opt_name .= $frm == 1 ? '' : $frm; self::$old_form_options = get_option($old_opt_name); if (!self::$old_form_options) { continue; } if ($force == 'force') { } else { // Make sure that the options for this form doesn't already exist self::$form_options = FSCF_Util::get_form_options($frm, $use_defaults = false); if (self::$form_options) { continue; } } // if max fields is missing it will be 8, or the value of the last one in the loop. if (isset(self::$old_form_options['max_fields']) && self::$old_form_options['max_fields'] > 0) { $max_fields_shim = self::$old_form_options['max_fields']; } else { self::$old_form_options['max_fields'] = $max_fields_shim; } $new_form_options = self::convert_form_options(self::$old_form_options, self::$old_form_options['max_fields']); //print_r($new_form_options)."<br>\n"; // Save the imported form $form_option_name = 'fs_contact_form' . $frm; // Add form name to the form list... if ($new_form_options['form_name'] == '') { $new_form_options['form_name'] = __('imported', 'si-contact-form'); } self::$global_options['form_list'][$frm] = $new_form_options['form_name']; update_option($form_option_name, $new_form_options); } // end for loop (forms) self::$global_options['import_success'] = true; self::$global_options['import_msg'] = true; // recalibrate max_form_num to the highest form number (not count) ksort(self::$global_options['form_list']); self::$global_options['max_form_num'] = max(array_keys(self::$global_options['form_list'])); //print_r(self::$global_options)."<br>\n"; update_option('fs_contact_global', self::$global_options); // Display a notice on the admin page FSCF_Util::add_admin_notice(__('Fast Secure Contact Form has imported settings from the old version.', 'si-contact-form'), 'updated'); // Force reload of global and form options FSCF_Options::unload_options(); }
static function is_captcha_enabled($frm_num) { // See if captcha is enabled for this user and this form // Returns true or false if (!self::$form_options) { self::$form_options = FSCF_Util::get_form_options($frm_num, $use_defaults = true); } $captcha_enabled = true; if (self::$form_options['captcha_enable'] !== 'true') { $captcha_enabled = false; // captcha setting is disabled for si contact } // skip the captcha if user is loggged in and the settings allow if (is_user_logged_in() && self::$form_options['captcha_perm'] == 'true') { // skip the CAPTCHA display if the minimum capability is met if (current_user_can(self::$form_options['captcha_perm_level'])) { $captcha_enabled = false; } } return $captcha_enabled; }
static function validate_date($input, $form_id_num) { // Checks date input for proper formatting of actual calendar dates // Matches the date format and also validates month and number of days in a month. // All leap year dates allowed. if (!self::$form_options) { self::$form_options = FSCF_Util::get_form_options($form_id_num, $use_defaults = true); } $date_format = self::$form_options['date_format']; // find the delimiter of the date_format setting: slash, dash, or dot if (strpos($date_format, '/')) { $delim = '/'; $regexdelim = '\\/'; } else { if (strpos($date_format, '-')) { $delim = '-'; $regexdelim = '-'; } else { if (strpos($date_format, '.')) { $delim = '.'; $regexdelim = '\\.'; } } } if ($date_format == "mm{$delim}dd{$delim}yyyy") { $regex = "/^(((0[13578]|(10|12)){$regexdelim}(0[1-9]|[1-2][0-9]|3[0-1]))|(02{$regexdelim}(0[1-9]|[1-2][0-9]))|((0[469]|11){$regexdelim}(0[1-9]|[1-2][0-9]|30))){$regexdelim}[0-9]{4}\$/"; } if ($date_format == "dd{$delim}mm{$delim}yyyy") { $regex = "/^(((0[1-9]|[1-2][0-9]|3[0-1]){$regexdelim}(0[13578]|(10|12)))|((0[1-9]|[1-2][0-9]){$regexdelim}02)|((0[1-9]|[1-2][0-9]|30){$regexdelim}(0[469]|11))){$regexdelim}[0-9]{4}\$/"; } if ($date_format == "yyyy{$delim}mm{$delim}dd") { $regex = "/^[0-9]{4}{$regexdelim}(((0[13578]|(10|12)){$regexdelim}(0[1-9]|[1-2][0-9]|3[0-1]))|(02{$regexdelim}(0[1-9]|[1-2][0-9]))|((0[469]|11){$regexdelim}(0[1-9]|[1-2][0-9]|30)))\$/"; } if (!preg_match($regex, $input)) { return false; } else { return true; } }
static function send_test_email() { // Send a test mail if necessary if (isset($_POST['si_contact_to']) && check_admin_referer('fs_contact_options-options', 'fs_options')) { // Send a test email // new lines should be (\n for UNIX, \r\n for Windows and \r for Mac) FSCF_Options::$form_options = FSCF_Util::get_form_options(FSCF_Options::$current_form, true); // get_options(); $php_eol = !defined('PHP_EOL') ? ($eol = strtolower(substr(PHP_OS, 0, 3))) == 'win' ? "\r\n" : ($eol == 'mac' ? "\r" : "\n") : PHP_EOL; $php_eol = !$php_eol ? "\n" : $php_eol; $email = $_POST['si_contact_to']; $name = __('Fast Secure Contact Form', 'si-contact-form'); if (FSCF_Util::validate_email($email)) { $subject = __('Test email to ', 'si-contact-form') . $email; $message = __('This is a test email generated by the Fast Secure Contact Form WordPress plugin.', 'si-contact-form'); $message = wordwrap($message, 70, $php_eol); $smtp_debug = ''; $ctf_email_on_this_domain = FSCF_Options::$form_options['email_from']; // optional // prepare the email header self::$si_contact_from_name = $name; self::$si_contact_from_email = $email; //$si_contact_mail_sender = $ctf_email_on_this_domain; if ($ctf_email_on_this_domain != '') { if (!preg_match("/,/", $ctf_email_on_this_domain)) { // just an email: user1@example.com $si_contact_mail_sender = $ctf_email_on_this_domain; if (FSCF_Options::$form_options['email_from_enforced'] == 'true') { self::$si_contact_from_email = $ctf_email_on_this_domain; } } else { // name and email: webmaster,user1@example.com list($key, $value) = explode(",", $ctf_email_on_this_domain); $key = trim($key); $value = trim($value); $si_contact_mail_sender = $value; if (FSCF_Options::$form_options['email_from_enforced'] == 'true') { self::$si_contact_from_email = $value; } } } $header_php = 'From: ' . self::$si_contact_from_name . ' <' . self::$si_contact_from_email . '>\\n'; // header for php mail only $header = ''; // for php mail and wp_mail if (FSCF_Options::$form_options['email_reply_to'] != '') { // custom reply_to $header .= "Reply-To: " . FSCF_Options::$form_options['email_reply_to'] . "\n"; } else { $header .= "Reply-To: {$email}\n"; } if ($ctf_email_on_this_domain != '') { $header .= 'X-Sender: ' . $si_contact_mail_sender . "\n"; $header .= 'Return-Path: ' . $si_contact_mail_sender . "\n"; } $header .= 'Content-type: text/plain; charset=' . get_option('blog_charset') . $php_eol; @ini_set('sendmail_from', self::$si_contact_from_email); // Check for safe mode $safe_mode = (bool) @ini_get('safe_mode') === false ? 0 : 1; if (FSCF_Options::$form_options['php_mailer_enable'] == 'php') { // sending with php mail $header_php .= $header; // Start output buffering to grab smtp debugging output ob_start(); if ($ctf_email_on_this_domain != '' && !$safe_mode) { // Pass the Return-Path via sendmail's -f command. $result = mail($email, $subject, $message, $header_php, '-f ' . $si_contact_mail_sender); } else { // the fifth parameter is not allowed in safe mode $result = mail($email, $subject, $message, $header_php); } $smtp_debug = ob_get_clean(); } else { if (FSCF_Options::$form_options['php_mailer_enable'] == 'wordpress') { // sending with wp_mail add_filter('wp_mail_from', 'FSCF_Action::si_contact_form_from_email', 1); // took out _form add_filter('wp_mail_from_name', 'FSCF_Action::si_contact_form_from_name', 1); // took out _form if ($ctf_email_on_this_domain != '') { // Add an action on phpmailer_init to add Sender $this->si_contact_mail_sender for Return-path in wp_mail // this helps spf checking when the Sender email address matches the site domain name add_action('phpmailer_init', 'FSCF_Action::si_contact_form_mail_sender', 1); } global $phpmailer; // Make sure the PHPMailer class has been instantiated // (copied verbatim from wp-includes/pluggable.php) // (Re)create it, if it's gone missing if (!is_object($phpmailer) || !is_a($phpmailer, 'PHPMailer')) { require_once ABSPATH . WPINC . '/class-phpmailer.php'; require_once ABSPATH . WPINC . '/class-smtp.php'; $phpmailer = new PHPMailer(); } // Set SMTPDebug to level 2 $phpmailer->SMTPDebug = 2; // Start output buffering to grab smtp debugging output ob_start(); // Send the test mail $result = wp_mail($email, $subject, $message, $header); // Grab the smtp debugging output $smtp_debug = ob_get_clean(); } } // Output the response ?> <div id="message" class="updated"><p><strong><?php _e('Test Message Sent', 'si-contact-form'); echo '<br />' . FSCF_Options::$form_options['php_mailer_enable']; echo ' ' . $subject; ?> </strong></p> <?php if ($result != true) { ?> <p><?php _e('The result was:', 'si-contact-form'); ?> </p> <?php echo '<p><a href="http://www.fastsecurecontactform.com/email-does-not-send">' . __('See FAQ', 'si-contact-form') . '</a></p>'; ?> <pre><?php esc_html(var_dump($result)); ?> </pre> <?php if (FSCF_Options::$form_options['php_mailer_enable'] == 'wordpress') { ?> <p><?php _e('The full debugging output is shown below:', 'si-contact-form'); ?> </p> <?php echo '<p><a href="http://www.fastsecurecontactform.com/email-does-not-send">' . __('See FAQ', 'si-contact-form') . '</a></p>'; ?> <pre><?php esc_html(var_dump($phpmailer)); ?> </pre> <?php } } else { echo '<p>' . _e('Be sure to check your email to see if you received it.', 'si-contact-form') . '</p>'; echo '<p><a href="http://www.fastsecurecontactform.com/email-does-not-send">' . __('See FAQ', 'si-contact-form') . '</a></p>'; } if ($smtp_debug != '') { ?> <p><?php _e('The Email debugging output is shown below:', 'si-contact-form'); ?> </p> <?php echo '<p><a href="http://www.fastsecurecontactform.com/email-does-not-send">' . __('See FAQ', 'si-contact-form') . '</a></p>'; ?> <pre><?php echo esc_html($smtp_debug); ?> </pre> <?php } } else { echo '<div id="message" class="updated"><p><strong>' . __('Test failed: Invalid email address', 'si-contact-form') . '</strong></p>'; } ?> </div> <?php } // end Send a test mail if necessary }