Changeset 2513195
- Timestamp:
- 04/12/2021 10:06:02 AM (5 years ago)
- Location:
- vaptcha-sms/trunk
- Files:
-
- 3 edited
-
VaptchaSmsPlugin.php (modified) (28 diffs)
-
js/sms.js (modified) (22 diffs)
-
options.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vaptcha-sms/trunk/VaptchaSmsPlugin.php
r2511966 r2513195 38 38 * 加载vaptcha 39 39 */ 40 private function get_captcha($form, $btn, $type)40 private function get_captcha($form, $btn, $type) 41 41 { 42 42 $loading = plugins_url('images/vaptcha-loading.gif', __FILE__); … … 115 115 // 选择国别码 116 116 117 function select_code_box(){ 117 function select_code_box() 118 { 118 119 $dropdown = plugins_url('images/dropdown.png', __FILE__); 119 120 … … 177 178 <input type="text" id="country_code" class="form-control" style="border: none;outline: none!important;" value="86" name="country_code"> 178 179 <button id="btn-down" type="button" style="background: none;border: none;outline: none;padding: 0 3px"> 179 <img id="dropdown-icon" src="' . $dropdown.'" style="width: 10px;"/>180 <img id="dropdown-icon" src="' . $dropdown . '" style="width: 10px;"/> 180 181 </button> 181 182 </div> … … 242 243 //判断是否在登陆时出现vaptcha验证,为off时不验证 243 244 if ($this->options['button_no_secret'] == 'off') return; 244 else {245 else { 245 246 $ajaxUrl = admin_url('admin-ajax.php'); 246 if ($this->options['button_international'] == 'off') {247 if ($this->options['button_international'] == 'off') { 247 248 echo '<p id="phone-verify-fields"> 248 249 <label for="user_phone">手机号</label> … … 250 251 </p> 251 252 '; 252 } else{253 } else { 253 254 echo $this->select_code_box(); 254 255 }; … … 278 279 <input type="hidden" name="reset_way" id="reset_way" value="phone"> 279 280 </p>'; 280 echo $this->get_captcha('loginform', 'submit', 'click');281 echo $this->get_captcha('loginform', 'submit', 'click'); 281 282 echo <<<HTML 282 283 <button type="button" id="submit_form_button" class="button" style="height: 32px;float: right;background: #2271b1;color: white;">免密登录</button> 283 <button type="button" id="sms_login_button" class="button" style="display: none; height: 32px;float: right;background: #2271b1;color: white;">登录</button>284 <button type="button" id="sms_login_button" class="button" style="display: none;padding: 0 15px;height: 32px;float: right;background: #2271b1;color: white;">登录</button> 284 285 HTML; 285 286 } … … 302 303 //验证账号密码是否输入的是手机号 303 304 return $error; 304 } else{305 } else { 305 306 //通过手机号查找用户 306 307 $args = array( … … 309 310 ); 310 311 $phoneFindUser = get_users($args); 311 if ( !empty($phoneFindUser)) {312 if (!empty($phoneFindUser)) { 312 313 $phoneFindUser = $phoneFindUser[0]; 313 314 } 314 315 //通过用户名和手机号都未找到用户 315 if ( !($phoneFindUser instanceof WP_User)) {316 if (!($phoneFindUser instanceof WP_User)) { 316 317 return new WP_Error('captcha_wrong', __('该手机号未绑定用户。', 'vaptcha')); 317 318 } … … 329 330 * @return string 330 331 */ 331 function yang_allow_phone_login($username, $raw_username, $strict) { 332 if( !empty($raw_username) && preg_match("/^(((13[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/", $raw_username) ){ 332 function yang_allow_phone_login($username, $raw_username, $strict) 333 { 334 if (!empty($raw_username) && preg_match("/^(((13[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/", $raw_username)) { 333 335 global $wpdb; 334 336 $user_id = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta jw WHERE jw.meta_key='%s' AND jw.meta_value='%s'", 'phone', $raw_username)); 335 if (empty($user_id)) {337 if (empty($user_id)) { 336 338 wp_die(__('ERROR: There is no user registered with that phone number.'), '用户名不正确'); 337 } else{338 if ( function_exists('get_user_by') ){339 include_once(ABSPATH .'wp-includes/pluggable.php');339 } else { 340 if (function_exists('get_user_by')) { 341 include_once(ABSPATH . 'wp-includes/pluggable.php'); 340 342 } 341 343 $user = get_user_by('id', $user_id); 342 344 return $user->user_login; 343 345 } 344 } else{346 } else { 345 347 return $username; 346 348 } … … 348 350 349 351 350 351 352 /** 352 353 * 修改注册表单 … … 354 355 function captcha_in_register_form() 355 356 { 356 if ($this->options['button_international'] == 'off') {357 if ($this->options['button_international'] == 'off') { 357 358 echo '<p> 358 359 <label for="user_phone">手机号</label> 359 360 <input type="text" name="user_phone" id="user_phone" class="input" size="20" autocapitalize="off" /> 360 361 </p>'; 361 } else{362 } else { 362 363 echo $this->select_code_box(); 363 364 } 364 365 365 echo '<p> 366 echo ' 367 <style> 368 #wp-submit{ 369 display: none; 370 } 371 </style> 372 <p> 366 373 <p><label for="">短信验证码</label></p> 367 374 <input type="text" name="register_sms_code" id="register_sms_code" style="width: 150px;" autocapitalize="off" /> 368 375 <button type="button" id="get_sms_code" class="button" style="height: 40px;width: 110px">发送验证码</button> 369 376 </p> 377 <p><button type="button" id="submit-btn" class="button" style="height: 32px;padding: 0 15px;float: right;background: #2271b1;color: white;margin-top: 30px">注册</button></p> 370 378 '; 371 echo $this->get_captcha('registerform', 'submit', 'invisible');379 echo $this->get_captcha('registerform', 'submit', 'invisible'); 372 380 } 373 381 … … 379 387 function captcha_validate_register($errors) 380 388 { 381 $smsid = get_option('vaptcha_options')['vaptcha_smsid'];382 $smskey = get_option('vaptcha_options')['vaptcha_smskey'];383 $phone = sanitize_text_field($_POST['user_phone']);384 $vcode = sanitize_text_field($_POST['register_sms_code']);385 386 if(!$phone){387 $errors->add('captcha_wrong', "<strong>ERROR</strong>:" . __('请输入手机号。', 'vaptcha'));388 }else{389 390 $args = array(391 'meta_key' => 'phone',392 'meta_value' => $phone,393 );394 $phoneFindUser = get_users($args);395 396 if(!!$phoneFindUser){397 $errors->add('captcha_wrong', "<strong>ERROR</strong>:" . __('该手机号已绑定其他用户。', 'vaptcha'));398 }else{399 $res = $this->vaptcha->validateSmsCode($smsid,$smskey,$phone,$vcode);400 if (!empty($res)) {401 $errors->add('captcha_wrong', "<strong>ERROR</strong>:" . __($res, 'vaptcha'));402 }403 }404 }389 // $smsid = get_option('vaptcha_options')['vaptcha_smsid']; 390 // $smskey = get_option('vaptcha_options')['vaptcha_smskey']; 391 // $phone = sanitize_text_field($_POST['user_phone']); 392 // $vcode = sanitize_text_field($_POST['register_sms_code']); 393 // 394 // if (!$phone) { 395 // $errors->add('captcha_wrong', "<strong>ERROR</strong>:" . __('请输入手机号。', 'vaptcha')); 396 // } else { 397 // 398 // $args = array( 399 // 'meta_key' => 'phone', 400 // 'meta_value' => $phone, 401 // ); 402 // $phoneFindUser = get_users($args); 403 // 404 // if (!!$phoneFindUser) { 405 // $errors->add('captcha_wrong', "<strong>ERROR</strong>:" . __('该手机号已绑定其他用户。', 'vaptcha')); 406 // } else { 407 // $res = $this->vaptcha->validateSmsCode($smsid, $smskey, $phone, $vcode); 408 // if ($res == 601) { 409 // $errors->add('captcha_wrong', "<strong>ERROR</strong>:" . __('短信验证码错误。', 'vaptcha')); 410 // } 411 // } 412 // } 405 413 return $errors; 406 414 } … … 410 418 * 保存用户手机号码 411 419 */ 412 function user_register_prestige($user_id){ 420 function user_register_prestige($user_id) 421 { 413 422 $user_phone = sanitize_text_field($_POST['user_phone']); 414 update_user_meta($user_id, 'phone',$user_phone);423 update_user_meta($user_id, 'phone', $user_phone); 415 424 } 416 425 … … 447 456 $userid = $user->ID; 448 457 $user_phone = $validated['vaptcha_phone']; 449 update_user_meta($userid, 'phone',$user_phone);458 update_user_meta($userid, 'phone', $user_phone); 450 459 return $validated; 451 460 } … … 465 474 466 475 467 /** 468 * 退出设备菜单 469 */ 470 471 function exit_device(){ 472 473 $this->removeDevice(); 474 475 } 476 /** 477 * 退出设备菜单 478 */ 479 480 function exit_device() 481 { 482 483 $this->removeDevice(); 484 485 } 476 486 477 487 … … 575 585 public function load_sms_js() 576 586 { 577 wp_register_script('vaptcha_sms_js', plugins_url('js/sms.js', __FILE__), array('jquery'), '1.1', true);587 wp_register_script('vaptcha_sms_js', plugins_url('js/sms.js', __FILE__), array('jquery'), '1.1', true); 578 588 wp_enqueue_script('vaptcha_sms_js'); 579 589 580 wp_register_script('vaptcha_v3_js', 'https://v.vaptcha.com/v3.js', array('jquery'), '1.1', true);590 wp_register_script('vaptcha_v3_js', 'https://v.vaptcha.com/v3.js', array('jquery'), '1.1', true); 581 591 wp_enqueue_script('vaptcha_v3_js'); 592 } 593 594 /** 595 * 验证注册表单 596 */ 597 598 public function validateRegister() 599 { 600 $smsid = get_option('vaptcha_options')['vaptcha_smsid']; 601 $smskey = get_option('vaptcha_options')['vaptcha_smskey']; 602 $username = sanitize_text_field($_POST['username']); 603 $email = sanitize_text_field($_POST['email']); 604 $phone = sanitize_text_field($_POST['phone']); 605 $smscode = sanitize_text_field($_POST['smscode']); 606 607 $args = array( 608 'meta_key' => 'phone', 609 'meta_value' => $phone, 610 ); 611 $phoneFindUser = get_users($args); 612 $exists = email_exists($email);//检查邮箱是否存在 613 $user = username_exists($username);//检查用户名是否存在 614 if ($user) { 615 $name = '该用户名已被注册。'; 616 } 617 if ($exists) { 618 $mail = '该邮箱地址已被注册。'; 619 } 620 if (!!$phoneFindUser) { 621 $phoneNumber = '该手机号已绑定其他用户。'; 622 } else { 623 $res = $this->vaptcha->validateSmsCode($smsid, $smskey, $phone, $smscode); 624 if ($res == 601) { 625 $code = '短信验证码错误'; 626 } 627 } 628 if ($name === null && $mail === null && $phoneNumber=== null && $code === null){ 629 wp_send_json_success(); 630 }else{ 631 wp_send_json_error(array( 632 'name' => $name, 633 'email' => $mail, 634 'phone' => $phoneNumber, 635 'smscode' => $code 636 )); 637 } 638 582 639 } 583 640 … … 591 648 $url = 'https://sms.vaptcha.com/smsid?id=' . $vid . '&key=' . $key; 592 649 $response = wp_remote_get($url); 593 $data = json_decode($response['body']);650 $data = json_decode($response['body']); 594 651 wp_send_json_success($data); 595 652 } … … 598 655 * 发送手机短信验证码 599 656 */ 600 public function sendSmsCode(){ 657 public function sendSmsCode() 658 { 601 659 $countrycode = sanitize_text_field($_POST['countrycode']); 602 660 $post_data = array( … … 612 670 613 671 $args = array( 614 'body' => $post_data,615 'timeout' => '5',672 'body' => $post_data, 673 'timeout' => '5', 616 674 'redirection' => '5', 617 675 'httpversion' => '1.0', 618 'blocking' => true,619 'headers' => array("Content-type:application/json;charset='utf-8'",676 'blocking' => true, 677 'headers' => array("Content-type:application/json;charset='utf-8'", 620 678 "Accept:application/json"), 621 679 ); 622 680 623 $response = wp_remote_post($url, $args);624 $data = json_decode($response['body']);681 $response = wp_remote_post($url, $args); 682 $data = json_decode($response['body']); 625 683 wp_send_json_success($data); 626 684 } … … 630 688 * 631 689 */ 632 public function getDeviceLogin(){ 690 public function getDeviceLogin() 691 { 633 692 $phone = sanitize_text_field($_GET['phone']); 634 693 $token = sanitize_text_field($_GET['token']); … … 639 698 ); 640 699 $phoneFindUser = get_users($args); 641 if ( !empty($phoneFindUser)) {700 if (!empty($phoneFindUser)) { 642 701 $phoneFindUser = $phoneFindUser[0]; 643 702 } 644 703 //通过用户名和手机号都未找到用户 645 if ( !($phoneFindUser instanceof WP_User)) {646 wp_send_json_error(array( 'code'=> 444 ,'msg'=> '该手机未绑定用户'));704 if (!($phoneFindUser instanceof WP_User)) { 705 wp_send_json_error(array('code' => 444, 'msg' => '该手机未绑定用户')); 647 706 } 648 707 if (!$token || !$this->vaptcha->validate('', $token)) { 649 wp_send_json_error(array( 'code'=> 444 ,'msg'=> '人机验证未通过'));708 wp_send_json_error(array('code' => 444, 'msg' => '人机验证未通过')); 650 709 } 651 710 $url = 'https://auth.vaptcha.com/api/v1/device?id=' . $phone . '&token=' . $token . '&renewal=1'; 652 711 $response = wp_remote_get($url); 653 $data = json_decode($response['body']);712 $data = json_decode($response['body']); 654 713 wp_send_json_success($data); 655 714 } … … 658 717 * 添加登录设备 659 718 */ 660 public function addDevice(){ 719 public function addDevice() 720 { 661 721 $smsid = get_option('vaptcha_options')['vaptcha_smsid']; 662 722 $smskey = get_option('vaptcha_options')['vaptcha_smskey']; … … 670 730 ); 671 731 $phoneFindUser = get_users($args); 672 if ( !empty($phoneFindUser)) {732 if (!empty($phoneFindUser)) { 673 733 $phoneFindUser = $phoneFindUser[0]; 674 734 } 675 735 //通过用户名和手机号都未找到用户 676 if ( !($phoneFindUser instanceof WP_User)) {677 wp_send_json_error(array( 'code'=> 400 ,'msg'=> '该手机未绑定用户'));678 } 679 680 $res = $this->vaptcha->validateSmsCode($smsid, $smskey,$phone,$vcode);736 if (!($phoneFindUser instanceof WP_User)) { 737 wp_send_json_error(array('code' => 400, 'msg' => '该手机未绑定用户')); 738 } 739 740 $res = $this->vaptcha->validateSmsCode($smsid, $smskey, $phone, $vcode); 681 741 if (!empty($res) && $res != 600) { 682 wp_send_json_error(array( 'code'=> $res ,'msg'=> '短信验证未通过'));742 wp_send_json_error(array('code' => $res, 'msg' => '短信验证未通过')); 683 743 } 684 744 if (!$token || !$this->vaptcha->validate('', $token)) { 685 wp_send_json_error(array( 'code'=> 400 ,'msg'=> '人机验证未通过'));745 wp_send_json_error(array('code' => 400, 'msg' => '人机验证未通过')); 686 746 } 687 747 $data = array( … … 691 751 $url = 'https://auth.vaptcha.com/api/v1/device'; 692 752 $args = array( 693 'method' => 'PUT',694 'body' => $data,695 'timeout' => '5',753 'method' => 'PUT', 754 'body' => $data, 755 'timeout' => '5', 696 756 'redirection' => '5', 697 757 'httpversion' => '1.0', 698 'blocking' => true,699 'headers' => array("Content-type:application/json;charset='utf-8'",758 'blocking' => true, 759 'headers' => array("Content-type:application/json;charset='utf-8'", 700 760 "Accept:application/json"), 701 761 ); 702 $response = wp_remote_request($url, $args);703 $data = json_decode($response['body']);762 $response = wp_remote_request($url, $args); 763 $data = json_decode($response['body']); 704 764 wp_send_json_success($data); 705 765 … … 711 771 * @return string|string[] 712 772 */ 713 function removeDevice(){ 773 function removeDevice() 774 { 714 775 $user = get_currentuserinfo(); 715 776 $userid = $user->ID; … … 722 783 $url = 'http://192.168.100.11:8080/api/v1/device'; 723 784 $args = array( 724 'method' => 'DELETE',725 'body' => json_encode($data),726 'timeout' => '5',785 'method' => 'DELETE', 786 'body' => json_encode($data), 787 'timeout' => '5', 727 788 'redirection' => '5', 728 789 'httpversion' => '1.0', 729 'blocking' => true,730 'headers' => array("Content-type:application/json;charset='utf-8'",790 'blocking' => true, 791 'headers' => array("Content-type:application/json;charset='utf-8'", 731 792 "Accept:application/json"), 732 793 ); 733 $response = wp_remote_request($url, $args);794 $response = wp_remote_request($url, $args); 734 795 // $data = json_decode($response['body']); 735 796 // wp_send_json_success($user); … … 761 822 //发送短信验证码 762 823 add_action('wp_ajax_nopriv_send_smscode', array($this, 'sendSmsCode')); 824 add_action('wp_ajax_nopriv_submit_register', array($this, 'validateRegister')); 763 825 //设备登录 764 826 add_action('wp_ajax_nopriv_device_login', array($this, 'getDeviceLogin')); … … 779 841 add_filter('wp_logout', array($this, 'exit_device'), 101, 2);//注销钩子 780 842 add_filter('authenticate', array($this, 'captcha_validate_login'), 101, 3);//authenticate 781 add_filter('sanitize_user', array($this, 'yang_allow_phone_login'), 10, 3);843 add_filter('sanitize_user', array($this, 'yang_allow_phone_login'), 10, 3); 782 844 add_filter('registration_errors', array($this, 'captcha_validate_register'), 100, 1); 783 845 add_filter('woocommerce_process_registration_errors', array($this, 'captcha_validate_woocommerce'), 100, 1); -
vaptcha-sms/trunk/js/sms.js
r2511966 r2513195 1 jQuery(function ($) {1 jQuery(function ($) { 2 2 3 3 // 设置页获取短信id … … 17 17 }, 18 18 success: function (response) { 19 if (response.data.code === 200){19 if (response.data.code === 200) { 20 20 $('#vaptcha_smsid').val(response.data.data.smsid) 21 21 $('#vaptcha_smskey').val(response.data.data.smskey) 22 } else {22 } else { 23 23 alert(response.data.msg) 24 24 } … … 29 29 30 30 // 后台设置国别码 31 $('#get_code').focus(function () {32 $('#code_menu').show()33 }) 34 $('#admin_phone').focus(function () {31 $('#get_code').focus(function () { 32 $('#code_menu').show() 33 }) 34 $('#admin_phone').focus(function () { 35 35 $('#code_menu').hide() 36 36 }) 37 37 38 $('#more_icon').click(function () {39 if ($("#code_menu").is(":hidden")){38 $('#more_icon').click(function () { 39 if ($("#code_menu").is(":hidden")) { 40 40 $('#code_menu').show() 41 } else {41 } else { 42 42 $('#code_menu').hide() 43 43 } … … 45 45 46 46 //选择国别号下拉点击 47 $("#code_menu").children("li").click(function (e) {47 $("#code_menu").children("li").click(function (e) { 48 48 $(this).addClass("active").siblings("li").removeClass("active"); 49 49 var code = $(this).data('value');//点击时 当前li的值 … … 53 53 54 54 // 加载vaptcha 55 var operaticon ='deviceLogin';55 var operaticon = 'deviceLogin'; 56 56 var obj; 57 57 var ajaxUrl = document.getElementById('vaptcha-hidden-url').getAttribute('data-ajax-url') … … 63 63 console.log(type) 64 64 vaptcha({ 65 vid: vid, // 验证单元id65 vid: vid, // 验证单元id 66 66 type: 'invisible', // 显示类型 隐藏式 67 67 scene: 0, // 场景值 默认0 … … 72 72 vaptchaObj.listen('pass', function () { 73 73 // 验证成功进行后续操作 74 if (operaticon === 'register'){75 sendSmsCode(vaptchaObj.getToken(), 'register')76 } 77 if (operaticon === 'deviceLogin'){74 if (operaticon === 'register') { 75 sendSmsCode(vaptchaObj.getToken(), 'register') 76 } 77 if (operaticon === 'deviceLogin') { 78 78 deviceLogin(vaptchaObj.getToken()) 79 79 } 80 if (operaticon === 'smsLogin') {80 if (operaticon === 'smsLogin') { 81 81 addDevice(vaptchaObj.getToken()) 82 82 } 83 if (operaticon === 'getSmsCode'){84 sendSmsCode(vaptchaObj.getToken(), 'login')83 if (operaticon === 'getSmsCode') { 84 sendSmsCode(vaptchaObj.getToken(), 'login') 85 85 } 86 86 vaptchaObj.reset() //重置验证码 … … 93 93 94 94 //发送验证码 95 function sendSmsCode(token, key){96 $.ajax({ 97 type: 'post',95 function sendSmsCode(token, key) { 96 $.ajax({ 97 type: 'post', 98 98 url: ajaxUrl, 99 99 dataType: "json", … … 107 107 templateid: modelid, 108 108 }, 109 success: function (res){110 if (res.data === 200){111 key === 'register' ? sendCountdown() : loginSendCountdown()112 } else {109 success: function (res) { 110 if (res.data === 200) { 111 key === 'register' ? sendCountdown() : loginSendCountdown() 112 } else { 113 113 alert(res.data) 114 114 } … … 118 118 119 119 //设备登录 120 function deviceLogin(token) {121 $.ajax({ 122 type: 'get',120 function deviceLogin(token) { 121 $.ajax({ 122 type: 'get', 123 123 url: ajaxUrl, 124 124 dataType: "json", … … 128 128 token: token, 129 129 }, 130 success: function(res){131 if (res.data.code === 444){132 // $('#loginform').before('<p id="ajax-error-tips" class="message" style="border-left-color:red;display: none;">该手机号为未绑定已注册用户 <button id="to-bind-user" style="margin-top: -5px;" type="button" class="button button-primary">绑定用户</button><br> </p>');130 success: function (res) { 131 if (res.data.code === 444) { 132 // $('#loginform').before('<p id="ajax-error-tips" class="message" style="border-left-color:red;display: none;">该手机号为未绑定已注册用户 <button id="to-bind-user" style="margin-top: -5px;" type="button" class="button button-primary">绑定用户</button><br> </p>'); 133 133 alert(res.data.msg) 134 } else if(res.data.code === 200){135 $('#loginform').submit()136 }else if(res.data.code === 400){137 $('#sms-code').show()138 $('#submit_form_button').hide()139 $('#sms_login_button').show()140 operaticon = 'smsLogin'141 sendSmsCode(token,'login')142 }134 } else if (res.data.code === 200) { 135 $('#loginform').submit() 136 } else if (res.data.code === 400) { 137 $('#sms-code').show() 138 $('#submit_form_button').hide() 139 $('#sms_login_button').show() 140 operaticon = 'smsLogin' 141 sendSmsCode(token, 'login') 142 } 143 143 // } 144 144 } … … 146 146 } 147 147 148 149 //验证注册表单 150 $('#registerform').before('<p id="have_null" class="message" style="border-left-color:#e00101;display: none"><strong>错误:</strong>请将信息填写完整。</p>'); 151 $('#registerform').before('<p id="wrong_phone" class="message" style="border-left-color:#e00101;display: none"><strong>错误:</strong>请填写正确的手机号码。</p>'); 152 $('#registerform').before('<p id="wrong_email" class="message" style="border-left-color:#e00101;display: none"><strong>错误:</strong>请填写正确的手机号码。</p>'); 153 $('#registerform').before('<p id="exist_name" class="message" style="border-left-color:#e00101;margin-bottom: 0;padding: 5px 12px;display: none"><strong>错误:</strong>该用户名已被注册。</p>'); 154 $('#registerform').before('<p id="exist_email" class="message" style="border-left-color:#e00101;margin-bottom: 0;padding: 5px 12px;display: none"><strong>错误:</strong>该邮箱地址已被注册。</p>'); 155 $('#registerform').before('<p id="exist_phone" class="message" style="border-left-color:#e00101;margin-bottom: 0;padding: 5px 12px;display: none"><strong>错误:</strong>该手机号已绑定其他用户。</p>'); 156 $('#registerform').before('<p id="wrong_code" class="message" style="border-left-color:#e00101;margin-bottom: 0;padding: 5px 12px;display: none"><strong>错误:</strong>短信验证码错误。</p>'); 157 158 $('#submit-btn').click(function () { 159 var username = $('#user_login').val() 160 var email = $('#user_email').val() 161 var phone = $('#user_phone').val() 162 var smscode = $('#register_sms_code').val() 163 if (username == '' || smscode == '' || email == '' || phone == '') { 164 $('#have_null').show() 165 return 166 } else { 167 $('#have_null').hide() 168 } 169 var pattern = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/; 170 strEmail = pattern.test(email); 171 if (!strEmail) { 172 $('#wrong_email').show() 173 return 174 } else { 175 $('#wrong_email').hide() 176 } 177 if (phone === '' || !phone.match(/^1[3-9]\d{9}$/)) { 178 $('#wrong_phone').show() 179 return 180 } else { 181 $('#wrong_phone').hide() 182 } 183 if (smscode.length < 6 || smscode.length > 6) { 184 $('#wrong_code').show() 185 return; 186 } else { 187 $('#wrong_code').hide() 188 } 189 $.ajax({ 190 type: 'post', 191 url: ajaxUrl, 192 dataType: "json", 193 data: { 194 action: 'submit_register', 195 username: username, 196 email: email, 197 phone: phone, 198 smscode: smscode 199 }, 200 success: function (res) { 201 if (res.success === true) { 202 $('#registerform').submit() 203 } else if (res.success === false) { 204 if (res.data.name != null) { 205 $('#exist_name').show() 206 } else { 207 $('#exist_name').hide() 208 } 209 if (res.data.email != null) { 210 $('#exist_email').show() 211 } else { 212 $('#exist_email').hide() 213 } 214 if (res.data.phone != null) { 215 $('#exist_phone').show() 216 } else { 217 $('#exist_phone').hide() 218 } 219 if (res.data.smscode != null) { 220 $('#wrong_code').show() 221 } else { 222 $('#wrong_code').hide() 223 } 224 } 225 } 226 }) 227 }) 228 148 229 // 添加登录设备 149 function addDevice(token) {150 $.ajax({ 151 type: 'post',230 function addDevice(token) { 231 $.ajax({ 232 type: 'post', 152 233 url: ajaxUrl, 153 234 dataType: "json", … … 160 241 code: $('#sms_code').val() 161 242 }, 162 success: function (res){163 if (res.data.code === 200){243 success: function (res) { 244 if (res.data.code === 200) { 164 245 $('#loginform').submit() 165 } else{246 } else { 166 247 alert(res.data.msg) 167 248 } … … 172 253 // 重新获取验证码短信时间间隔 173 254 var waitTime = 60; 255 174 256 function sendCountdown() { 175 257 if (waitTime > 0) { … … 195 277 196 278 //切换账号密码登录 197 $('#name-or-email-login').click(function () {279 $('#name-or-email-login').click(function () { 198 280 $(this).hide(); 199 281 $('#phone-login').show(); … … 204 286 $('#user_login').parent().find('label').text('用户名、手机号或电子邮箱地址'); 205 287 $('.user-pass-wrap').show(); 206 $('#user_pass').attr('disabled', false)207 208 $('#wp-submit').val('登录').css({"display": "block","margin-right":"0"});288 $('#user_pass').attr('disabled', false) 289 290 $('#wp-submit').val('登录').css({"display": "block", "margin-right": "0"}); 209 291 $('#select_phone').hide(); 210 292 $('#submit_form_button').hide(); … … 212 294 213 295 //切换免密登录 214 $('#phone-login').click(function () {296 $('#phone-login').click(function () { 215 297 $(this).hide(); 216 298 $('#name-or-email-login').show(); … … 219 301 $('.user-pass-wrap').hide(); 220 302 221 $('#wp-submit').val('登录').css({"display": "none","margin-right":"0"});303 $('#wp-submit').val('登录').css({"display": "none", "margin-right": "0"}); 222 304 $('#select_phone').show(); 223 305 $('#submit_form_button').show(); … … 249 331 250 332 //免密登录按钮 251 $('#submit_form_button').click(function () {333 $('#submit_form_button').click(function () { 252 334 var phone = $("#user_phone").val(); 253 335 if (phone === '' || !phone.match(/^1[3-9]\d{9}$/)) { … … 260 342 261 343 //登录按钮 262 $('#sms_login_button').click(function () {344 $('#sms_login_button').click(function () { 263 345 operaticon = 'smsLogin'; 264 346 obj.validate() … … 266 348 267 349 //输入国别号弹出下拉 268 $('#country_code').focus(function () {350 $('#country_code').focus(function () { 269 351 $('#dropdown-menu').show() 270 352 }) 271 $('#country_code').blur(function () {353 $('#country_code').blur(function () { 272 354 // $('#dropdown-menu').hide() 273 355 }) … … 275 357 276 358 //选择国别号弹出下拉 277 $('#btn-down').click(function () {278 if ($("#dropdown-menu").is(":hidden")){359 $('#btn-down').click(function () { 360 if ($("#dropdown-menu").is(":hidden")) { 279 361 $('#dropdown-menu').show() 280 } else {362 } else { 281 363 $('#dropdown-menu').hide() 282 364 } 283 365 }) 284 366 //选择国别号下拉点击 285 $("#dropdown-menu").children("li").click(function (e) {367 $("#dropdown-menu").children("li").click(function (e) { 286 368 $(this).addClass("active").siblings("li").removeClass("active"); 287 369 var code = $(this).data('value');//点击时 当前li的值 -
vaptcha-sms/trunk/options.php
r2511904 r2513195 22 22 <div class='vaptcha-badge'></div> 23 23 <div> 24 <h2><?php _e(' 手机登录注册', 'vaptcha') ?></h2>25 <p class="vaptcha-about-text"><?php _e( ' 由智能人机验证服务商VAPTCHA提供的手机注册插件。短信单价经过补贴后远低于市场价,并集成了先进的人机验证策略,不用担心短信被刷,同时支持设备免密登录,pc/手机/平板均可。', 'vaptcha' ); ?>24 <h2><?php _e('VAPTCHA-SMS', 'vaptcha') ?></h2> 25 <p class="vaptcha-about-text"><?php _e( '为了避免冲突,VAPTCHA及VAPTCHA-SMS仅能同时启用其中一个插件;短信单价经过补贴后远低于市场价,低至2.8分/条,插件安装即赠送30条测试短信,超出请自行充值后使用。', 'vaptcha' ); ?> 26 26 </div> 27 27 </div> … … 57 57 <tr> 58 58 <th class="form-title"><b style="font-size: 16px;"><?php _e('短信接口设置', 'vaptcha') ?></b></th> 59 <td >60 <?php _e( '(登录VAPTCHA - 短信接口 - 获取参数。 注意,默认模板签名被公用,到达率较低,建议使用自定义短信模板,自定义模板内容只能包含验证码一个变量)', 'vaptcha' ); ?>59 <td style="width: 1000px"> 60 <?php _e( '(登录VAPTCHA - 短信接口 - 获取参数。默认模板签名被公用,到达率较低,建议使用自定义短信模板,自定义模板内容只能包含验证码一个变量)', 'vaptcha' ); ?> 61 61 </td> 62 62 </tr> … … 86 86 </fieldset> 87 87 </td> 88 <td class='descript' ><?php _e('建议使用自定义模板,示例:【XX网站】您的验证码是{变量},请在十分钟内输入', 'vaptcha') ?></td>88 <td class='descript' style="width: 550px"><?php _e('建议使用自定义模板,示例:【XX网站】您的验证码是{变量},请在十分钟内输入', 'vaptcha') ?></td> 89 89 </tr> 90 90 <tr>
Note: See TracChangeset
for help on using the changeset viewer.