Now 129344 iCalcreator
users worldwide!!
Donate
You can show your appreciation for our free software
and can support future development by making a donation to the kigkonsult projects.
Make a donation of any size by clicking here. Thanks in advance!
Services
kigkonsult offer professional services for software support, design and new/re-development, customizations and adaptations
of PHP/MySQL solutions with focus on software lifecycle management, including long term utility, reliability and maintainability.
If you need any custom modules, modification or amendment based on iCalcreator
to suit your needs or professional support, don't hesitate to contact us.
iCalcreator used in.. .
- AgenDAV
- albaven
- All-in-One Event Calendar
- Bugscope
- Date iCal
- Dokeos
- event_connect
- ESS Feed
- Exponent CMS
- EQDKP Plus
- GCalendar
- GLPI
- Gumbo Millennium
- Hypecal
- iCal
- JCal Pro
- kitEvent
- luryevents
- MarkupiCalendar
- One Big SYSTem
- Open Atrium
- Repository based CMS
- sfiCalCreatorPlugin
- Telaen
- terncal
- twical
- Virtual Loup-De-Mer
- "Weather Forecast"
-
- And many more.. .
-
Tell us
what iCalcreator is missing,
use the contact page
Credits & Licenses
iCalcreator and the related PHP software was conceived and written by Kjell-Inge Gustafsson.
Many people have contributed, through providing questions, issues, reporting bugs and sending patches.
iCalcreator (standard) and the related PHP software are released under the
LGPL
/
GPL
/
CC
licences.
ipTools
ipTools is a PHP IP number utility toolbox.
"Don't thrust an IP address... ", but sometime you have to deal with them..
- Provides IP v4/v6
- validation: IP in IP/network(CIDR) ranges
-
- and util services:
- is valid IP,
- expand/compress IP number
- IP number to binary and reverse
- netmask/cidr etc
- ...
With courtesy of and inspiration from Paul Gregg <pgregg_at_pgregg_dot_com>
and the excellent functions decbin32 and ip_in_range.
Click to get ipTools
from github
- at packagist
|
USAGE
How to check an IPv4/v6 number is valid and in a validity range :
1 - Build a validity range filter
<?php
$validityRange = [
'192.168.0.1', // specific match
'192.168.0.10-192.168.0.20' // within a range
'192.168.1.* // with wildcard
'192.168.2.0/25 // cidr
'192.168.3.0/255.255.255.128' // or netmask
];
For filters in detail, examine IpTool::isIpNumInRange, below.
2a - 'ad hoc' check
<?php
use Kigkonsult\IpTools\IpTool;
if( ! Iptool::factory( $validityRange )->checkIPnumInRange( $IpNumToTest )) {
echo 'error message';
}
- Iptool::factory( [ filter ] )
- filter array|string
- throws InvalidArgumentException on invalid filter.
2b - class instance check (with added filter)
<?php
use Kigkonsult\IpTools\IpTool;
$ipValidator = new Iptool( $baseFilterArr );
...
$adHocFilter = '192.168.4.*';
...
if( ! $ipValidator->addFilter( $adHocFilter )
->checkIPnumInRange( $IpNumToTest )) {
echo 'error message';
}
- Iptool::__construct( [ filter ] )
- filter array|string
- throws InvalidArgumentException on invalid filter.
-
- IpTool::AddFilter( filter )
- filter array|string
- throws InvalidArgumentException on invalid filter.
-
- IpTool::deleteFilter()
- removes filter
-
- IpTool::getFilter()
- returns (array) filter.
-
(static) METHODS
Here you will find of IPnumber utility methods
- IpTool::isValidIP( ipNum )
- Return bool true on valid IP (string) v4/v6 number
-
- IpTool::expand( ipNum )
- Return expanded (string) IPv4 number to 4 octets / full IPv6 number
-
- IpTool::isIpNumInRange( ipNum , array acceptRanges [, & matchIx ] )
- Return bool true if (valid) (string) IPv4/v6 number match
(any element in array of) IPv4/v6-network filter range(s)
- on found, (int) matchIx holds the filter range array index
- For filters in detail, examine IpTool::isIpv4InRange and IpTool::isIpv6InRange, below.
-
- IpTool::cidr2NetmaskBin( cidr, bitNum )
- Return (int) IPv4/v6 CIDR block as binary
- bitNum: (int) 32 (IpV4) / 128 (IpV6)
-
IPv4 utility methods
- IpTool::isValidIPv4( ipNum )
- Return bool true on valid (string) IPv4 number
-
- IpTool::hasIPv4port( ipNum )
- Return bool true if IP v4 number has trailing port
-
- IpTool::getIPv4port( ipNum )
- Return IP v4 port
-
- IpTool::getIPv4withoutPort( ipNum )
- Return IP v4 without port
-
- IpTool::IPv42bin( ipNum )
- Return (string) IPv4 number as binary
-
- IpTool::bin2IPv4( IPbin )
- Return binary as IPv4 number
-
- IpTool::IpTool::decbin32( dec )
- Return binary string (left-)padded to 32 bit numbers
-
- IpTool::hasIPv4ValidHost( ipNum )
- Return true if hostName exists for a valid (string) IPv4 number and resolves back
-
- IpTool::expandIPv4( $ipNum )
- Return expanded (string) IPv4 number to 4 octets
-
- IpTool::isValidIPv4Cidr( cidr )
- Return bool true on valid (int) IPv4 cidr
-
- IpTool::ipv4CIDR2Netmask( cidr )
- Return (int) IPv4 cidr as netmask
-
- IpTool::ipv4Netmask2Cidr( netmask )
- Return (string) IPv4 netmask as cidr
-
- IpTool::getNetworkFromIpv4Cidr( ipNum, cidr )
- Return IPv4 network from (string) IPv4num and (int) cidr
-
- IpTool::IPv4Breakout( ipAddress, ipNetmaskCidr [, outputAsIpNum = false ] )
- Return array( network, firstIp, lastIP, broadcastIp )
- ipAddress string
- ipNetmaskCidr = (string) netmask or (int) cidr
- outputAsIpNum = false returns binary
- outputAsIpNum = true returns (string) Ipv4 numbers
-
- IpTool::isIPv4InRange( ipNum , array acceptRanges [, & matchIx ] )
- Return true if (valid) (string) IPv4 match any element in array of IPv4/network ranges
- on found, (int) matchIx holds the filter range array index
-
- IPv4 network filter ranges can be specified as:
example | type
|
'*' | Accept all IPs // warning, accepts all
|
'1.2.3.4' | Specific Ipv4
|
'1.2.3.*' | Ipv4 with wildcard
|
'1.2.3/24' | Ipv4 with cidr
|
'1.2.3.4/255.255.255.0' | Ipv4/netmask format
|
'1.2.3.0-1.2.3.255' | Start-End Ipv4 range, note, '-' as separator
|
-
- NOTE, a search for match is done array order !!
IPv6 utility methods
- IpTool::isValidIPv6( ipNum )
- Return true on valid (string) IPv6 number
-
- IpTool::hasIPv6port( ipNum )
- Return bool true if IP v6 number has trailing port
-
- IpTool::getIPv6port( ipNum )
- Return IP v6 port
-
- IpTool::getIPv6withoutPort( ipNum )
- Return IP v6 without port
-
- IpTool::isIPv4MappedIPv6( ipNum )
- Return bool true if (string) IP is v4 mapped IPv6
-
- IpTool::IPv62bin( ipNum )
- Return IPv6 number as binary
-
- IpTool::bin2IPv6( IPbin )
- Return binary string as IPv6 number
-
- IpTool::getIpv6InterfaceIdentifier( ipNum )
- Return (unicast/anycast) (string) IPv6 number interface identifier (last 64 bits as hex)
-
- IpTool::getIpv6NetworkPrefix( ipNum )
- Return (unicast/anycast) (string) IPv6 number network prefix (first 64 bits as hex)
-
- IpTool::expandIPv6( ipNum )
- Return expanded (condensed) full (string) IP v6 number
-
- IpTool::compressIPv6( ipNum )
- ipNum string
- Return condensed IPv6 number or IPv6 bitBlock group
-
- IpTool::isValidIPv6Cidr( cidr )
- Return bool true on valid (int) IP v6 cidr
-
- IpTool::isIPv6InRange( ipNum , array acceptRanges [, & matchIx ] )
- Return bool true if (valid) IP number match any element in array of IP/network ranges
- ipNum string
- on found, (int) matchIx holds the filter range array index
-
- IPv6 network filter ranges can be specified as:
example | type
|
'*' | Accept all IPs // warning, accepts all
|
'<IPv6num>' | Specific Ipv6
|
'<IPv6num>/82' | Ipv6 with cidr
|
'<IPv6num>-<IPv6num>' | Start-End Ipv6 range, note, '-' as separator
|
-
- NOTE, a search for match is done array order !!