本文整理汇总了PHP中IPAddress::getTable方法的典型用法代码示例。如果您正苦于以下问题:PHP IPAddress::getTable方法的具体用法?PHP IPAddress::getTable怎么用?PHP IPAddress::getTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPAddress
的用法示例。
在下文中一共展示了IPAddress::getTable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createNetworkNameFromItem
/**
* @param $itemtype
* @param $items_id
* @param $main_items_id
* @param $main_itemtype
* @param $entities_id
* @param $IP
**/
function createNetworkNameFromItem($itemtype, $items_id, $main_items_id, $main_itemtype, $entities_id, $IP)
{
global $migration;
// Using gethostbyaddr() allows us to define its reald internet name according to its IP.
// But each gethostbyaddr() may reach several milliseconds. With very large number of
// Networkports or NetworkeEquipment, the migration may take several minutes or hours ...
//$computerName = gethostbyaddr($IP);
$computerName = $IP;
if ($computerName != $IP) {
$position = strpos($computerName, ".");
$name = substr($computerName, 0, $position);
$domain = substr($computerName, $position + 1);
$query = "SELECT `id`\n FROM `glpi_fqdns`\n WHERE `fqdn` = '{$domain}'";
$result = $DB->query($query);
if ($DB->numrows($result) == 1) {
$data = $DB->fetch_assoc($result);
$domainID = $data['id'];
}
} else {
$name = "migration-" . str_replace('.', '-', $computerName);
$domainID = 0;
}
$IPaddress = new IPAddress();
if ($IPaddress->setAddressFromString($IP)) {
$input = array('name' => $name, 'fqdns_id' => $domainID, 'entities_id' => $entities_id, 'items_id' => $items_id, 'itemtype' => $itemtype);
$networknames_id = $migration->insertInTable('glpi_networknames', $input);
$input = $IPaddress->setArrayFromAddress(array('entities_id' => $entities_id, 'itemtype' => 'NetworkName', 'items_id' => $networknames_id), "version", "name", "binary");
$migration->insertInTable($IPaddress->getTable(), $input);
} else {
// Don't add the NetworkName if the address is not valid
addNetworkPortMigrationError($items_id, 'invalid_address');
logNetworkPortError('invalid IP address', $items_id, $main_itemtype, $main_items_id, "{$IP}");
}
unset($IPaddress);
}