当前位置: 首页>>代码示例>>PHP>>正文


PHP IPAddress::delete方法代码示例

本文整理汇总了PHP中IPAddress::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP IPAddress::delete方法的具体用法?PHP IPAddress::delete怎么用?PHP IPAddress::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPAddress的用法示例。


在下文中一共展示了IPAddress::delete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: pluginFusioninventoryUpdate


//.........这里部分代码省略.........
    }
    if (TableExists('glpi_plugin_fusioninventory_configs')) {
        $id = 'id';
        if (FieldExists('glpi_plugin_fusioninventory_configs', 'ID')) {
            $id = 'ID';
        }
        $query = "SELECT *  FROM `glpi_plugin_fusioninventory_configs`\n            WHERE `type`='version'\n            LIMIT 1, 10";
        $result = $DB->query($query);
        while ($data = $DB->fetch_array($result)) {
            $DB->query("DELETE FROM `glpi_plugin_fusioninventory_configs`\n               WHERE `" . $id . "`='" . $data[$id] . "'");
        }
    }
    $a_table = array();
    $a_table['name'] = 'glpi_plugin_fusioninventory_configs';
    $a_table['oldname'] = array('glpi_plugin_tracker_config');
    $a_table['fields'] = array();
    $a_table['fields']['id'] = array('type' => 'autoincrement', 'value' => '');
    $a_table['fields']['type'] = array('type' => 'string', 'value' => NULL);
    $a_table['fields']['value'] = array('type' => 'string', 'value' => NULL);
    $a_table['oldfields'] = array();
    $a_table['oldfields'][] = 'version';
    $a_table['oldfields'][] = 'URL_agent_conf';
    $a_table['oldfields'][] = 'ssl_only';
    $a_table['oldfields'][] = 'authsnmp';
    $a_table['oldfields'][] = 'inventory_frequence';
    $a_table['oldfields'][] = 'criteria1_ip';
    $a_table['oldfields'][] = 'criteria1_name';
    $a_table['oldfields'][] = 'criteria1_serial';
    $a_table['oldfields'][] = 'criteria1_macaddr';
    $a_table['oldfields'][] = 'criteria2_ip';
    $a_table['oldfields'][] = 'criteria2_name';
    $a_table['oldfields'][] = 'criteria2_serial';
    $a_table['oldfields'][] = 'criteria2_macaddr';
    $a_table['oldfields'][] = 'delete_agent_process';
    $a_table['oldfields'][] = 'activation_history';
    $a_table['oldfields'][] = 'activation_connection';
    $a_table['oldfields'][] = 'activation_snmp_computer';
    $a_table['oldfields'][] = 'activation_snmp_networking';
    $a_table['oldfields'][] = 'activation_snmp_peripheral';
    $a_table['oldfields'][] = 'activation_snmp_phone';
    $a_table['oldfields'][] = 'activation_snmp_printer';
    $a_table['oldfields'][] = 'plugins_id';
    $a_table['oldfields'][] = 'module';
    $a_table['renamefields'] = array();
    $a_table['renamefields']['ID'] = 'id';
    $a_table['keys'] = array();
    $a_table['keys'][] = array('field' => array("type"), 'name' => 'unicity', 'type' => 'UNIQUE');
    $a_table['oldkeys'] = array();
    migrateTablesFusionInventory($migration, $a_table);
    /*
     * Table glpi_plugin_fusioninventory_entities
     */
    $a_table = array();
    $a_table['name'] = 'glpi_plugin_fusioninventory_entities';
    $a_table['oldname'] = array();
    $a_table['fields'] = array();
    $a_table['fields']['id'] = array('type' => 'autoincrement', 'value' => '');
    $a_table['fields']['entities_id'] = array('type' => 'integer', 'value' => NULL);
    $a_table['fields']['transfers_id_auto'] = array('type' => 'integer', 'value' => NULL);
    $a_table['fields']['agent_base_url'] = array('type' => 'string', 'value' => '');
    $a_table['oldfields'] = array();
    $a_table['renamefields'] = array();
    $a_table['keys'] = array();
    $a_table['keys'][] = array('field' => array('entities_id', 'transfers_id_auto'), 'name' => 'entities_id', 'type' => 'INDEX');
    $a_table['oldkeys'] = array();
    migrateTablesFusionInventory($migration, $a_table);
开发者ID:C-Duv,项目名称:fusioninventory-for-glpi,代码行数:67,代码来源:update.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));
                 }
             }
         }
     }
 }
开发者ID:kipman,项目名称:glpi,代码行数:27,代码来源:networkname.class.php

