Ejemplo n.º 1
0
function insert($NAME, $IVALUE, $TVALUE = "")
{
    global $list_hardware_id, $tab_hadware_id;
    //delete old value before insert new
    erase($NAME);
    // if it's for group or a machine
    if (isset($list_hardware_id)) {
        $arg = array($list_hardware_id, $NAME, $IVALUE);
        if ($TVALUE != "") {
            $sql = "INSERT INTO devices(HARDWARE_ID,NAME,IVALUE,TVALUE) VALUES ('%s', '%s', '%s', '%s')";
            array_push($arg, $TVALUE);
        } else {
            $sql = "INSERT INTO devices(HARDWARE_ID, NAME, IVALUE) VALUES('%s', '%s', '%s')";
        }
        mysql2_query_secure($sql, $_SESSION['OCS']["writeServer"], $arg);
    } else {
        //else : request
        $i = 0;
        while ($tab_hadware_id[$i]) {
            $arg = array($tab_hadware_id[$i], $NAME, $IVALUE);
            if ($TVALUE != "") {
                $sql = "INSERT INTO devices(HARDWARE_ID,NAME,IVALUE,TVALUE) VALUES ('%s', '%s', '%s', '%s')";
                array_push($arg, $TVALUE);
            } else {
                $sql = "INSERT INTO devices(HARDWARE_ID, NAME, IVALUE) VALUES ('%s', '%s', '%s')";
            }
            mysql2_query_secure($sql, $_SESSION['OCS']["writeServer"], $arg);
            $i++;
        }
    }
}
function look_config_default_values($field_name, $like = '', $default_values = '')
{
    if ($like == '') {
        $sql = "select NAME,IVALUE,TVALUE,COMMENTS from config where NAME in ";
        $arg_sql = array();
        $arg = mysql2_prepare($sql, $arg_sql, $field_name);
    } else {
        $arg['SQL'] = "select NAME,IVALUE,TVALUE,COMMENTS from config where NAME like '%s'";
        $arg['ARG'] = $field_name;
    }
    $resdefaultvalues = mysql2_query_secure($arg['SQL'], $_SESSION['OCS']["readServer"], $arg['ARG']);
    while ($item = mysqli_fetch_object($resdefaultvalues)) {
        $result['name'][$item->NAME] = $item->NAME;
        $result['ivalue'][$item->NAME] = $item->IVALUE;
        $result['tvalue'][$item->NAME] = $item->TVALUE;
        $result['comments'][$item->NAME] = $item->COMMENTS;
    }
    if (is_array($default_values)) {
        foreach ($default_values as $key => $value) {
            $key = strtolower($key);
            if (is_array($value)) {
                foreach ($value as $name => $val) {
                    if (!isset($result[$key][$name]) or $result[$key][$name] == '') {
                        $result[$key][$name] = $val;
                    }
                }
            }
        }
    }
    return $result;
}
function exec_fichier_sql($fichier, $link)
{
    global $l;
    $db_file = $fichier;
    $dbf_handle = @fopen($db_file, "r");
    echo "<br>";
    if (!$dbf_handle) {
        msg_error($l->g(2112) . " : " . $fichier);
        return true;
    } else {
        if (filesize($db_file) > 0) {
            $sql_query = fread($dbf_handle, filesize($db_file));
            fclose($dbf_handle);
            $data_sql = explode(";", $sql_query);
            foreach ($data_sql as $k => $v) {
                if (trim($v) != "") {
                    echo ".";
                    ob_flush();
                    flush();
                    mysql2_query_secure($v, $link);
                }
            }
            return false;
        }
        return true;
    }
}
function show_computer_summary($computer)
{
    global $l;
    $urls = $_SESSION['OCS']['url_service'];
    $labels = array('SYSTEM' => array('USERID' => $l->g(24), 'OSNAME' => $l->g(274), 'OSVERSION' => $l->g(275), 'OSCOMMENTS' => $l->g(286), 'DESCRIPTION' => $l->g(53), 'WINCOMPANY' => $l->g(51), 'WINOWNER' => $l->g(348), 'WINPRODID' => $l->g(111), 'WINPRODKEY' => $l->g(553), 'VMTYPE' => $l->g(1267)), 'NETWORK' => array('WORKGROUP' => $l->g(33), 'USERDOMAIN' => $l->g(557), 'IPADDR' => $l->g(34), 'NAME_RZ' => $l->g(304)), 'HARDWARE' => array('SWAP' => $l->g(50), 'MEMORY' => $l->g(26), 'UUID' => $l->g(1268), 'ARCH' => $l->g(1247)), 'AGENT' => array('USERAGENT' => $l->g(357), 'LASTDATE' => $l->g(46), 'LASTCOME' => $l->g(820)));
    $cat_labels = array('SYSTEM' => $l->g(1387), 'NETWORK' => $l->g(1388), 'HARDWARE' => $l->g(1389), 'AGENT' => $l->g(1390));
    foreach ($labels as $cat_key => $cat) {
        foreach ($cat as $key => $lbl) {
            if ($key == "MEMORY") {
                $sqlMem = "SELECT SUM(capacity) AS 'capa' FROM memories WHERE hardware_id=%s";
                $argMem = $computer->ID;
                $resMem = mysql2_query_secure($sqlMem, $_SESSION['OCS']["readServer"], $argMem);
                $valMem = mysqli_fetch_array($resMem);
                if ($valMem["capa"] > 0) {
                    $memory = $valMem["capa"];
                } else {
                    $memory = $computer->{$key};
                }
                $data[$key] = $memory;
            } elseif ($key == "LASTDATE" or $key == "LASTCOME") {
                $data[$key] = dateTimeFromMysql($computer->{$key});
            } elseif ($key == "NAME_RZ") {
                $data[$key] = "";
                $data_RZ = subnet_name($computer->ID);
                $nb_val = count($data_RZ);
                if ($nb_val == 1) {
                    $data[$key] = $data_RZ[0];
                } elseif (isset($data_RZ)) {
                    foreach ($data_RZ as $index => $value) {
                        $data[$key] .= $index . " => " . $value . "<br>";
                    }
                }
            } elseif ($key == "VMTYPE" and $computer->UUID != '') {
                $sqlVM = "select vm.hardware_id,vm.vmtype, h.name from virtualmachines vm left join hardware h on vm.hardware_id=h.id where vm.uuid='%s' order by h.name DESC";
                $argVM = $computer->UUID;
                $resVM = mysql2_query_secure($sqlVM, $_SESSION['OCS']["readServer"], $argVM);
                $valVM = mysqli_fetch_array($resVM);
                $data[$key] = $valVM['vmtype'];
                $link_vm = "<a href='index.php?" . PAG_INDEX . "=" . $urls->getUrl('ms_computer') . "&head=1&systemid=" . $valVM['hardware_id'] . "'  target='_blank'><font color=red>" . $valVM['name'] . "</font></a>";
                $link[$key] = true;
                if ($data[$key] != '') {
                    msg_info($l->g(1266) . "<br>" . $l->g(1269) . ': ' . $link_vm);
                }
            } elseif ($key == "IPADDR" and $_SESSION['OCS']['profile']->getRestriction('WOL', 'NO') == "NO") {
                $data[$key] = $computer->{$key} . " <a href=# OnClick='confirme(\"\",\"WOL\",\"bandeau\",\"WOL\",\"" . $l->g(1283) . "\");'><i>WOL</i></a>";
                $link[$key] = true;
            } elseif ($computer->{$key} != '') {
                $data[$key] = $computer->{$key};
            }
        }
    }
    echo open_form("bandeau");
    show_summary($data, $labels, $cat_labels, $link);
    echo "<input type='hidden' id='WOL' name='WOL' value=''>";
    echo close_form();
}
function get_redistrib_package_info($timestamp)
{
    $query = "SELECT FILEID, NAME, PRIORITY, FRAGMENTS, SIZE, OSNAME, COMMENT FROM download_available" . " WHERE NAME LIKE '%%_redistrib' AND COMMENT LIKE '%%[PACK REDISTRIBUTION %s]%%'";
    $res = mysql2_query_secure($query, $_SESSION['OCS']['readServer'], $timestamp);
    if (mysqli_num_rows($res)) {
        return mysqli_fetch_assoc($res);
    } else {
        return false;
    }
}
Ejemplo n.º 6
0
function delkey($id)
{
    //find the registry key
    $sql = "select name from regconfig where id =%s";
    $arg = $id;
    $res = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg);
    $row = mysql_fetch_object($res);
    $name = $row->name;
    //delete key
    $sql_reg = "delete from regconfig where id =%s ";
    mysql2_query_secure($sql_reg, $_SESSION['OCS']["writeServer"], $arg);
    //delete cache
    $sql_reg = "delete from registry_name_cache where name ='%s' ";
    mysql2_query_secure($sql_reg, $_SESSION['OCS']["writeServer"], $name);
}
function find_device_line($status, $packid)
{
    $sql = "select hardware_id,ivalue from devices where name='DOWNLOAD' and tvalue";
    if ($status == "NULL") {
        $sql .= " IS NULL ";
        $arg = $packid;
    } elseif ($status == "NOTNULL") {
        $sql .= " IS NOT NULL ";
        $arg = $packid;
    } else {
        $sql .= " LIKE '%s' ";
        $arg = array($status, $packid);
    }
    $sql .= "AND ivalue IN (SELECT id FROM download_enable WHERE fileid='%s') " . "AND hardware_id NOT IN (SELECT id FROM hardware WHERE deviceid='_SYSTEMGROUP_')";
    $res = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg);
    while ($row = mysqli_fetch_object($res)) {
        $result['HARDWARE_ID'][] = $row->hardware_id;
        $result['IVALUE'][] = $row->ivalue;
    }
    return $result;
}
        }
        if ($listIDdel != '') {
            foreach ($listIDdel as $k => $v) {
                desactive_packet('', $v);
            }
        }
        mysql2_query_secure("DELETE FROM download_enable WHERE FILEID=%s", $_SESSION['OCS']["writeServer"], $protectedPost['DEL_ALL']);
        echo "<script>window.opener.document.packlist.submit(); self.close();</script>";
    }
    if ($protectedPost['SUP_PROF'] != '') {
        desactive_packet('', $protectedPost['SUP_PROF']);
        mysql2_query_secure("DELETE FROM download_enable WHERE ID=%s", $_SESSION['OCS']["writeServer"], $protectedPost['SUP_PROF']);
    }
}
$sql_details = "select distinct priority,fragments,size from download_available where fileid=%s";
$res_details = mysql2_query_secure($sql_details, $_SESSION['OCS']["readServer"], $protectedGet['timestamp']);
$val_details = mysqli_fetch_array($res_details);
$tps = "<br>" . $l->g(992) . " : <b><font color=red>" . tps_estimated($val_details) . "</font></b>";
PrintEnTete($l->g(481) . $tps);
echo "<br>";
$form_name = "tele_actives";
//ouverture du formulaire
echo open_form($form_name);
$list_fields = array($l->g(460) => 'e.ID', 'Timestamp' => 'e.FILEID', $l->g(470) => 'e.INFO_LOC', $l->g(471) => 'e.PACK_LOC', $l->g(49) => 'a.NAME', $l->g(440) => 'a.PRIORITY', $l->g(480) => 'a.FRAGMENTS', $l->g(462) => 'a.SIZE', $l->g(25) => 'a.OSNAME');
if (!$cant_active) {
    $list_fields['SUP'] = 'e.ID';
}
$table_name = "LIST_ACTIVES";
$default_fields = $list_fields;
$list_col_cant_del = array($l->g(460) => $l->g(460), 'SUP' => 'SUP');
$querypack = 'SELECT distinct ';
Ejemplo n.º 9
0
$querygroup .= " group by h.ID";
$result = mysql2_query_secure($sql_nb_mach, $_SESSION['OCS']["readServer"]);
while ($item = mysql_fetch_object($result)) {
    //on force les valeurs du champ "nombre" � l'affichage
    $tab_options['VALUE']['NBRE'][$item->group_id] = $item->nb;
}
//Modif ajout�e pour la prise en compte
//du chiffre � rajouter dans la colonne de calcul
//quand on a un seul groupe et qu'aucune machine n'est dedant.
if (!isset($tab_options['VALUE']['NBRE'])) {
    $tab_options['VALUE']['NBRE'][] = 0;
}
//on recherche les groupes visible pour cocher la checkbox � l'affichage
if ($protectedPost['onglet'] == "STAT") {
    $sql = "select id from hardware where workgroup='GROUP_4_ALL'";
    $result = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"]);
    while ($item = mysql_fetch_object($result)) {
        $protectedPost['check' . $item->id] = "check";
    }
}
//on ajoute un javascript lorsque l'on clic sur la visibilit� du groupe pour tous
$tab_options['JAVA']['CHECK']['NAME'] = "NAME";
$tab_options['JAVA']['CHECK']['QUESTION'] = $l->g(811);
$tab_options['FILTRE'] = array('NAME' => $l->g(679), 'DESCRIPTION' => $l->g(53));
//affichage du tableau
$result_exist = tab_req($table_name, $list_fields, $default_fields, $list_col_cant_del, $querygroup, $form_name, 100, $tab_options);
//if your profil is an admin groups, you can create one
if ($_SESSION['OCS']['CONFIGURATION']['GROUPS'] == "YES") {
    echo "</td></tr></table>";
    if ($protectedPost['onglet'] == "STAT") {
        echo "<BR><input type='submit' name='add_static_group' value='" . $l->g(587) . "'>";
Ejemplo n.º 10
0
         $insert = mysql2_prepare($sql_insert, $arg_sql, $array_values);
         mysql2_query_secure($insert['SQL'], $_SESSION['OCS']["writeServer"], $insert['ARG']);
         //	mysql_query( "INSERT INTO ".$table." (".$fields.") VALUES('".$values."')", $_SESSION['OCS']["writeServer"]) or mysql_error($_SESSION['OCS']["writeServer"]);
         //If we add a field, you must add a new colonm in downloadwk_pack table
         if ($table == "downloadwk_fields") {
             $id = mysql_insert_id($_SESSION['OCS']["writeServer"]);
             if (is_numeric($id)) {
                 if ($protectedPost["newtype"] == 1) {
                     $type = "LONGTEXT";
                 } elseif ($protectedPost["newtype"] == 8) {
                     $type = "BLOB";
                 } else {
                     $type = "VARCHAR(255)";
                 }
                 $sql_add_column = "ALTER TABLE downloadwk_pack ADD COLUMN fields_" . $id . " " . $type . " default NULL";
                 mysql2_query_secure($sql_add_column, $_SESSION['OCS']["writeServer"]);
             } else {
                 msg_error("mysql_insert_id() problem");
             }
         }
         msg_success($l->g(1069));
         reloadform_closeme($protectedGet['form']);
         if ($protectedPost['Valid_modif_x'] != "") {
             unset($protectedPost['newfield'], $protectedPost['newlbl']);
         }
     } else {
         msg_error($ERROR);
     }
 }
 //NAME FIELD
 $name_field = array("newfield");
