本文整理汇总了PHP中IPAddress::is_valid方法的典型用法代码示例。如果您正苦于以下问题:PHP IPAddress::is_valid方法的具体用法?PHP IPAddress::is_valid怎么用?PHP IPAddress::is_valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPAddress
的用法示例。
在下文中一共展示了IPAddress::is_valid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: computerInventoryTransformation
static function computerInventoryTransformation($array)
{
global $DB, $PF_ESXINVENTORY, $CFG_GLPI;
// Initialize
$a_inventory = array('Computer' => array(), 'fusioninventorycomputer' => array(), 'processor' => array(), 'memory' => array(), 'harddrive' => array(), 'drive' => array(), 'graphiccard' => array(), 'networkcard' => array(), 'soundcard' => array(), 'controller' => array(), 'SOFTWARES' => array(), 'virtualmachine' => array(), 'computerdisk' => array(), 'networkport' => array(), 'antivirus' => array(), 'licenseinfo' => array(), 'batteries' => array(), 'monitor' => array(), 'printer' => array(), 'peripheral' => array(), 'storage' => array());
$thisc = new self();
$pfConfig = new PluginFusioninventoryConfig();
$ignorecontrollers = array();
if (isset($array['ACCOUNTINFO'])) {
$a_inventory['ACCOUNTINFO'] = $array['ACCOUNTINFO'];
}
// * HARDWARE
$array_tmp = $thisc->addValues($array['HARDWARE'], array('NAME' => 'name', 'OSNAME' => 'operatingsystems_id', 'OSVERSION' => 'operatingsystemversions_id', 'WINPRODID' => 'os_licenseid', 'WINPRODKEY' => 'os_license_number', 'WORKGROUP' => 'domains_id', 'UUID' => 'uuid', 'LASTLOGGEDUSER' => 'users_id', 'operatingsystemservicepacks_id' => 'operatingsystemservicepacks_id', 'manufacturers_id' => 'manufacturers_id', 'computermodels_id' => 'computermodels_id', 'serial' => 'serial', 'computertypes_id' => 'computertypes_id'));
if ($array_tmp['operatingsystemservicepacks_id'] == '' && isset($array['HARDWARE']['OSCOMMENTS']) && $array['HARDWARE']['OSCOMMENTS'] != '') {
$array_tmp['operatingsystemservicepacks_id'] = $array['HARDWARE']['OSCOMMENTS'];
}
if (isset($array_tmp['users_id'])) {
if ($array_tmp['users_id'] == '') {
unset($array_tmp['users_id']);
} else {
$array_tmp['contact'] = $array_tmp['users_id'];
$tmp_users_id = $array_tmp['users_id'];
$split_user = explode("@", $tmp_users_id);
$query = "SELECT `id`\n FROM `glpi_users`\n WHERE `name` = '" . $split_user[0] . "'\n LIMIT 1";
$result = $DB->query($query);
if ($DB->numrows($result) == 1) {
$array_tmp['users_id'] = $DB->result($result, 0, 0);
} else {
$array_tmp['users_id'] = 0;
}
}
}
$array_tmp['is_dynamic'] = 1;
$a_inventory['Computer'] = $array_tmp;
$array_tmp = $thisc->addValues($array['HARDWARE'], array('OSINSTALLDATE' => 'operatingsystem_installationdate', 'WINOWNER' => 'winowner', 'WINCOMPANY' => 'wincompany'));
$array_tmp['last_fusioninventory_update'] = date('Y-m-d H:i:s');
// * Determine "Public contact address"
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
// Try "X-Forwarded-For" HTTP header
// Parse "X-Forwarded-For" header (can contain multiple IP addresses, client should be first)
$forwarded_for_ip_tmp = explode(', ', $_SERVER['HTTP_X_FORWARDED_FOR']);
$forwarded_for_ip_tmp = new IPAddress($forwarded_for_ip_tmp[0]);
if ($forwarded_for_ip_tmp->is_valid()) {
$array_tmp['remote_addr'] = $forwarded_for_ip_tmp->getTextual();
}
} elseif (isset($_SERVER['HTTP_X_REAL_IP'])) {
// Then try "X-Real-IP" HTTP header
$real_ip_tmp = new IPAddress($_SERVER['HTTP_X_REAL_IP']);
if ($real_ip_tmp->is_valid()) {
$array_tmp['remote_addr'] = $real_ip_tmp->getTextual();
}
} elseif (isset($_SERVER['REMOTE_ADDR'])) {
// Fall back on the currently connected IP
$array_tmp['remote_addr'] = $_SERVER['REMOTE_ADDR'];
}
$a_inventory['fusioninventorycomputer'] = $array_tmp;
if (isset($array['OPERATINGSYSTEM']['INSTALL_DATE']) && !empty($array['OPERATINGSYSTEM']['INSTALL_DATE'])) {
$a_inventory['fusioninventorycomputer']['operatingsystem_installationdate'] = $array['OPERATINGSYSTEM']['INSTALL_DATE'];
}
if (isset($array['HARDWARE']['DESCRIPTION'])) {
$a_inventory['fusioninventorycomputer']['oscomment'] = $array['HARDWARE']['DESCRIPTION'];
}
if (empty($a_inventory['fusioninventorycomputer']['operatingsystem_installationdate'])) {
$a_inventory['fusioninventorycomputer']['operatingsystem_installationdate'] = "NULL";
}
// * BIOS
if (isset($array['BIOS'])) {
if (isset($array['BIOS']['ASSETTAG'])) {
$a_inventory['fusioninventorycomputer']['bios_assettag'] = $array['BIOS']['ASSETTAG'];
}
if (isset($array['BIOS']['SMANUFACTURER']) and !empty($array['BIOS']['SMANUFACTURER'])) {
$a_inventory['Computer']['manufacturers_id'] = $array['BIOS']['SMANUFACTURER'];
} else {
if (isset($array['BIOS']['MMANUFACTURER']) and !empty($array['BIOS']['MMANUFACTURER'])) {
$a_inventory['Computer']['manufacturers_id'] = $array['BIOS']['MMANUFACTURER'];
} else {
if (isset($array['BIOS']['BMANUFACTURER']) and !empty($array['BIOS']['BMANUFACTURER'])) {
$a_inventory['Computer']['manufacturers_id'] = $array['BIOS']['BMANUFACTURER'];
} else {
if (isset($array['BIOS']['MMANUFACTURER']) and !empty($array['BIOS']['MMANUFACTURER'])) {
$a_inventory['Computer']['manufacturers_id'] = $array['BIOS']['MMANUFACTURER'];
} else {
if (isset($array['BIOS']['BMANUFACTURER']) and !empty($array['BIOS']['BMANUFACTURER'])) {
$a_inventory['Computer']['manufacturers_id'] = $array['BIOS']['BMANUFACTURER'];
}
}
}
}
}
if (isset($array['BIOS']['MMANUFACTURER']) and !empty($array['BIOS']['MMANUFACTURER'])) {
$a_inventory['Computer']['mmanufacturer'] = $array['BIOS']['MMANUFACTURER'];
}
if (isset($array['BIOS']['BMANUFACTURER']) and !empty($array['BIOS']['BMANUFACTURER'])) {
$a_inventory['Computer']['bmanufacturer'] = $array['BIOS']['BMANUFACTURER'];
}
if (isset($array['BIOS']['SMODEL']) and $array['BIOS']['SMODEL'] != '') {
$a_inventory['Computer']['computermodels_id'] = $array['BIOS']['SMODEL'];
} else {
if (isset($array['BIOS']['MMODEL']) and $array['BIOS']['MMODEL'] != '') {
$a_inventory['Computer']['computermodels_id'] = $array['BIOS']['MMODEL'];
//.........这里部分代码省略.........