Пример #1
0
 function connect()
 {
     $PluginSccmConfig = new PluginSccmConfig();
     $PluginSccmConfig->getFromDB(1);
     $host = $PluginSccmConfig->getField('sccmdb_host');
     $dbname = $PluginSccmConfig->getField('sccmdb_dbname');
     $user = $PluginSccmConfig->getField('sccmdb_user');
     $password = $PluginSccmConfig->getField('sccmdb_password');
     $password = Toolbox::decrypt($password, GLPIKEY);
     $this->dbconn = mssql_connect($host, $user, $password) or die('Connection error : ' . mssql_get_last_message());
     if (!mssql_select_db($dbname, $this->dbconn)) {
         die('Unable to connect do DB!' . mssql_get_last_message());
     }
     return true;
 }
Пример #2
0
    }
}
$REP_XML = GLPI_PLUGIN_DOC_DIR . '/sccm/xml/';
$PluginSccmConfig = new PluginSccmConfig();
$PluginSccmConfig->getFromDB(1);
$PluginSccmSccm = new PluginSccmSccm();
$PluginSccmSccmdb = new PluginSccmSccmdb();
$PluginSccmSccmdb->connect();
$action = isset($_GET['task']) ? $_GET['task'] : "home";
if (!in_array($action, array('home', 'test', 'inject', 'showtable'))) {
    die('Erreur');
}
switch ($action) {
    case 'test':
        include 'test.php';
        break;
    case 'showtable':
        include 'showtable.php';
        break;
    case 'inject':
        if ($PluginSccmConfig->getField('active_sync') == 1) {
            include 'inject.php';
        } else {
            echo __("Synchronization is disabled by configuration.", "sccm");
        }
        break;
    case 'home':
        $PluginSccmSccm->showHome();
        break;
}
$PluginSccmSccmdb->disconnect();
Пример #3
0
 static function executeSync()
 {
     $REP_XML = GLPI_PLUGIN_DOC_DIR . '/sccm/xml/';
     $PluginSccmConfig = new PluginSccmConfig();
     $PluginSccmConfig->getFromDB(1);
     $PluginSccmSccm = new PluginSccmSccm();
     if ($PluginSccmConfig->getField('active_sync') == 1) {
         Toolbox::logInFile('sccm', "Inject start \n", true);
         $PluginSccmSccm->getDevices();
         Toolbox::logInFile('sccm', "getDevices OK \n", true);
         Toolbox::logInFile('sccm', "Generate XML start : " . count($PluginSccmSccm->devices) . " files\n", true);
         foreach ($PluginSccmSccm->devices as $device_values) {
             $PluginSccmSccmxml = new PluginSccmSccmxml($device_values);
             $PluginSccmSccmxml->setAccessLog();
             $PluginSccmSccmxml->setAccountInfos();
             $PluginSccmSccmxml->setHardware();
             $PluginSccmSccmxml->setOS();
             $PluginSccmSccmxml->setBios();
             $PluginSccmSccmxml->setProcessors();
             $PluginSccmSccmxml->setSoftwares();
             $PluginSccmSccmxml->setUsers();
             $PluginSccmSccmxml->setNetworks();
             $PluginSccmSccmxml->setDrives();
             $SXML = $PluginSccmSccmxml->sxml;
             $SXML->asXML($REP_XML . $PluginSccmSccmxml->device_id . ".ocs");
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, $PluginSccmConfig->getField('fusioninventory_url'));
             curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
             curl_setopt($ch, CURLOPT_HEADER, 0);
             curl_setopt($ch, CURLOPT_POST, 1);
             curl_setopt($ch, CURLOPT_POSTFIELDS, $SXML->asXML());
             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
             curl_setopt($ch, CURLOPT_REFERER, $PluginSccmConfig->getField('fusioninventory_url'));
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             $ch_result = curl_exec($ch);
             curl_close($ch);
             Toolbox::logInFile('sccm', "Ajout OK - " . $PluginSccmSccmxml->device_id . " \n", true);
         }
     } else {
         echo __("Synchronization is disabled by configuration.", "sccm");
     }
 }