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


PHP IPAddress::find方法代码示例

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


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

示例1: pluginFusioninventoryUpdate


//.........这里部分代码省略.........
    $a_table['name'] = 'glpi_plugin_fusioninventory_inventorycomputercomputers';
    $a_table['oldname'] = array('glpi_plugin_fusinvinventory_computers');
    $a_table['fields'] = array();
    $a_table['fields']['id'] = array('type' => 'autoincrement', 'value' => '');
    $a_table['fields']['computers_id'] = array('type' => 'integer', 'value' => NULL);
    $a_table['fields']['bios_date'] = array('type' => 'datetime', 'value' => NULL);
    $a_table['fields']['bios_version'] = array('type' => 'string', 'value' => NULL);
    $a_table['fields']['bios_assettag'] = array('type' => 'string', 'value' => NULL);
    $a_table['fields']['bios_manufacturers_id'] = array('type' => 'integer', 'value' => NULL);
    $a_table['fields']['operatingsystem_installationdate'] = array('type' => 'datetime', 'value' => NULL);
    $a_table['fields']['winowner'] = array('type' => 'string', 'value' => NULL);
    $a_table['fields']['wincompany'] = array('type' => 'string', 'value' => NULL);
    $a_table['fields']['last_fusioninventory_update'] = array('type' => 'datetime', 'value' => NULL);
    $a_table['fields']['remote_addr'] = array('type' => 'string', 'value' => NULL);
    $a_table['fields']['plugin_fusioninventory_computerarchs_id'] = array('type' => 'integer', 'value' => NULL);
    $a_table['fields']['serialized_inventory'] = array('type' => 'longblob', 'value' => "");
    $a_table['fields']['is_entitylocked'] = array('type' => 'bool', 'value' => "0");
    $a_table['fields']['oscomment'] = array('type' => 'text', 'value' => NULL);
    $a_table['oldfields'] = array();
    $a_table['renamefields'] = array();
    $a_table['keys'] = array();
    $a_table['keys'][] = array('field' => 'computers_id', 'name' => '', 'type' => 'INDEX');
    $a_table['keys'][] = array('field' => 'last_fusioninventory_update', 'name' => '', 'type' => 'INDEX');
    $a_table['oldkeys'] = array();
    migrateTablesFusionInventory($migration, $a_table);
    // Migrate libserialization
    require_once GLPI_ROOT . "/plugins/fusioninventory/inc/inventorycomputercomputer.class.php";
    $pfInventoryComputerComputer = new PluginFusioninventoryInventoryComputerComputer();
    if (TableExists('glpi_plugin_fusinvinventory_libserialization')) {
        $query = "SELECT * FROM `glpi_plugin_fusinvinventory_libserialization`";
        $result = $DB->query($query);
        while ($data = $DB->fetch_array($result)) {
            $a_pfcomputer = array();
            $a_pfcomputer = current($pfInventoryComputerComputer->find("`computers_id`='" . $data['computers_id'] . "'", "", 1));
            if (empty($a_pfcomputer)) {
                // Add
                if (countElementsInTable("glpi_computers", "`id`='" . $data['computers_id'] . "'") > 0) {
                    $input = array();
                    $input['computers_id'] = $data['computers_id'];
                    $input['last_fusioninventory_update'] = $data['last_fusioninventory_update'];
                    $pfInventoryComputerComputer->add($input);
                }
            } else {
                // Update
                $a_pfcomputer['last_fusioninventory_update'] = $data['last_fusioninventory_update'];
                $pfInventoryComputerComputer->update($a_pfcomputer);
            }
        }
    }
    $migration->dropTable('glpi_plugin_fusinvinventory_libserialization');
    /*
     * Table glpi_plugin_fusioninventory_inventorycomputerstats
     */
    if (!TableExists("glpi_plugin_fusioninventory_inventorycomputerstats")) {
        $a_table = array();
        $a_table['name'] = 'glpi_plugin_fusioninventory_inventorycomputerstats';
        $a_table['oldname'] = array();
        $a_table['fields'] = array();
        $a_table['fields']['id'] = array('type' => "smallint(3) NOT NULL AUTO_INCREMENT", 'value' => '');
        $a_table['fields']['day'] = array('type' => "smallint(3) NOT NULL DEFAULT '0'", 'value' => '');
        $a_table['fields']['hour'] = array('type' => "tinyint(2) NOT NULL DEFAULT '0'", 'value' => '');
        $a_table['fields']['counter'] = array('type' => 'integer', 'value' => NULL);
        $a_table['oldfields'] = array();
        $a_table['renamefields'] = array();
        $a_table['keys'] = array();
        $a_table['oldkeys'] = array();
开发者ID:C-Duv,项目名称:fusioninventory-for-glpi,代码行数:67,代码来源:update.php

示例2: getIPforDevice

 static function getIPforDevice($itemtype, $items_id)
 {
     $NetworkPort = new NetworkPort();
     $networkName = new NetworkName();
     $iPAddress = new IPAddress();
     $a_ips = array();
     $a_ports = $NetworkPort->find("`itemtype`='" . $itemtype . "'\n                                       AND `items_id`='" . $items_id . "'\n                                          AND `instantiation_type` != 'NetworkPortLocal'");
     foreach ($a_ports as $a_port) {
         $a_networknames = $networkName->find("`itemtype`='NetworkPort'\n                                              AND `items_id`='" . $a_port['id'] . "'");
         foreach ($a_networknames as $a_networkname) {
             $a_ipaddresses = $iPAddress->find("`itemtype`='NetworkName'\n                                              AND `items_id`='" . $a_networkname['id'] . "'");
             foreach ($a_ipaddresses as $data) {
                 if ($data['name'] != '127.0.0.1' && $data['name'] != '::1') {
                     $a_ips[$data['name']] = $data['name'];
                 }
             }
         }
     }
     return array_unique($a_ips);
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:20,代码来源:toolbox.class.php

示例3: 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

示例4: updatePrinterFromNetdiscovery

 /**
  * @test
  */
 public function updatePrinterFromNetdiscovery()
 {
     global $DB;
     $DB->connect();
     $pfCNetworkDiscovery = new PluginFusioninventoryCommunicationNetworkDiscovery();
     $GLPIlog = new GLPIlogs();
     $networkName = new NetworkName();
     $iPAddress = new IPAddress();
     $_SESSION['SOURCE_XMLDEVICE'] = array('AUTHSNMP' => '1', 'DESCRIPTION' => 'Photosmart D7200 series', 'ENTITY' => '0', 'FIRMWARE' => '', 'IP' => '192.168.20.102', 'MAC' => '00:21:5a:0b:bb:c4', 'MANUFACTURER' => 'Hewlett-Packard', 'MODEL' => '', 'MODELSNMP' => 'Printer0093', 'NETBIOSNAME' => 'HP00215A0BBBC4', 'SERIAL' => 'MY89AQG0V9050N', 'SNMPHOSTNAME' => 'HP0BBBC4new', 'TYPE' => 'PRINTER');
     $printer = new Printer();
     $a_printers = $printer->find("`serial`='MY89AQG0V9050N'");
     $a_printer = current($a_printers);
     $printers_id = $a_printer['id'];
     $printer->getFromDB($printers_id);
     $pfCNetworkDiscovery->importDevice($printer);
     $GLPIlog->testSQLlogs();
     $GLPIlog->testPHPlogs();
     $printer->getFromDB($printers_id);
     $this->assertEquals('HP0BBBC4new', $printer->fields['name'], 'Name must be updated');
     $a_printerextends = getAllDatasFromTable('glpi_plugin_fusioninventory_printers', "`printers_id`='" . $printers_id . "'");
     $this->assertEquals('1', count($a_printerextends), 'May have one printer extend line for this printer');
     $a_printerextend = current($a_printerextends);
     $this->assertEquals('1', $a_printerextend['plugin_fusioninventory_configsecurities_id'], 'SNMPauth may be with id 1');
     $this->assertEquals('Photosmart D7200 series', $a_printerextend['sysdescr'], 'Sysdescr not updated correctly');
     // Check mac
     $networkPort = new NetworkPort();
     $a_ports = $networkPort->find("`itemtype`='Printer' AND `items_id`='" . $printers_id . "'");
     $this->assertEquals('1', count($a_ports), 'May have one network port');
     $a_port = current($a_ports);
     $this->assertEquals('00:21:5a:0b:bb:c4', $a_port['mac'], 'Mac address');
     // check ip
     $a_networknames = $networkName->find("`itemtype`='NetworkPort'\n         AND `items_id`='" . $a_port['id'] . "'");
     $this->assertEquals('1', count($a_networknames), 'May have one networkname');
     $a_networkname = current($a_networknames);
     $a_ipaddresses = $iPAddress->find("`itemtype`='NetworkName'\n         AND `items_id`='" . $a_networkname['id'] . "'");
     $this->assertEquals('1', count($a_ipaddresses), 'May have one IP address');
     $a_ipaddress = current($a_ipaddresses);
     $this->assertEquals('192.168.20.102', $a_ipaddress['name'], 'IP address');
 }
开发者ID:C-Duv,项目名称:fusioninventory-for-glpi,代码行数:42,代码来源:PrinterUpdateTest.php

示例5: getIp

 static function getIp($items_id, $itemtype, $hostname)
 {
     global $DB;
     $networkPort = new NetworkPort();
     $networkName = new NetworkName();
     $iPAddress = new IPAddress();
     $pmHostaddress = new PluginMonitoringHostaddress();
     $ip = '';
     $networkports_id = 0;
     $query = "SELECT * FROM `" . $pmHostaddress->getTable() . "`\n      WHERE `items_id`='" . $items_id . "'\n         AND `itemtype`='" . $itemtype . "'\n      LIMIT 1";
     $result = $DB->query($query);
     if ($DB->numrows($result) == '1') {
         $data = $DB->fetch_assoc($result);
         if ($data['ipaddresses_id'] > 0) {
             $iPAddress->getFromDB($data['ipaddresses_id']);
             return $iPAddress->fields['name'];
         } else {
             $networkports_id = $data['networkports_id'];
         }
     }
     if ($ip == '') {
         if ($networkports_id > 0) {
             $a_listnetwork = $networkPort->find("`id`='" . $networkports_id . "'");
         } else {
             $a_listnetwork = $networkPort->find("`itemtype`='" . $itemtype . "'\n               AND `items_id`='" . $items_id . "'", "`id`");
         }
         foreach ($a_listnetwork as $networkports_id => $datanetwork) {
             $a_networknames_find = current($networkName->find("`items_id`='" . $networkports_id . "'\n                                                               AND `itemtype`='NetworkPort'", "", 1));
             if (isset($a_networknames_find['id'])) {
                 $networknames_id = $a_networknames_find['id'];
                 $a_ips_fromDB = $iPAddress->find("`itemtype`='NetworkName'\n                                                 AND `items_id`='" . $networknames_id . "'");
                 foreach ($a_ips_fromDB as $data) {
                     if ($data['name'] != '' && $data['name'] != '127.0.0.1' && $data['name'] != '::1') {
                         return $data['name'];
                     }
                 }
             }
         }
     }
     return $hostname;
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:41,代码来源:hostaddress.class.php

示例6: NetworkEquipmentInternalPorts

 /**
  * @test
  */
 public function NetworkEquipmentInternalPorts()
 {
     global $DB;
     $DB->connect();
     $networkPort = new NetworkPort();
     $networkName = new NetworkName();
     $iPAddress = new IPAddress();
     $a_networkports = $networkPort->find("`instantiation_type`='NetworkPortAggregate'\n         AND `itemtype`='NetworkEquipment'\n         AND `items_id`='1'\n         AND `logical_number`='0'");
     $this->assertEquals(1, count($a_networkports), 'Number internal ports');
     $a_networkport = current($a_networkports);
     $this->assertEquals('6c:50:4d:39:59:80', $a_networkport['mac']);
     // May have 3 IP
     $a_networkname = current($networkName->find("`items_id`='" . $a_networkport['id'] . "'\n                                                         AND `itemtype`='NetworkPort'", "", 1));
     $a_ips_fromDB = $iPAddress->find("`itemtype`='NetworkName'\n                                     AND `items_id`='" . $a_networkname['id'] . "'", "`name`");
     $a_ips = array();
     foreach ($a_ips_fromDB as $data) {
         $a_ips[] = $data['name'];
     }
     $this->assertEquals(array('192.168.30.67', '192.168.40.67', '192.168.50.67'), $a_ips);
 }
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:23,代码来源:NetworkEquipmentUpdateTest.php

示例7: showNetworkPortDetail


//.........这里部分代码省略.........
                 echo "</td>";
                 break;
             case 10:
                 if ($pfNetworkPort->fields["portduplex"] == 2) {
                     echo "<td background='#cf9b9b' class='tab_bg_1_2'>";
                     echo __('Half', 'fusioninventory');
                     echo '</td>';
                 } else {
                     if ($pfNetworkPort->fields["portduplex"] == 3) {
                         echo '<td>';
                         echo __('Full', 'fusioninventory');
                         echo '</td>';
                     } else {
                         echo "<td></td>";
                     }
                 }
                 break;
             case 11:
                 // ** internal mac
                 echo "<td>" . $networkPort->fields["mac"] . "</td>";
                 break;
             case 13:
                 // ** Mac address and link to device which are connected to this port
                 $opposite_port = $nw->getOppositeContact($data["id"]);
                 if ($opposite_port != "" && $opposite_port != 0) {
                     $networkPortOpposite = new NetworkPort();
                     if ($networkPortOpposite->getFromDB($opposite_port)) {
                         $data_device = $networkPortOpposite->fields;
                         $item = new $data_device["itemtype"]();
                         $item->getFromDB($data_device["items_id"]);
                         $link1 = $item->getLink(1);
                         $link = str_replace($item->getName(0), $data_device["mac"], $item->getLink());
                         // * GetIP
                         $a_networknames = current($networkName->find("`itemtype`='NetworkPort'\n                                          AND `items_id`='" . $item->getID() . "'", "", 1));
                         $a_ipaddresses = current($iPAddress->find("`itemtype`='NetworkName'\n                                          AND `items_id`='" . $a_networknames['id'] . "'", "", 1));
                         $link2 = str_replace($item->getName(0), $a_ipaddresses['name'], $item->getLink());
                         if ($data_device["itemtype"] == 'PluginFusioninventoryUnmanaged') {
                             $icon = $this->getItemtypeIcon($item->fields["item_type"]);
                             if ($item->getField("accepted") == "1") {
                                 echo "<td style='background:#bfec75'\n                                     class='tab_bg_1_2'>" . $icon . $link1;
                             } else {
                                 echo "<td background='#cf9b9b'\n                                     class='tab_bg_1_2'>" . $icon . $link1;
                             }
                             if (!empty($link)) {
                                 echo "<br/>" . $link;
                             }
                             if (!empty($link2)) {
                                 echo "<br/>" . $link2;
                             }
                             if ($item->getField("hub") == "1") {
                                 $this->displayHubConnections($data_device["items_id"], $background_img);
                             }
                             echo "</td>";
                         } else {
                             $icon = $this->getItemtypeIcon($data_device["itemtype"]);
                             echo "<td>" . $icon . $link1;
                             if (!empty($link)) {
                                 echo "<br/>" . $link;
                             }
                             if (!empty($link2)) {
                                 echo "<br/>" . $link2;
                             }
                             if ($data_device["itemtype"] == 'Phone') {
                                 $query_devicephone = "SELECT *\n                                   FROM `glpi_networkports`\n                                   WHERE `itemtype`='Phone'\n                                       AND `items_id`='" . $data_device["items_id"] . "'\n                                       AND `id`!='" . $data_device["id"] . "'\n                                   LIMIT 1";
                                 $result_devicephone = $DB->query($query_devicephone);
                                 if ($DB->numrows($result_devicephone) > 0) {
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:67,代码来源:networkequipment.class.php

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