cvs: pear /Net_IPv4 IPv4.php package.xml

From: Date: Tue, 29 Nov 2005 12:56:39 +0000
Subject: cvs: pear /Net_IPv4 IPv4.php package.xml
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-36589@lists.php.net to get a copy of this message
fa Tue Nov 29 07:56:39 2005 EDT Modified files: /pear/Net_IPv4 IPv4.php package.xml Log: many phpdoc fixes, prepared for new release, added myself to package.xml

http://cvs.php.net/diff.php/pear/Net_IPv4/IPv4.php?r1=1.10&r2=1.11&ty=u Index: pear/Net_IPv4/IPv4.php diff -u pear/Net_IPv4/IPv4.php:1.10 pear/Net_IPv4/IPv4.php:1.11 --- pear/Net_IPv4/IPv4.php:1.10 Tue Nov 22 07:51:05 2005 +++ pear/Net_IPv4/IPv4.php Tue Nov 29 07:56:35 2005 @@ -1,29 +1,36 @@ <?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2003 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Eric Kilfoil <eric@ypass.net> | -// +----------------------------------------------------------------------+ -// +/** +* Class to provide IPv4 calculations +* +* PHP versions 4 and 5 +* +* LICENSE: This source file is subject to version 3.01 of the PHP license +* that is available through the world-wide-web at the following URI: +* http://www.php.net/license/3_01.txt. If you did not receive a copy of +* the PHP License and are unable to obtain it through the web, please +* send a note to license@php.net so we can mail you a copy immediately. +* +* @category Net +* @package Net_IPv4 +* @author Eric Kilfoil <edk@ypass.net> +* @author Marco Kaiser <bate@php.net> +* @author Florian Anderiasch <fa@php.net> +* @copyright 1997-2005 The PHP Group +* @license http://www.php.net/license/3_01.txt PHP License 3.01 +* @version CVS: $Id: IPv4.php,v 1.11 2005/11/29 12:56:35 fa Exp $ +* @link http://pear.php.net/package/Net_IPv4 +*/ -require_once("PEAR.php"); +require_once 'PEAR.php'; +// {{{ GLOBALS /** * Map of bitmasks to subnets * * This array contains every valid netmask. The index of the dot quad * netmask value is the corresponding CIDR notation (bitmask). + * + * @global array $GLOBALS['Net_IPv4_Netmask_Map'] */ $GLOBALS['Net_IPv4_Netmask_Map'] = array( 0 => "0.0.0.0", @@ -60,7 +67,8 @@ 31 => "255.255.255.254", 32 => "255.255.255.255" ); - +// }}} +// {{{ Net_IPv4 /** * Class to provide IPv4 calculations @@ -68,19 +76,29 @@ * Provides methods for validating IP addresses, calculating netmasks, * broadcast addresses, network addresses, conversion routines, etc. * -* @author Eric Kilfoil <edk@ypass.net> -* @package Net_IPv4 -* @version 1.0 +* @category Net +* @package Net_IPv4 +* @author Eric Kilfoil <edk@ypass.net> +* @author Marco Kaiser <bate@php.net> +* @author Florian Anderiasch <fa@php.net> +* @copyright 1997-2005 The PHP Group +* @license http://www.php.net/license/3_01.txt PHP License 3.01 +* @version CVS: @package_version@ +* @link http://pear.php.net/package/Net_IPv4 * @access public */ class Net_IPv4 { + // {{{ properties var $ip = ""; var $bitmask = false; var $netmask = ""; var $network = ""; var $broadcast = ""; var $long = 0; + + // }}} + // {{{ validateIP() /** * Validate the syntax of the given IP adress @@ -102,6 +120,9 @@ return false; } } + + // }}} + // {{{ check_ip() /** * Validate the syntax of the given IP address (compatibility) @@ -117,6 +138,9 @@ return $this->validateIP($ip); } + // }}} + // {{{ validateNetmask() + /** * Validate the syntax of a four octet netmask * @@ -136,6 +160,9 @@ return true; } + // }}} + // {{{ parseAddress() + /** * Parse a formatted IP address * @@ -151,7 +178,7 @@ * The first would be [IP Address]/[BitMask]: * 192.168.0.0/16 * - * The second would be [IP Address] [Subnet Mask in quad dot notation]: + * The second would be [IP Address] [Subnet Mask in dot quad notation]: * 192.168.0.0/255.255.0.0 * * The third would be [IP Address] [Subnet Mask as Hex string] @@ -222,6 +249,9 @@ } } + // }}} + // {{{ calculate() + /** * Calculates network information based on an IP address and netmask. * @@ -274,6 +304,9 @@ return true; } + // }}} + // {{{ getNetmask() + function getNetmask($length) { if (! PEAR::isError($ipobj = Net_IPv4::parseAddress("0.0.0.0/" . $length))) { @@ -283,6 +316,9 @@ } return false; } + + // }}} + // {{{ getNetLength() function getNetLength($netmask) { @@ -294,6 +330,9 @@ return false; } + // }}} + // {{{ getSubnet() + function getSubnet($ip, $netmask) { if (! PEAR::isError($ipobj = Net_IPv4::parseAddress($ip . "/" . $netmask))) { @@ -304,6 +343,9 @@ return false; } + // }}} + // {{{ inSameSubnet() + function inSameSubnet($ip1, $ip2) { if (! is_object($ip1) || strcasecmp(get_class($ip1), 'net_ipv4') <> 0) { @@ -324,9 +366,14 @@ } return false; } + + // }}} + // {{{ atoh() /** - * Converts a dot-quad formmated IP address into a hexadecimal string + * Converts a dot-quad formatted IP address into a hexadecimal string + * @param string $addr IP-adress in dot-quad format + * @return mixed false if invalid IP and hexadecimal representation as string if valid */ function atoh($addr) { @@ -337,8 +384,13 @@ return sprintf("%02x%02x%02x%02x", $ap[0], $ap[1], $ap[2], $ap[3]); } + // }}} + // {{{ htoa() + /** * Converts a hexadecimal string into a dot-quad formatted IP address + * @param string $addr IP-adress in hexadecimal format + * @return mixed false if invalid IP and dot-quad formatted IP as string if valid */ function htoa($addr) { @@ -349,14 +401,23 @@ } return false; } + + // }}} + // {{{ ip2double() + /** * Converts an IP address to a PHP double. Better than ip2long because * a long in PHP is a signed integer. + * @param string $ip dot-quad formatted IP adress + * @return float IP adress as double - positive value unlike ip2long */ function ip2double($ip) { return (double)(sprintf("%u", ip2long($ip))); } + + // }}} + // {{{ ipInNetwork() /** * Determines whether or not the supplied IP is within the supplied network. @@ -366,9 +427,9 @@ * network ($network) may be either a string containing a CIDR * formatted network definition, or a Net_IPv4 object. * - * @param string $ip A quad-dot representation of an IP address - * @param string $network A string representing the network in CIDR format or a Net_IPv4 object. - * @return boolean true if the IP address exists within the network + * @param string $ip A dot quad representation of an IP address + * @param string $network A string representing the network in CIDR format or a Net_IPv4 object. + * @return bool true if the IP address exists within the network */ function ipInNetwork($ip, $network) { @@ -385,9 +446,13 @@ } return false; } + + // }}} } +// }}} + /* * vim: sts=4 ts=4 sw=4 cindent fdm=marker */ -?> \ No newline at end of file +?> http://cvs.php.net/diff.php/pear/Net_IPv4/package.xml?r1=1.6&r2=1.7&ty=u Index: pear/Net_IPv4/package.xml diff -u pear/Net_IPv4/package.xml:1.6 pear/Net_IPv4/package.xml:1.7 --- pear/Net_IPv4/package.xml:1.6 Tue Nov 22 07:51:05 2005 +++ pear/Net_IPv4/package.xml Tue Nov 29 07:56:36 2005 @@ -17,6 +17,12 @@ <email>bate@php.net</email> <role>lead</role> </maintainer> + <maintainer> + <user>fa</user> + <name>Florian Anderiasch</name> + <email>fa@php.net</email> + <role>developer</role> + </maintainer> </maintainers> <release> <version>1.2</version>
« previous php.pear.cvs (#36589) next »