⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ipcidrformatrule.class.php

📁 一个用PHP编写的
💻 PHP
字号:
<?php    lt_include(PLOG_CLASS_PATH."class/data/validator/rules/regexprule.class.php");    define( "IP_CIDR_FORMAT_RULE_REG_EXP", "^([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})/([0-9]{1,2})$");    define( "ERROR_RULE_IP_CIDR_FORMAT_WRONG", "error_rule_ip_cidr_format_wrong");    /**	 * \ingroup Validator_Rules	 *	 * Returns true if a given IP address is in valid CIDR format (Classless Inter-Domain Routing) These addresses	 * should have the following format: 	 *	 * <pre>xxx.yyy.zzz.www</pre>	 *	 * where each one of the elements is an integer between 0 and 255.     */    class IpCidrFormatRule extends RegExpRule    {        /**         * Initializes the rule         */        function IpCidrFormatRule()        {            $this->RegExpRule(IP_CIDR_FORMAT_RULE_REG_EXP, false);        }        /**         * Retursn true if the given IP address is in valid CIDR format         *         * @param value the IP address to validate         */        function validate($value)        {            if (!ereg($this->_regExp, $value, $regs))            {                $this->_setError(ERROR_RULE_IP_CIDR_FORMAT_WRONG);                return false;            }            else if ($regs[1] > 255 || $regs[2] > 255 || $regs[3] > 255 || $regs[4] > 255 || $regs[5] > 32)            {                $this->_setError(ERROR_RULE_IP_CIDR_FORMAT_WRONG);                return false;            }            else            {                $this->_setError(false);                return true;            }        }    }?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -