<?php
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals

if ( ! defined( 'ABSPATH' ) ) {
	 exit;
}

$dbhandler = new WPEFB_DBhandler();
?>
<div class="advrf-wrapper wrap wef-forms-modern wef-dashboard-modern wef-configure-modern">
    <div class="advrf-page-title">		 
        <h1 class="wpefb-page-heading">
             <?php esc_html_e( 'Security', 'vedrixa-forms-registration-builder' ); ?></h1>
        <ul class="advrf-nav">
            <li class="advrf-nav-item">
                <a href="<?php echo esc_url( admin_url( 'admin.php?page=wpefb_global_settings' ) ); ?>">
                    <span class="dashicons dashicons-admin-generic"></span>
                    <?php esc_html_e( 'Global Settings', 'vedrixa-forms-registration-builder' ); ?></a>
            </li>
            <li class="advrf-nav-item">
                <a href="<?php echo esc_url( admin_url( 'admin.php?page=wpefb_manage_forms' ) ); ?>">
                    <span class="dashicons dashicons-feedback"></span>
                    <?php esc_html_e( 'All Forms', 'vedrixa-forms-registration-builder' ); ?></a>
            </li>    
        </ul>

    </div>
    <div class="clearfix">
        <div class="advrf-form-conf-wrapper">
            <?php if ( absint( filter_input( INPUT_GET, 'updated', FILTER_SANITIZE_NUMBER_INT ) ) ) : ?>
                <div class="notice notice-success is-dismissible"><p><?php esc_html_e( 'Security settings saved.', 'vedrixa-forms-registration-builder' ); ?></p></div>
            <?php endif; ?>
            <form action="" method="post" id="advrf_configuration_form">
                <fieldset class="advrf-config-wrap">
                    <div>

                        <div class="group-wrap">

                            <div class="advrf-row">
                                <div class="advrf-control-label">
                                    <label><?php esc_html_e( 'Enable reCaptcha', 'vedrixa-forms-registration-builder' ); ?></label>
                                </div>
                                <div class="advrf-control advrf-has-child">
                                    <input class="advrf_toggle"  type="checkbox" value="1" id="wpefb_enable_recaptcha" name="wpefb_enable_recaptcha" data-has-child="1" data-toggle-target="wpefb_enable_recaptcha_html" <?php checked( $dbhandler->get_global_option_value( 'wpefb_enable_recaptcha' ), '1' ); ?> />
                                    <label></label>
                                    <p class="description"><?php esc_html_e( 'Shows recaptcha above the submit button. It verifies if the user is human before accepting submission', 'vedrixa-forms-registration-builder' ); ?></p>
                                </div>  
                            </div>

                            <div class="advrf-child-rows advrf-child-options" id="wpefb_enable_recaptcha_html" style="<?php echo !empty( $dbhandler->get_global_option_value( 'wpefb_enable_recaptcha' ) ) ? '' : 'display:none'; ?>">

                                <div class="advrf-row">
                                    <div class="advrf-control-label">
                                        <label><?php esc_html_e( 'Version', 'vedrixa-forms-registration-builder' ); ?></label>
                                    </div>
                                    <div class="advrf-control">
                                        <select name="wpefb_recaptcha_version" id="wpefb_recaptcha_version" class="advrf-input-field">
                                            <option value="v2" <?php selected( $dbhandler->get_global_option_value( 'wpefb_recaptcha_version' ), 'v2' ); ?>><?php esc_html_e( 'reCaptcha v2', 'vedrixa-forms-registration-builder' ); ?></option>
                                            <option value="v3" <?php selected( $dbhandler->get_global_option_value( 'wpefb_recaptcha_version' ), 'v3' ); ?>><?php esc_html_e( 'reCaptcha v3', 'vedrixa-forms-registration-builder' ); ?></option>
                                        </select>
                                        <p class="description"><?php echo esc_html__( 'Select reCaptcha version you want to use with your forms.', 'vedrixa-forms-registration-builder' ); ?></p>
                                    </div>
                                </div>

                                <div class="advrf-row">
                                    <div class="advrf-control-label">
                                        <label><?php esc_html_e( 'Site Key', 'vedrixa-forms-registration-builder' ); ?></label>
                                    </div>
                                    <div class="advrf-control">
                                        <input type="text" class="advrf-input-field" id="wpefb_recaptcha_site_key" name="wpefb_recaptcha_site_key" value="<?php echo esc_attr( $dbhandler->get_global_option_value( 'wpefb_recaptcha_site_key' ) ); ?>">
                                        <p class="description"><?php esc_html_e( 'Required to make reCAPTCHA work. You can generate site key from ', 'vedrixa-forms-registration-builder' ); ?></p>
                                    </div>
                                </div>

                                <div class="advrf-row">
                                    <div class="advrf-control-label">
                                        <label><?php esc_html_e( 'Secret Key', 'vedrixa-forms-registration-builder' ); ?></label>
                                    </div>
                                    <div class="advrf-control">
                                        <input type="text" class="advrf-input-field" id="wpefb_recaptcha_secret_key" name="wpefb_recaptcha_secret_key" value="<?php echo esc_attr( $dbhandler->get_global_option_value( 'wpefb_recaptcha_secret_key' ) ); ?>">
                                        <p class="description"><?php esc_html_e( 'Required to make reCAPTCHA work. It will be provided when you generate site key.', 'vedrixa-forms-registration-builder' ); ?></p>
                                    </div>
                                </div>


                            </div>
                            
                            <div class="advrf-row">
                                <div class="advrf-control-label">
                                    <label><?php esc_html_e( 'Form Submission Limit for a Device', 'vedrixa-forms-registration-builder' ); ?></label>
                                </div>
                                <div class="advrf-control">
                                    <input class="advrf-input-field" type="number" value="<?php echo esc_attr( $dbhandler->get_global_option_value( 'wpefb_device_submission_limit' ) ); ?>" min="0" id="wpefb_device_submission_limit" name="wpefb_device_submission_limit" />
                                    <p class="description">
                                        <?php esc_html_e( 'Limits how many times a form can be submitted from a device within a day. Helpful to prevent spam. Set it to zero (0) to disable this feature.', 'vedrixa-forms-registration-builder' ); ?>
                                    </p>
                                </div>
                            </div>
                            
                            
                            
                            <div class="advrf-row">
                                    <div class="advrf-control-label">
                                        <label><?php esc_html_e( 'Banned IP Addresses from Accessing Forms', 'vedrixa-forms-registration-builder' ); ?></label>
                                    </div>
                                    <div class="advrf-control">
                                        <textarea class="advrf-input-field" name="wpefb_banned_ip"><?php echo esc_textarea( (string) $dbhandler->get_global_option_value( 'wpefb_banned_ip' ) ); ?></textarea>
                                        <p class="description"><?php esc_html_e( 'Enter IP addresses to ban. Separate multiple addresses with spaces. Wildcard (?) is allowed for IPv4 addresses only. Example: 127.233.12?.01? blocks 127.233.120.010 to 127.233.129.019. This also applies to the login form.', 'vedrixa-forms-registration-builder' ); ?></p>
                                    </div>
                                </div>
                            
                            <div class="advrf-row">
                                    <div class="advrf-control-label">
                                        <label><?php esc_html_e( 'Banned Email Addresses from Submitting Forms', 'vedrixa-forms-registration-builder' ); ?></label>
                                    </div>
                                    <div class="advrf-control">
                                        <textarea class="advrf-input-field" name="wpefb_banned_emails"><?php echo esc_textarea( (string) $dbhandler->get_global_option_value( 'wpefb_banned_emails' ) ); ?></textarea>
                                        <p class="description"><?php esc_html_e( 'Enter email addresses to ban. Separate multiple addresses with spaces. Wildcards (* and ?) are allowed. Example: joh*@gmail.com blocks submissions from gmail addresses starting with "joh".', 'vedrixa-forms-registration-builder' ); ?></p>
                                    </div>
                                </div>

                            
                            
                            
                            
                        </div>
                    </div>





                </fieldset>

                <p class="submit">
                    <?php wp_nonce_field( 'save_wpefb_global_settings' ); ?>
                    <input type="submit" value="<?php esc_attr_e( 'Save', 'vedrixa-forms-registration-builder' ); ?>" class="button button-primary" name="submit_settings" id="submit_settings" onClick="return advrf_global_settings_validation('security')"/>
                    <a class="button button-secondary" href="<?php echo esc_url( admin_url( 'admin.php?page=wpefb_global_settings' ) ); ?>"><?php esc_html_e( 'Cancel', 'vedrixa-forms-registration-builder' ); ?></a>
                    <div class="all_error_text" style="display:none;"></div>
                </p>
            </form>  
        </div>    

    </div>    
</div>
