function migrate_profiles_2_2()
{
    if (!file_exists(DOCUMENT_REAL_ROOT . '/config/profiles')) {
        mkdir(DOCUMENT_REAL_ROOT . '/config/profiles');
    }
    if (!is_writable(DOCUMENT_REAL_ROOT . '/config/profiles')) {
        msg_error($l->g(2116));
        exit;
    }
    $txt_serializer = new TxtProfileSerializer();
    $xml_serializer = new XMLProfileSerializer();
    foreach (scandir($_SESSION['OCS']['CONF_PROFILS_DIR']) as $file) {
        if (preg_match('/^(.+)_config\\.txt$/', $file, $matches) and $matches[1] != '4all') {
            $profile_name = $matches[1];
            $profile_data = read_profil_file($profile_name);
            $profile = $txt_serializer->unserialize($profile_name, $profile_data);
            $xml = $xml_serializer->serialize($profile);
            file_put_contents(DOCUMENT_REAL_ROOT . '/config/profiles/' . $profile_name . '.xml', $xml);
        }
    }
}
示例#2
0
function create_profil($new_profil, $lbl_profil, $ref_profil)
{
    $new_value = read_profil_file($ref_profil);
    $new_value['INFO']['NAME'] = $lbl_profil;
    update_config_file($new_profil, $new_value, 'NO');
    //getcopy_config_file($protectedPost['ref_profil'],'YES',$protectedPost['new_profil']);
}
示例#3
0
<?php

