chengkun
2025-04-27 ecc546d7df6ad021bfbc531674b10c2ffd224637
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
 
class geetest_controller extends common{
    function index_action(){
 
        session_start();
        
        require_once LIB_PATH . '/class.geetestlib.php';
        
        $GtSdk = new GeetestLib($this->config['sy_geetestid'], $this->config['sy_geetestkey']);
        
        $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";  
 
        $str ="";
 
        for ( $i = 0; $i < 4; $i++ )  {  
            $str.= substr($chars, mt_rand(0, strlen($chars)-1), 1);   
        }
        $user_id = $str;
 
        $data = array(
                "user_id" => $user_id, # 网站用户id
                "client_type" => "h5", #web:电脑上的浏览器;h5:手机上的浏览器
                "ip_address" => "127.0.0.1" # 请在此处传输用户请求验证时所携带的IP
        );
 
        $status = $GtSdk->pre_process($data, 1);
 
        $_SESSION['gtserver'] = $status;
        $_SESSION['user_id'] = $str;
        echo $GtSdk->get_response_str();
    }
    
}
?>