nigel/ip
最新稳定版本:1.0.4
Composer 安装命令:
composer require nigel/ip
包简介
Package to get IP address and check if IP address is in your range of allowed addresses
README 文档
README
Package to get visitor IP address and check if visitor's IP address is in your range of allowed addresses
Install latest with Composer
composer require nigel/ip
Full example
<?php use Nigel\Ip\IpAddress; require_once __DIR__ . '/vendor/autoload.php'; header('Content-type: application/json'); //Initialize IpAddress $ipService = new IpAddress(); // Define your IP address ranges $allowedRanges = [ '127.0.0.1/18', ]; // Get the visitor's IP address $visitorIp = $ipService->getIp(); // Validate IP address format if ($ipService->validateIPAddress($visitorIp) === false) { echo json_encode([ 'status' => 'error', 'message' => 'Invalid Ip Address' ]); } // Check if the visitor's IP address is within any of the allowed ranges if ($ipService->checkVisitorIpInRange($allowedRanges, $visitorIp)) { echo json_encode([ 'status' => 'success', 'message' => 'Valid IP Address' ]); } else { echo json_encode([ 'status' => 'error', 'message' => 'Invalid IP Address' ]); }
统计信息
- 总下载量: 37
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-10-22