function validate_profile_create_form($data) { $errors = array(); $profiles = get_profile_labels(); // TODO check for field sizes // Check mandatory data $mandatory_fields = array('name', 'label', 'duplicate_profile'); foreach ($mandatory_fields as $field) { if (!$data[$field]) { $errors[$field][] = $l->g(1391); } } // Check dropdown lists if ($data['duplicate_profile'] and !isset($profiles[$data['duplicate_profile']])) { $errors['duplicate_profile'][] = $l->g(1392); } // Check profile name regex if ($data['name'] and !preg_match('/^[0-9A-Za-z]+$/', $data['name'])) { $errors['name'][] = $l->g(1394); } // Check profile name doesn't exist if ($data['name'] and isset($profiles[$data['name']])) { $errors['name'][] = $l->g(1395); } return $errors; }
function show_profile_create_form() { global $l; ?> <div class="form-frame form-frame-create-profile"> <h3><?php echo $l->g(1399); ?> </h3> <?php $field_options = array('field_class' => 'big-label'); echo open_form('create-profile', '#'); show_form_field(array(), array(), 'input', 'name', $l->g(1396), $field_options); show_form_field(array(), array(), 'input', 'label', $l->g(1397), $field_options); show_form_field(array(), array(), 'select', 'duplicate_profile', $l->g(1398), array_merge($field_options, array('options' => get_profile_labels()))); ?> <div class="form-buttons"> <input type="submit" value="<?php echo $l->g(1363); ?> "/> <input type="reset" value="<?php echo $l->g(1364); ?> "/> </div> <?php echo close_form(); ?> </div> <?php }
<?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 //==================================================================================== require_once 'require/function_users.php'; if (isset($protectedPost['Valid_modif'])) { $protectedPost['ACCESSLVL'] = $_SESSION['OCS']['lvluser']; $protectedPost['ID'] = $_SESSION['OCS']["loggeduser"]; $protectedPost['MODIF'] = $_SESSION['OCS']["loggeduser"]; $msg = add_user($_POST, get_profile_labels()); if ($msg != $l->g(374)) { msg_error($msg); } else { msg_success($l->g(1186)); } } $form_name = "pass"; echo open_form($form_name); admin_user($_SESSION['OCS']["loggeduser"], true); echo close_form();
parse_str($protectedPost['ocs']['0'], $params); $protectedPost += $params; ob_start(); $ajax = true; } else { $ajax = false; require_once 'views/users_views.php'; show_users_left_menu('ms_users'); echo '<div class="right-content">'; echo '<div class="mlt_bordure">'; echo '<h3>' . $l->g(1400) . '</h3>'; } require_once 'require/function_search.php'; require_once 'require/function_users.php'; // Définition des onglets $profiles = get_profile_labels(); $data_on = $profiles; $data_on[4] = $l->g(244); if ($_SESSION['OCS']['profile']->getConfigValue('MANAGE_PROFIL') == 'YES') { $data_on[5] = $l->g(1146); } $form_name = "admins"; $tab_options = $protectedPost; $tab_options['form_name'] = $form_name; echo open_form($form_name); $table_name = "TAB_ACCESSLVL" . $protectedPost['onglet']; if ($protectedPost['onglet'] == "") { $protectedPost['onglet'] = current($data_on); } //suppression d'une liste de users if (isset($protectedPost['del_check']) and $protectedPost['del_check'] != '') {
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')); } } } }
function pageConnexion($form_name) { global $l, $numeric, $sup1; require_once 'require/function_users.php'; //what ligne we need? $champs = array('CONEX_LDAP_SERVEUR' => 'CONEX_LDAP_SERVEUR', 'CONEX_LDAP_PORT' => 'CONEX_LDAP_PORT', 'CONEX_DN_BASE_LDAP' => 'CONEX_DN_BASE_LDAP', 'CONEX_LOGIN_FIELD' => 'CONEX_LOGIN_FIELD', 'CONEX_LDAP_PROTOCOL_VERSION' => 'CONEX_LDAP_PROTOCOL_VERSION', 'CONEX_ROOT_DN' => 'CONEX_ROOT_DN', 'CONEX_ROOT_PW' => 'CONEX_ROOT_PW', 'CONEX_LDAP_CHECK_FIELD1_NAME' => 'CONEX_LDAP_CHECK_FIELD1_NAME', 'CONEX_LDAP_CHECK_FIELD1_VALUE' => 'CONEX_LDAP_CHECK_FIELD1_VALUE', 'CONEX_LDAP_CHECK_FIELD1_ROLE' => 'CONEX_LDAP_CHECK_FIELD1_ROLE', 'CONEX_LDAP_CHECK_FIELD2_NAME' => 'CONEX_LDAP_CHECK_FIELD2_NAME', 'CONEX_LDAP_CHECK_FIELD2_VALUE' => 'CONEX_LDAP_CHECK_FIELD2_VALUE', 'CONEX_LDAP_CHECK_FIELD2_ROLE' => 'CONEX_LDAP_CHECK_FIELD2_ROLE', 'CONEX_LDAP_CHECK_DEFAULT_ROLE' => 'CONEX_LDAP_CHECK_DEFAULT_ROLE'); $values = look_config_default_values($champs); $role1 = get_profile_labels(); $default_role[''] = ''; $default_role = array_merge($default_role, $role1); debut_tab(); ligne('CONEX_LDAP_SERVEUR', $l->g(830), 'input', array('VALUE' => $values['tvalue']['CONEX_LDAP_SERVEUR'], 'SIZE' => "30%", 'MAXLENGTH' => 200)); ligne('CONEX_ROOT_DN', $l->g(1016) . '<br>' . $l->g(1018), 'input', array('VALUE' => $values['tvalue']['CONEX_ROOT_DN'], 'SIZE' => "30%", 'MAXLENGTH' => 200)); ligne('CONEX_ROOT_PW', $l->g(1017) . '<br>' . $l->g(1018), 'input', array('VALUE' => $values['tvalue']['CONEX_ROOT_PW'], 'SIZE' => "30%", 'MAXLENGTH' => 200)); ligne('CONEX_LDAP_PORT', $l->g(831), 'input', array('VALUE' => $values['tvalue']['CONEX_LDAP_PORT'], 'SIZE' => "30%", 'MAXLENGTH' => 20)); ligne('CONEX_DN_BASE_LDAP', $l->g(832), 'input', array('VALUE' => $values['tvalue']['CONEX_DN_BASE_LDAP'], 'SIZE' => "30%", 'MAXLENGTH' => 200)); ligne('CONEX_LOGIN_FIELD', $l->g(833), 'input', array('VALUE' => $values['tvalue']['CONEX_LOGIN_FIELD'], 'SIZE' => "30%", 'MAXLENGTH' => 200)); ligne('CONEX_LDAP_PROTOCOL_VERSION', $l->g(834), 'input', array('VALUE' => $values['tvalue']['CONEX_LDAP_PROTOCOL_VERSION'], 'SIZE' => "30%", 'MAXLENGTH' => 5)); ligne('CONEX_LDAP_CHECK_FIELD1_NAME', $l->g(1111), 'input', array('VALUE' => $values['tvalue']['CONEX_LDAP_CHECK_FIELD1_NAME'], 'SIZE' => "30%", 'MAXLENGTH' => 200)); ligne('CONEX_LDAP_CHECK_FIELD1_VALUE', $l->g(1112), 'input', array('VALUE' => $values['tvalue']['CONEX_LDAP_CHECK_FIELD1_VALUE'], 'SIZE' => "30%", 'MAXLENGTH' => 200)); ligne('CONEX_LDAP_CHECK_FIELD1_ROLE', $l->g(1113), 'select', array('VALUE' => $values['tvalue']['CONEX_LDAP_CHECK_FIELD1_ROLE'], 'SELECT_VALUE' => $role1)); ligne('CONEX_LDAP_CHECK_FIELD2_NAME', $l->g(1114), 'input', array('VALUE' => $values['tvalue']['CONEX_LDAP_CHECK_FIELD2_NAME'], 'SIZE' => "30%", 'MAXLENGTH' => 200)); ligne('CONEX_LDAP_CHECK_FIELD2_VALUE', $l->g(1115), 'input', array('VALUE' => $values['tvalue']['CONEX_LDAP_CHECK_FIELD2_VALUE'], 'SIZE' => "30%", 'MAXLENGTH' => 200)); ligne('CONEX_LDAP_CHECK_FIELD2_ROLE', $l->g(1116), 'select', array('VALUE' => $values['tvalue']['CONEX_LDAP_CHECK_FIELD2_ROLE'], 'SELECT_VALUE' => $role1)); ligne('CONEX_LDAP_CHECK_DEFAULT_ROLE', $l->g(1277), 'select', array('VALUE' => $values['tvalue']['CONEX_LDAP_CHECK_DEFAULT_ROLE'], 'SELECT_VALUE' => $default_role)); fin_tab($form_name); }