unset($_SESSION['OCS']['COUNT_CONSOLE']);
}
if ($protectedPost['ADMIN'] == 'ADMIN' and !isset($_SESSION['OCS']['ADMIN_CONSOLE'])) {
    $_SESSION['OCS']['ADMIN_CONSOLE'] = 'ADMIN';
} elseif ($protectedPost['ADMIN'] == 'ADMIN' and isset($_SESSION['OCS']['ADMIN_CONSOLE'])) {
    unset($_SESSION['OCS']['ADMIN_CONSOLE']);
}
if (isset($protectedPost['VISIBLE']) and $protectedPost['VISIBLE'] != '' and isset($_SESSION['OCS']['ADMIN_CONSOLE'])) {
    insert_update($protectedPost['VISIBLE'], 1, '', 'IVALUE');
}
if (isset($protectedPost['NO_VISIBLE']) and $protectedPost['NO_VISIBLE'] != '' and isset($_SESSION['OCS']['ADMIN_CONSOLE'])) {
    delete($protectedPost['NO_VISIBLE']);
}
if (isset($protectedPost['UPDATE_VALUE']) and $protectedPost['UPDATE_VALUE'] != '' and isset($_SESSION['OCS']['ADMIN_CONSOLE'])) {
    $arg = look_config_default_values($protectedPost['UPDATE_VALUE']);
    insert_update($protectedPost['UPDATE_VALUE'], $protectedPost[$protectedPost['UPDATE_VALUE']], $arg['ivalue'][$protectedPost['UPDATE_VALUE']], 'IVALUE');
}
require_once 'require/function_console.php';
$data_on = define_tab();
$data_tab = show_active_tab($data_on);
echo open_form($form_name);
if (isset($protectedPost["onglet"]) and !isset($data_tab['DATA'][$protectedPost["onglet"]])) {
    $protectedPost["onglet"] = $data_tab['DEFAULT'];
}
if ($data_tab['DATA'] != array()) {
    show_tabs($data_tab['DATA'], $form_name, "onglet", 8);
    echo '<div class="right-content"><div class="mlt_bordure" >';
    if ($_SESSION['OCS']['profile']->getConfigValue('CONSOLE') == 'YES') {
        echo "<table align='right' border='0'><tr><td colspan=10 align='right'><a href=# OnClick='pag(\"ADMIN\",\"ADMIN\",\"" . $form_name . "\");'>";
        if (isset($_SESSION['OCS']['ADMIN_CONSOLE']) and $_SESSION['OCS']['ADMIN_CONSOLE'] == 'ADMIN') {
            echo "<img src='image/success.png'>";
Example #2
0
         $affected = count($matches[0]);
         begin();
         $separator = $_POST["separator"] == "csv" ? "," : ($_POST["separator"] == "tsv" ? "\t" : ";");
         foreach ($matches[0] as $key => $val) {
             preg_match_all("~((\"[^\"]*\")+|[^{$separator}]*){$separator}~", $val . $separator, $matches2);
             if (!$key && !array_diff($matches2[1], $cols)) {
                 //! doesn't work with column names containing ",\n
                 // first row corresponds to column names - use it for table structure
                 $cols = $matches2[1];
                 $affected--;
             } else {
                 $set = array();
                 foreach ($matches2[1] as $i => $col) {
                     $set[idf_escape($cols[$i])] = $col == "" && $fields[$cols[$i]]["null"] ? "NULL" : q(str_replace('""', '"', preg_replace('~^"|"$~', '', $col)));
                 }
                 $result = insert_update($TABLE, $set, $primary);
                 if (!$result) {
                     break;
                 }
             }
         }
         if ($result) {
             queries("COMMIT");
         }
         queries_redirect(remove_from_uri("page"), lang('%d row(s) have been imported.', $affected), $result);
         queries("ROLLBACK");
         // after queries_redirect() to not overwrite error
     } else {
         $error = upload_error($file);
     }
 }
function update_default_value($POST)
{
    global $l;
    $i = 0;
    //tableau des champs ou il faut juste mettre � jour le tvalue
    $array_simple_tvalue = array('DOWNLOAD_SERVER_URI', 'DOWNLOAD_SERVER_DOCROOT', 'OCS_FILES_FORMAT', 'OCS_FILES_PATH', 'CONEX_LDAP_SERVEUR', 'CONEX_LDAP_PORT', 'CONEX_DN_BASE_LDAP', 'CONEX_LOGIN_FIELD', 'CONEX_LDAP_PROTOCOL_VERSION', 'CONEX_ROOT_DN', 'CONEX_ROOT_PW', 'CONEX_LDAP_CHECK_FIELD1_NAME', 'CONEX_LDAP_CHECK_FIELD1_VALUE', 'CONEX_LDAP_CHECK_DEFAULT_ROLE', 'CONEX_LDAP_CHECK_FIELD1_ROLE', 'CONEX_LDAP_CHECK_FIELD2_NAME', 'CONEX_LDAP_CHECK_FIELD2_VALUE', 'CONEX_LDAP_CHECK_FIELD2_ROLE', 'IT_SET_NAME_TEST', 'IT_SET_NAME_LIMIT', 'IT_SET_TAG_NAME', 'IT_SET_NIV_CREAT', 'IT_SET_NIV_TEST', 'IT_SET_NIV_REST', 'IT_SET_NIV_TOTAL', 'EXPORT_SEP', 'WOL_PORT');
    //tableau des champs ou il faut juste mettre � jour le ivalue
    $array_simple_ivalue = array('INVENTORY_DIFF', 'INVENTORY_TRANSACTION', 'INVENTORY_WRITE_DIFF', 'INVENTORY_SESSION_ONLY', 'INVENTORY_CACHE_REVALIDATE', 'LOGLEVEL', 'PROLOG_FREQ', 'LOCK_REUSE_TIME', 'TRACE_DELETED', 'SESSION_VALIDITY_TIME', 'IPDISCOVER_BETTER_THRESHOLD', 'IPDISCOVER_LATENCY', 'IPDISCOVER_MAX_ALIVE', 'IPDISCOVER_NO_POSTPONE', 'IPDISCOVER_USE_GROUPS', 'ENABLE_GROUPS', 'GROUPS_CACHE_OFFSET', 'GROUPS_CACHE_REVALIDATE', 'REGISTRY', 'GENERATE_OCS_FILES', 'OCS_FILES_OVERWRITE', 'PROLOG_FILTER_ON', 'INVENTORY_FILTER_ENABLED', 'INVENTORY_FILTER_FLOOD_IP', 'INVENTORY_FILTER_FLOOD_IP_CACHE_TIME', 'INVENTORY_FILTER_ON', 'LOG_GUI', 'DOWNLOAD', 'DOWNLOAD_CYCLE_LATENCY', 'DOWNLOAD_FRAG_LATENCY', 'DOWNLOAD_GROUPS_TRACE_EVENTS', 'DOWNLOAD_PERIOD_LATENCY', 'DOWNLOAD_TIMEOUT', 'DOWNLOAD_PERIOD_LENGTH', 'DEPLOY', 'AUTO_DUPLICATE_LVL', 'TELEDIFF_WK', 'IT_SET_PERIM', 'IT_SET_MAIL', 'IT_SET_MAIL_ADMIN', 'SNMP', 'DOWNLOAD_REDISTRIB', 'SNMP_INVENTORY_DIFF', 'TAB_CACHE', 'INVENTORY_CACHE_ENABLED', 'USE_NEW_SOFT_TABLES');
    //tableau des champs ou il faut interpr�ter la valeur retourner et mettre � jour ivalue
    $array_interprete_tvalue = array('DOWNLOAD_REP_CREAT' => 'DOWNLOAD_REP_CREAT_edit', 'DOWNLOAD_PACK_DIR' => 'DOWNLOAD_PACK_DIR_edit', 'IPDISCOVER_IPD_DIR' => 'IPDISCOVER_IPD_DIR_edit', 'LOG_DIR' => 'LOG_DIR_edit', 'LOG_SCRIPT' => 'LOG_SCRIPT_edit', 'DOWNLOAD_URI_FRAG' => 'DOWNLOAD_URI_FRAG_edit', 'DOWNLOAD_URI_INFO' => 'DOWNLOAD_URI_INFO_edit', 'LOG_SCRIPT' => 'LOG_SCRIPT_edit', 'CONF_PROFILS_DIR' => 'CONF_PROFILS_DIR_edit', 'OLD_CONF_DIR' => 'OLD_CONF_DIR_edit', 'LOCAL_URI_SERVER' => 'LOCAL_URI_SERVER_edit', 'WOL_BIOS_PASSWD' => 'WOL_BIOS_PASSWD_edit');
    //tableau des champs ou il faut interpr�ter la valeur retourner et mettre � jour tvalue
    $array_interprete_ivalue = array('FREQUENCY' => 'FREQUENCY_edit', 'IPDISCOVER' => 'IPDISCOVER_edit', 'INVENTORY_VALIDITY' => 'INVENTORY_VALIDITY_edit');
    //recherche des valeurs par d�faut
    $sql_exist = " select NAME,ivalue,tvalue from config ";
    $result_exist = mysql2_query_secure($sql_exist, $_SESSION['OCS']["readServer"]);
    while ($value_exist = mysql_fetch_array($result_exist)) {
        if ($value_exist["ivalue"] != null) {
            $optexist[$value_exist["NAME"]] = $value_exist["ivalue"];
        } elseif ($value_exist["tvalue"] != null) {
            $optexist[$value_exist["NAME"]] = $value_exist["tvalue"];
        } elseif ($value_exist["tvalue"] == null and $value_exist["ivalue"] == null) {
            $optexist[$value_exist["NAME"]] = 'null';
        }
    }
    //pour obliger à prendre en compte
    //le AUTO_DUPLICATE_LVL quand il est vide
    //on doit l'initialiser tout le temps
    if ($POST['onglet'] == $l->g(499)) {
        insert_update('AUTO_DUPLICATE_LVL', 0, $optexist['AUTO_DUPLICATE_LVL'], 'ivalue');
        $optexist['AUTO_DUPLICATE_LVL'] = '0';
    }
    //check all post
    foreach ($POST as $key => $value) {
        if (!isset($optexist[$key])) {
            $optexist[$key] = '';
        }
        if ($key == "INVENTORY_CACHE_ENABLED" and $value == '1' and $optexist['INVENTORY_CACHE_ENABLED'] != $value) {
            $sql = "update engine_persistent set ivalue=1 where name='INVENTORY_CACHE_CLEAN_DATE'";
            $arg = '';
            mysql2_query_secure($sql, $_SESSION['OCS']["writeServer"], $arg, $l->g(821));
        }
        $name_field_modif = '';
        $value_field_modif = '';
        //check AUTO_DUPLICATE_LVL. Particular field
        if (strstr($key, 'AUTO_DUPLICATE_LVL_')) {
            $AUTO_DUPLICATE['AUTO_DUPLICATE_LVL_1'] = $POST['AUTO_DUPLICATE_LVL_1'];
            $AUTO_DUPLICATE['AUTO_DUPLICATE_LVL_2'] = $POST['AUTO_DUPLICATE_LVL_2'];
            $AUTO_DUPLICATE['AUTO_DUPLICATE_LVL_3'] = $POST['AUTO_DUPLICATE_LVL_3'];
            $AUTO_DUPLICATE['AUTO_DUPLICATE_LVL_4'] = $POST['AUTO_DUPLICATE_LVL_4'];
            $AUTO_DUPLICATE['AUTO_DUPLICATE_LVL_5'] = $POST['AUTO_DUPLICATE_LVL_5'];
            $AUTO_DUPLICATE['AUTO_DUPLICATE_LVL_6'] = $POST['AUTO_DUPLICATE_LVL_6'];
            $value = auto_duplicate_lvl_poids($AUTO_DUPLICATE, 2);
            $key = 'AUTO_DUPLICATE_LVL';
        }
        if (in_array($key, $array_simple_tvalue)) {
            //update tvalue simple
            insert_update($key, $value, $optexist[$key], 'tvalue');
        } elseif (in_array($key, $array_simple_ivalue)) {
            //update ivalue simple
            insert_update($key, $value, $optexist[$key], 'ivalue');
        } elseif (isset($array_interprete_tvalue[$key])) {
            $name_field_modif = "tvalue";
            $value_field_modif = $array_interprete_tvalue[$key];
        } elseif (isset($key, $array_interprete_ivalue[$key])) {
            $name_field_modif = "ivalue";
            $value_field_modif = $array_interprete_ivalue[$key];
        }
        if ($name_field_modif != '') {
            if ($value == "DEFAULT") {
                delete($key);
            } elseif ($value == "CUSTOM" or $value == "ON") {
                insert_update($key, $POST[$value_field_modif], $optexist[$key], $name_field_modif);
            } elseif ($value == "ALWAYS" or $value == 'OFF') {
                insert_update($key, '0', $optexist[$key], $name_field_modif);
            } elseif ($value == "NEVER") {
                insert_update($key, '-1', $optexist[$key], $name_field_modif);
            }
        }
    }
}