Ejemplo n.º 11
0
function insert_with_rules($list_id, $rule_detail, $fileid)
{
    if (is_array($list_id)) {
        $list_id_hardware = implode(',', $list_id);
    } else {
        $list_id_hardware = $list_id;
    }
    if ($list_id_hardware == "") {
        return;
    }
    //for servers
    //recherche de tous les hardware_id des servers et des id de download_enable correspondant
    $sql_infoServ = "select server_id,id from download_enable where group_id != '' \n\t\t\t\t\t\t\t\tand fileid=%s";
    $arg_infoServ = $fileid;
    //echo $sql_infoServ;
    $res_infoServ = mysql2_query_secure($sql_infoServ, $_SESSION['OCS']["readServer"], $arg_infoServ);
    //cr�ation de la liste des id_hardware des servers et d'un tableau de l'id de download_enable en fonction de l'hardware_id
    while ($val_infoServ = mysql_fetch_array($res_infoServ)) {
        $list_serverId[$val_infoServ['server_id']] = $val_infoServ['server_id'];
        $tab_Server[$val_infoServ['server_id']] = $val_infoServ['id'];
    }
    if ($rule_detail['compto'] == "NAME" or $rule_detail['compto'] == "WORKGROUP" or $rule_detail['compto'] == "USERID") {
        $tablecompto = "hardware";
        $id_server = "ID";
    }
    if ($rule_detail['compto'] == "IPSUBNET" or $rule_detail['compto'] == "IPADDRESS") {
        $tablecompto = "networks";
        $id_server = "HARDWARE_ID";
    }
    $sql_servValues = "select a.%s,a.%s,d.id as id_download_enable from %s a,download_enable d\n\t\t\t\t\t\t where a.%s in ";
    $arg_servValues = array($rule_detail['compto'], $id_server, $tablecompto, $id_server);
    $arg = mysql2_prepare($sql_servValues, $arg_servValues, $list_serverId);
    $arg['SQL'] .= " and d.server_id=a.%s  and fileid='%s'";
    array_push($arg['ARG'], $id_server);
    array_push($arg['ARG'], $fileid);
    $res_servValues = mysql2_query_secure($arg['SQL'], $_SESSION['OCS']["readServer"], $arg['ARG']);
    //echo $sql_servValues."<br><br>";
    while ($val_servValues = mysql_fetch_array($res_servValues)) {
        $tab_serValues[$val_servValues[$rule_detail['compto']]] = $val_servValues[$id_server];
        $correspond_servers[$val_servValues[$id_server]] = $val_servValues['id_download_enable'];
    }
    //for machines
    if ($rule_detail['cfield'] == "NAME" or $rule_detail['cfield'] == "WORKGROUP" or $rule_detail['cfield'] == "USERID") {
        $tablefield = "hardware";
        $id_mach = "ID";
    }
    if ($rule_detail['cfield'] == "IPSUBNET" or $rule_detail['cfield'] == "IPADDRESS") {
        $tablefield = "networks";
        $id_mach = "HARDWARE_ID";
    }
    $sql_machValue = "select %s,%s from %s where %s in ";
    $arg_machValue = array($rule_detail['cfield'], $id_mach, $tablefield, $id_mach);
    $arg = mysql2_prepare($sql_machValue, $arg_machValue, $list_id_hardware);
    $res_machValue = mysql2_query_secure($arg['SQL'], $_SESSION['OCS']["readServer"], $arg['ARG']);
    //print_r($tab_serValues);
    while ($val_machValue = mysql_fetch_array($res_machValue)) {
        if ($rule_detail['op'] == "EGAL") {
            //echo "<br>".$val_machValue[$rule_detail['cfield']]."<br>";
            //cas of egal
            if (isset($tab_serValues[$val_machValue[$rule_detail['cfield']]])) {
                $tab_final[$val_machValue[$id_mach]] = $correspond_servers[$tab_serValues[$val_machValue[$rule_detail['cfield']]]];
                $verif_idMach[$val_machValue[$id_mach]] = $val_machValue[$id_mach];
            } else {
                $not_match[$val_machValue[$id_mach]] = $val_machValue[$id_mach];
                //$nb_notMatch++;
            }
        } elseif ($rule_detail['op'] == "DIFF") {
            if (!isset($tab_serValues[$val_machValue[$rule_detail['cfield']]])) {
                $tab_final[$val_machValue[$id_mach]] = $correspond_servers[$tab_serValues[$val_machValue[$rule_detail['cfield']]]];
                $verif_idMach[$val_machValue[$id_mach]] = $val_machValue[$id_mach];
            } else {
                $not_match[$val_machValue[$id_mach]] = $val_machValue[$id_mach];
                //$nb_notMatch++;
            }
        }
    }
    if (isset($verif_idMach)) {
        $sql_verif = "select d.hardware_id as hardware_id\n\t\t\t  from devices d,download_enable d_e \n\t\t\t  where d.ivalue=d_e.id and fileid=%s\n\t\t\t\tAND d.HARDWARE_ID in ";
        $arg_verif = array($fileid);
        $arg = mysql2_prepare($sql_verif, $arg_verif, $verif_idMach);
        $arg['SQL'] .= " and d.name='DOWNLOAD'";
        $res_verif = mysql2_query_secure($arg['SQL'], $_SESSION['OCS']["readServer"], $arg['ARG']);
        //recup�ration des machines en doublon
        while ($val_verif = mysql_fetch_array($res_verif)) {
            //cr�ation du tableau de doublon
            $exist[$val_verif['hardware_id']] = $val_verif['hardware_id'];
            //suppression des doublons
            //unset($tab_final[$val_verif['hardware_id']]);
            //$nb_exist++;
        }
        //suppression des doublons pour remettre le statut a attente de notification
        if ($exist != '') {
            desactive_mach_serv(implode(',', $exist), $fileid);
        }
        //insertion en base
        $nb_insert = 0;
        foreach ($tab_final as $key => $value) {
            $query = "INSERT INTO devices(HARDWARE_ID, NAME, IVALUE) VALUES('%s', '%s','%s')";
            $arg = array($key, 'DOWNLOAD', $value);
            mysql2_query_secure($query, $_SESSION['OCS']["writeServer"], $arg);
            $insert[$key] = $value;
            $nb_insert++;
        }
    }
    $not_found = array();
    if (is_array($not_match)) {
        foreach ($not_match as $key => $value) {
            $not_found[] = $value;
        }
    }
    $already_exist = array();
    if (is_array($exist)) {
        foreach ($exist as $key => $value) {
            if (!isset($insert[$key])) {
                $already_exist[] = $value;
            }
        }
    }
    //retour des erreurs
    $don['not_match'] = $not_found;
    $don['nb_not_match'] = count($not_found);
    $don['exist'] = $already_exist;
    $don['nb_exist'] = count($already_exist);
    $don['nb_insert'] = $nb_insert;
    //print_r($don);
    return $don;
}
function add_rule($RULE_NAME, $RULE_VALUES, $ID_RULE = '')
{
    global $l, $protectedPost;
    $rule_exist = verify_name($RULE_NAME);
    if ($rule_exist == 'NAME_NOT_EXIST') {
        //verify this id is new
        $sql = "select id from download_affect_rules where id='%s'";
        $arg = $ID_RULE;
        $result_id = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg);
        $id_exist = mysqli_fetch_object($result_id);
        //generate id
        if (!is_numeric($ID_RULE) or $ID_RULE == '' or isset($id_exist->id)) {
            $sql_new_id = "select max(RULE) as ID_RULE from download_affect_rules";
            $result_new_id = mysql2_query_secure($sql_new_id, $_SESSION['OCS']["readServer"]);
            $new_id = mysqli_fetch_object($result_new_id);
            $ID_RULE = $new_id->ID_RULE;
            $ID_RULE++;
        }
        //insert new rule
        $i = 1;
        while ($RULE_VALUES['PRIORITE_' . $i]) {
            if ($RULE_VALUES['CFIELD_' . $i] != "") {
                $sql_insert_rule = "insert into download_affect_rules (RULE,RULE_NAME,PRIORITY,CFIELD,OP,COMPTO,SERV_VALUE) \n\t\t\t\tvalue (%s,'%s',%s,'%s','%s','%s','%s')";
                $arg = array($ID_RULE, $protectedPost['RULE_NAME'], $RULE_VALUES['PRIORITE_' . $i], $RULE_VALUES['CFIELD_' . $i], $RULE_VALUES['OP_' . $i], $RULE_VALUES['COMPTO_' . $i], $RULE_VALUES['COMPTO_TEXT_' . $i]);
                mysql2_query_secure($sql_insert_rule, $_SESSION['OCS']["writeServer"], $arg);
            }
            $i++;
        }
    } else {
        echo msg_error($l->g(670));
    }
}
*/
//origin = workflow teledeploy
if ($protectedGet['prov'] == "dde_wk") {
    $sql = "select FILE,FILE_NAME,FILE_TYPE,FILE_SIZE\n\t\t\t FROM temp_files \n\t\t\t where id = '%s'";
    $arg = array($protectedGet["value"]);
}
if ($protectedGet['prov'] == "agent") {
    $sql = "select %s as FILE,name as FILE_NAME from deploy where name = '%s'";
    $arg = array('content', $protectedGet["value"]);
}
if ($protectedGet['prov'] == "ssl") {
    $sql = "select FILE,FILE_NAME from ssl_store where id = '%s'";
    $arg = array($protectedGet["value"]);
}
if (isset($sql) and $sql != '') {
    $res_document_root = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg);
    $val_document_root = mysqli_fetch_array($res_document_root);
    if (!isset($val_document_root['FILE_TYPE']) or $val_document_root['FILE_TYPE'] != '') {
        $val_document_root['FILE_TYPE'] = "application/force-download";
    }
    if (!isset($val_document_root['FILE_SIZE']) or $val_document_root['FILE_SIZE'] != '') {
        $val_document_root['FILE_SIZE'] = strlen($val_document_root['FILE']);
    }
}
if (isset($val_document_root['FILE_NAME'])) {
    // iexplorer problem
    if (ini_get("zlib.output-compression")) {
        ini_set("zlib.output-compression", "Off");
    }
    header("Pragma: public");
    header("Expires: 0");
     $msg_header_error_sol[] = $l->g(2023);
 }
 //defaut user already exist on databases?
 try {
     $link_read = mysqli_connect(SERVER_READ, DFT_DB_CMPT, DFT_DB_PSWD);
     $link_write = mysqli_connect(SERVER_WRITE, DFT_DB_CMPT, DFT_DB_PSWD);
     mysqli_select_db($link_read, DB_NAME);
     mysqli_select_db($link_write, DB_NAME);
     $msg_header_error[] = $l->g(2024) . ' ' . DB_NAME;
     $msg_header_error_sol[] = $l->g(2025);
 } catch (Exception $e) {
 }
 //admin user already exist on data base with defaut password?
 $reqOp = "SELECT id,user_group FROM operators WHERE id='%s' and passwd ='%s'";
 $arg_reqOp = array(DFT_GUI_CMPT, md5(DFT_GUI_PSWD));
 $resOp = mysql2_query_secure($reqOp, $_SESSION['OCS']["readServer"], $arg_reqOp);
 $rowOp = mysqli_fetch_object($resOp);
 if (isset($rowOp->id)) {
     $msg_header_error[] = $l->g(2026);
     $msg_header_error_sol[] = $l->g(2027);
 }
 /***************************************************** WARNING MESSAGES *****************************************************/
 $msg_header_warning = array();
 //Demo mode activate?
 if (DEMO) {
     $msg_header_warning[] = $l->g(2104) . " " . GUI_VER_SHOW . "<br>";
 }
 if ($_SESSION['OCS']['LOG_GUI'] == 1) {
     //check if the GUI logs directory is writable
     $rep_ok = is_writable($_SESSION['OCS']['LOG_DIR']);
     if (!$rep_ok) {
Ejemplo n.º 15
0
//$base = 'OTHER';
$base = "OCS";
connexion_local_read();
mysql_select_db($db_ocs, $link_ocs);
$sql_black = "select SUBNET,MASK from blacklist_subnet";
$res_black = mysql2_query_secure($sql_black, $link_ocs);
while ($row = mysql_fetch_object($res_black)) {
    $subnet_to_balcklist[$row->SUBNET] = $row->MASK;
}
$req = "select distinct ipsubnet,s.name,s.id \n\t\t\tfrom networks n left join subnet s on s.netid=n.ipsubnet\n\t\t\t,accountinfo a\n\t\twhere a.hardware_id=n.HARDWARE_ID \n\t\t\tand n.status='Up'";
if (isset($_SESSION['OCS']["mesmachines"]) and $_SESSION['OCS']["mesmachines"] != '' and $_SESSION['OCS']["mesmachines"] != 'NOTAG') {
    $req .= "\tand " . $_SESSION['OCS']["mesmachines"] . " order by ipsubnet";
} else {
    $req .= " union select netid,name,id from subnet";
}
$res = mysql2_query_secure($req, $link_ocs) or die(mysql_error($link_ocs));
while ($row = mysql_fetch_object($res)) {
    unset($id);
    $list_subnet[] = $row->ipsubnet;
    /*	foreach ($subnet_to_balcklist as $key=>$value){
    		if ($key == $row -> ipsubnet)
    			$id='--'.$l->g(703).'--';
    	}
    */
    /*
    applied again patch of revision 484 ( fix bug: https://bugs.launchpad.net/ocsinventory-ocsreports/+bug/637834 )
    */
    if (is_array($subnet_to_balcklist)) {
        foreach ($subnet_to_balcklist as $key => $value) {
            if ($key == $row->ipsubnet) {
                $id = '--' . $l->g(703) . '--';
Ejemplo n.º 16
0
function print_computers_cached($systemid)
{
    global $l, $server_group, $protectedPost, $list_fields, $list_col_cant_del, $default_fields, $tab_options;
    //print_r($protectedPost);
    //traitement des machines du groupe
    if (isset($protectedPost["actshowgroup"]) and $protectedPost["modify"] != "") {
        foreach ($protectedPost as $key => $val) {
            //check65422
            if (substr($key, 0, 5) == "check") {
                update_computer_group(substr($key, 5), $systemid, $protectedPost["actshowgroup"]);
            }
        }
        $tab_options['CACHE'] = 'RESET';
    }
    if ($_SESSION['OCS']['RESTRICTION']['GUI'] == "YES") {
        $sql_mesMachines = "select hardware_id from accountinfo a where " . $_SESSION['OCS']["mesmachines"];
        $res_mesMachines = mysql2_query_secure($sql_mesMachines, $_SESSION['OCS']["readServer"]);
        $mesmachines = "(";
        while ($item_mesMachines = mysql_fetch_object($res_mesMachines)) {
            $mesmachines .= $item_mesMachines->hardware_id . ",";
        }
        $mesmachines = "and e.hardware_id IN " . substr($mesmachines, 0, -1) . ")";
    }
    $form_name = "list_computer_groupcache";
    $table_name = $form_name;
    echo open_form($form_name);
    $queryDetails = "SELECT ";
    foreach ($list_fields as $lbl => $value) {
        $queryDetails .= $value . ",";
    }
    $queryDetails = substr($queryDetails, 0, -1) . " FROM  hardware h LEFT JOIN accountinfo a ON a.hardware_id=h.id\n\t\t\t\t\t\t,groups_cache e\n\t\t\t\t\t\twhere group_id='" . $systemid . "' and h.id=e.HARDWARE_ID ";
    if (isset($mesmachines) and $mesmachines != '') {
        $queryDetails .= $mesmachines;
    }
    $tab_options['FILTRE'] = array('h.NAME' => 'Nom');
    $statut = tab_req($table_name, $list_fields, $default_fields, $list_col_cant_del, $queryDetails, $form_name, 80, $tab_options);
    if ($statut) {
        form_action_group($systemid);
    }
    echo close_form();
}
Ejemplo n.º 17
0
         while ($cont = mysql_fetch_array($result, MYSQL_ASSOC)) {
             foreach ($col as $field => $lbl) {
                 if (array_key_exists($lbl, $cont)) {
                     $data_fixe[$cont['HARDWARE_ID']][$field] = $cont[$lbl];
                 }
             }
         }
         $i++;
     }
 }
 if ($_SESSION['OCS']['csv']['ARG'][$protectedGet['tablename']]) {
     $arg = $_SESSION['OCS']['csv']['ARG'][$protectedGet['tablename']];
 } else {
     $arg = '';
 }
 $result = mysql2_query_secure($_SESSION['OCS']['csv']['SQL'][$protectedGet['tablename']], $link, $arg);
 $i = 0;
 require_once 'require/function_admininfo.php';
 $inter = interprete_accountinfo($col, array());
 while ($cont = mysql_fetch_array($result, MYSQL_ASSOC)) {
     //p($cont);
     foreach ($col as $field => $lbl) {
         if ($lbl == "name_of_machine" and !isset($cont[$field])) {
             $field = 'name';
         }
         $found = false;
         // find value case-insensitive
         foreach ($cont as $key => $val) {
             if (strtolower($key) == strtolower($field)) {
                 if (($field == 'TAG' or substr($field, 0, 7) == 'fields_') and isset($inter['TAB_OPTIONS']['REPLACE_VALUE'][$lbl])) {
                     // administrative data
function show_console_field($fields, $form_name)
{
    global $sql_field, $myids, $no_restrict, $table, $link, $pages_refs, $multi_search;
    $no_groups_sql = " deviceid != '_SYSTEMGROUP_' and deviceid != '_DOWNLOADGROUP_' ";
    $no_show = look_config_default_values('OCS_REPORT_%', 1);
    echo "<table ALIGN = 'Center' cellspacing='5' CELLPADDING='4'><tr ><td align =center><font size=2>";
    foreach ($fields as $key => $value) {
        if (isset($_SESSION['OCS']['ADMIN_CONSOLE'])) {
            if (isset($no_show['name'][$key])) {
                $icon = "<td align=center><a href=# OnClick='pag(\"" . $key . "\",\"NO_VISIBLE\",\"" . $form_name . "\");'><img src='image/red.png'></a></td>";
            } else {
                $icon = "<td align=center><a href=# OnClick='pag(\"" . $key . "\",\"VISIBLE\",\"" . $form_name . "\");'><img src='image/green.png'></a></td>";
            }
        } else {
            $icon = "";
        }
        $arg_result = $sql_field[$key]['ARG'];
        if (isset($sql_field[$key]['SQL'])) {
            $sql_result = $sql_field[$key]['SQL'];
        } else {
            $sql_result = "select %s from %s %s";
        }
        if ($table[$key] == 'hardware') {
            if (isset($arg_result[2]) and $arg_result[2] != '') {
                $sql_result .= " and " . $no_groups_sql;
            } else {
                $sql_result .= " where " . $no_groups_sql;
            }
        }
        if ($myids) {
            if (!in_array($key, $no_restrict)) {
                if (isset($arg_result[2]) and $arg_result[2] != '' or $table[$key] == 'hardware' or isset($sql_field[$key]['SQL']) and $sql_field[$key]['SQL'] != '') {
                    $sql_result .= " and ";
                } else {
                    $sql_result .= " where ";
                }
                if ($table[$key] != 'hardware' and $table[$key] != 'snmp' and $table[$key] != 'nk') {
                    $sql_result .= $table[$key] . ".hardware_id in " . $myids['SQL'];
                } elseif ($table[$key] == 'hardware') {
                    $sql_result .= " id in " . $myids['SQL'];
                } elseif ($table[$key] == 'snmp') {
                } elseif ($table[$key] == 'nk') {
                    $sql_result = substr($sql_result, 0, -4);
                }
                if (is_array($sql_field[$key]['ARG'])) {
                    $arg_result = array_merge($arg_result, $myids['ARG']);
                } else {
                    $arg_result = $myids['ARG'];
                }
            }
        }
        if (!isset($_SESSION['OCS']['COUNT_CONSOLE'][$key])) {
            $res = mysql2_query_secure($sql_result, $_SESSION['OCS']["readServer"], $arg_result);
            if ($res) {
                $count = mysqli_fetch_object($res);
                $_SESSION['OCS']['COUNT_CONSOLE'][$key] = $count->c;
            }
        }
        if (isset($_SESSION['OCS']['COUNT_CONSOLE'][$key]) and is_numeric($_SESSION['OCS']['COUNT_CONSOLE'][$key])) {
            $id_count = $_SESSION['OCS']['COUNT_CONSOLE'][$key];
            if (is_array($link[$key]) and $id_count != 0) {
                if (isset($link[$key]['PAGE'])) {
                    $link_me_begin = "<a href='index.php?" . PAG_INDEX . "=" . $pages_refs[$link[$key]['PAGE']];
                    if (isset($multi_search[$key]['FIELD'])) {
                        //'ARG'=>'&fields=HARDWARE-LASTCOME&comp=tall&values='.date($l->g(1242))
                        $link_me_begin .= "&fields=" . $multi_search[$key]['FIELD'] . "&comp=" . $multi_search[$key]['COMP'] . "&values=" . $multi_search[$key]['VALUE'] . "&values2=" . $multi_search[$key]['VALUE2'] . "&type_field=" . $multi_search[$key]['TYPE_FIELD'];
                    }
                    $link_me_begin .= "'>";
                    $link_me_end = "</a>";
                } elseif (isset($link[$key]['RELOAD'])) {
                    $link_me_begin = "<a href=# OnClick='pag(\"" . $link[$key]['RELOAD'] . "\",\"SHOW_ME\",\"" . $form_name . "\");'>";
                    $link_me_end = "</a>";
                }
            } else {
                $link_me_begin = "";
                $link_me_end = "";
            }
            echo $value . "</font></td><td>&nbsp;</td><td align=center><font size=2><B>" . $link_me_begin . $id_count . $link_me_end . "</B></font></td>" . $icon . "</tr><tr><td align =center><font size=2>";
        } elseif ($_SESSION['OCS']['DEBUG'] == 'ON') {
            echo "<font color=red><b>ERROR=>" . $value . "</b></font></font></td><td>&nbsp;</td><td align=center></font></td>" . $icon . "</tr><tr><td align =center><font size=2>";
        }
    }
    echo "</table>";
}
Ejemplo n.º 19
0
    // select the main database
    mysql_select_db($db_ocs, $link_ocs);
    $resOp = mysql2_query_secure($reqOp, $link_ocs, $argOp);
    $rowOp = mysql_fetch_object($resOp);
    if (isset($rowOp->accesslvl)) {
        $lvluser = $rowOp->accesslvl;
        $ms_cfg_file = $_SESSION['OCS']['CONF_PROFILS_DIR'] . $lvluser . "_config.txt";
        $search = array('RESTRICTION' => 'MULTI');
        $res = read_configuration($ms_cfg_file, $search);
        $restriction = $res['RESTRICTION']['GUI'];
        //if this user has RESTRICTION
        //search all tag for this user
        if ($restriction == 'YES') {
            $sql = "select tag from tags where login='******'";
            $arg = array($_SESSION['OCS']["loggeduser"]);
            $res = mysql2_query_secure($sql, $link_ocs, $arg);
            while ($row = mysql_fetch_object($res)) {
                $list_tag[$row->tag] = $row->tag;
            }
            if (!isset($list_tag)) {
                $ERROR = $l->g(893);
            }
        } elseif ($restriction != 'NO') {
            $ERROR = $restriction;
        }
    } else {
        $ERROR = $l->g(894);
    }
} else {
    $ERROR = $l->g(1278);
}
function show_packages($systemid, $page = "ms_computer")
{
    global $l, $pages_refs, $ii, $td3, $td2, $td4;
    $query = "SELECT a.name, d.tvalue,d.ivalue,d.comments,e.fileid, e.pack_loc,h.name as name_server,h.id,a.comment\n\t\t\tFROM devices d left join download_enable e on e.id=d.ivalue\n\t\t\t\t\t\tLEFT JOIN download_available a ON e.fileid=a.fileid\n\t\t\t\t\t\tLEFT JOIN hardware h on h.id=e.server_id\n\t\t\tWHERE d.name='DOWNLOAD' and a.name != '' and pack_loc != ''   AND d.hardware_id=%s\n\t\t\tunion\n\t\t\tSELECT '%s', d.tvalue,d.ivalue,d.comments,e.fileid, '%s',h.name,h.id,a.comment \n\t\t\tFROM devices d left join download_enable e on e.id=d.ivalue\n\t\t\t\t\t\tLEFT JOIN download_available a ON e.fileid=a.fileid\n\t\t\t\t\t\tLEFT JOIN hardware h on h.id=e.server_id\n\t\t\tWHERE d.name='DOWNLOAD' and a.name is null and pack_loc is null  AND d.hardware_id=%s";
    $arg_query = array($systemid, $l->g(1129), $l->g(1129), $systemid);
    $resDeploy = mysql2_query_secure($query, $_SESSION['OCS']["readServer"], $arg_query);
    if (mysqli_num_rows($resDeploy) > 0) {
        while ($valDeploy = mysqli_fetch_array($resDeploy)) {
            $ii++;
            $td3 = $ii % 2 == 0 ? $td2 : $td4;
            if (strpos($valDeploy["comment"], "[VISIBLE=1]") or strpos($valDeploy["comment"], "[VISIBLE=]") or !$_SESSION['OCS']['profile']->getRestriction('TELEDIFF_VISIBLE') and strpos($valDeploy["comment"], "[VISIBLE=0]") or !strpos($valDeploy["comment"], "[VISIBLE") or $_SESSION['OCS']['profile']->getRestriction('TELEDIFF_VISIBLE', 'NO') == "NO" and preg_match("[VISIBLE=0]", $valDeploy["comment"])) {
                //echo $valDeploy["comment"];
                //	echo $_SESSION['OCS']['profile']->getRestriction('TELEDIFF_VISIBLE');
                echo "<tr>";
                echo "<td bgcolor='white' align='center' valign='center'><img width='15px' src='image/red.png'></td>";
                echo $td3 . $l->g(498) . " <b>" . $valDeploy["name"] . "</b>";
                if (isset($valDeploy["fileid"])) {
                    echo "(<small>" . $valDeploy["fileid"] . "</small>)";
                }
                if ($valDeploy["name_server"] != "") {
                    echo " (" . $l->g(499) . " redistrib: <a href='index.php?" . PAG_INDEX . "=" . $pages_refs[$page] . "&head=1&systemid=" . $valDeploy["id"] . "' target='_blank'><b>" . $valDeploy["name_server"] . "</b></a>";
                } else {
                    echo " (" . $l->g(499) . ": " . $valDeploy["pack_loc"] . " ";
                }
                echo ")</td>";
                if ($page == "ms_computer") {
                    echo $td3 . $l->g(81) . ": " . ($valDeploy["tvalue"] != "" ? $valDeploy["tvalue"] : $l->g(482));
                    echo $valDeploy["comments"] != "" ? " (" . $valDeploy["comments"] . ")" : "";
                    echo "</td>";
                    if ($_SESSION['OCS']['profile']->getConfigValue('TELEDIFF') == "YES") {
                        echo "{$td3} <a href='index.php?" . PAG_INDEX . "=" . $pages_refs[$page] . "&head=1&suppack=" . $valDeploy["ivalue"] . "&systemid=" . urlencode($systemid) . "&option=cd_configuration'>" . $l->g(122) . "</a></td>";
                    } elseif (strstr($valDeploy["tvalue"], 'ERR_') or strstr($valDeploy["tvalue"], 'EXIT_CODE')) {
                        echo $td3 . "<a href='index.php?" . PAG_INDEX . "=" . $pages_refs[$page] . "&head=1&affect_reset=" . $valDeploy["ivalue"] . "&systemid=" . urlencode($systemid) . "&option=cd_configuration'>" . $l->g(113) . "</a>";
                        if ($valDeploy["name"] != $l->g(1129)) {
                            echo $td3 . "<a href='index.php?" . PAG_INDEX . "=" . $pages_refs[$page] . "&head=1&affect_again=" . $valDeploy["ivalue"] . "&systemid=" . urlencode($systemid) . "&option=cd_configuration'>" . $l->g(1246) . "</a></td>";
                        }
                    } elseif (strstr($valDeploy["tvalue"], 'NOTIFIED')) {
                        if (isset($valDeploy["comments"]) and strtotime($valDeploy["comments"]) < strtotime("-12 week")) {
                            echo $td3 . "<a href='index.php?" . PAG_INDEX . "=" . $pages_refs[$page] . "&head=1&reset_notified=" . $valDeploy["ivalue"] . "&systemid=" . urlencode($systemid) . "&option=cd_configuration'><img src=image/delete-small.png></a>";
                        }
                    }
                } else {
                    if ($_SESSION['OCS']['profile']->getConfigValue('TELEDIFF') == "YES") {
                        echo "{$td3} <a href='index.php?" . PAG_INDEX . "=" . $pages_refs[$page] . "&popup=1&suppack=" . $valDeploy["ivalue"] . "&systemid=" . urlencode($systemid) . "&option=" . urlencode($l->g(500)) . "'>" . $l->g(122) . "</a></td>";
                    }
                    show_stat($valDeploy["fileid"]);
                    echo "</tr>";
                    //print_r($valDeploy);
                }
                echo "</tr>";
            }
        }
    }
}
} else {
    $ajax = false;
}
print_item_header($l->g(54));
if (!isset($protectedPost['SHOW'])) {
    $protectedPost['SHOW'] = 'NOSHOW';
}
$form_name = "affich_processors";
$table_name = $form_name;
$tab_options = $protectedPost;
$tab_options['form_name'] = $form_name;
$tab_options['table_name'] = $table_name;
echo open_form($form_name);
$sql = "select id from cpus where hardware_id=%s";
$arg = $systemid;
$res = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg);
$val = mysqli_fetch_array($res);
if (isset($val['id'])) {
    $list_fields = array($l->g(64) => 'MANUFACTURER', $l->g(66) => 'TYPE', $l->g(36) => 'SERIALNUMBER', $l->g(429) => 'SPEED', $l->g(1317) => 'CORES', $l->g(1318) => 'L2CACHESIZE', $l->g(1247) => 'CPUARCH', $l->g(1312) => 'DATA_WIDTH', $l->g(1313) => 'CURRENT_ADDRESS_WIDTH', $l->g(1314) => 'LOGICAL_CPUS', $l->g(1319) => 'VOLTAGE', $l->g(1315) => 'CURRENT_SPEED', $l->g(1316) => 'SOCKET');
    $list_col_cant_del = $list_fields;
    $default_fields = $list_fields;
    $queryDetails = "SELECT * FROM cpus WHERE (hardware_id={$systemid})";
} else {
    $list_fields = array($l->g(66) => 'PROCESSORT', $l->g(377) => 'PROCESSORS', $l->g(55) => 'PROCESSORN');
    $list_col_cant_del = $list_fields;
    $default_fields = $list_fields;
    //	$tab_options['FILTRE']=array('NAME'=>$l->g(49),'MANUFACTURER'=>$l->g(64),'TYPE'=>$l->g(66));
    $queryDetails = "SELECT * FROM hardware WHERE (id={$systemid})";
}
ajaxtab_entete_fixe($list_fields, $default_fields, $tab_options, $list_col_cant_del);
echo close_form();
function id_without_idgroups($list_id)
{
    $sql = "select id from hardware where deviceid <> '_SYSTEMGROUP_' \n\t\t\t\t\t\t\t\t\t\tAND deviceid <> '_DOWNLOADGROUP_' \n\t\t\t\t\t\t\t\t\t\tAND id in ";
    $arg = array();
    $sql = mysql2_prepare($sql, $arg, $list_id);
    $result = mysql2_query_secure($sql['SQL'], $_SESSION['OCS']["readServer"], $sql['ARG']);
    while ($item = mysqli_fetch_object($result)) {
        $res[$item->id] = $item->id;
    }
    return $res;
}
function delete_tab($id_tab)
{
    $info_fields_into_tab = find_all_field_by_tab($id_tab);
    if (isset($info_fields_into_tab) and $info_fields_into_tab != '') {
        $result = delete_field($info_fields_into_tab);
    } else {
        $result = true;
    }
    if ($result) {
        $id_tab = prepare_id($id_tab);
        if (is_array($id_tab)) {
            $sql_downloadwk_tab_values = "DELETE FROM downloadwk_tab_values WHERE ID in ";
            $downloadwk_tab_values = mysql2_prepare($sql_downloadwk_tab_values, array(), $id_tab);
            mysql2_query_secure($downloadwk_tab_values['SQL'], $_SESSION['OCS']["writeServer"], $downloadwk_tab_values['ARG']);
            addLog('DEL_WK_TELEDIFF', 'delete TAB (downloadwk_tab_values) => ' . mysql_affected_rows() . ' values');
        }
    }
}
 echo open_form($form_name);
 onglet($list_tab, $form_name, "onglet", 6);
 echo '<div class="mlt_bordure" >';
 if ($_SESSION['OCS']['profile']->getConfigValue('ACCOUNTINFO') == 'YES') {
     $show_admin_button = "<a href=# OnClick='pag(\"ADMIN\",\"ADMIN\",\"" . $form_name . "\");'>";
     if (isset($_SESSION['OCS']['ADMIN']['ACCOUNTINFO'])) {
         $show_admin_button .= "<img src='image/success.png'></a>";
     } else {
         $show_admin_button .= "<img src='image/modif_tab.png'></a>";
     }
 } else {
     $show_admin_button = '';
 }
 $sql_admin_info = "select ID,TYPE,NAME,COMMENT,NAME_ACCOUNTINFO,SHOW_ORDER from accountinfo_config where ID_TAB = %s and account_type='SNMP'\n\t\t\t\t\t\torder by SHOW_ORDER ASC";
 $arg_admin_info = array($protectedPost['onglet']);
 $res_admin_info = mysql2_query_secure($sql_admin_info, $_SESSION['OCS']["readServer"], $arg_admin_info);
 $num_row = mysqli_num_rows($res_admin_info);
 $name_field = array();
 $tab_name = array();
 $type_field = array();
 $value_field = array();
 $config['COMMENT_AFTER'] = array();
 $config['SELECT_DEFAULT'] = array();
 $config['JAVASCRIPT'] = array();
 $config['SIZE'] = array();
 $config['DDE'] = array();
 $nb_row = 1;
 while ($val_admin_info = mysqli_fetch_array($res_admin_info)) {
     array_push($config['DDE'], $systemid);
     //if name_accountinfo is not null
     //column name in accountinfo table is name_accountinfo
Ejemplo n.º 25
0
    $search_soft['SQL'] .= " where name like '%s'";
    $search_soft['ARG'] = array($protectedPost['onglet'] . "%");
    $and_where = " where ";
    if (isset($protectedPost['NAME_RESTRICT']) and $protectedPost['NAME_RESTRICT'] != "") {
        //$forcedRequest['SQL'].= $and_where." name like '%s' ";
        //$forcedRequest['ARG']=array("%".$protectedPost['NAME_RESTRICT']."%");
        $search_soft['SQL'] .= " and name like '%s' ";
        array_push($search_soft['ARG'], "%" . $protectedPost['NAME_RESTRICT'] . "%");
        $and_where = " and ";
    }
    /*if (isset($protectedPost['CLASS']) and $protectedPost['CLASS'] != ""){
    	//	$fin_sql=" and dico_soft.extracted is not null ";
    		$forcedRequest.= $and_where." (dico_soft.formatted in ('".implode("','",$list_soft_by_statut[$protectedPost['CLASS']])."') ) and ";
    		$search_soft.=" and (dico_soft.formatted in ('".implode("','",$list_soft_by_statut[$protectedPost['CLASS']])."') ) ";		
    	}*/
    $result_search_soft = mysql2_query_secure($search_soft['SQL'], $_SESSION['OCS']["readServer"], $search_soft['ARG']);
    $list_soft = "";
    while ($item_search_soft = mysql_fetch_object($result_search_soft)) {
        if (isset($_SESSION['OCS']['USE_NEW_SOFT_TABLES']) and $_SESSION['OCS']['USE_NEW_SOFT_TABLES'] == 1) {
            $list_soft[] = $item_search_soft->id;
        } else {
            $list_soft[] = $item_search_soft->name;
        }
    }
}
if (isset($_SESSION['OCS']['USE_NEW_SOFT_TABLES']) and $_SESSION['OCS']['USE_NEW_SOFT_TABLES'] == 1) {
    $field_name_soft = "s.name_id";
} elseif ($_SESSION['OCS']["usecache"] == 1) {
    $field_name_soft = "s.name";
} else {
    $field_name_soft = "s.name";
Ejemplo n.º 26
0
    }
}
echo "<tr><td colspan=100></td></tr>";
//TELEDEPLOY
show_packages($systemid);
$hrefBase = "index.php?" . PAG_INDEX . "=" . $pages_refs['ms_computer'] . "&head=1&systemid=" . urlencode($systemid) . "&option=cd_configuration";
echo "<tr><td colspan='10' align='right'>";
if ($_SESSION['OCS']['CONFIGURATION']['TELEDIFF'] == "YES") {
    echo "<a href=# Onclick=window.open(\"index.php?" . PAG_INDEX . "=" . $pages_refs['ms_custom_pack'] . "&head=1&idchecked=" . $systemid . "&origine=mach\",\"rollo\",\"location=0,status=0,scrollbars=1,menubar=0,resizable=0,width=800,height=500\");>" . $l->g(501) . "</a> ";
}
$reqGroups = "SELECT h.name,h.id,h.workgroup \n\t\t\t\t\t  FROM hardware h,groups g \n\t\t\t\t\t  WHERE  g.hardware_id=h.id  and h.deviceid='_SYSTEMGROUP_'";
if (!($_SESSION['OCS']['CONFIGURATION']['GROUPS'] == "YES")) {
    $reqGroups .= " and workgroup = 'GROUP_4_ALL'";
}
$reqGroups .= " order by h.name";
$resGroups = mysql2_query_secure($reqGroups, $_SESSION['OCS']["readServer"]);
$first = true;
while ($valGroups = mysql_fetch_array($resGroups)) {
    if ($first) {
        echo $l->g(386) . " <a href=# OnClick=window.location='{$hrefBase}&actgrp=1&grp='+document.getElementById(\"groupcombo\").options[document.getElementById(\"groupcombo\").selectedIndex].value>" . $l->g(589) . "</a>";
        echo " <select id='groupcombo'>";
        $first = false;
    }
    echo "<option value='" . $valGroups["id"] . "'>" . $valGroups["name"] . "</option>";
}
if (!$first) {
    echo "</select>";
}
echo "</td></tr>";
//}
echo "</table><br>";
        }
        if (isset($form_to_reload)) {
            echo "<script language='javascript'> window.opener.document." . $form_to_reload . ".submit();</script>";
        }
    } else {
        echo "<script>alert('" . $l->g(983) . "')</script>";
    }
}
$default = look_config_default_values(array('DOWNLOAD', 'DOWNLOAD_CYCLE_LATENCY', 'DOWNLOAD_PERIOD_LENGTH', 'DOWNLOAD_FRAG_LATENCY', 'DOWNLOAD_PERIOD_LATENCY', 'DOWNLOAD_TIMEOUT', 'PROLOG_FREQ'));
$optdefault = $default["ivalue"];
//not a sql query
if (isset($protectedGet['origine']) and is_numeric($protectedGet['idchecked'])) {
    //looking for value of systemid
    $sql_value_idhardware = "select NAME,IVALUE,TVALUE from devices where name != 'DOWNLOAD' and hardware_id=%s";
    $arg_value_idhardware = $protectedGet['idchecked'];
    $result_value = mysql2_query_secure($sql_value_idhardware, $_SESSION['OCS']["readServer"], $arg_value_idhardware);
    while ($value = mysqli_fetch_array($result_value)) {
        $optvalue[$value["NAME"]] = $value["IVALUE"];
        $optvalueTvalue[$value["NAME"]] = $value["TVALUE"];
    }
    $champ_ignored = 0;
} elseif ($list_id) {
    $tab_hadware_id = explode(",", $list_id);
    $champ_ignored = 1;
}
if ($list_id) {
    onglet($def_onglets, $form_name, 'onglet', 7);
    echo '<div class="mlt_bordure" >';
    if ($protectedPost['onglet'] == 'INV') {
        include 'ms_custom_frequency.php';
    }
Ejemplo n.º 28
0
                 $fileid_show = array();
                 break;
             }
         }
         if ($fileid_show == array()) {
             $fileid_show = $fileid_total;
         }
     }
 } else {
     $perim = 'GROUPS';
     //origine => group
     if ($protectedGet['origine'] == "group") {
         //search info of this group
         $queryMachine = "SELECT REQUEST,\r\n\t\t\t\t\t\t  CREATE_TIME,\r\n\t\t\t\t\t\t  NAME,\r\n\t\t\t\t\t\t  XMLDEF,\r\n\t\t\t\t\t\t  DESCRIPTION,LASTDATE,OSCOMMENTS,DEVICEID FROM hardware h left join groups g on g.hardware_id=h.id \r\n\t\t\t\t  WHERE ID='%s' AND (deviceid ='_SYSTEMGROUP_' or deviceid='_DOWNLOADGROUP_')";
         $argMachine = $protectedGet['idchecked'];
         $result = mysql2_query_secure($queryMachine, $_SESSION['OCS']["readServer"], $argMachine);
         $item = mysql_fetch_object($result);
         $arg_affect_pack = array();
         //This group is define as TEST zone
         if ($item->NAME == $conf_Wk['tvalue']['IT_SET_NAME_TEST']) {
             $restrict = $conf_Wk['tvalue']['IT_SET_NIV_TEST'];
             $msg_wk .= $l->g(1192) . "<br>";
             array_push($arg_affect_pack, $restrict);
             $fileid_show = array_merge($fileid_test, $fileid_show);
         }
         //This group is define as RESTRICT zone
         if ($item->NAME == $conf_Wk['tvalue']['IT_SET_NAME_LIMIT']) {
             $restrict = $conf_Wk['tvalue']['IT_SET_NIV_REST'];
             $msg_wk .= $l->g(1193) . "<br>";
             array_push($arg_affect_pack, $restrict);
             $fileid_show = array_merge($fileid_rest, $fileid_show);
             $table[$i] = "HARDWARE";
             $field[$i] = "ID";
             $field_value_complement[$i] = "";
         }
     }
 }
 if (isset($_SESSION['OCS']['USE_NEW_SOFT_TABLES']) and $_SESSION['OCS']['USE_NEW_SOFT_TABLES'] == 1 and $table[$i] == "SOFTWARES" and ($field[$i] == 'NAME' or $field[$i] == "VERSION")) {
     if ($field[$i] == 'NAME') {
         $table_explode = "type_softwares_name";
     } else {
         $table_explode = "type_softwares_version";
     }
     $sql_temp = "select name, id from %s where name %s '%s'";
     //A REVOIR POUR ENLEVER LES ' DEVANT LE CHAMP DE RECHERCHE
     $arg_temp = array($table_explode, $field_compar[$i], str_replace("'", "", $field_value[$i]));
     $result_temp = mysql2_query_secure($sql_temp, $_SESSION['OCS']["readServer"], $arg_temp);
     while ($val_temp = mysqli_fetch_array($result_temp)) {
         $list[] = $val_temp['id'];
         if ($limit_result_cache < count($list)) {
             $ERROR = $l->g(959);
             break;
         }
     }
     if (!isset($list)) {
         $ERROR = $l->g(960);
     } else {
         $field[$i] = $field[$i] . "_ID";
         $field_compar[$i] = " IN ";
         $field_value[$i] = " (" . implode(",", $list) . ")";
         $field_modif = "field_value";
         $sql_temp = generate_secure_sql($sql_temp, $arg_temp);
Ejemplo n.º 30
0
function exec_fichier_sql($fichier)
{
    $db_file = $fichier;
    $dbf_handle = @fopen($db_file, "r");
    if (!$dbf_handle) {
        msg_error($l->g(2112) . " : " . $fichier);
        return true;
    } else {
        if (filesize($db_file) > 0) {
            $sql_query = fread($dbf_handle, filesize($db_file));
            fclose($dbf_handle);
            $data_sql = explode(";", $sql_query);
            foreach ($data_sql as $k => $v) {
                if (trim($v) != "") {
                    mysql2_query_secure($v, $_SESSION['OCS']["writeServer"]);
                }
            }
            return false;
        }
        return true;
    }
}