修复判断入口文件ip_check.php以及新增复制配置选项
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
require_once dirname(__DIR__) . '/Cloak/ReasonHelper.php';
|
||||
require_once dirname(__DIR__) . '/Cloak/VisitorApiAudit.php';
|
||||
|
||||
/**
|
||||
* 访客上下文与 API 判定(类名保留历史拼写 visitorInfo)
|
||||
@@ -93,6 +94,7 @@ class visitorInfo
|
||||
$jsonData['country_code'] = $this->check_country; //设置该参数后,将替换"广告策略》访问者地理位置>过滤"的设置,填写国家代码,多个用逗号分隔,如:US,GB,CA,AU,IE,NZ
|
||||
$jsonData['referer'] = get_SERVER_value('HTTP_REFERER');
|
||||
$jsonData['headers'] = json_encode($headers);
|
||||
VisitorApiAudit::recordByApiRequest($jsonData);
|
||||
$ch = curl_init('www.tiktokba.com/cloak/byApi');
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
@@ -114,14 +116,19 @@ class visitorInfo
|
||||
if ($return == false) {
|
||||
$curl_error = curl_error($ch);
|
||||
curl_close($ch);
|
||||
return ['result' => false, 'reason' => 'API请求失败:' . $curl_error, 'country' => ''];
|
||||
$errorPayload = ['result' => false, 'reason' => 'API请求失败:' . $curl_error, 'country' => ''];
|
||||
VisitorApiAudit::recordByApiResponse($errorPayload);
|
||||
return $errorPayload;
|
||||
}
|
||||
curl_close($ch);
|
||||
$decoded = json_decode($return, true);
|
||||
if (!is_array($decoded)) {
|
||||
$invalidPayload = ['result' => false, 'reason' => 'API响应失败,请检查API密钥以及广告策略 ID', 'country' => '', '_raw' => $return];
|
||||
VisitorApiAudit::recordByApiResponse($invalidPayload);
|
||||
return ['result' => false, 'reason' => 'API响应失败,请检查API密钥以及广告策略 ID', 'country' => ''];
|
||||
}
|
||||
|
||||
VisitorApiAudit::recordByApiResponse($decoded);
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user