MediaWiki REL1_34
IP.php File Reference

Functions and constants to play with IP addresses and ranges. More...

Go to the source code of this file.

Classes

class  IP
 A collection of public static functions to play with IP address and IP ranges. More...
 

Variables

const IP_ADDRESS_STRING '(?:' . RE_IP_ADD . '(?:\/' . RE_IP_PREFIX . ')?' . '|' . RE_IPV6_ADD . '(?:\/' . RE_IPV6_PREFIX . ')?' . ')'
 
const RE_IP_ADD RE_IP_BYTE . '\.' . RE_IP_BYTE . '\.' . RE_IP_BYTE . '\.' . RE_IP_BYTE
 
const RE_IP_BYTE '(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|0?[0-9]?[0-9])'
 
const RE_IP_PREFIX '(3[0-2]|[12]?\d)'
 
const RE_IP_RANGE RE_IP_ADD . '\/' . RE_IP_PREFIX
 
const RE_IPV6_ADD '(?:' . ':(?::|(?::' . RE_IPV6_WORD . '){1,7})' . '|' . RE_IPV6_WORD . '(?::' . RE_IPV6_WORD . '){0,6}::' . '|' . RE_IPV6_WORD . '(?::((?(-1)|:))?' . RE_IPV6_WORD . '){1,6}(?(-2)|^)' . '|' . RE_IPV6_WORD . '(?::' . RE_IPV6_WORD . '){7}' . ')'
 
const RE_IPV6_GAP ':(?:0+:)*(?::(?:0+:)*)?'
 
const RE_IPV6_PREFIX '(12[0-8]|1[01][0-9]|[1-9]?\d)'
 
const RE_IPV6_RANGE RE_IPV6_ADD . '\/' . RE_IPV6_PREFIX
 
const RE_IPV6_V4_PREFIX '0*' . RE_IPV6_GAP . '(?:ffff:)?'
 
const RE_IPV6_WORD '([0-9A-Fa-f]{1,4})'
 

Detailed Description

Functions and constants to play with IP addresses and ranges.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. http://www.gnu.org/copyleft/gpl.html

Author
Antoine Musso "<hashar at free dot fr>"

Definition in file IP.php.

Variable Documentation

◆ IP_ADDRESS_STRING

const IP_ADDRESS_STRING '(?:' . RE_IP_ADD . '(?:\/' . RE_IP_PREFIX . ')?' . '|' . RE_IPV6_ADD . '(?:\/' . RE_IPV6_PREFIX . ')?' . ')'

Definition at line 61 of file IP.php.

◆ RE_IP_ADD

const RE_IP_ADD RE_IP_BYTE . '\.' . RE_IP_BYTE . '\.' . RE_IP_BYTE . '\.' . RE_IP_BYTE

Definition at line 30 of file IP.php.

◆ RE_IP_BYTE

const RE_IP_BYTE '(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|0?[0-9]?[0-9])'

Definition at line 29 of file IP.php.

Referenced by ApiBase\validateUser().

◆ RE_IP_PREFIX

const RE_IP_PREFIX '(3[0-2]|[12]?\d)'

Definition at line 32 of file IP.php.

◆ RE_IP_RANGE

const RE_IP_RANGE RE_IP_ADD . '\/' . RE_IP_PREFIX

Definition at line 33 of file IP.php.

◆ RE_IPV6_ADD

const RE_IPV6_ADD '(?:' . ':(?::|(?::' . RE_IPV6_WORD . '){1,7})' . '|' . RE_IPV6_WORD . '(?::' . RE_IPV6_WORD . '){0,6}::' . '|' . RE_IPV6_WORD . '(?::((?(-1)|:))?' . RE_IPV6_WORD . '){1,6}(?(-2)|^)' . '|' . RE_IPV6_WORD . '(?::' . RE_IPV6_WORD . '){7}' . ')'

Definition at line 48 of file IP.php.

◆ RE_IPV6_GAP

const RE_IPV6_GAP ':(?:0+:)*(?::(?:0+:)*)?'

Definition at line 52 of file IP.php.

◆ RE_IPV6_PREFIX

const RE_IPV6_PREFIX '(12[0-8]|1[01][0-9]|[1-9]?\d)'

Definition at line 38 of file IP.php.

◆ RE_IPV6_RANGE

const RE_IPV6_RANGE RE_IPV6_ADD . '\/' . RE_IPV6_PREFIX

Definition at line 50 of file IP.php.

◆ RE_IPV6_V4_PREFIX

const RE_IPV6_V4_PREFIX '0*' . RE_IPV6_GAP . '(?:ffff:)?'

Definition at line 53 of file IP.php.

◆ RE_IPV6_WORD

const RE_IPV6_WORD '([0-9A-Fa-f]{1,4})'

Definition at line 37 of file IP.php.