static function cleanArray($data)
 {
     foreach ($data as $key => $value) {
         //if (is_array($value)) {
         if ((array) $value === $value) {
             if (count($value) == 0) {
                 $value = '';
             } else {
                 $value = PluginFusioninventoryFormatconvert::cleanArray($value);
             }
         } else {
             if (strpos($value, "\\'")) {
                 $value = str_replace("\\'", "'", $value);
             }
             if (preg_match("/[^a-zA-Z0-9 \\-_\\(\\)]+/", $value)) {
                 $value = Toolbox::addslashes_deep($value);
             }
             $value = Toolbox::clean_cross_side_scripting_deep($value);
         }
         $data[$key] = $value;
     }
     return array_change_key_case($data, CASE_UPPER);
 }
 /**
  * Manage a hub (many mac on a port mean you have a hub)
  *
  * @param $pfNetworkport object Informations of the network port (switch port)
  *
  * @return bool
  *
  **/
 function hubNetwork($pfNetworkport, $a_mac)
 {
     $nn = new NetworkPort_NetworkPort();
     $Netport = new NetworkPort();
     // Get port connected on switch port
     $hub_id = 0;
     $ID = $nn->getOppositeContact($pfNetworkport->fields['networkports_id']);
     if ($ID) {
         $Netport->getFromDB($ID);
         if ($Netport->fields["itemtype"] == $this->getType()) {
             $this->getFromDB($Netport->fields["items_id"]);
             if ($this->fields["hub"] == "1") {
                 // It's a hub connected, so will update connections
                 //$this->releaseHub($this->fields['id'], $p_oPort);
                 $hub_id = $this->fields['id'];
             } else {
                 // It's a direct connection, so disconnect and create a hub
                 $this->disconnectDB($ID);
                 $hub_id = $this->createHub($pfNetworkport, $a_mac);
             }
         } else {
             // It's a direct connection, so disconnect and create a hub
             $this->disconnectDB($ID);
             $hub_id = $this->createHub($pfNetworkport, $a_mac);
         }
     } else {
         // No connections found and create a hub
         $hub_id = $this->createHub($pfNetworkport, $a_mac);
     }
     // State : Now we have hub and it's id
     // Add source port id in comment of hub
     $h_input = array();
     $h_input['id'] = $hub_id;
     $h_input['comment'] = "Port : " . $pfNetworkport->fields['networkports_id'];
     $this->update($h_input);
     // Get all ports connected to this hub
     $a_portglpi = array();
     $a_ports = $Netport->find("`items_id`='" . $hub_id . "'\n          AND `itemtype`='" . $this->getType() . "'");
     foreach ($a_ports as $data) {
         $id = $nn->getOppositeContact($data['id']);
         if ($id) {
             $a_portglpi[$id] = $data['id'];
         }
     }
     foreach ($a_mac as $ifmac) {
         $a_ports = $Netport->find("`mac`='" . $ifmac . "'", "", 1);
         if (count($a_ports) == "1") {
             if (!$this->searchIfmacOnHub($a_ports, $a_portglpi)) {
                 // Connect port (port found in GLPI)
                 $this->connectPortToHub($a_ports, $hub_id);
             }
         } else {
             if (count($a_ports) == "0") {
                 // Port don't exist
                 // Create unmanaged device
                 $input = array();
                 $a_manufacturer = array(0 => PluginFusioninventoryInventoryExternalDB::getManufacturerWithMAC($ifmac));
                 $a_manufacturer = PluginFusioninventoryFormatconvert::cleanArray($a_manufacturer);
                 $input['name'] = $a_manufacturer[0];
                 if (isset($_SESSION["plugin_fusioninventory_entity"])) {
                     $input['entities_id'] = $_SESSION["plugin_fusioninventory_entity"];
                 }
                 $unmanageds_id = $this->add($input);
                 $input = array();
                 $input["items_id"] = $unmanageds_id;
                 $input["itemtype"] = $this->getType();
                 $input["mac"] = $ifmac;
                 $input['instantiation_type'] = "NetworkPortEthernet";
                 $id_port = $Netport->add($input);
                 $Netport->getFromDB($id_port);
                 $this->connectPortToHub(array($id_port => $Netport->fields), $hub_id);
             }
         }
     }
 }