|
|
@@ -16,7 +16,7 @@ class IpFilter
|
|
|
* @throws BadRequestHttpException
|
|
|
* @return bool
|
|
|
*/
|
|
|
- public function frontApiCheck($source, $isLogin = false)
|
|
|
+ public function checkIp($source, $isLogin = false): bool
|
|
|
{
|
|
|
$request = Yii::$app->request;
|
|
|
$getParams = Yii::$app->request->get();
|
|
|
@@ -24,7 +24,7 @@ class IpFilter
|
|
|
$remoteAddr = $_SERVER['REMOTE_ADDR']; // 获取用户 IP 地址
|
|
|
|
|
|
//如果IP不在指定范围内
|
|
|
- if (!self::remoteAddrCall($remoteAddr)) {
|
|
|
+ if (!self::checkIpInAllowRange($remoteAddr)) {
|
|
|
$logPreix = $isLogin ? 'nc_ip_filter_login' : 'nc_ip_filter_other';
|
|
|
$getLog = sprintf('%s_%s: remote_ip%s: url(%s): param%s', $source, $logPreix, $remoteAddr, $request->getAbsoluteUrl(), (is_array($getParams) ? json_encode($getParams) : $getParams));
|
|
|
$postLog = sprintf('%s_%s: remote_ip%s: url(%s): param%s', $source, $logPreix, $remoteAddr, $request->getAbsoluteUrl(), (is_array($postParams) ? json_encode($postParams) : $postParams));
|
|
|
@@ -43,7 +43,7 @@ class IpFilter
|
|
|
* @throws AddressNotFoundException
|
|
|
* @throws InvalidDatabaseException
|
|
|
*/
|
|
|
- public static function remoteAddrCall($remoteAddr): bool
|
|
|
+ public static function checkIpInAllowRange($remoteAddr): bool
|
|
|
{
|
|
|
// 是否有效的IP
|
|
|
if (!filter_var($remoteAddr, FILTER_VALIDATE_IP)) {
|