本文整理汇总了PHP中IPAddress::update方法的典型用法代码示例。如果您正苦于以下问题:PHP IPAddress::update方法的具体用法?PHP IPAddress::update怎么用?PHP IPAddress::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPAddress
的用法示例。
在下文中一共展示了IPAddress::update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: NetworkPort
function _updateNetworkInfo($arrayinventory, $item_type, $id, $instanciation_type, $check_addresses)
{
$NetworkPort = new NetworkPort();
$port = current($NetworkPort->find("`itemtype`='{$item_type}' AND `items_id`='{$id}'" . " AND `instantiation_type`='{$instanciation_type}'", "", 1));
$port_id = 0;
if (isset($port['id'])) {
if (isset($arrayinventory['MAC']) and !empty($arrayinventory['MAC'])) {
$input = array();
$input['id'] = $port['id'];
$input['mac'] = $arrayinventory['MAC'];
$NetworkPort->update($input);
}
$port_id = $port['id'];
} else {
$input = array();
$input['itemtype'] = $item_type;
$input['items_id'] = $id;
$input['instantiation_type'] = $instanciation_type;
$input['name'] = "management";
if (isset($arrayinventory['MAC']) && !empty($arrayinventory['MAC'])) {
$input['mac'] = $arrayinventory['MAC'];
}
$port_id = $NetworkPort->add($input);
}
$NetworkName = new NetworkName();
$name = current($NetworkName->find("`itemtype`='NetworkPort' AND `items_id`='" . $port_id . "'", "", 1));
$name_id = 0;
if (isset($name['id'])) {
$name_id = $name['id'];
} else {
$input = array();
$input['itemtype'] = 'NetworkPort';
$input['items_id'] = $port_id;
$name_id = $NetworkName->add($input);
}
if (isset($arrayinventory['IP'])) {
$IPAddress = new IPAddress();
if ($check_addresses) {
$addresses = $IPAddress->find("`itemtype`='NetworkName'\n AND `items_id`='" . $name_id . "'", '', 1);
} else {
// Case of NetworkEquipment
$a_ips = $IPAddress->find("`itemtype`='NetworkName'\n AND `items_id`='" . $name_id . "'\n AND `name`='" . $arrayinventory['IP'] . "'", '', 1);
if (count($a_ips) > 0) {
$addresses = $a_ips;
} else {
$addresses = array();
}
}
if (count($addresses) == 0) {
$input = array();
$input['itemtype'] = 'NetworkName';
$input['items_id'] = $name_id;
$input['name'] = $arrayinventory['IP'];
$IPAddress->add($input);
} else {
$address = current($addresses);
if ($address['name'] != $arrayinventory['IP']) {
$input = array();
$input['id'] = $address['id'];
$input['name'] = $arrayinventory['IP'];
$IPAddress->update($input);
}
}
}
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:65,代码来源:communicationnetworkdiscovery.class.php
示例2: array
/**
* \brief Update IPAddress database
* Update IPAddress database to remove old IPs and add new ones.
**/
function post_workOnItem()
{
if (isset($this->input['_ipaddresses']) && is_array($this->input['_ipaddresses'])) {
$input = array('itemtype' => 'NetworkName', 'items_id' => $this->getID());
foreach ($this->input['_ipaddresses'] as $id => $ip) {
$ipaddress = new IPAddress();
$input['name'] = $ip;
if ($id < 0) {
if (!empty($ip)) {
$ipaddress->add($input);
}
} else {
if (!empty($ip)) {
$input['id'] = $id;
$ipaddress->update($input);
unset($input['id']);
} else {
$ipaddress->delete(array('id' => $id));
}
}
}
}
}
示例3: IPAddress
function post_updateItem($history = 1)
{
global $DB;
$this->post_workOnItem();
if (count($this->updates)) {
// Update Ticket Tco
if (in_array("itemtype", $this->updates) || in_array("items_id", $this->updates)) {
$ip = new IPAddress();
// Update IPAddress
foreach ($DB->request('glpi_ipaddresses', array('itemtype' => 'NetworkName', 'items_id' => $this->getID())) as $data) {
$ip->update(array('id' => $data['id'], 'itemtype' => 'NetworkName', 'items_id' => $this->getID()));
}
}
}
parent::post_updateItem($history);
}
示例4: IPAddress
/**
* @see CommonDBTM::post_updateItem
*/
function post_updateItem($history = 1)
{
global $DB;
if (count($this->updates)) {
// Update Ticket Tco
if (in_array("itemtype", $this->updates) || in_array("items_id", $this->updates)) {
$ip = new IPAddress();
// Update IPAddress
foreach ($DB->request('glpi_networknames', array('itemtype' => 'NetworkPort', 'items_id' => $this->getID())) as $dataname) {
foreach ($DB->request('glpi_ipaddresses', array('itemtype' => 'NetworkName', 'items_id' => $dataname['id'])) as $data) {
$ip->update(array('id' => $data['id'], 'mainitemtype' => $this->fields['itemtype'], 'mainitems_id' => $this->fields['items_id']));
}
}
}
}
parent::post_updateItem($history);
$this->updateDependencies(!$this->input['_no_history']);
}