glpi电脑,软件数据库分析

查询电脑

参考php文件:glpi-9.1.4\inc\computer.php

glpi电脑,软件数据库分析_第1张图片
电脑表结构关系
        SELECT
            'glpi' AS currentuser,
            `glpi_computers`.`entities_id`,
            `glpi_computers`.`is_recursive`,
            `glpi_computers`.`name` AS `ITEM_0`,
            `glpi_computers`.`id` AS `ITEM_0_id`,
            `glpi_states`.`completename` AS `ITEM_1`,
            `glpi_manufacturers`.`name` AS `ITEM_2`,
            `glpi_computers`.`serial` AS `ITEM_3`,
            `glpi_computertypes`.`name` AS `ITEM_4`,
            `glpi_computermodels`.`name` AS `ITEM_5`,
            `glpi_operatingsystems`.`name` AS `ITEM_6`,
            `glpi_locations`.`completename` AS `ITEM_7`,
            `glpi_computers`.`date_mod` AS `ITEM_8`,
            GROUP_CONCAT(
                DISTINCT CONCAT(
                    IFNULL(
                        `glpi_deviceprocessors_7083fb7d2b7a8b8abd619678acc5b604`.`designation`,
                        '__NULL__'
                    ),
                    '$#$',
                    `glpi_deviceprocessors_7083fb7d2b7a8b8abd619678acc5b604`.`id`
                ) SEPARATOR '$$##$$'
            ) AS `ITEM_9`,
            `glpi_computers`.`id` AS id
        FROM
            `glpi_computers`
        LEFT JOIN `glpi_states` ON (
            `glpi_computers`.`states_id` = `glpi_states`.`id`
        )
        LEFT JOIN `glpi_manufacturers` ON (
            `glpi_computers`.`manufacturers_id` = `glpi_manufacturers`.`id`
        )
        LEFT JOIN `glpi_computertypes` ON (
            `glpi_computers`.`computertypes_id` = `glpi_computertypes`.`id`
        )
        LEFT JOIN `glpi_computermodels` ON (
            `glpi_computers`.`computermodels_id` = `glpi_computermodels`.`id`
        )
        LEFT JOIN `glpi_operatingsystems` ON (
            `glpi_computers`.`operatingsystems_id` = `glpi_operatingsystems`.`id`
        )
        LEFT JOIN `glpi_locations` ON (
            `glpi_computers`.`locations_id` = `glpi_locations`.`id`
        )
        LEFT JOIN `glpi_items_deviceprocessors` ON (
            `glpi_computers`.`id` = `glpi_items_deviceprocessors`.`items_id`
            AND `glpi_items_deviceprocessors`.`itemtype` = 'Computer'
        )
        LEFT JOIN `glpi_deviceprocessors` AS `glpi_deviceprocessors_7083fb7d2b7a8b8abd619678acc5b604` ON (
            `glpi_items_deviceprocessors`.`deviceprocessors_id` = `glpi_deviceprocessors_7083fb7d2b7a8b8abd619678acc5b604`.`id`
        )
        WHERE
            `glpi_computers`.`is_deleted` = '0'
        AND `glpi_computers`.`is_template` = '0'
        GROUP BY
            `glpi_computers`.`id`
        ORDER BY
            ITEM_0 ASC
        LIMIT 0,
         20

查询软件

参考php文件:glpi-9.1.4\inc\computer_softwareversion.class.php

glpi电脑,软件数据库分析_第2张图片
软件表结构关系
    SELECT
        `glpi_softwares`.`softwarecategories_id`,
        `glpi_softwares`.`name` AS softname,
        `glpi_computers_softwareversions`.`id`,
        `glpi_computers_softwareversions`.`is_dynamic`,
        `glpi_states`.`name` AS state,
        `glpi_softwareversions`.`id` AS verid,
        `glpi_softwareversions`.`softwares_id`,
        `glpi_softwareversions`.`name` AS VERSION,
        `glpi_softwares`.`is_valid` AS softvalid,
        `glpi_computers_softwareversions`.`date_install` AS dateinstall
    FROM
        `glpi_computers_softwareversions`
    LEFT JOIN `glpi_softwareversions` ON (
        `glpi_computers_softwareversions`.`softwareversions_id` = `glpi_softwareversions`.`id`
    )
    LEFT JOIN `glpi_states` ON (
        `glpi_states`.`id` = `glpi_softwareversions`.`states_id`
    )
    LEFT JOIN `glpi_softwares` ON (
        `glpi_softwareversions`.`softwares_id` = `glpi_softwares`.`id`
    )
    WHERE
        `glpi_computers_softwareversions`.`computers_id` = '3'
    AND `glpi_computers_softwareversions`.`is_deleted` = '0'
    ORDER BY
        `softname`,
        `version`

查询磁盘信息

glpi电脑,软件数据库分析_第3张图片
磁盘信息表结构
        SELECT
            `glpi_filesystems`.`name` AS fsname,
            `glpi_computerdisks`.*
        FROM
            `glpi_computerdisks`
        LEFT JOIN `glpi_filesystems` ON (
            `glpi_computerdisks`.`filesystems_id` = `glpi_filesystems`.`id`
        )
        WHERE
            `computers_id` = '3'
        AND `is_deleted` = '0'

网络端口

参考php文件:glpi-9.1.4\inc\networkport.class.php

glpi电脑,软件数据库分析_第4张图片
网络端口表结构
        SELECT
            *
        FROM
            `glpi_networkports`
        WHERE
            `items_id` = '3'
        AND `itemtype` = 'Computer'
        AND `instantiation_type` = 'NetworkPortEthernet'
        AND `is_deleted` = '0'
        ORDER BY
            `name`,
            `logical_number`

杀毒软件

参考php文件:glpi-9.1.4\inc\computerantivirus.class.php


glpi电脑,软件数据库分析_第5张图片
杀毒软件表结构
        SELECT
            *
        FROM
            `glpi_computerantiviruses`
        WHERE
            `computers_id` = 3
        AND `is_deleted` = 0

控制器查询

查询所有devicecontrols_id

    SELECT
        *
    FROM
        `glpi_items_devicecontrols`
    WHERE
        `itemtype` = 'Computer'
    AND `items_id` = '3'
    AND `is_deleted` = '0'
    ORDER BY
        devicecontrols_id
glpi电脑,软件数据库分析_第6张图片
查询所有devices id

遍历查询每个 devicecontrols_id 的具体信息

    SELECT
        *
    FROM
        `glpi_devicecontrols`
    WHERE
        `glpi_devicecontrols`.`id` = '3'
    LIMIT 1 
单个control id 对应的control具体信息

查询所有devices control信息

        SELECT
            *
        FROM
            `glpi_devicecontrols`
glpi电脑,软件数据库分析_第7张图片
查询所有control信息

