定制 alexeevdv/yii2-ip-validator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

alexeevdv/yii2-ip-validator

Composer 安装命令:

composer require alexeevdv/yii2-ip-validator

包简介

Yii2 IP address validator

README 文档

README

Yii2 ip address validator. Can check that IP address is valid or in given range

Installation

The preferred way to install this extension is through composer.

Either run

$ php composer.phar require alexeevdv/yii2-ip-validator "dev-master"

or add

"alexeevdv/yii2-ip-validator": "dev-master"

to the require section of your composer.json file.

Usage

public function rules() {
    return [
        //...
        ['ip', \alexeevdv\ip\Validator::className(), "range" => [
            "192.168.1.1", 
            "10.62.15.0/24", 
            "109.232.0.0/16"
        ]],
        //...
    ];
}

// or

$validator = new \alexeevdv\ip\Validator([
    "allowPrivate" => false,
    "allowReserved" => false,
]);

$validator->validate("127.0.0.1"); // false

Params

/**
 * Allow private ip addresses?
 * 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16
 */
bool $allowPrivate = true;

/**
 * Allow reserved ip addresses?
 * 0.0.0.0/8, 169.254.0.0/16, 192.0.2.0/24 and 224.0.0.0/4
 */
bool $allowReserved = true;

/**
 * Range of allowed ip addresses. Array of subnets and ip addresses.
 */
array $range = [];

统计信息

  • 总下载量: 115
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-23