You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ss-panel-v3-mod_Uim2/app/Utils/Geetest.php

46 lines
1.2 KiB
PHP

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace App\Utils;
use App\Services\Config;
/**
* 极验行为式验证安全平台,php 网站主后台包含的库文件
*
* @author Tanxu
*/
class Geetest
{
public static function get($user_id = null)
{
$GtSdk = new GeetestLib(Config::get('geetest_id'), Config::get('geetest_key'));
$status = $GtSdk->pre_process($user_id);
$ret = json_decode($GtSdk->get_response_str());
session_start();
$_SESSION['gtserver'] = $status;
$_SESSION['user_id'] = $user_id;
return $ret;
}
public static function verify($geetest_challenge, $geetest_validate, $geetest_seccode)
{
session_start();
$GtSdk = new GeetestLib(Config::get('geetest_id'), Config::get('geetest_key'));
$user_id = $_SESSION['user_id'];
if ($_SESSION['gtserver'] == 1) {
$result = $GtSdk->success_validate($geetest_challenge, $geetest_validate, $geetest_seccode, $user_id);
if ($result) {
return true;
}
return false;
}
if ($GtSdk->fail_validate($geetest_challenge, $geetest_validate, $geetest_seccode)) {
return true;
}
return false;
}
}