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


PHP NetworkPort::splitInputForElements方法代码示例

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


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

示例1: prepareDB

 /**
  * @test
  */
 public function prepareDB()
 {
     global $DB;
     $DB->connect();
     $entity = new Entity();
     $computer = new Computer();
     $pfAgent = new PluginFusioninventoryAgent();
     $pfTask = new PluginFusioninventoryTask();
     $pfTaskjob = new PluginFusioninventoryTaskjob();
     $pfIPRange = new PluginFusioninventoryIPRange();
     $networkEquipment = new NetworkEquipment();
     $networkPort = new NetworkPort();
     $printer = new Printer();
     $pfNetworkEquipment = new PluginFusioninventoryNetworkEquipment();
     // Create entities
     $_SESSION['glpiactive_entity'] = 0;
     $DB->query("INSERT INTO `glpi_entities`\n         (`id`, `name`, `entities_id`, `completename`, `level`)\n         VALUES (1, 'ent1', 0, 'Entité racine > ent1', 2)");
     $DB->query("INSERT INTO `glpi_entities`\n         (`id`, `name`, `entities_id`, `completename`, `level`)\n         VALUES (2, 'ent2', 0, 'Entité racine > ent2', 2)");
     $DB->query("INSERT INTO `glpi_entities`\n         (`id`, `name`, `entities_id`, `completename`, `level`)\n         VALUES (3, 'ent1.1', 1, 'Entité racine > ent1 > ent1.1', 3)");
     // Create computers + agents
     $input = array('entities_id' => 0, 'name' => 'computer1');
     $computers_id = $computer->add($input);
     $input = array('entities_id' => 0, 'name' => 'computer1', 'version' => '{"INVENTORY":"v2.3.11"}', 'device_id' => 'computer1', 'useragent' => 'FusionInventory-Agent_v2.3.11', 'computers_id' => $computers_id);
     $pfAgent->add($input);
     // Create Network Equipments
     $input = array('name' => 'sw0', 'entities_id' => 0);
     $networkEquipment->add($input);
     $input = array('entities_id' => 0, 'name' => 'management', 'items_id' => 1, 'itemtype' => 'NetworkEquipment', 'instantiation_type' => 'NetworkPortAggregate', 'NetworkName__ipaddresses' => array('-1' => '10.0.0.10'));
     $networkPort->splitInputForElements($input);
     $networkPort->add($input);
     $networkPort->updateDependencies(1);
     $input = array('networkequipments_id' => 1, 'plugin_fusioninventory_configsecurities_id' => 2);
     $pfNetworkEquipment->add($input);
     $input = array('name' => 'sw1', 'entities_id' => 1);
     $networkEquipment->add($input);
     $input = array('entities_id' => 1, 'name' => 'management', 'items_id' => 2, 'itemtype' => 'NetworkEquipment', 'instantiation_type' => 'NetworkPortAggregate', 'NetworkName__ipaddresses' => array('-1' => '10.0.0.11'));
     $networkPort->splitInputForElements($input);
     $networkPort->add($input);
     $networkPort->updateDependencies(1);
     $input = array('networkequipments_id' => 2, 'plugin_fusioninventory_configsecurities_id' => 2);
     $pfNetworkEquipment->add($input);
     $input = array('name' => 'sw2', 'entities_id' => 2);
     $networkEquipment->add($input);
     $input = array('entities_id' => 2, 'name' => 'management', 'items_id' => 3, 'itemtype' => 'NetworkEquipment', 'instantiation_type' => 'NetworkPortAggregate', 'NetworkName__ipaddresses' => array('-1' => '10.0.0.12'));
     $networkPort->splitInputForElements($input);
     $networkPort->add($input);
     $networkPort->updateDependencies(1);
     $input = array('networkequipments_id' => 3, 'plugin_fusioninventory_configsecurities_id' => 2);
     $pfNetworkEquipment->add($input);
     $input = array('name' => 'sw3/1.1', 'entities_id' => 3);
     $networkEquipment->add($input);
     $input = array('entities_id' => 3, 'name' => 'management', 'items_id' => 4, 'itemtype' => 'NetworkEquipment', 'instantiation_type' => 'NetworkPortAggregate', 'NetworkName__ipaddresses' => array('-1' => '10.0.0.21'));
     $networkPort->splitInputForElements($input);
     $networkPort->add($input);
     $networkPort->updateDependencies(1);
     $input = array('networkequipments_id' => 4, 'plugin_fusioninventory_configsecurities_id' => 2);
     $pfNetworkEquipment->add($input);
     // Create Printers
     // Add IPRange
     $input = array('entities_id' => 1, 'name' => 'Office', 'ip_start' => '10.0.0.1', 'ip_end' => '10.0.0.254');
     $ipranges_id = $pfIPRange->add($input);
     // Allow all agents to do network discovery
     $query = "UPDATE `glpi_plugin_fusioninventory_agentmodules` " . " SET `is_active`='1' " . " WHERE `modulename`='NETWORKINVENTORY'";
     $DB->query($query);
     // create task
     $input = array('entities_id' => 0, 'name' => 'network inventory', 'is_active' => 1);
     $tasks_id = $pfTask->add($input);
     // create taskjob
     $input = array('plugin_fusioninventory_tasks_id' => $tasks_id, 'entities_id' => 0, 'name' => 'inventory', 'method' => 'networkinventory', 'targets' => '[{"PluginFusioninventoryIPRange":"' . $ipranges_id . '"}]', 'actors' => '[{"PluginFusioninventoryAgent":"1"}]');
     $pfTaskjob->add($input);
 }
