// ***** For debug only ***** //
//$GLOBALS["HTTP_RAW_POST_DATA"] = gzcompress('');
// ********** End ********** //
// Get conf tu know if SSL is only
$fusioninventory_config = new PluginFusioninventoryConfig();
$ssl = $fusioninventory_config->getValue('ssl_only');
if (isset($_SERVER["HTTPS"]) and $_SERVER["HTTPS"] == "on" and $ssl == "1" or $ssl == "0") {
    // echo "On continue";
} else {
    $ptc->setXML("<?xml version='1.0' encoding='ISO-8859-1'?>\n<REPLY>\n</REPLY>");
    $ptc->noSSL();
    exit;
}
$ocsinventory = '0';
file_put_contents(GLPI_PLUGIN_DOC_DIR . "/fusioninventory/dial.log" . rand(), gzuncompress($GLOBALS["HTTP_RAW_POST_DATA"]));
$state = $ptc->importToken(gzuncompress($GLOBALS["HTTP_RAW_POST_DATA"]));
if ($state == '2') {
    // agent created
    $ocsinventory = '1';
}
$top0 = gettimeofday();
if (!$ptc->import(gzuncompress($GLOBALS["HTTP_RAW_POST_DATA"]))) {
    //if ($ac->connectionOK($errors)) {
    if (1) {
        $res .= "1'" . $errors . "'";
        $p_xml = gzuncompress($GLOBALS["HTTP_RAW_POST_DATA"]);
        $pxml = @simplexml_load_string($p_xml);
        if (isset($pxml->DEVICEID)) {
            $ptc->setXML("<?xml version='1.0' encoding='ISO-8859-1'?>\n<REPLY>\n</REPLY>");
            $pta = new PluginFusioninventoryAgents();
            $ptt = new PluginFusioninventoryTask();