Esempio n. 1
0
if (is_dir(GLPI_SESSION_DIR) && is_writable(GLPI_SESSION_DIR)) {
    echo "GLPI_SESSION_DIR_OK\n";
} else {
    echo "GLPI_SESSION_DIR_PROBLEM\n";
    $ok = false;
}
// Reestablished DB connection
if (($ok_master || $ok_slave) && DBConnection::establishDBConnection(false, false, false)) {
    // Check OCS connections
    $query = "SELECT `id`, `name`\n             FROM `glpi_ocsservers`";
    if ($result = $DB->query($query)) {
        if ($DB->numrows($result)) {
            echo "Check OCS servers:";
            while ($data = $DB->fetch_assoc($result)) {
                echo " " . $data['name'];
                if (OcsServer::checkOCSconnection($data['id'])) {
                    echo "_OK";
                } else {
                    echo "_PROBLEM";
                    $ok = false;
                }
                echo "\n";
            }
        } else {
            echo "No OCS server\n";
        }
    }
    // Check Auth connections
    $auth = new Auth();
    $auth->getAuthMethods();
    $ldap_methods = $auth->authtypes["ldap"];
 function prepareInputDataForProcess($input, $computers_id)
 {
     global $DBocs;
     $tables = $this->getTablesForQuery();
     $fields = $this->getFieldsForQuery();
     $rule_parameters = array();
     $select_sql = "";
     //Build the select request
     foreach ($fields as $field) {
         switch (utf8_strtoupper($field)) {
             //OCS server ID is provided by extra_params -> get the configuration associated with the ocs server
             case "OCS_SERVER":
                 $rule_parameters["OCS_SERVER"] = $this->ocsservers_id;
                 break;
                 //TAG and DOMAIN should come from the OCS DB
             //TAG and DOMAIN should come from the OCS DB
             default:
                 $select_sql .= ($select_sql != "" ? " , " : "") . $field;
         }
     }
     //Build the FROM part of the request
     //Remove all the non duplicated table names
     $from_sql = "FROM `hardware` ";
     foreach ($tables as $table => $linkfield) {
         if ($table != 'hardware' && !empty($linkfield)) {
             $from_sql .= " LEFT JOIN `{$table}` ON (`{$table}`.`{$linkfield}` = `hardware`.`ID`)";
         }
     }
     if ($select_sql != "") {
         //Build the all request
         $sql = "SELECT {$select_sql}\n                 {$from_sql}\n                 WHERE `hardware`.`ID` = '{$computers_id}'";
         OcsServer::checkOCSconnection($this->ocsservers_id);
         $result = $DBocs->query($sql);
         $ocs_datas = array();
         $fields = $this->getFieldsForQuery(1);
         //May have more than one line : for example in case of multiple network cards
         if ($DBocs->numrows($result) > 0) {
             while ($datas = $DBocs->fetch_array($result)) {
                 foreach ($fields as $field) {
                     if ($field != "OCS_SERVER" && isset($datas[$field])) {
                         $ocs_datas[$field][] = $datas[$field];
                     }
                 }
             }
         }
         //This cas should never happend but...
         //Sometimes OCS can't find network ports but fill the right ip in hardware table...
         //So let's use the ip to proceed rules (if IP is a criteria of course)
         if (in_array("IPADDRESS", $fields) && !isset($ocs_datas['IPADDRESS'])) {
             $ocs_datas['IPADDRESS'] = OcsServer::getGeneralIpAddress($this->ocsservers_id, $computers_id);
         }
         return array_merge($rule_parameters, $ocs_datas);
     }
     return $rule_parameters;
 }