static function getInstance() { if (!isset(self::$_instance)) { self::$_instance = new self(); if (!self::$_instance->getFromDB(1)) { self::$_instance->getEmpty(); } } return self::$_instance; }
function plugin_sccm_uninstall() { global $DB; if (is_dir(GLPI_PLUGIN_DOC_DIR . '/sccm')) { rrmdir(GLPI_PLUGIN_DOC_DIR . '/sccm'); } require 'inc/config.class.php'; require 'inc/sccm.class.php'; return PluginSccmConfig::uninstall(); return PluginSccmSccm::uninstall(); return true; }
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; }
exit; } if (isset($argv)) { for ($i = 1; $i < count($argv); $i++) { //To be able to use = in search filters, enter \= instead in command line //Replace the \= by ° not to match the split function $arg = str_replace('\\=', '°', $argv[$i]); $it = explode("=", $arg); $it[0] = preg_replace('/^--/', '', $it[0]); //Replace the ° by = the find the good filter $it = str_replace('°', '=', $it); $_GET[$it[0]] = $it[1]; } } $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', 'showtable'))) { die('Erreur'); } switch ($action) { case 'test': include 'test.php'; break; case 'showtable': include 'showtable.php'; break;
exit; } if (isset($argv)) { for ($i = 1; $i < count($argv); $i++) { //To be able to use = in search filters, enter \= instead in command line //Replace the \= by ° not to match the split function $arg = str_replace('\\=', '°', $argv[$i]); $it = explode("=", $arg); $it[0] = preg_replace('/^--/', '', $it[0]); //Replace the ° by = the find the good filter $it = str_replace('°', '=', $it); $_GET[$it[0]] = $it[1]; } } $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;
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"); } }
LICENSE This file is part of GLPISCCMPlugin. GLPISCCMPlugin is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GLPISCCMPlugin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GLPISCCMPlugin. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ // Original Author of file: François Legastelois <*****@*****.**> // ---------------------------------------------------------------------- include '../../../inc/includes.php'; require_once '../inc/config.class.php'; Session::haveRight("config", UPDATE); Html::header(__("Setup - SCCM", "sccm"), $_SERVER["PHP_SELF"], "plugins", "sccm", "configuration"); $PluginSccmConfig = new PluginSccmConfig(); if (isset($_POST["update"])) { $PluginSccmConfig->update($_POST); Html::back(); } $PluginSccmConfig->showConfigForm($PluginSccmConfig); Html::footer();