nigel/ip 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固