';
echo __( 'Internal Error: Invalid form number.', 'si-contact-form' );
echo "\n";
self::$current_form = $form_num_default;
}
self::$form_option_name = "fs_contact_form" . self::$current_form;
// Check for the current tab number
if ( isset( $_REQUEST['fscf_tab'] ) && is_numeric( $_REQUEST['fscf_tab'] ) )
self::$current_tab = absint($_REQUEST['fscf_tab']);
else
self::$current_tab = 1;
}
static function register_options_page() {
// Adds link on admin 'Settings' menu
add_options_page(
__('Fast Secure Contact Form Options', 'si-contact-form'), // The text to the display in the browser when this menu item is active
__('FS Contact Form', 'si-contact-form'), // The text for this menu item
'manage_options', // Which type of users can see this menu
// The slug should point to the main plugin file, not this one!
'si-contact-form/si-contact-form.php', // __FILE__, // The unique ID - the slug - for this menu item
'FSCF_Options::display_options' // The function used to render the menu for this page to the screen
);
}
static function get_options() {
if ( ! isset( self::$form_defaults ) )
self::$form_defaults = FSCF_Util::set_defaults ( );
if ( ! self::$global_options ) {
self::$global_options = FSCF_Util::get_global_options();
}
if ( ! self::$form_options ) {
self::$form_options = FSCF_Util::get_form_options(self::$current_form, true);
}
// See if the form name has changed--if so, update it in the list
if ( ( self::$global_options['form_list'][self::$current_form] <> self::$form_options['form_name'] ) &&
self::$form_options['form_name'] <> "" ) {
self::$global_options['form_list'][self::$current_form] = self::$form_options['form_name'];
update_option( 'fs_contact_global', self::$global_options );
}
if ( count( self::$form_options ) < count( self::$form_defaults ) ) {
// add missing elements from the default form options array
self::$form_options = array_merge( self::$form_defaults, self::$form_options );
}
}
static function unload_options() {
// Forces the reload of global and form options
// Called by FSCF_Action::restore_settings()
self::$global_options = false;
self::$form_options = false;
}
static function initialize_options() {
// Carry out form backup if requested
if ( isset($_POST['ctf_action']) && esc_attr__('Backup Settings', 'si-contact-form') == $_POST['ctf_action'] ) FSCF_Action::backup_download();
// Get the current form
self::get_form_num();
// Register settings sections
add_settings_section(
'fscf_basic_settings', // ID used to identify this section and with which to register options
__('Basic Settings', 'si-contact-form'), // Title to be displayed on the administration page
'FSCF_Options::basic_settings_callback', // Callback used to render the description of the section
'tab_page1' // Page on which to add this section of options
);
add_settings_section(
'fscf_email_settings',
__('Email Settings', 'si-contact-form'),
'FSCF_Options::email_settings_callback',
'tab_page1'
);
add_settings_section(
'fscf_field_settings',
__('Field Settings', 'si-contact-form'),
'FSCF_Options::field_settings_callback',
'tab_page2'
);
add_settings_section(
'fscf_style_settings',
__('Style Settings', 'si-contact-form'),
'FSCF_Options::style_settings_callback',
'tab_page3'
);
add_settings_section(
'fscf_label_settings',
__('Field Label Settings', 'si-contact-form'),
'FSCF_Options::label_settings_callback',
'tab_page4'
);
add_settings_section(
'fscf_tooltip_settings',
__('Tooltip Label Settings', 'si-contact-form'),
'FSCF_Options::tooltip_settings_callback',
'tab_page4'
);
add_settings_section(
'fscf_error_settings',
__('Error Message Settings', 'si-contact-form'),
'FSCF_Options::error_settings_callback',
'tab_page4'
);
add_settings_section(
'fscf_captcha_settings',
__('CAPTCHA Settings', 'si-contact-form'),
'FSCF_Options::captcha_settings_callback',
'tab_page5'
);
add_settings_section(
'fscf_akismet_settings',
__('Akismet Settings', 'si-contact-form'),
'FSCF_Options::akismet_settings_callback',
'tab_page5'
);
add_settings_section(
'fscf_domain_settings',
__('Domain Protect Settings', 'si-contact-form'),
'FSCF_Options::domain_settings_callback',
'tab_page5'
);
add_settings_section(
'fscf_confirmation_email',
__('Confirmation Email Settings', 'si-contact-form'),
'FSCF_Options::confirmation_email_callback',
'tab_page6'
);
add_settings_section(
'fscf_redirect',
__('Redirect Settings', 'si-contact-form'),
'FSCF_Options::redirect_callback',
'tab_page6'
);
add_settings_section(
'fscf_advanced_form',
__('Advanced Form Settings', 'si-contact-form'),
'FSCF_Options::advanced_form_callback',
'tab_page6'
);
add_settings_section(
'fscf_advanced_email',
__('Advanced Email Settings', 'si-contact-form'),
'FSCF_Options::advanced_email_callback',
'tab_page6'
);
add_settings_section(
'fscf_silent_sending',
__('Silent Remote Sending Settings', 'si-contact-form'),
'FSCF_Options::silent_sending_callback',
'tab_page6'
);
add_settings_section(
'fscf_data_export',
__('Data Export Settings', 'si-contact-form'),
'FSCF_Options::data_export_callback',
'tab_page6'
);
add_settings_section(
'fscf_meeting_settings',
__('vCita Online Scheduling Settings', 'si-contact-form'),
'FSCF_Options::meeting_settings_callback',
'tab_page7'
);
add_settings_section(
'fscf_tools_settings',
__('Tools and Backup', 'si-contact-form'),
'FSCF_Options::tools_callback',
'tab_page8'
);
//
';
settings_fields( 'fs_contact_options' );
do_settings_sections( 'tab_page' . $i );
if ( $i < $num_tabs ) {
// submit_button();
// XXX if moving tabs around, you have may have to change 8 to a diff number, also make a change in fscf-scripts-admin.js if (tabId < 8) {
if ($i != 8) { // skip tab 8 for the tools tab
?>
';
echo __('Caution: "External Style Sheet CSS" is enabled in the Styles tab. This setting requires your theme\'s style.css to include the custom CSS. You can get the custom CSS on the Styles tab. Be sure your theme includes the custom CSS from this plugin, if it does not, then add the custom CSS to your theme or change the setting back to "Internal Style Sheet CSS".', 'si-contact-form');
echo " \n";
echo '
';
echo __('Note: "Internal Style Sheet CSS" fields below are not editable while "External Style Sheet CSS" is enabled.', 'si-contact-form');
echo "
';
echo __( 'Warning: Enabling this setting requires all the confirmation email fields below to also be set.', 'si-contact-form' );
echo "\n";
}
if ( ! self::$autoresp_ok && self::$form_options['auto_respond_enable'] == 'true' && self::$form_options['auto_respond_from_name'] != '' && self::$form_options['auto_respond_from_email'] != '' && self::$form_options['auto_respond_reply_to'] != '' && self::$form_options['auto_respond_subject'] != '' && self::$form_options['auto_respond_message'] != '' ) {
echo '
';
echo __( 'Warning: You have disabled the email address field on the Fields tab, you will not be able to reply to emails and the confirmation email (if enabled) will not work.', 'si-contact-form' );
echo "
\n";
}
if ( ! self::$autoresp_ok ) {
echo '
';
echo __( 'Warning: You have disabled the email address field on the Fields tab, you will not be able to reply to emails and the confirmation email (if enabled) will not work.', 'si-contact-form' );
echo "
\n";
}
?>
[from_name]
";
?>
[from_name]
";
}
?>
value="true" />
<html><body>
<h1></h1>
</body></html>
value="true" />
';
echo __( 'Warning: Enabling this setting requires the "Enable redirect" to also be set.', 'si-contact-form' );
echo "\n";
}
?>
value="true" />
";
?>
from_name=name
from_email=email
";
?>
account=3629675
newsletter=join
action=signup
';
echo __( 'Warning: Enabling this setting requires the "Enable redirect" and "Enable posted data to be sent as a query string" to also be set.', 'si-contact-form' );
echo "\n";
}
?>
';
echo __( 'Just a reminder: You have turned off email sending in the setting below. If that is what you intended, then ignore this message.', 'si-contact-form' );
echo "\n";
}
?>
value="true" />
value="true" />
value="true" />
value="true" />
OK - Writable ' . substr(sprintf('%o', fileperms($check_this_dir)), -4);
} else if ( !file_exists( $check_this_dir ) ) {
echo '';
echo __( 'There is a problem with the directory', 'si-contact-form' );
echo ' /captcha/cache/. ';
echo __( 'The directory is not found, a permissions problem may have prevented this directory from being created.', 'si-contact-form' );
echo ' ';
echo __( 'Fixing the actual problem is recommended, but you can check this setting on the contact form options page: "Use PHP Sessions" and the captcha will work this way just fine (as long as PHP Sessions are supported by your web host).', 'si-contact-form');
echo ' ';
} else {
echo '';
echo __( 'There is a problem with the directory', 'si-contact-form' ) . ' /captcha/cache/. ';
echo __( 'The directory Unwritable (fix permissions)', 'si-contact-form' ) . '. ';
echo __( 'Permissions are: ', 'si-contact-form' );
echo ' ';
echo substr( sprintf( '%o', fileperms( $check_this_dir ) ), -4 );
echo ' ';
echo __( 'Fixing this may require assigning 0755 permissions or higher (e.g. 0777 on some hosts. Try 0755 first, because 0777 is sometimes too much and will not work.)', 'si-contact-form' );
echo ' ';
echo __( 'Fixing the actual problem is recommended, but you can check this setting on the contact form options page: "Use PHP Sessions" and the captcha will work this way just fine (as long as PHP Sessions are supported by your web host).', 'si-contact-form');
echo ' ';
}
}
?>
value="true" />
Visitor Maps plugin to enable geolocation and then city, state, country will automatically be included.', 'si-contact-form' ); ?>
value="true" />
value="true" />
';
echo __( 'Warning: Enabling this setting requires the "Silent Remote URL" to also be set.', 'si-contact-form' );
echo "\n";
}
?>
";
?>
from_name=name
from_email=email
";
?>
account=3629675
newsletter=join
action=signup
";
?>
';
echo __( 'Warning: Enabling this setting requires the "Silent Remote Send" and "Silent Remote URL" to also be set.', 'si-contact-form' );
echo "\n";
}
?>
';
echo __( 'Just a reminder: You have turned off email sending in the setting below. This is just a reminder in case that was a mistake. If that is what you intended, then ignore this message.', 'si-contact-form' );
echo "\n";
}
?>
value="true" />
Contact Form DB plugin.', 'si-contact-form' ), 'http://www.fastsecurecontactform.com/save-to-database' ); ?>
";
?>
from_name=name
from_email=email
";
?>
account=3629675
newsletter=join
action=signup
';
echo __( 'Just a reminder: You have turned off email sending in the setting below. This is just a reminder in case that was a mistake. If that is what you intended, then ignore this message.', 'si-contact-form' );
echo "\n";
}
?>
value="true" />
value="true" />
value="true" />
';
echo __( 'Warning: reCAPTCHA V2 API key(s) missing. Enabling reCAPTCHA V2 on the Security tab requires the keys to also be set.', 'si-contact-form' );
echo "\n";
}
?>
Get reCAPTCHA V2 keys for your site here', 'si-contact-form' ); ?>
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'];
// recaptcha keys are a global setting so all forms will have it filled in
if ( ! empty($_POST['recaptcha_public_key']))
self::$global_options['recaptcha_public_key'] = sanitize_text_field( $_POST['recaptcha_public_key'] );
if ( ! empty($_POST['recaptcha_secret_key']))
self::$global_options['recaptcha_secret_key'] = sanitize_text_field( $_POST['recaptcha_secret_key'] );
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(
// 'border_enable' => 'false',
// reset labels on top
// Alignment DIVs
'form_style' => 'width:99%; max-width:555px;', // Form DIV, how wide is the form DIV
'left_box_style' => 'float:left; width:55%; max-width:270px;', // left box DIV, container for vcita
'right_box_style' => 'float:left; width:235px;', // right box DIV, container for vcita
'clear_style' => 'clear:both;', // clear both
'field_left_style' => 'clear:left; float:left; width:99%; max-width:550px; margin-right:10px;', // field left
'field_prefollow_style' => 'clear:left; float:left; width:99%; max-width:250px; margin-right:10px;', // field pre follow
'field_follow_style' => 'float:left; padding-left:10px; width:99%; max-width:250px;', // field follow
'title_style' => 'text-align:left; padding-top:5px;', // Input labels alignment DIV
'field_div_style' => 'text-align:left;', // Input fields alignment DIV
'captcha_div_style_sm' => 'width:175px; height:50px; padding-top:2px;', // Small CAPTCHA DIV
'captcha_div_style_m' => 'width:250px; height:65px; padding-top:2px;', // Large CAPTCHA DIV
'captcha_image_style' => 'border-style:none; margin:0; padding:0px; padding-right:5px; float:left;', // CAPTCHA image alignment
'captcha_reload_image_style' => 'border-style:none; margin:0; padding:0px; vertical-align:bottom;', // CAPTCHA reload image alignment
'submit_div_style' => 'text-align:left; clear:both; padding-top:15px;', // Submit DIV
'border_style' => 'border:1px solid black; width:99%; max-width:550px; padding:10px;', // style of the fieldset box (if enabled)
);
// 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(
//'border_enable' => 'false',
// reset labels on left
// Alignment DIVs
'form_style' => 'width:655px;', // how wide is the form DIV
'left_box_style' => 'float:left; width:450px;', // left box DIV, container for vcita
'right_box_style' => 'float:left; width:235px;', // right box DIV, container for vcita
'clear_style' => 'clear:both;', // clear both
'field_left_style' => 'clear:left; float:left; margin-right:10px;', // field left
'field_prefollow_style' => 'clear:left; float:left; margin-right:10px;', // field pre follow
'field_follow_style' => 'float:left; padding-left:10px;', // field follow
'title_style' => 'width:138px; float:left; clear:left; text-align:right; padding-top:8px; padding-right:10px;', // Input labels alignment DIV
'field_div_style' => 'text-align:left; float:left; padding-top:10px;', // Input fields alignment DIV
'captcha_div_style_sm' => 'float:left; width:162px; height:50px; padding-top:5px;', // Small CAPTCHA DIV
'captcha_div_style_m' => 'float:left; width:362px; height:65px; padding-top:5px;', // Large CAPTCHA DIV
'captcha_image_style' => 'border-style:none; margin:0; padding:0px; padding-right:5px; float:left;', // CAPTCHA image alignment
'captcha_reload_image_style' => 'border-style:none; margin:0; padding:0px; vertical-align:bottom;', // CAPTCHA reload image alignment
'submit_div_style' => 'padding-left:146px; float:left; clear:left; text-align:left; padding-top:15px;', // Submit DIV
'border_style' => 'border:1px solid black; width:99%; max-width:450px; padding:10px;', // style of the fieldset box (if enabled)
);
// 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',
// reset labels only
// Style of labels, fields and text
'required_style' => 'text-align:left;', // required field indicator
'required_text_style' => 'text-align:left;', // required field text
'hint_style' => 'font-size:x-small; font-weight:normal;', // small text hints like please enter your email again
'error_style' => 'text-align:left; color:red;', // Input validation messages
'redirect_style' => 'text-align:left;', // Redirecting message
'fieldset_style' => 'border:1px solid black; width:97%; max-width:500px; padding:10px;', // style of the fieldset box (for fields)
'label_style' => 'display:inline;', // Field labels
'option_label_style' => 'display:inline;', // Options labels
'field_style' => 'text-align:left; margin:0; width:99%; max-width:250px;', // Input text fields (out of place here?)
'captcha_input_style' => 'text-align:left; margin:0; width:50px;', // CAPTCHA input field
'textarea_style' => 'text-align:left; margin:0; width:99%; max-width:250px; height:120px;', // Input Textarea
'select_style' => 'text-align:left;', // Input Select
'checkbox_style' => 'width:22px; height:32px;', // Input checkbox
'radio_style' => 'width:22px; height:32px;', // Input radio
'placeholder_style' => 'opacity:0.6; color:#333333;', // placeholder style
'button_style' => 'cursor:pointer; margin:0;', // Submit button
'reset_style' => 'cursor:pointer; margin:0;', // Reset button
'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 button
'vcita_div_button_style' => 'border-left:1px dashed #ccc; margin-top:25px; height:50px; padding:8px 20px;', // vCita button div box
'powered_by_style' => 'font-size:x-small; font-weight:normal; padding-top:5px; text-align:center;', // the "powered by" link
);
// 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_check_easy',
'email_html', 'akismet_disable', 'captcha_enable', 'recaptcha_enable', 'recaptcha_dark', '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';
if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML ) // do not allow unfiltered HTML
$html_fields = array( );
foreach ( $text as $key => $value ) {
if ( is_string($value) ) {
if ( in_array( $key, $html_fields ) ) {
$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; // allow html
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(self::sanitize_slug_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(self::sanitize_slug_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(self::sanitize_slug_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(self::sanitize_slug_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 );
}
}
if( isset( $text['fields'][$key]['slug'] ) )
$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 = esc_url_raw(remove_query_arg( 'fscf_tab', $_REQUEST['_wp_http_referer'] ));
$wp_referer = esc_url_raw(add_query_arg( 'fscf_tab', $_POST['current_tab'], $wp_referer ));
if ( isset( $text['akismet_check'] ) ) {
// Request Akismet check on page reload
$wp_referer = esc_url_raw(add_query_arg( 'akismet_check', 'true', $wp_referer ));
unset ( $text['akismet_check'] ); // Don't save this in database
} else {
$wp_referer = esc_url_raw(remove_query_arg( 'akismet_check', $wp_referer ));
}
$_REQUEST['_wp_http_referer'] = $wp_referer;
}
return( $text );
} // end function validate($text);
static function sanitize_slug_with_dashes( $title, $raw_title = '' ) {
$title = strip_tags($title);
// Preserve escaped octets.
$title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title);
// Remove percent signs that are not part of an octet.
$title = str_replace('%', '', $title);
// Restore octets.
$title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title);
if (seems_utf8($title)) {
$title = utf8_uri_encode($title, 200);
}
$title = preg_replace('/&.+?;/', '', $title); // kill entities
$title = str_replace('.', '-', $title);
$title = preg_replace('/[^%a-zA-Z0-9 _-]/', '', $title);
$title = preg_replace('/\s+/', '-', $title);
$title = preg_replace('|-+|', '-', $title);
$title = trim($title, '-');
return $title;
}
// function sanitize_title_with_dashes
static function get_post_types_slugs() {
// check for custom post types, returns the global static self::$post_types_slugs
// 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
$pt_args = array('public' => true,'_builtin' => false);
$post_types = get_post_types( $pt_args, 'objects' );
if ( $post_types ) {
foreach ( $post_types as $post_type ) {
self::$post_types_slugs[] = ( isset( $post_type->rewrite_slug ) ) ? $post_type->rewrite_slug : $post_type->name;
}
}
}
static function check_slug($slug, $slug_list) {
// Checks the slug, and adds a number if necessary to make it unique
// $slug -- the slug to be checked
// $slug_list -- a list of existing slugs
// Returns the new slug
$slug_list = array_merge( self::$post_types_slugs, $slug_list );
// Duplicates have a two digit number appended to the end to make them unique
// XXX do I neeed any messages about changing the slug?
$numb = preg_match( '/\d{2}$/', $slug, $match);
while ( in_array( $slug, $slug_list ) ) {
if ( $numb ) {
$new_numb = sprintf("%02d", substr($slug,strlen($slug)-2,2) + 1);
$slug = substr($slug, 0, strlen($slug)-2) . $new_numb;
} else {
$slug .= '01';
$numb = 1;
}
} // end while
return($slug);
}
static function clean_textarea($data) {
// cleans blank lines and trims gaps from textarea list inputs
// Returns the new data
$new_data = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $data);
$data_array = explode("\n",$new_data);
$new_data = '';
foreach($data_array as $line) {
$line = trim($line);
if ($line != '') // do not use !empty, or an option '0' is deleted
$new_data .= "$line\n";
}
return trim($new_data);
} // end function clean_textarea
static function set_fld_array() {
// Set up the list of available tags for email
self::get_options();
self::$av_fld_arr = array(); // used to show available field tags this form
self::$av_fld_subj_arr = array(); // used to show available field tags for this form subject
// Fields
foreach ( self::$form_options['fields'] as $key => $field ) {
switch ($field['standard']) {
case FSCF_NAME_FIELD :
if ($field['disable'] == 'false') {
switch (self::$form_options['name_format']) {
case 'name':
self::$av_fld_arr[] = 'from_name';
break;
case 'first_last':
self::$av_fld_arr[] = 'first_name';
self::$av_fld_arr[] = 'last_name';
break;
case 'first_middle_i_last':
self::$av_fld_arr[] = 'first_name';
self::$av_fld_arr[] = 'middle_initial';
self::$av_fld_arr[] = 'last_name';
break;
case 'first_middle_last':
self::$av_fld_arr[] = 'first_name';
self::$av_fld_arr[] = 'middle_name';
self::$av_fld_arr[] = 'last_name';
break;
}
}
break;
case FSCF_EMAIL_FIELD :
// email
self::$autoresp_ok = 1; // used in autoresp settings below
if ($field['disable'] == 'false') {
self::$av_fld_arr[] = 'from_email';
}else{
self::$autoresp_ok = 0;
}
break;
case FSCF_SUBJECT_FIELD :
break;
case FSCF_MESSAGE_FIELD :
$msg_key = $key; // this is used below
break;
default :
// This is an added field
if ( $field['type'] != 'fieldset-close' && $field['standard'] < 1) {
if ( $field['type'] == 'fieldset' ) {
} else if ( $field['type'] == 'attachment' && self::$form_options['php_mailer_enable'] == 'wordpress') {
self::$av_fld_arr[] = $field['slug'];
} else { // text, textarea, date, password, email, url, hidden, time, select, select-multiple, radio, checkbox, checkbox-multiple
self::$av_fld_arr[] = $field['slug'];
if ( $field['type'] == 'email' )
$autoresp_ok = 1;
}
}
} // end switch
} // end foreach
self::$av_fld_subj_arr = self::$av_fld_arr;
self::$av_fld_arr[] = 'subject';
if (self::$form_options['fields'][$msg_key]['disable'] == 'false')
self::$av_fld_arr[] = 'message';
self::$av_fld_arr[] = 'full_message';
if ( function_exists('akismet_verify_key') && self::$form_options['akismet_disable'] == 'false' )
self::$av_fld_arr[] = 'akismet';
self::$av_fld_arr[] = 'date_time';
self::$av_fld_arr[] = 'ip_address';
self::$av_fld_subj_arr[] = 'form_label';
} // function set_fld_array()
static function add_field() {
check_admin_referer( 'fs_contact_options-options', 'fs_options' );
self::get_options();
self::$form_options['fields'][] = FSCF_Util::$field_defaults;
self::$new_field_added = __( 'A new field has been added. Now you must edit the field name and details, then click Save Changes.', 'si-contact-form' );
echo '
' . self::$new_field_added . '
';
} // end function add_field()
static function add_form() {
// Add a new form
check_admin_referer( 'fs_contact_options-options', 'fs_options' );
self::$global_options = FSCF_Util::get_global_options();
// Find the next form number
// When forms are deleted, their form number is NOT reused
self::$global_options['form_list'][self::$current_form] = __('New Form', 'si-contact-form');
// 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
// 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']));
update_option( 'fs_contact_global', self::$global_options );
echo '
' . sprintf( __( 'Form %d has been added.', 'si-contact-form' ), self::$current_form ) . '
';
return;
}
static function reset_form() {
// Reset the current form to the defaults, but preserve the name
check_admin_referer( 'fs_contact_options-options', 'fs_options' );
self::get_options();
$form_name = self::$form_options['form_name'];
self::$form_options = self::$form_defaults;
self::$form_options['form_name'] = $form_name;
update_option(self::$form_option_name, self::$form_options);
echo '
' . sprintf( __( 'Form %d has been reset to the default settings.', 'si-contact-form' ), self::$current_form ) . '
';
}
static function delete_form() {
// Delete the current form
check_admin_referer( 'fs_contact_options-options', 'fs_options' );
self::get_options();
if ( isset($_POST['form_num']) && is_numeric( $_POST['form_num'] ) ) {
$form_num = absint($_POST['form_num']);
$op_name = 'fs_contact_form' . $form_num ;
$result = delete_option( $op_name );
if ( ! $result ) {
// Error deleting option
echo '
' . sprintf( __( 'An error has occured. Form %d could not be deleted.', 'si-contact-form' ), $form_num ) . '
';
} else {
unset( self::$global_options['form_list'][$form_num] );
// 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
ksort(self::$global_options['form_list']);
self::$global_options['max_form_num'] = max(array_keys(self::$global_options['form_list']));
update_option( 'fs_contact_global', self::$global_options );
echo '
' . sprintf( __( 'Form %d has been deleted.', 'si-contact-form' ), $form_num ) . '
';
}
}
}
/**
* Remotely fetch, cache, and display HTML ad for the Fast Secure Contact Form Newsletter plugin addon.
* for Constant Contact on Newsletter tab
*/
static function kws_get_remote_ad() {
// The ad is stored locally for 30 days as a transient. See if it exists.
$cache = function_exists('get_site_transient') ? get_site_transient('fscf_kws_ad4') : get_transient('fscf_kws_ad4');
// If it exists, use that (so we save some request time), unless ?cache is set.
if(!empty($cache) && !isset($_REQUEST['cache'])) { return $cache; }
// Get the advertisement remotely. An encrypted site identifier, the language of the site, and the version of the FSCF plugin will be sent to katz.co
$response = wp_remote_post('http://katz.co/ads/', array('timeout' => 45,'body' => array('siteid' => sha1(site_url()), 'language' => get_bloginfo('language'), 'version' => FSCF_VERSION)));
// If it was a successful request, process it.
if(!is_wp_error($response)) {
// Basically, remove