PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 2.3.1
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v2.3.1
3.5.4 3.5.3 3.5.2 3.5.1 3.4.9 3.5.0 3.4.8 3.4.7 trunk 2.3.1 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6
supportcandy / includes / admin / tickets / sign_in / set_user_login.php

set_user_login.php in SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent 2.3.1, at includes/admin/tickets/sign_in/set_user_login.php

66 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit; // Exit if accessed directly
4 }
5
6 // Check nonce
7 if( !isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce']) ){
8 die(__('Cheating huh?', 'supportcandy'));
9 }
10
11 $username = isset($_POST['username']) ? sanitize_text_field($_POST['username']) : '';
12 if (!$username) die();
13
14 $password = isset($_POST['password']) ? $_POST['password'] : '';
15 if (!$password) die();
16
17 $remember = isset($_POST['remember']) ? true : false;
18 $wpsc_captcha = get_option('wpsc_login_captcha',0);
19
20 if ($wpsc_captcha) {
21
22 $wpsc_recaptcha_type = get_option('wpsc_recaptcha_type');
23
24 if ($wpsc_recaptcha_type){
25
26 $captcha_key = isset($_COOKIE) && isset($_COOKIE['wpsc_secure_code']) ? intval($_COOKIE['wpsc_secure_code']) : 0;
27 if(!isset($_POST['captcha_code']) || !wp_verify_nonce($_POST['captcha_code'],$captcha_key)){
28 die(__('Cheating huh?', 'supportcandy'));
29 }
30
31 } else {
32
33 $captcha = isset($_POST['g-recaptcha-response']) ? $_POST['g-recaptcha-response'] : '';
34 if (!$captcha) die(__('Cheating huh?', 'supportcandy'));
35
36 $secretKey = get_option('wpsc_get_secret_key');
37 $ip = $_SERVER['REMOTE_ADDR'];
38
39 $response = wp_remote_get("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip);
40 $body = !is_wp_error($response) ? json_decode(wp_remote_retrieve_body($response)) : false;
41 if (!$body || intval($body->success) !== 1) {
42 die(__('Cheating huh?', 'supportcandy'));
43 }
44 }
45
46 setcookie('wpsc_secure_code','123');
47 }
48
49 $creds = array(
50 'user_login' => $username,
51 'user_password' => $password,
52 'remember' => $remember,
53 );
54 $user = wp_signon( $creds, false );
55
56 $response = array();
57
58 if ( is_wp_error( $user ) ) {
59 $response['error'] = '1';
60 $response['message'] = $user->get_error_message();
61 } else {
62 $response['error'] = '0';
63 $response['message'] = __('Success!','supportcandy');
64 }
65
66 echo json_encode( $response );