$iptype

From Scriptwiki
Revision as of 10:55, 5 March 2011 by NaNg (talk | contribs) (Created page with "Returns "ipv4" or "ipv6" if text is is a valid IP address format. $iptype(text) Where ''text'' is the address to check its type. The following properties are available for $ipt...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Returns "ipv4" or "ipv6" if text is is a valid IP address format.

$iptype(text)

Where text is the address to check its type.

The following properties are available for $iptype:

Property Description
compress compresses the address (IPv6)
expand expands the address (IPv6)

Examples

if (!$iptype(%ip)) {
  echo -ag Invalid IP Address!
}
elseif ($iptype(%ip) == ipv4) {
  echo -ag %ip is an IPv4 address
}
elseif ($iptype(%ip) == ipv6) {
  echo -ag %ip is an IPv6 address, compressed: $iptype(%ip).compress ; expanded: $iptype(%ip).expand
}

This echos the IP type if valid.