示例3: manageNetworkPort

 function manageNetworkPort($inventory_networkports, $computers_id, $no_history)
 {
     global $DB;
     $networkPort = new NetworkPort();
     $networkName = new NetworkName();
     $iPAddress = new IPAddress();
     $iPNetwork = new IPNetwork();
     $networkPortEthernet = new NetworkPortEthernet();
     $item_DeviceNetworkCard = new Item_DeviceNetworkCard();
     foreach ($inventory_networkports as $a_networkport) {
         if ($a_networkport['mac'] != '') {
             $a_networkports = $networkPort->find("`mac`='" . $a_networkport['mac'] . "'\n               AND `itemtype`='PluginFusioninventoryUnmanaged'", "", 1);
             if (count($a_networkports) > 0) {
                 $input = current($a_networkports);
                 $unmanageds_id = $input['items_id'];
                 $input['logical_number'] = $a_networkport['logical_number'];
                 $input['itemtype'] = 'Computer';
                 $input['items_id'] = $computers_id;
                 $input['is_dynamic'] = 1;
                 $input['name'] = $a_networkport['name'];
                 $networkPort->update($input, !$no_history);
                 $pfUnmanaged = new PluginFusioninventoryUnmanaged();
                 $pfUnmanaged->delete(array('id' => $unmanageds_id), 1);
             }
         }
     }
     // end get port from unknwon device
     $db_networkport = array();
     if ($no_history === FALSE) {
         $query = "SELECT `id`, `name`, `mac`, `instantiation_type`, `logical_number`\n             FROM `glpi_networkports`\n             WHERE `items_id` = '{$computers_id}'\n               AND `itemtype`='Computer'\n               AND `is_dynamic`='1'";
         $result = $DB->query($query);
         while ($data = $DB->fetch_assoc($result)) {
             $idtmp = $data['id'];
             unset($data['id']);
             if (is_null($data['mac'])) {
                 $data['mac'] = '';
             }
             if (preg_match("/[^a-zA-Z0-9 \\-_\\(\\)]+/", $data['name'])) {
                 $data['name'] = Toolbox::addslashes_deep($data['name']);
             }
             $db_networkport[$idtmp] = array_map('strtolower', $data);
         }
     }
     $simplenetworkport = array();
     foreach ($inventory_networkports as $key => $a_networkport) {
         // Add ipnetwork if not exist
         if ($a_networkport['gateway'] != '' && $a_networkport['netmask'] != '' && $a_networkport['subnet'] != '') {
             if (countElementsInTable('glpi_ipnetworks', "`address`='" . $a_networkport['subnet'] . "'\n                                     AND `netmask`='" . $a_networkport['netmask'] . "'\n                                     AND `gateway`='" . $a_networkport['gateway'] . "'\n                                     AND `entities_id`='" . $_SESSION["plugin_fusioninventory_entity"] . "'") == 0) {
                 $input_ipanetwork = array('name' => $a_networkport['subnet'] . '/' . $a_networkport['netmask'] . ' - ' . $a_networkport['gateway'], 'network' => $a_networkport['subnet'] . ' / ' . $a_networkport['netmask'], 'gateway' => $a_networkport['gateway'], 'entities_id' => $_SESSION["plugin_fusioninventory_entity"]);
                 $iPNetwork->add($input_ipanetwork, array(), !$no_history);
             }
         }
         // End add ipnetwork
         $a_field = array('name', 'mac', 'instantiation_type');
         foreach ($a_field as $field) {
             if (isset($a_networkport[$field])) {
                 $simplenetworkport[$key][$field] = $a_networkport[$field];
             }
         }
     }
     foreach ($simplenetworkport as $key => $arrays) {
         $arrayslower = array_map('strtolower', $arrays);
         foreach ($db_networkport as $keydb => $arraydb) {
             $logical_number = $arraydb['logical_number'];
             unset($arraydb['logical_number']);
             if ($arrayslower == $arraydb) {
                 if ($inventory_networkports[$key]['logical_number'] != $logical_number) {
                     $input = array();
                     $input['id'] = $keydb;
                     $input['logical_number'] = $inventory_networkports[$key]['logical_number'];
                     $networkPort->update($input, !$no_history);
                 }
                 // Add / update instantiation_type
                 if (isset($inventory_networkports[$key]['instantiation_type'])) {
                     if ($inventory_networkports[$key]['instantiation_type'] == 'NetworkPortEthernet') {
                         $portsethernet = $networkPortEthernet->find("`networkports_id`='" . $keydb . "'", '', 1);
                         if (count($portsethernet) == 1) {
                             $portethernet = current($portsethernet);
                             $input = $portethernet;
                         } else {
                             $input = array('networkports_id' => $keydb);
                         }
                         if (isset($inventory_networkports[$key]['speed'])) {
                             $input['speed'] = $inventory_networkports[$key]['speed'];
                             $input['speed_other_value'] = $inventory_networkports[$key]['speed'];
                         }
                         if (isset($inventory_networkports[$key]['mac'])) {
                             $networkcards = $item_DeviceNetworkCard->find("`mac`='" . $inventory_networkports[$key]['mac'] . "' " . " AND `itemtype`='Computer'" . " AND `items_id`='" . $computers_id . "'", '', 1);
                             if (count($networkcards) == 1) {
                                 $networkcard = current($networkcards);
                                 $input['items_devicenetworkcards_id'] = $networkcard['id'];
                             }
                         }
                         $input['_no_history'] = $no_history;
                         if (isset($input['id'])) {
                             $networkPortEthernet->update($input);
                         } else {
                             $networkPortEthernet->add($input);
                         }
                     }
//.........这里部分代码省略.........
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:101,代码来源:inventorycomputerlib.class.php

示例4: updateNetworkPort

 /**
  * @param $mac
  * @param $name
  * @param $computers_id
  * @param $instantiation_type
  * @param $inst_input
  * @param $ips
  * @param $check_name
  * @param $dohistory
  * @param $already_known_ports
  * @return ID
  */
 private static function updateNetworkPort($mac, $name, $computers_id, $instantiation_type, $inst_input, $ips, $check_name, $dohistory, $already_known_ports)
 {
     global $DB;
     $network_port = new NetworkPort();
     // Then, find or create the base NetworkPort
     $query = "SELECT `id`, `is_dynamic`\n                FROM `glpi_networkports`\n                WHERE `itemtype` = 'Computer'\n                   AND `items_id` = '{$computers_id}'\n                   AND `mac` = '{$mac}'";
     // If there is virtual ports, then, filter by port's name
     if ($check_name) {
         $query .= " AND `name` = '{$name}'";
     }
     if (count($already_known_ports) > 0) {
         $query .= " AND `id` NOT IN (" . implode(',', $already_known_ports) . ")";
     }
     // We order by is_dynamic to be sure to get the static ones first !
     $query .= " ORDER BY `is_dynamic`, `id`";
     $ports = $DB->request($query);
     if ($ports->numrows() == 0) {
         $port_input = array('name' => $name, 'mac' => $mac, 'items_id' => $computers_id, 'itemtype' => 'Computer', '_no_history' => !$dohistory, 'instantiation_type' => $instantiation_type, '_create_children' => 1, 'is_dynamic' => 1, 'is_deleted' => 0);
         $networkports_id = $network_port->add($port_input, array(), $dohistory);
         if ($networkports_id === false) {
             return -1;
         }
         $inst_input['networkports_id'] = $networkports_id;
         $instantiation = $network_port->getInstantiation();
         $instantiation->update($inst_input);
         unset($instantiation);
     } else {
         $line = $ports->next();
         $networkports_id = $line['id'];
         $network_port->getFromDB($networkports_id);
         if (!$check_name && $network_port->fields['name'] != $name) {
             $port_input = array('id' => $network_port->getID(), 'name' => $name, 'is_dynamic' => 1);
             $network_port->update($port_input);
         }
         if ($network_port->fields['instantiation_type'] != $instantiation_type && $network_port->fields['is_dynamic'] == 1) {
             $network_port->switchInstantiationType($instantiation_type);
             $inst_input['networkports_id'] = $network_port->getID();
             $instantiation = $network_port->getInstantiation();
             $instantiation->add($inst_input);
             unset($instantiation);
         }
         if ($network_port->fields['instantiation_type'] == $instantiation_type) {
             $instantiation = $network_port->getInstantiation();
             $inst_input['id'] = $instantiation->getID();
             $inst_input['networkports_id'] = $network_port->getID();
             $instantiation->update($inst_input);
             unset($instantiation);
         }
     }
     if ($network_port->isNewItem()) {
         return -1;
     }
     $network_name = new NetworkName();
     $query = "SELECT `id`, `is_dynamic`\n                FROM `glpi_networknames`\n                WHERE `itemtype` = 'NetworkPort'\n                   AND `items_id` = '{$networkports_id}'\n                ORDER BY `is_dynamic`";
     if (!$ips || count($ips) == 0) {
         foreach ($DB->request($query) as $line) {
             if ($line['is_dynamic']) {
                 $network_name->delete($line, true, $dohistory);
             }
         }
     } else {
         $names = $DB->request($query);
         if ($names->numrows() == 0) {
             $name_input = array('itemtype' => 'NetworkPort', 'items_id' => $networkports_id, 'is_dynamic' => 1, 'is_deleted' => 0, '_no_history' => !$dohistory, 'name' => 'OCS-INVENTORY-NG');
             $networknames_id = $network_name->add($name_input);
         } else {
             $line = $names->next();
             $networknames_id = $line['id'];
             foreach ($names as $line) {
                 if ($line['is_dynamic'] == 1 && $line['id'] != $networknames_id) {
                     $network_port->delete($line, true, $dohistory);
                 }
             }
         }
         $ip_address = new IPAddress();
         $already_known_addresses = array();
         $query = "SELECT `id`, `name`, `is_dynamic`, `mainitems_id`\n                   FROM `glpi_ipaddresses`\n                   WHERE `itemtype` = 'NetworkName'\n                     AND `items_id` = '{$networknames_id}'\n                   ORDER BY `is_dynamic`";
         foreach ($DB->request($query) as $line) {
             if (in_array($line['name'], $ips) && !empty($line['mainitems_id'])) {
                 $already_known_addresses[] = $line['id'];
                 $ips = array_diff($ips, array($line['name']));
             } elseif ($line['is_dynamic'] == 1) {
                 $ip_address->delete($line, true, $dohistory);
             }
         }
     }
     if ($ips) {
         foreach ($ips as $ip) {
//.........这里部分代码省略.........
开发者ID:pluginsGLPI,项目名称:ocsinventoryng,代码行数:101,代码来源:networkport.class.php

示例5: internalPorts

 /**
  * Import IPs
  *
  * @param $p_ips IPs code to import
  * @param $networkequipments_id id of network equipment
  *
  * @return errors string to be alimented if import ko / '' if ok
  **/
 function internalPorts($a_ips, $networkequipments_id, $mac, $networkname_name)
 {
     $networkPort = new NetworkPort();
     $iPAddress = new IPAddress();
     $pfUnmanaged = new PluginFusioninventoryUnmanaged();
     $networkName = new NetworkName();
     // Get agregated ports
     $a_networkPortAggregates = current($networkPort->find("`itemtype`='NetworkEquipment'\n                       AND `items_id`='" . $networkequipments_id . "'\n                       AND `instantiation_type`='NetworkPortAggregate'\n                       AND `logical_number` = '0'", '', 1));
     $a_ips_DB = array();
     $networkports_id = 0;
     if (isset($a_networkPortAggregates['id'])) {
         $a_networkPortAggregates['mac'] = $mac;
         $networkPort->update($a_networkPortAggregates);
         $networkports_id = $a_networkPortAggregates['id'];
     } else {
         $input = array();
         $input['itemtype'] = 'NetworkEquipment';
         $input['items_id'] = $networkequipments_id;
         $input['instantiation_type'] = 'NetworkPortAggregate';
         $input['name'] = 'general';
         $input['mac'] = $mac;
         $networkports_id = $networkPort->add($input);
     }
     // Get networkname
     $a_networknames_find = current($networkName->find("`items_id`='" . $networkports_id . "'\n                                                         AND `itemtype`='NetworkPort'", "", 1));
     $networknames_id = 0;
     if (isset($a_networknames_find['id'])) {
         $networknames_id = $a_networknames_find['id'];
         $a_networknames_find['name'] = $networkname_name;
         $networkName->update($a_networknames_find);
     } else {
         $input = array();
         $input['items_id'] = $networkports_id;
         $input['itemtype'] = 'NetworkPort';
         $input['name'] = $networkname_name;
         $networknames_id = $networkName->add($input);
     }
     $a_ips_fromDB = $iPAddress->find("`itemtype`='NetworkName'\n                                    AND `items_id`='" . $networknames_id . "'");
     foreach ($a_ips_fromDB as $data) {
         $a_ips_DB[$data['id']] = $data['name'];
     }
     foreach ($a_ips as $key => $ip) {
         foreach ($a_ips_DB as $keydb => $ipdb) {
             if ($ip == $ipdb) {
                 unset($a_ips[$key]);
                 unset($a_ips_DB[$keydb]);
                 break;
             }
         }
     }
     if (count($a_ips) == 0 and count($a_ips_DB) == 0) {
         // Nothing to do
     } else {
         if (count($a_ips_DB) != 0 && count($a_ips) != 0) {
             // Delete IPs in DB
             foreach ($a_ips_DB as $idtmp => $ip) {
                 $iPAddress->delete(array('id' => $idtmp));
             }
         }
         if (count($a_ips) != 0) {
             foreach ($a_ips as $ip) {
                 if ($ip != '127.0.0.1') {
                     $input = array();
                     $input['entities_id'] = 0;
                     $input['itemtype'] = 'NetworkName';
                     $input['items_id'] = $networknames_id;
                     $input['name'] = $ip;
                     $iPAddress->add($input);
                     // Search in unmanaged device if device with IP (LLDP) is yet added, in this case,
                     // we get id of this unmanaged device
                     $a_manageds = $pfUnmanaged->find("`ip`='" . $ip . "'", "", 1);
                     if (count($a_manageds) > 0) {
                         $datas = current($a_unmanageds);
                         $this->unmanagedCDP = $datas['id'];
                     }
                 }
             }
         }
     }
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:88,代码来源:inventorynetworkequipmentlib.class.php


注:本文中的IPAddress::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。