修复判断入口文件ip_check.php以及新增复制配置选项
This commit is contained in:
+42
-5
@@ -37,6 +37,8 @@ require_once __DIR__ . '/lib/DbHelper.php';
|
||||
require_once __DIR__ . '/lib/bootstrap.php';
|
||||
require_once __DIR__ . '/config/ConfigLoader.php';
|
||||
require_once __DIR__ . '/lib/Cloak/FpUrlHelper.php';
|
||||
require_once __DIR__ . '/lib/Cloak/VisitorApiAudit.php';
|
||||
require_once __DIR__ . '/lib/Cloak/RiskSecondaryGate.php';
|
||||
|
||||
$fp_host = parse_url($fingerprint_info['domain'], PHP_URL_HOST);
|
||||
if (empty($fp_host)) {
|
||||
@@ -44,6 +46,41 @@ if (empty($fp_host)) {
|
||||
}
|
||||
$config_name = ConfigLoader::loadByHost($fp_host);
|
||||
|
||||
$log_id = (int) ($fingerprint_info['log_id'] ?? 0);
|
||||
|
||||
if (!RiskSecondaryGate::isEnabled()) {
|
||||
$_SESSION['visit_to_3'] = 3;
|
||||
$_SESSION['check_result'] = 'true';
|
||||
|
||||
$resolved = FpUrlHelper::resolve($config_name, true);
|
||||
$fp_url = $resolved['url'];
|
||||
$response = [
|
||||
'reason' => '',
|
||||
'result' => true,
|
||||
'link' => $fp_url !== '' ? $fp_url : FpUrlHelper::fallbackUrl(),
|
||||
];
|
||||
|
||||
if ($log_id > 0) {
|
||||
$conn = new mysqli('localhost', DB_USERNAME, DB_PASSWORD, DB_NAME);
|
||||
if (!$conn->connect_error) {
|
||||
require_once __DIR__ . '/lib/Cloak/VisitorLogSchema.php';
|
||||
VisitorLogSchema::ensureColumns($conn);
|
||||
$resultEsc = cloak_db_escape($conn, 'true');
|
||||
$reasonEsc = cloak_db_escape($conn, '二次风控已关闭');
|
||||
$fpUrlEsc = cloak_db_escape($conn, strip_tags(cloak_db_string($response['link'])));
|
||||
$sql = "UPDATE `visitor_logs` SET `result`='{$resultEsc}',`reason`='{$reasonEsc}',`fp_url`='{$fpUrlEsc}' WHERE `id`='" . $log_id . "'";
|
||||
if ($conn->query($sql) !== true) {
|
||||
$handle = fopen(dirname(__FILE__) . '/err.txt', 'a+');
|
||||
fwrite($handle, date('Y-m-d H:i:s') . ' | f_check risk disabled update: ' . $conn->error . "\n");
|
||||
fclose($handle);
|
||||
}
|
||||
$conn->close();
|
||||
}
|
||||
}
|
||||
|
||||
exit(json_encode($response));
|
||||
}
|
||||
|
||||
$jsonData = [
|
||||
'id' => COSTM_IP_SCORE,
|
||||
'hdata' => $hdata,
|
||||
@@ -54,7 +91,7 @@ $jsonData = [
|
||||
'risk_number' => CLOAK_RISK_NUMBER,
|
||||
];
|
||||
|
||||
$ch = curl_init('https://www.tiktokba.com/cloak/byApiRisk');
|
||||
$ch = curl_init('www.tiktokba.com/cloak/byApiRisk');
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
||||
@@ -114,10 +151,8 @@ if($return['result']) {
|
||||
}
|
||||
}
|
||||
|
||||
$log_id = (int) ($fingerprint_info['log_id'] ?? 0);
|
||||
$update_log = [];
|
||||
|
||||
$update_log['result'] = $response['result'] ? "true" : "false";
|
||||
$update_log['result'] = $response['result'] ? 'true' : 'false';
|
||||
$update_log['reason'] = $response['reason'] ?? '';
|
||||
$update_log['fp_url'] = trim((string) ($response['link'] ?? ''));
|
||||
if ($update_log['fp_url'] === '') {
|
||||
@@ -148,9 +183,11 @@ if ($conn->connect_error) {
|
||||
$fpHdataJson = '';
|
||||
}
|
||||
$fpHdataEsc = cloak_db_escape($conn, $fpHdataJson);
|
||||
$apiRiskReqEsc = cloak_db_escape($conn, VisitorApiAudit::encode($jsonData));
|
||||
$apiRiskRespEsc = cloak_db_escape($conn, VisitorApiAudit::encode($return));
|
||||
require_once __DIR__ . '/lib/Cloak/VisitorLogSchema.php';
|
||||
VisitorLogSchema::ensureColumns($conn);
|
||||
$sql = "UPDATE `visitor_logs` SET `result`='{$resultEsc}',`reason`='{$reasonEsc}',`fp_url`='{$fpUrlEsc}',`fp_hdata`='{$fpHdataEsc}' WHERE `id`='" . (int) $log_id . "'";
|
||||
$sql = "UPDATE `visitor_logs` SET `result`='{$resultEsc}',`reason`='{$reasonEsc}',`fp_url`='{$fpUrlEsc}',`fp_hdata`='{$fpHdataEsc}',`api_risk_request`='{$apiRiskReqEsc}',`api_risk_response`='{$apiRiskRespEsc}' WHERE `id`='" . (int) $log_id . "'";
|
||||
|
||||
if ($conn->query($sql) != TRUE) {
|
||||
$handle = fopen(dirname(__FILE__) . "/err.txt", "a+");
|
||||
|
||||
Reference in New Issue
Block a user