开发者ID:C-Duv,项目名称:fusioninventory-for-glpi,代码行数:74,代码来源:NetworkInventoryTest.php

示例2: addNetworkEthernetPort

/**  Generate bigdump : Create networkport ethernet
 *
 * @since version 0.84
 *
 * @param $itemtype        item type
 * @param $items_id        item ID
 * @param $entities_id     item entity ID
 * @param $locations_id    ID of the location trying to link with network equipment (default 0)
**/
function addNetworkEthernetPort($itemtype, $items_id, $entities_id, $locations_id=0) {
   global $NET_LOC, $NET_PORT, $MAX, $VLAN_LOC;

   // Add networking ports
   $newIP   = getNextIP();
   $newMAC  = getNextMAC();

   if (($itemtype == 'NetworkEquipment') && $locations_id) {
      // Find father locations_id;
      $loc = new Location();
      if ($loc->getFromDB($locations_id)) {
         $locations_id = $loc->getField('locations_id');
      } else {
         $locations_id = 0;
      }
   }

   //insert netpoint
   $netpoint   = new NetPoint();
   $netpointID = $netpoint->add(toolbox::addslashes_deep(
                                array('entities_id'  => $entities_id,
                                      'locations_id' => $locations_id,
                                      'name'         => getNextNETPOINT(),
                                      'comment'      => "comment 'netpoint $locations_id")));

   if ($locations_id && !isset($VLAN_LOC[$locations_id])) {
      $vlanID                  = mt_rand(1,$MAX["vlan"]);
      $VLAN_LOC[$locations_id] = $vlanID;
   }
   if (!isset($NET_PORT[$itemtype][$items_id])) {
      $NET_PORT[$itemtype][$items_id]=0;
   }
   $np          = new NetworkPort();
   $nv          = new NetworkPort_Vlan();
   $newportname = "port of $itemtype-$items_id";
   $refportID   = 0;

   if ($locations_id && isset($NET_LOC[$locations_id]) && $NET_LOC[$locations_id]) {
      $refportname  = "link 'port to  $itemtype-$items_id";
      $newportname .= " link to 'NetworkEquipment' -".$NET_LOC[$locations_id];
      $newMAC2      = getNextMAC();
      $newIP2      = getNextIP();

      // Create new port on ref item
      $param = toolbox::addslashes_deep(
               array('itemtype'                 => 'NetworkEquipment',
                     'items_id'                 => $NET_LOC[$locations_id],
                     'entities_id'              => $entities_id,
                     'logical_number'  => $NET_PORT['NetworkEquipment'][$NET_LOC[$locations_id]]++,
                     'name'                     => "name '$refportname",
                     'instantiation_type'       => 'NetworkPortEthernet',
                     'mac'                      => $newMAC2,
                     'comment'                  => "comment '$refportname",
                     'netpoints_id'             => $netpointID,
                     'NetworkName_name'         => "NetworkEquipment$itemtype-$items_id-$entities_id",
                     'NetworkName__ipaddresses' => array(-100 => $newIP2['ip']),
                     ));

                     $np->splitInputForElements($param);
      $refportID = $np->add($param);
      $np->updateDependencies(1);
      if (isset($VLAN_LOC[$locations_id]) && $refportID) {
         $nv->add(array('networkports_id' => $refportID,
                        'vlans_id'        => $VLAN_LOC[$locations_id]));
      }
   }

//    $query = "INSERT INTO `glpi_networkports`
//                VALUES (NULL, '$netwID', 'NetworkEquipment', '$ID_entity', '0',
//                      '".$NET_PORT['NetworkEquipment'][$netwID]++."',
//                      'link port to netw ".$NET_LOC[$data['locations_id']]."',
//                      '".$newIP['ip']."', '$newMAC', '$iface', '$netpointID',
//                      '".$newIP['netwmask']."', '".$newIP['gateway']."',
//                      '".$newIP['subnet']."','comment')";
//    $DB->query($query) or die("PB REQUETE ".$query);

   $param = toolbox::addslashes_deep(
            array('itemtype'                 => $itemtype,
                  'items_id'                 => $items_id,
                  'entities_id'              => $entities_id,
                  'logical_number'           => $NET_PORT[$itemtype][$items_id]++,
                  'name'                     => "name '$newportname",
                  'instantiation_type'       => 'NetworkPortEthernet',
                  'mac'                      => $newMAC,
                  'comment'                  => "comment '$newportname",
                  'netpoints_id'             => $netpointID,
                  'NetworkName_name'         => "$itemtype-$items_id-$entities_id",
                  'NetworkName__ipaddresses' => array(-100 => $newIP['ip']),
                  ));

                  $np->splitInputForElements($param);
//.........这里部分代码省略.........
开发者ID:KaneoGmbH,项目名称:glpi,代码行数:101,代码来源:generate_bigdump.function.php

示例3: unset

$nn = new NetworkPort_NetworkPort();
$npv = new NetworkPort_Vlan();
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
if (isset($_POST["add"])) {
    // Is a preselected mac adress selected ?
    if (isset($_POST['pre_mac'])) {
        if (!empty($_POST['pre_mac'])) {
            $_POST['mac'] = $_POST['pre_mac'];
        }
        unset($_POST['pre_mac']);
    }
    if (!isset($_POST["several"])) {
        $np->check(-1, 'w', $_POST);
        $np->splitInputForElements($_POST);
        $newID = $np->add($_POST);
        $np->updateDependencies(1);
        Event::log($newID, "networkport", 5, "inventory", sprintf(__('%s adds an item'), $_SESSION["glpiname"]));
        Html::back();
    } else {
        Session::checkRight("networking", "w");
        $input = $_POST;
        unset($input['several']);
        unset($input['from_logical_number']);
        unset($input['to_logical_number']);
        for ($i = $_POST["from_logical_number"]; $i <= $_POST["to_logical_number"]; $i++) {
            $add = "";
            if ($i < 10) {
                $add = "0";
            }
开发者ID:geldarr,项目名称:hack-space,代码行数:31,代码来源:networkport.form.php


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