上报数据导入功能流程

  • 接收xml文件

      $pfCommunication = new PluginFusioninventoryCommunication(); 
      if (!isset($rawdata)) {
          $rawdata = file_get_contents("php://input");
      }
      if (isset($_GET['action']) && isset($_GET['machineid'])) {
          PluginFusioninventoryCommunicationRest::handleFusionCommunication();
      } else if (!empty($rawdata)) {
          $pfCommunication->handleOCSCommunication($rawdata);
      }
       session_destroy();
    
  • 解压缩xml文件
    $content_type = filter_input(INPUT_SERVER, "CONTENT_TYPE");
    if (!empty($xml)) {
    $compressmode = 'none';
    } else if ($content_type == "application/x-compress-zlib") {
    $xml = gzuncompress($rawdata);
    $compressmode = "zlib";
    } else if ($content_type == "application/x-compress-gzip") {
    $xml = $pfToolbox->gzdecode($rawdata);
    $compressmode = "gzip";
    } else if ($content_type == "application/xml") {
    $xml = $rawdata;
    $compressmode = 'none';
    }

  • 生成数组
    $_SESSION['plugin_fusioninventory_compressmode'] = $compressmode;
    // Convert XML into PHP array
    $arrayinventory = PluginFusioninventoryFormatconvert::XMLtoArray($pxml);

  • 写入数据库
    $deviceid = '';
    if (isset($arrayinventory['DEVICEID'])) {
    $deviceid = $arrayinventory['DEVICEID'];
    }
    $agent = new PluginFusioninventoryAgent();
    $agents_id = $agent->importToken($arrayinventory);
    $communication->import($arrayinventory)

    function importToken($arrayinventory) {
    
       if (isset($arrayinventory['DEVICEID'])) {
          $pfAgent = new PluginFusioninventoryAgent();
          $a_agent = $pfAgent->find("`device_id`='".$arrayinventory['DEVICEID']."'", "", "1");
          if (empty($a_agent)) {
             $a_input = array();
             if (isset($arrayinventory['TOKEN'])) {
                $a_input['token'] = $arrayinventory['TOKEN'];
             }
             $a_input['name']         = $arrayinventory['DEVICEID'];
             $a_input['device_id']    = $arrayinventory['DEVICEID'];
             $a_input['entities_id']  = 0;
             $a_input['last_contact'] = date("Y-m-d H:i:s");
             $a_input['useragent'] = filter_input(INPUT_SERVER, "HTTP_USER_AGENT");
             $agents_id = $pfAgent->add($a_input);
             if ($agents_id) {
                return $agents_id;
             }
          } else {
             foreach ($a_agent as $data) {
                $input = array();
                $input['id'] = $data['id'];
                if (isset($arrayinventory['TOKEN'])) {
                   $input['token'] = $arrayinventory['TOKEN'];
                }
                $input['last_contact'] = date("Y-m-d H:i:s");
                $input['useragent'] = filter_input(INPUT_SERVER, "HTTP_USER_AGENT");
                $pfAgent->update($input);
                return $data['id'];
             }
          }
       }
       return 0;
    }
    function import($arrayinventory) {
    
       $pfAgent = new PluginFusioninventoryAgent();
    
       PluginFusioninventoryToolbox::logIfExtradebug(
          'pluginFusioninventory-communication',
          'Function import().'
       );
    
       $this->message = $arrayinventory;
       $errors = '';
    
       $xmltag = $this->message['QUERY'];
       if ($xmltag == "NETDISCOVERY") {
          $xmltag = "NETWORKDISCOVERY";
       }
       if ($xmltag == "SNMPQUERY"
               OR $xmltag == "SNMPINVENTORY") {
          $xmltag = "NETWORKINVENTORY";
       }
    
       if (!isset($_SESSION['plugin_fusioninventory_agents_id'])) {
          $agent = $pfAgent->infoByKey($this->message['DEVICEID']);
       } else {
          $agent = array('id' => $_SESSION['plugin_fusioninventory_agents_id']);
       }
       if ($xmltag == "PROLOG") {
          return FALSE;
       }
    
       if (isset($this->message['CONTENT']['MODULEVERSION'])) {
          $pfAgent->setAgentVersions($agent['id'],
                                     $xmltag,
                                     $this->message['CONTENT']['MODULEVERSION']);
       } else if (isset($this->message['CONTENT']['VERSIONCLIENT'])) {
          $version = str_replace("FusionInventory-Agent_",
                                 "",
                                 $this->message['CONTENT']['VERSIONCLIENT']);
          $pfAgent->setAgentVersions($agent['id'], $xmltag, $version);
       }
    
       if (isset($this->message->CONTENT->MODULEVERSION)) {
          $pfAgent->setAgentVersions($agent['id'],
                                     $xmltag,
                                     (string)$this->message->CONTENT->MODULEVERSION);
       } else if (isset($this->message->CONTENT->VERSIONCLIENT)) {
          $version = str_replace("FusionInventory-Agent_",
                                 "",
                                 (string)$this->message->CONTENT->VERSIONCLIENT);
          $pfAgent->setAgentVersions($agent['id'], $xmltag, $version);
       }
    
       if (isset($_SESSION['glpi_plugin_fusioninventory']['xmltags']["$xmltag"])) {
          $moduleClass = $_SESSION['glpi_plugin_fusioninventory']['xmltags']["$xmltag"];
          $moduleCommunication = new $moduleClass();
          $errors.=$moduleCommunication->import($this->message['DEVICEID'],
                  $this->message['CONTENT'],
                  $arrayinventory);
       } else {
          $errors.=__('Unattended element in', 'fusioninventory').' QUERY : *'.$xmltag."*\n";
       }
       $result=TRUE;
       // TODO manage this error ( = delete it)
       if ($errors != '') {
          echo $errors;
          if (isset($_SESSION['glpi_plugin_fusioninventory_processnumber'])) {
             $result=TRUE;
          } else {
             // It's PROLOG
             $result=FALSE;
          }
       }
       return $result;
    }
    

