芝麻web文件管理V1.00
编辑当前文件:/home/seolotod/www/wp-content/plugins/cf7-advance-security/cf7as-class.php
type=='cf7ascaptcha' ) { $tag->name= 'cf7as-captchcode'; $finalCechking = ''; $cptha1 = isset($_POST['cf7as_hdn_cpthaval1']) ? sanitize_text_field(wp_unslash($_POST['cf7as_hdn_cpthaval1'])) : ''; $cptha2 = isset($_POST['cf7as_hdn_cpthaval2']) ? sanitize_text_field(wp_unslash($_POST['cf7as_hdn_cpthaval2'])) : ''; $cptha3 = isset($_POST['cf7as_hdn_cpthaaction']) ? sanitize_text_field(wp_unslash($_POST['cf7as_hdn_cpthaaction'])) : ''; $cptcha_value = isset($_POST['cf7as-captchcode']) ? intval($_POST['cf7as-captchcode']) : 0; $cptcha_zplusvalue = isset($_POST['cf7as-zplus']) ? sanitize_text_field(wp_unslash($_POST['cf7as-zplus'])) : ''; $required = isset( $tag->values[2] ) ? $tag->values[2] : 'Invalid Answer!'; if( $cptha3=='x' ) { $finalCechking=( $cptha1*$cptha2 ); }elseif( $cptha3=='+' ) { $finalCechking=( $cptha1+$cptha2 ); }else { $finalCechking=( $cptha1-$cptha2 ); } if( $cptcha_value=='' ) { $result->invalidate($tag,$required); } if( $cptcha_value!='' && $cptcha_value!=$finalCechking ) { $result->invalidate($tag,$required); } //check double security if( $cptcha_zplusvalue!='' ) { $result->invalidate($tag,'You are not human!'); } } return $result; } endif; } /** captcha */ if( !function_exists('cf7as_shortcodes_capctha') ) : function cf7as_shortcodes_capctha() { /* wpcf7_add_form_tag( 'cf7ascaptcha1', 'cf7as_captcha_shortcode_handler', array( 'name-attr' => true ) );*/ } endif; add_action( 'wpcf7_init', 'custom_add_form_tag_time_selector' ); function custom_add_form_tag_time_selector() { wpcf7_add_form_tag( 'cf7ascaptcha', 'cf7as_captcha_shortcode_handler' ); } if( !function_exists('cf7as_captcha_shortcode_handler') ) : function cf7as_captcha_shortcode_handler( $tag ) { $title = isset( $tag->values[0] ) ? $tag->values[0] : 'What is '; $placeholder = isset( $tag->values[1] ) ? $tag->values[1] : 'Type your answer'; $operationAry=array('+','x','-'); $random_action=array_rand($operationAry,2); $random_actionVal=$operationAry[$random_action[0]]; $actnVal1 = wp_rand(1, 9); $actnVal2 = wp_rand(1, 9); $cf7as_captcha='
'; $cf7as_captcha.=$title.'
'.$actnVal2.'
'.$random_actionVal.'
'.$actnVal1.'
'.wp_nonce_field('cf7as_captcha_nonce_action', 'cf7as_captcha_nonce', true, false); return $cf7as_captcha; } endif; /** End Captcha Code */ add_action( 'wpcf7_admin_init', 'cf7as_add_tag_generator_button', 55, 0 ); function cf7as_add_tag_generator_button() { if ( class_exists( 'WPCF7_TagGenerator' ) ) { $tag_generator = WPCF7_TagGenerator::get_instance(); $tag_generator->add( 'cf7ascaptcha', __( 'cf7ascaptcha', 'cf7-advance-security' ), array( 'features' => array( 'nameless' => true ), 'callback' => 'cf7as_tag_generator_cf7ascaptcha', ) ); } } function cf7as_tag_generator_cf7ascaptcha( $contact_form, $args = '' ) { $args = wp_parse_args( $args, array() ); $description = __( "Generate a form advance secuirty captcha", 'cf7-advance-security' ); $desc_link = 'https://www.wp-experts.in'; ?>
Sample Shortcode
[cf7ascaptcha "What is your answer" "enter answer" "invalid answer"]