本文整理汇总了PHP中Addresses::transform_to_decimal方法的典型用法代码示例。如果您正苦于以下问题:PHP Addresses::transform_to_decimal方法的具体用法?PHP Addresses::transform_to_decimal怎么用?PHP Addresses::transform_to_decimal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Addresses
的用法示例。
在下文中一共展示了Addresses::transform_to_decimal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reformat_IPv4_for_search
/**
* Reformat possible nun-full IPv4 address for search
*
* e.g. 10.10.10 -> 10.10.10.0 - 10.10.10.255
*
* @access public
* @param mixed $address
* @return array high/low decimal address
*/
public function reformat_IPv4_for_search($address)
{
# remove % sign if present
$address = str_replace("%", "", $address);
# we need Addresses class
$Addresses = new Addresses($this->Database);
# if subnet is provided we have all data
if (strpos($address, "/") > 0) {
# Initialize PEAR NET object
$this->initialize_pear_net_IPv4();
$net = $this->Net_IPv4->parseAddress($ip);
$result['low'] = $Addresses->transform_to_decimal($net->network);
$result['high'] = $Addresses->transform_to_decimal($net->broadcast);
} else {
# if subnet is not provided maye wildcard is, so explode it to array
$address = array_filter(explode(".", $address));
# 4 pieces is ok, host
if (sizeof($address) == 4) {
$result['low'] = $result['high'] = $Addresses->transform_to_decimal(implode(".", $address));
} elseif (sizeof($address) == 3) {
$result['low'] = $Addresses->transform_to_decimal(implode(".", array_merge($address, array(0))));
$result['high'] = $Addresses->transform_to_decimal(implode(".", array_merge($address, array(255))));
} elseif (sizeof($address) == 2) {
$result['low'] = $Addresses->transform_to_decimal(implode(".", array_merge($address, array(0, 0))));
$result['high'] = $Addresses->transform_to_decimal(implode(".", array_merge($address, array(255, 255))));
} elseif (sizeof($address) == 1) {
$result['low'] = $Addresses->transform_to_decimal(implode(".", array_merge($address, array(0, 0, 0))));
$result['high'] = $Addresses->transform_to_decimal(implode(".", array_merge($address, array(255, 255, 255))));
} else {
$result['low'] = implode(".", $address);
$result['high'] = implode(".", $address);
}
}
# return result array low/high
return $result;
}