//====================================================================================
// OCS INVENTORY REPORTS
// Copyleft Erwan GOALOU 2010 (erwan(at)ocsinventory-ng(pt)org)
// Web: http://www.ocsinventory-ng.org
//
// This code is open source and may be copied and modified as long as the source
// code is always made freely available.
// Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
//====================================================================================
//Select config file depending on user profile
$profil_data = read_profil_file($_SESSION['OCS']["lvluser"]);
if (is_array($profil_data)) {
    foreach ($profil_data as $key => $value) {
        $_SESSION['OCS'][$key] = $value;
    }
}
//Config for all user
$config_file = read_config_file();
if (is_array($config_file)) {
    foreach ($config_file as $key => $value) {
        $_SESSION['OCS'][$key] = $value;
    }
}
//Splitting name_menu array for use with the "show_menu" javascript function
if (isset($_SESSION['OCS']['MENU'])) {
    foreach ($_SESSION['OCS']['MENU'] as $key => $value) {
        if (isset($_SESSION['OCS']['PAGE_PROFIL'][$key])) {
            $show_menu[$value]++;
        }
function admin_profil($form)
{
    global $protectedPost, $l, $pages_refs;
    $yes_no = array('YES' => $l->g(455), 'NO' => $l->g(454));
    $info_field = array('NAME' => array('INFO' => array('LBL' => $l->g(1153) . ": ", 'VALUE' => '')), 'GUI' => array('RESTRICTION' => array('LBL' => $l->g(1154) . ": ", 'VALUE' => $yes_no)), 'TELEDIFF_ACTIVATE' => array('RESTRICTION' => array('LBL' => $l->g(1158) . ": ", 'VALUE' => $yes_no)), 'TELEDIFF_VISIBLE' => array('RESTRICTION' => array('LBL' => $l->g(1301) . ": ", 'VALUE' => $yes_no)), 'EXPORT_XML' => array('RESTRICTION' => array('LBL' => $l->g(1305), 'VALUE' => $yes_no)), 'WOL' => array('RESTRICTION' => array('LBL' => $l->g(1281) . ": ", 'VALUE' => $yes_no)), 'MACADD' => array('ADMIN_BLACKLIST' => array('LBL' => $l->g(1159) . ": ", 'VALUE' => $yes_no)), 'SERIAL' => array('ADMIN_BLACKLIST' => array('LBL' => $l->g(1160) . ": ", 'VALUE' => $yes_no)), 'IPDISCOVER' => array('ADMIN_BLACKLIST' => array('LBL' => $l->g(1161) . ": ", 'VALUE' => $yes_no), 'CONFIGURATION' => array('LBL' => $l->g(1172) . ": ", 'VALUE' => $yes_no)), 'TELEDIFF' => array('CONFIGURATION' => array('LBL' => $l->g(1162) . ": ", 'VALUE' => $yes_no)), 'CONFIG' => array('CONFIGURATION' => array('LBL' => $l->g(1163) . ": ", 'VALUE' => $yes_no)), 'GROUPS' => array('CONFIGURATION' => array('LBL' => $l->g(1164) . ": ", 'VALUE' => $yes_no)), 'CONSOLE' => array('CONFIGURATION' => array('LBL' => $l->g(1165) . ": ", 'VALUE' => $yes_no)), 'ALERTE_MSG' => array('CONFIGURATION' => array('LBL' => $l->g(1166) . ": ", 'VALUE' => $yes_no)), 'ACCOUNTINFO' => array('CONFIGURATION' => array('LBL' => $l->g(1167) . ": ", 'VALUE' => $yes_no)), 'CHANGE_ACCOUNTINFO' => array('CONFIGURATION' => array('LBL' => $l->g(1168) . ": ", 'VALUE' => $yes_no)), 'CHANGE_USER_GROUP' => array('CONFIGURATION' => array('LBL' => $l->g(1169) . ": ", 'VALUE' => $yes_no)), 'MANAGE_PROFIL' => array('CONFIGURATION' => array('LBL' => $l->g(1170) . ": ", 'VALUE' => $yes_no)), 'MANAGE_USER_GROUP' => array('CONFIGURATION' => array('LBL' => $l->g(1171) . ": ", 'VALUE' => $yes_no)), 'MANAGE_SMTP_COMMUNITIES' => array('CONFIGURATION' => array('LBL' => $l->g(1205) . ": ", 'VALUE' => $yes_no)), 'DELETE_COMPUTERS' => array('CONFIGURATION' => array('LBL' => $l->g(1272) . ": ", 'VALUE' => $yes_no)));
    $lbl_cat = array('INFO' => $l->g(1173), 'PAGE_PROFIL' => $l->g(1174), 'RESTRICTION' => $l->g(1175), 'ADMIN_BLACKLIST' => $l->g(1176), 'CONFIGURATION' => $l->g(1177));
    if ($protectedPost['Valid_modif_profil']) {
        //read profil file
        $forprofil = read_profil_file($protectedPost['PROFILS']);
        //read all profil value
        $forall = read_config_file();
        //build new tab with new values
        foreach ($info_field as $if_name => $if_value) {
            foreach ($if_value as $if_cat => $if_val) {
                if (isset($protectedPost[$if_name]) and $protectedPost['cat'] == $if_cat) {
                    $new_value[$if_cat][$if_name] = $protectedPost[$if_name];
                } else {
                    $new_value[$if_cat][$if_name] = $forprofil[$if_cat][$if_name];
                }
            }
        }
        foreach ($forall['URL'] as $name => $value) {
            if (isset($protectedPost[$name]) and $protectedPost['cat'] == "PAGE_PROFIL") {
                $new_value["PAGE_PROFIL"][$name] = '';
            }
        }
        if (!isset($new_value['PAGE_PROFIL'])) {
            $new_value['PAGE_PROFIL'] = $forprofil['PAGE_PROFIL'];
        }
        update_config_file($protectedPost['PROFILS'], $new_value);
        msg_success($l->g(1274));
    }
    $array_profil = get_profile_labels();
    echo $l->g(1196) . ": " . show_modif($array_profil, "PROFILS", 2, $form);
    echo "<a href=\"index.php?" . PAG_INDEX . "=" . $pages_refs['ms_new_profil'] . "&head=1&form=" . $form . "\"><img src=image/plus.png></a>";
    if (isset($protectedPost['PROFILS']) and $protectedPost['PROFILS'] != '') {
        $forall = read_config_file();
        $forprofil = read_profil_file($protectedPost['PROFILS'], 'WRITE');
        if (is_array($forprofil) and is_array($forall)) {
            foreach ($forprofil as $key => $value) {
                if (isset($lbl_cat[$key])) {
                    $data_on[$key] = $lbl_cat[$key];
                }
            }
            onglet($data_on, $form, "cat", 10);
            if (isset($forprofil[$protectedPost['cat']]) and $protectedPost['cat'] != 'PAGE_PROFIL') {
                $name_field = array();
                $type_field = array();
                $tab_name = array();
                $value_field = array();
                foreach ($info_field as $if_name => $if_value) {
                    foreach ($if_value as $if_cat => $if_val) {
                        if ($protectedPost['cat'] == $if_cat) {
                            if (isset($forprofil[$if_cat][$if_name])) {
                                $protectedPost[$if_name] = $forprofil[$if_cat][$if_name];
                            }
                            array_push($name_field, $if_name);
                            array_push($tab_name, $if_val['LBL']);
                            if (is_array($if_val['VALUE'])) {
                                array_push($type_field, 2);
                                if (!isset($protectedPost[$if_name])) {
                                    array_push($if_val['VALUE'], '');
                                }
                                array_push($value_field, $if_val['VALUE']);
                            } else {
                                array_push($type_field, 0);
                                array_push($value_field, replace_language($forprofil[$if_cat][$if_name]));
                            }
                        }
                    }
                }
                $tab_typ_champ = show_field($name_field, $type_field, $value_field);
                tab_modif_values($tab_name, $tab_typ_champ, $tab_hidden, array('button_name' => 'modif_profil'));
            } elseif ($protectedPost['cat'] == 'PAGE_PROFIL') {
                $champs = "<table align=center><tr><td align=center>";
                $i = 0;
                ksort($forall['URL']);
                foreach ($forall['URL'] as $key => $value) {
                    $champs .= "<input type='checkbox' name='" . $key . "' id='" . $key . "' ";
                    if (isset($forprofil[$protectedPost['cat']][$key])) {
                        $champs .= " checked ";
                    }
                    $champs .= " ></td><td>" . $key . "</td><td align=center>";
                    $i++;
                    if ($i == 4) {
                        $champs .= "</td></tr><tr><td align=center>";
                        $i = 0;
                    }
                }
                $champs .= "</td></tr></table>";
                tab_modif_values($champs, array(), array(), array('button_name' => 'modif_profil'));
            }
        }
    }
}