inventorycomputerinventory.class.php

/**
 * import data
 *
 * @global object $DB
 * @global array $CFG_GLPI
 * @param string $p_DEVICEID
 * @param array $a_CONTENT
 * @param array $arrayinventory
 * @return string errors
 */
function import($p_DEVICEID, $a_CONTENT, $arrayinventory)
{
    global $DB, $CFG_GLPI;

    $this->logArray($arrayinventory);

    $errors = '';
    $_SESSION["plugin_fusioninventory_entity"] = -1;

    // Prevent 2 computers with same name (Case of have the computer inventory 2 times in same time
    // and so we don't want it create 2 computers instead one)
    $name = '';
    if (isset($arrayinventory['CONTENT']['HARDWARE']['NAME'])) {
        $name = strtolower($arrayinventory['CONTENT']['HARDWARE']['NAME']);
    }

    // Clean all DB LOCK if exist more than 10 minutes
    $time = 600;
    $query = "DELETE FROM `glpi_plugin_fusioninventory_dblockinventorynames` "
        . " WHERE `date` <  CURRENT_TIMESTAMP() - " . $time;
    $DB->query($query);
    $query = "DELETE FROM `glpi_plugin_fusioninventory_dblockinventories` "
        . " WHERE `date` <  CURRENT_TIMESTAMP() - " . $time;
    $DB->query($query);
    $query = "DELETE FROM `glpi_plugin_fusioninventory_dblocksoftwares` "
        . " WHERE `date` <  CURRENT_TIMESTAMP() - " . $time;
    $DB->query($query);
    $query = "DELETE FROM `glpi_plugin_fusioninventory_dblocksoftwareversions` "
        . " WHERE `date` <  CURRENT_TIMESTAMP() - " . $time;
    $DB->query($query);

    // DB LOCK   数据库加锁操作
    $query = "INSERT INTO `glpi_plugin_fusioninventory_dblockinventorynames`
        SET `value`='" . $name . "'";
    $CFG_GLPI["use_log_in_files"] = FALSE;
    $start_time = date('U');
    while (!$DB->query($query)) {
        usleep(100000);
        if ((date('U') - $start_time) > 5) {
            $communication = new PluginFusioninventoryCommunication();
            $communication->setMessage("
     
     ERROR: Timeout for DB lock based on name
     ");
            $communication->sendMessage($_SESSION['plugin_fusioninventory_compressmode']);
            exit;
        }
    }
    $CFG_GLPI["use_log_in_files"] = TRUE;
    $this->sendCriteria($p_DEVICEID, $arrayinventory);
    // DB UNLOCK 数据库解锁操作
    $query = "DELETE FROM `glpi_plugin_fusioninventory_dblockinventorynames`
        WHERE `value`='" . $name . "'";
    $DB->query($query);

    return $errors;
}


/**
 * Send Computer to inventoryruleimport
 *
 * @param string $p_DEVICEID
 * @param array $arrayinventory
 */
function sendCriteria($p_DEVICEID, $arrayinventory)
{

    if (isset($_SESSION['plugin_fusioninventory_entityrestrict'])) {
        unset($_SESSION['plugin_fusioninventory_entityrestrict']);
    }

    $this->device_id = $p_DEVICEID;
    // * Hacks

    // Hack to put OS in software
    if (isset($arrayinventory['CONTENT']['HARDWARE']['OSNAME'])) {
        $inputos = array();
        if (isset($arrayinventory['CONTENT']['HARDWARE']['OSCOMMENTS'])) {
            $inputos['COMMENTS'] = $arrayinventory['CONTENT']['HARDWARE']['OSCOMMENTS'];
        }
        $inputos['NAME'] = $arrayinventory['CONTENT']['HARDWARE']['OSNAME'];
        if (isset($arrayinventory['CONTENT']['HARDWARE']['OSVERSION'])) {
            $inputos['VERSION'] = $arrayinventory['CONTENT']['HARDWARE']['OSVERSION'];
        }
        if (isset($arrayinventory['CONTENT']['SOFTWARES']['VERSION'])) {
            $temparray = $arrayinventory['CONTENT']['SOFTWARES'];
            $arrayinventory['CONTENT']['SOFTWARES'] = array();
            $arrayinventory['CONTENT']['SOFTWARES'][] = $temparray;
        }
        $arrayinventory['CONTENT']['SOFTWARES'][] = $inputos;
    }

    // Hack for USB Printer serial
    if (isset($arrayinventory['CONTENT']['PRINTERS'])) {
        foreach ($arrayinventory['CONTENT']['PRINTERS'] as $key => $printer) {
            if ((isset($printer['SERIAL']))
                AND (preg_match('/\/$/', $printer['SERIAL']))
            ) {
                $arrayinventory['CONTENT']['PRINTERS'][$key]['SERIAL'] =
                    preg_replace('/\/$/', '', $printer['SERIAL']);
            }
        }
    }

    // Hack to remove Memories with Flash types see ticket
    // http://forge.fusioninventory.org/issues/1337
    if (isset($arrayinventory['CONTENT']['MEMORIES'])) {
        foreach ($arrayinventory['CONTENT']['MEMORIES'] as $key => $memory) {
            if ((isset($memory['TYPE']))
                AND (preg_match('/Flash/', $memory['TYPE']))
            ) {

                unset($arrayinventory['CONTENT']['MEMORIES'][$key]);
            }
        }
    }
    // End hack
    $a_computerinventory = PluginFusioninventoryFormatconvert::computerInventoryTransformation(
        $arrayinventory['CONTENT']);

    // Get tag is defined and put it in fusioninventory_agent table
    $tagAgent = "";
    if (isset($a_computerinventory['ACCOUNTINFO'])) {
        if (isset($a_computerinventory['ACCOUNTINFO']['KEYNAME'])
            && $a_computerinventory['ACCOUNTINFO']['KEYNAME'] == 'TAG'
        ) {
            if (isset($a_computerinventory['ACCOUNTINFO']['KEYVALUE'])
                && $a_computerinventory['ACCOUNTINFO']['KEYVALUE'] != ''
            ) {
                $tagAgent = $a_computerinventory['ACCOUNTINFO']['KEYVALUE'];
            }
        }
    }
    $pfAgent = new PluginFusioninventoryAgent();
    $input = array();
    $input['id'] = $_SESSION['plugin_fusioninventory_agents_id'];
    $input['tag'] = $tagAgent;
    $pfAgent->update($input);

    $pfBlacklist = new PluginFusioninventoryInventoryComputerBlacklist();
    $a_computerinventory = $pfBlacklist->cleanBlacklist($a_computerinventory);

    if (isset($a_computerinventory['monitor'])) {
        foreach ($a_computerinventory['monitor'] as $num => $a_monit) {
            $a_computerinventory['monitor'][$num] = $pfBlacklist->cleanBlacklist($a_monit);
        }
    }
    $this->fillArrayInventory($a_computerinventory);

    $input = array();

    // Global criterias

    if ((isset($a_computerinventory['Computer']['serial'])) AND (!empty($a_computerinventory['Computer']['serial']))) {
        $input['serial'] = $a_computerinventory['Computer']['serial'];
    }

    if ((isset($a_computerinventory['Computer']['uuid'])) AND (!empty($a_computerinventory['Computer']['uuid']))) {
        $input['uuid'] = $a_computerinventory['Computer']['uuid'];
    }

    foreach ($a_computerinventory['networkport'] as $network) {
        if (((isset($network['virtualdev'])) && ($network['virtualdev'] != 1)) OR (!isset($network['virtualdev']))) {
            if ((isset($network['mac'])) AND (!empty($network['mac']))) {
                $input['mac'][] = $network['mac'];
            }
            foreach ($network['ipaddress'] as $ip) {
                if ($ip != '127.0.0.1' && $ip != '::1') {
                    $input['ip'][] = $ip;
                }
            }
            if ((isset($network['subnet'])) AND (!empty($network['subnet']))) {
                $input['subnet'][] = $network['subnet'];
            }
        }
    }
    // Case of virtualmachines
    if (!isset($input['mac']) && !isset($input['ip'])) {
        foreach ($a_computerinventory['networkport'] as $network) {
            if ((isset($network['mac'])) AND (!empty($network['mac']))) {
                $input['mac'][] = $network['mac'];
            }
            foreach ($network['ipaddress'] as $ip) {
                if ($ip != '127.0.0.1' && $ip != '::1') {
                    $input['ip'][] = $ip;
                }
            }
            if ((isset($network['subnet'])) AND (!empty($network['subnet']))) {
                $input['subnet'][] = $network['subnet'];
            }
        }
    }

    if ((isset($a_computerinventory['Computer']['os_license_number'])) AND (!empty($a_computerinventory['Computer']['os_license_number']))) {
        $input['mskey'] = $a_computerinventory['Computer']['os_license_number'];
    }

    if ((isset($a_computerinventory['Computer']['operatingsystems_id'])) AND (!empty($a_computerinventory['Computer']['operatingsystems_id']))) {
        $input['osname'] = $a_computerinventory['Computer']['operatingsystems_id'];
    }

    if ((isset($a_computerinventory['fusioninventorycomputer']['oscomment'])) AND (!empty($a_computerinventory['fusioninventorycomputer']['oscomment']))) {
        $input['oscomment'] = $a_computerinventory['fusioninventorycomputer']['oscomment'];
    }

    if ((isset($a_computerinventory['Computer']['computermodels_id'])) AND (!empty($a_computerinventory['Computer']['computermodels_id']))) {
        $input['model'] = $a_computerinventory['Computer']['computermodels_id'];
    }

    if ((isset($a_computerinventory['Computer']['domains_id'])) AND (!empty($a_computerinventory['Computer']['domains_id']))) {
        $input['domains_id'] = $a_computerinventory['Computer']['domains_id'];
    }

    $input['tag'] = $tagAgent;

    if ((isset($a_computerinventory['Computer']['name'])) AND ($a_computerinventory['Computer']['name'] != '')) {
        $input['name'] = $a_computerinventory['Computer']['name'];
    } else {
        $input['name'] = '';
    }
    $input['itemtype'] = "Computer";

    // If transfer is disable, get entity and search only on this entity
    // (see http://forge.fusioninventory.org/issues/1503)

    // * entity rules
    $inputent = $input;
    if ((isset($a_computerinventory['Computer']['domains_id'])) AND (!empty($a_computerinventory['Computer']['domains_id']))) {
        $inputent['domain'] = $a_computerinventory['Computer']['domains_id'];
    }

    if (isset($inputent['serial'])) {
        $inputent['serialnumber'] = $inputent['serial'];
    }

    $ruleEntity = new PluginFusioninventoryInventoryRuleEntityCollection();

    // * Reload rules (required for unit tests)
    $ruleEntity->getCollectionPart();

    $dataEntity = $ruleEntity->processAllRules($inputent, array());
    if (isset($dataEntity['_ignore_import'])) {
        return;
    }

    if (isset($dataEntity['entities_id']) && $dataEntity['entities_id'] >= 0) {
        $_SESSION["plugin_fusioninventory_entity"] = $dataEntity['entities_id'];
        $input['entities_id'] = $dataEntity['entities_id'];

    } else if (isset($dataEntity['entities_id']) && $dataEntity['entities_id'] == -1) {
        $input['entities_id'] = 0;
        $_SESSION["plugin_fusioninventory_entity"] = -1;
    } else {
        $input['entities_id'] = 0;
        $_SESSION["plugin_fusioninventory_entity"] = 0;
    }

    if (isset($dataEntity['locations_id'])) {
        $_SESSION['plugin_fusioninventory_locations_id'] = $dataEntity['locations_id'];
    }
    // End entity rules
    $_SESSION['plugin_fusioninventory_classrulepassed'] =
        "PluginFusioninventoryInventoryComputerInventory";

    $ruleLocation = new PluginFusioninventoryInventoryRuleLocationCollection();

    // * Reload rules (required for unit tests)
    $ruleLocation->getCollectionPart();

    $dataLocation = $ruleLocation->processAllRules($input, array());
    if (isset($dataLocation['locations_id'])) {
        $_SESSION['plugin_fusioninventory_locations_id'] =
            $dataLocation['locations_id'];
    }

    $rule = new PluginFusioninventoryInventoryRuleImportCollection();

    // * Reload rules (required for unit tests)
    $rule->getCollectionPart();

    $data = $rule->processAllRules($input, array(), array('class' => $this));
    PluginFusioninventoryToolbox::logIfExtradebug("pluginFusioninventory-rules",
        $data);

    if (isset($data['_no_rule_matches']) AND ($data['_no_rule_matches'] == '1')) {
        $this->rulepassed(0, "Computer");
    } else if (!isset($data['found_equipment'])) {
        $pfIgnoredimportdevice = new PluginFusioninventoryIgnoredimportdevice();
        $inputdb = array();
        $inputdb['name'] = $input['name'];
        $inputdb['date'] = date("Y-m-d H:i:s");
        $inputdb['itemtype'] = "Computer";

        if ((isset($a_computerinventory['Computer']['domains_id'])) AND (!empty($a_computerinventory['Computer']['domains_id']))) {
            $inputdb['domain'] = $a_computerinventory['Computer']['domains_id'];
        }

        if (isset($a_computerinventory['Computer']['serial'])) {
            $inputdb['serial'] = $a_computerinventory['Computer']['serial'];
        }

        if (isset($a_computerinventory['Computer']['uuid'])) {
            $inputdb['uuid'] = $a_computerinventory['Computer']['uuid'];
        }

        if (isset($input['ip'])) {
            $inputdb['ip'] = $input['ip'];
        }

        if (isset($input['mac'])) {
            $inputdb['mac'] = $input['mac'];
        }

        $inputdb['entities_id'] = $input['entities_id'];

        if (isset($input['ip'])) {
            $inputdb['ip'] = exportArrayToDB($input['ip']);
        }

        if (isset($input['mac'])) {
            $inputdb['mac'] = exportArrayToDB($input['mac']);
        }

        $inputdb['rules_id'] = $data['_ruleid'];
        $inputdb['method'] = 'inventory';
        $pfIgnoredimportdevice->add($inputdb);
    }
}

你可能感兴趣的:(glpi电脑,软件数据库分析)