Subversion Repositories ALCASAR

Rev

Rev 2340 | Rev 2349 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log

<?php
# $Id: user_edit.php 2341 2017-07-21 20:01:36Z tom.houdayer $

//gestion de la langue
if (is_file("../lib/langues.php"))
        include("../lib/langues.php");

//update Filter-Id for protocol filtering
if (isset($_POST['Filter-Proto']) && isset($_POST['Filter-Id0']))
{
        $upId = (int)$_POST['Filter-Proto'];
        $downId = (int)$_POST['Filter-Id0'];
        $upId = $upId+$downId;
        $upId = str_pad($upId, 8, '0', STR_PAD_LEFT);
        $_POST['Filter-Id0'] = $upId;
}

require('/etc/freeradius-web/config.php');
require('../lib/attrshow.php');
require('../lib/defaults.php');
require("../lib/operators.php");

if(!isset($change)) $change = 0;
if(!isset($user_type)) $user_type = 'user';
if(!isset($badusers)) $badusers = 0;
if(!isset($cn)) $cn = '';

if ($user_type != 'group'){
        if (is_file("../lib/$config[general_lib_type]/user_info.php"))
                include("../lib/$config[general_lib_type]/user_info.php");
        if ($config['general_lib_type'] == 'sql' && $config['sql_show_all_groups'] == 'true'){
                $saved_login = $login;
                $login = '';
                if (is_file("../lib/$config[general_lib_type]/group_info.php"))
                        include("../lib/$config[general_lib_type]/group_info.php");
                $login = $saved_login;
        }
}
else{
        if (is_file("../lib/$config[general_lib_type]/group_info.php"))
                include("../lib/$config[general_lib_type]/group_info.php");
}
if (false && /* Hide operator column */ $config['general_lib_type'] == 'sql' && $config['sql_use_operators'] == 'true') {
        $colspan = 2;
        $show_ops = 1;
} else {
        $show_ops = 0;
        $colspan = 1;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Users & groups edition</title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $config['general_charset']?>">
<link rel="stylesheet" href="/css/style.css">
<script type="text/javascript" src="/js/fonctions.js"></script>
<script language="javascript" type="text/javascript">
var chars='0123456789abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ'
function password(size)
  {
  var pass=''
  while(pass.length < size)
  {
    pass+=chars.charAt(Math.round(Math.random() * (chars.length)))
  }
  document.edituser.passwd.value=pass
  document.edituser.pwdgene.value=pass
}
</script>
<script type="text/javascript" src="/js/epoch_classes.js"></script>
<script language="javascript" type="text/javascript">
        // Insertion du calendrier
        var dp_cal;
        window.onload = function () {
                dp_cal = new Epoch('epoch_popup', 'popup', document.getElementById('popup_container'));
        };
</script>
<script type="text/javascript">
        function showAdvancedFields(show) {
                var form = document.forms['edituser'];
                var btn_show = document.getElementById('show-advanced-fields');
                var btn_hide = document.getElementById('hide-advanced-fields');

                if (show) {
                        btn_hide.style.display = null;
                        btn_show.style.display = 'none';
                        form.className += ' hide-advanced-fields';
                } else {
                        btn_show.style.display = null;
                        btn_hide.style.display = 'none';
                        form.className = form.className.replace(' hide-advanced-fields', '');

                }
        }
</script>
<style type="text/css">
        .hide-advanced-fields .advanced-field {
                display: none;
        }
</style>
</head>
<body>
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr><th><?= (($user_type !== 'group') ? $l_users_managment : $l_groups_managment) ?></th></tr>
        <tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1"
height="2"></td></tr>
</TABLE>
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
        <tr><td valign="middle" align="left">
        <center>
        <table border=0 width=640 cellpadding=0 cellspacing=2>
<?php
if ($user_type != 'group'){
        include("../html/user_toolbar.html.php");
        $titre=$l_user;
}else{
        include("../html/group_toolbar.html.php");
        $titre=$l_group;
}
print <<<EOM
</table>
<br>
<table border=0 width=620 cellpadding=1 cellspacing=1>
<tr valign=top>
<td width=400></td>
<td bgcolor="black">
        <table border=0 width=100% cellpadding=2 cellspacing=0>
        <tr bgcolor="#907030" align=center valign=top><th>
        <font color="white">$titre : $login ($cn)</font>
        </th></tr>
        </table>
</td></tr>
<tr bgcolor="black" valign=top><td colspan="2">
        <table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
        <tr><td>
EOM;

if ($change == 1) {
        if (is_file("../lib/$config[general_lib_type]/change_attrs.php"))
                include("../lib/$config[general_lib_type]/change_attrs.php");
        if ($user_type != 'group'){
                if ($config['general_show_user_password'] != 'no' && $passwd != ''
                        && is_file("../lib/$config[general_lib_type]/change_passwd.php"))
                        include("../lib/$config[general_lib_type]/change_passwd.php");
                if (is_file("../lib/$config[general_lib_type]/user_info.php"))
                        include("../lib/$config[general_lib_type]/user_info.php");
                if ($group_change && $config['general_lib_type'] == 'sql' && $config['sql_show_all_groups'] == 'true'){
                        include("../lib/$config[general_lib_type]/group_change.php");
                        include("../lib/defaults.php");
                }
                # Disconnecting user for re-authentication
                $mac=exec("sudo /usr/sbin/chilli_query list | grep ".escapeshellarg(" $login ")." | awk '{print $1}'");
                exec("sudo /usr/sbin/chilli_query logout ".escapeshellarg($mac));
        }
        else{
                if (is_file("../lib/$config[general_lib_type]/group_info.php"))
                        include("../lib/$config[general_lib_type]/group_info.php");
                # Disconnecting all users from the selected group for re-authentication
                if (isset($group_members)){
                        foreach ($group_members as $g_member => $member){
                                $mac=exec("sudo /usr/sbin/chilli_query list | grep ".escapeshellarg(" $member ")." | awk '{print $1}'");
                                exec("sudo /usr/sbin/chilli_query logout ".escapeshellarg($mac));
                        }
                }
        }
}
else if ($badusers == 1){
        if (is_file("../lib/add_badusers.php"))
                include("../lib/add_badusers.php");
}

//si l'utilisateur fait parti d'un groupe, on charge les attributs du groupe, pour les afficher ensuite.
if(isset($member_groups) && ($user_type != 'group')) {
        $group = array_values($member_groups)[0];
        $login_saved = $login;
        $login = array_values($member_groups)[0];
        include("../lib/$config[general_lib_type]/group_info.php");
        $login = $login_saved;
        
        foreach ($show_attrs as $key => $desc) {
                $name = $attrmap["$key"];
                $generic = (isset($attrmap['generic']["$key"])) ? $attrmap['generic']["$key"] : '';
                if ($name == 'none')
                        continue;
                unset($vals);
                unset($selected);
                unset($ops);
                $def_added = 0;
                if (isset($item_vals["$key"]['count']) && $item_vals["$key"]['count']) {
                        for($i=0;$i<$item_vals["$key"]['count'];$i++){
                                $vals[] = $item_vals["$key"][$i];
                                $ops[] = $item_vals["$key"]['operator'][$i];
                        }
                } else {
                        if (isset($default_vals["$key"]['count']) && $default_vals["$key"]['count']) {
                                for ($i=0;$i<$default_vals["$key"]['count'];$i++) {
                                        $vals[] = $default_vals["$key"][$i];
                                        $ops[] = $default_vals["$key"]['operator'][$i];
                                }
                        } else {
                                $vals[] = '';
                                $ops[] = '=';
                        }
                        $def_added = 1;
                }
                if ($generic == 'generic' && $def_added == 0) {
                        for($i=0;$i<$default_vals["$key"]['count'];$i++){
                                $vals[] = $default_vals["$key"][$i];
                                $ops[] = $default_vals["$key"]['operator'][$i];
                        }
                }
                if (isset($add) && $add && $name == $add_attr){
                        $vals[] = $default_vals["$key"][0];
                        $ops[] = ($default_vals["$key"]['operator'][0] != '') ? $default_vals["$key"]['operator'][0] : '=';
                }

                $i = 0;
                foreach ($vals as $val) {
                        $name1 = $name . $i;
                        $val = preg_replace('/\"/','&quot;',$val);
                        $oper_name = $name1 . '_op';
                        $oper = $ops[$i];
                        $selected[$oper] = 'selected';
                        $i++;

                        switch ($key)
                                {
                                case 'Simultaneous-Use' :
                                        $grp_simuse = $val;
                                        break;
                                case 'Login-Time' :
                                        $grp_logtime = $val;
                                        break;
                                case 'Expiration' :
                                        $grp_exp = $val;
                                        break;
                                case 'Max-All-Session' :
                                        $grp_maxall = $val;
                                        break;
                                case 'Session-Timeout' :
                                        $grp_sesstim = $val;
                                        break;
                                case 'Max-Daily-Session' :
                                        $grp_maxday = $val;
                                        break;
                                case 'Max-Weekly-Session' :
                                        $grp_maxweek = $val;
                                        break;
                                case 'Max-Monthly-Session' :
                                        $grp_maxmonth = $val;
                                        break;
                                case 'ChilliSpot-Max-Input-Octets' :
                                        $grp_maxio = $val;
                                        break;
                                case 'ChilliSpot-Max-Output-Octets' :
                                        $grp_maxoo = $val;
                                        break;
                                case 'ChilliSpot-Max-Total-Octets' :
                                        $grp_maxto = $val;
                                        break;
                                case 'ChilliSpot-Bandwidth-Max-Up' :
                                        $grp_bwup = $val;
                                        break;
                                case 'ChilliSpot-Bandwidth-Max-Down' :
                                        $grp_bwdown = $val;
                                        break;
                                case 'WISPr-Redirection-URL' :
                                        $grp_redir = $val;
                                        break;
                                case 'Filter-Id' :
                                        if (empty($val)) {
                                                $val = '00000000'; // Set no filters if value is not set
                                        }

                                        if ($val[5] === '1') {
                                                $grp_filter = $l_filtering_havp_wl;
                                        } else if ($val[6] === '1') {
                                                $grp_filter = $l_filtering_havp_bl;
                                        } else if ($val[7] === '1') {
                                                $grp_filter = $l_filtering_havp;
                                        } else {
                                                $grp_filter = $l_filtering_none;
                                        }

                                        if ($val[2] === '1') {
                                                $grp_proto = $l_proto_3;
                                        } else if ($val[1] === '1') {
                                                $grp_proto = $l_proto_2;
                                        } else if ($val[0] === '1') {
                                                $grp_proto = $l_proto_1;
                                        } else {
                                                $grp_proto = $l_proto_0;
                                        }
                                        
                                        break;
                        }
                }
        }

        /*on charge les attributs utilisateurs afin de montrer les groupes disponibles*/
        if ($user_type != 'group') {
                if (is_file("../lib/$config[general_lib_type]/user_info.php"))
                        include("../lib/$config[general_lib_type]/user_info.php");
                if ($config['general_lib_type'] == 'sql' && $config['sql_show_all_groups'] == 'true'){
                        $saved_login = $login;
                        $login = '';
                        if (is_file("../lib/$config[general_lib_type]/group_info.php"))
                                include("../lib/$config[general_lib_type]/group_info.php");
                        $login = $saved_login;
                }
        }
}
?>
   <form name="edituser" method="post" class="">
      <input type="hidden" name="login" value="<?= $login ?>">
      <input type="hidden" name="user_type" value="<?= $user_type ?>">
      <input type="hidden" name="change" value="0">
      <input type="hidden" name="add" value="0">
      <input type="hidden" name="badusers" value="0">
      <input type="hidden" name="group_change" value="0">
        <table border="1" bordercolordark="#ffffe0" bordercolorlight="#000000" width="100%" cellpadding="2" cellspacing="0" bgcolor="#ffffe0" valign="top">
<?php
if (($user_type !== 'group') && (isset($member_groups))) {
        echo <<<EOM
        <tr>
                <td colspan="$colspan"></td>
                <td>$l_group_desc</td>
                <td>$l_user_desc</td>
        </tr>
EOM;
}
if ($user_type != 'group' && $config['general_show_user_password'] != 'no') {


        echo <<<EOM
        <tr>
        <td align=right colspan="$colspan" bgcolor="#d0ddb0">
        $l_new_password<br>
        </td>
EOM;

        if(isset($member_groups)){
                echo <<<EOM
                <td bgcolor="#BEBEBE">
                <br/>
                </td>
EOM;
        }


        echo <<<EOM
        <td>
        <input type="password" name="passwd" value="" size="20">
        <br /><input type="button" value="$l_passwd_gen" onclick="password(8)">
        <input type="text" value="" name="pwdgene" size="10" readonly>
        </td>
        </tr>
EOM;
}

        foreach($show_attrs as $key => $desc){
                $name = $attrmap["$key"];
                $generic = (isset($attrmap['generic']["$key"])) ? $attrmap['generic']["$key"] : '';
                if ($name == 'none')
                        continue;
                unset($vals);
                unset($selected);
                unset($ops);
                $def_added = 0;
                if (isset($item_vals["$key"]['count']) && $item_vals["$key"]['count']){
                        for($i=0;$i<$item_vals["$key"]['count'];$i++){
                                $vals[] = $item_vals["$key"][$i];
                                $ops[] = $item_vals["$key"]['operator'][$i];
                        }
                } else {
                        if (isset($default_vals["$key"]['count']) && $default_vals["$key"]['count']){
                                for($i=0;$i<$default_vals["$key"]['count'];$i++){
                                        $vals[] = $default_vals["$key"][$i];
                                        $ops[] = $default_vals["$key"]['operator'][$i];
                                }
                        }
                        else{
                                $vals[] = '';
                                $ops[] = '=';
                        }
                        $def_added = 1;
                }
                if ($generic == 'generic' && $def_added == 0){
                        for($i=0;$i<$default_vals["$key"]['count'];$i++){
                                $vals[] = $default_vals["$key"][$i];
                                $ops[] = $default_vals["$key"]['operator'][$i];
                        }
                }
                if (isset($add) && $add && $name == $add_attr){
                        $vals[] = $default_vals["$key"][0];
                        $ops[] = ($default_vals["$key"]['operator'][0] != '') ? $default_vals["$key"]['operator'][0] : '=';
                }

                $i = 0;
                foreach($vals as $val) {
                        $name1 = $name . $i;
                        $val = preg_replace('/\"/','&quot;',$val);
                        $oper_name = $name1 . '_op';
                        $oper = $ops[$i];
                        $selected[$oper] = 'selected';
                        $i++;
                        switch ($key)
                        {
                                        // $advanced = 1 : champs de saisie amélioré (calendrier, convertisseur, etc.)
                                case 'Simultaneous-Use' :
                                        $advanced = false;
                                        $help_link = "help/simultaneous_use_help.html";
                                        $desc = $l_simultaneous_use;
                                        break;
                                case 'Max-All-Session' :
                                        $advanced = false;
                                        $help_link = "help/max_all_session_help.html";
                                        $desc = $l_max_all_session;
                                        break;
                                case 'Session-Timeout' :
                                        $advanced = true;
                                        $help_link = "help/session_timeout_help.html";
                                        $desc = $l_session_timeout;
                                        break;
                                case 'Max-Daily-Session' :
                                        $advanced = true;
                                        $help_link = "help/session_timeout_help.html";
                                        $desc = $l_daily_timeout;
                                        break;
                                case 'Max-Monthly-Session' :
                                        $advanced = true;
                                        $help_link = "help/session_timeout_help.html";
                                        $desc = $l_monthly_timeout;
                                        break;
                                case 'Login-Time' :
                                        $advanced = true;
                                        $help_link = "help/login_time_help.html";
                                        $desc = $l_login_time;
                                        break;
                                case 'Expiration' :
                                        $advanced = false;
                                        $help_link = "help/expiration_help.html";
                                        $desc = $l_expiration;
                                        break;
                                case 'ChilliSpot-Max-Input-Octets' :
                                        $advanced = true;
                                        $help_link = "help/chillispot_max_input_octets_help.html";
                                        $desc = $l_max_input_octets;
                                        break;
                                case 'ChilliSpot-Max-Output-Octets' :
                                        $advanced = true;
                                        $help_link = "help/chillispot_max_output_octets_help.html";
                                        $desc = $l_max_output_octets;
                                        break;
                                case 'ChilliSpot-Max-Total-Octets' :
                                        $advanced = true;
                                        $help_link = "help/chillispot_max_total_octets_help.html";
                                        $desc = $l_max_total_octets;
                                        break;
                                case 'ChilliSpot-Bandwidth-Max-Up' :
                                        $advanced = true;
                                        $help_link = "help/chillispot_bandwidth_max_up_help.html";
                                        $desc = $l_max_bandwidth_up;
                                        break;
                                case 'ChilliSpot-Bandwidth-Max-Down' :
                                        $advanced = true;
                                        $help_link = "help/chillispot_bandwidth_max_down_help.html";
                                        $desc = $l_max_bandwidth_down;
                                        break;
                                case 'WISPr-Redirection-URL' :
                                        $advanced = true;
                                        $help_link = "help/wispr_redirection_url_help.html";
                                        $desc = $l_wispr_redirection;
                                        break;
                                case 'Filter-Id' :
                                        $advanced = false;
                                        $help_link = "help/filtering_help.html";
                                        $desc = $l_filtering;
                                        break;
                                default:
                                        $advanced = true;
                                        break;
                        }

                        $advancedField = ($advanced) ? ' class="advanced-field"' : '';

                        if ($show_ops) {
                                print <<<EOM
                                        <tr$advancedField>
                                        <td class="etiquette">
                                        <a href="$help_link" target="help" onclick="window.open('$help_link','help','width=600,height=350,toolbar=no,scrollbars=no,resizable=yes')" title="$l_click_for_help"><font color="blue">$desc</font></a>
                                        </td>
EOM;
                                if(!isset($selected[$op_eq])) $selected[$op_eq] = '';
                                switch ($key){
                                        case 'Simultaneous-Use' :
                                        case 'Max-All-Session' :
                                        case 'Max-Daily-Session' :
                                        case 'Max-Weekly-Session' :
                                        case 'Max-Monthly-Session' :
                                        case 'Login-Time' :
                                        case 'Expiration' :
                                        case 'Filter-Id' :
                                                echo "<td><select name=\"$oper_name\"><option $selected[$op_eq] value=\":=\">:=</option></select></td>";
                                                break;
                                        case 'Session-Timeout' :
                                        case 'ChilliSpot-Max-Input-Octets' :
                                        case 'ChilliSpot-Max-Output-Octets' :
                                        case 'ChilliSpot-Max-Total-Octets' :
                                        case 'ChilliSpot-Bandwidth-Max-Up' :
                                        case 'ChilliSpot-Bandwidth-Max-Down' :
                                        case 'WISPr-Redirection-URL' :
                                                echo "<td><select name=\"$oper_name\"><option $selected[$op_eq] value=\"=\">=</option></select></td>";
                                                break;
                                        default :
                                                print <<<EOM
                                                        <td>
                                                                <select name=\"$oper_name\">
                                                                        <option $selected[$op_eq] value="=">=</option>
                                                                        <option $selected[$op_set] value=":=">:=</option>
                                                                        <option $selected[$op_add] value="+=">+=</option>
                                                                        <option $selected[$op_eq2] value="==">==</option>
                                                                        <option $selected[$op_ne] value="!=">!=</option>
                                                                        <option $selected[$op_gt] value=">">&gt;</option>
                                                                        <option $selected[$op_ge] value=">=">&gt;=</option>
                                                                        <option $selected[$op_lt] value="<">&lt;</option>
                                                                        <option $selected[$op_le] value="<=">&lt;=</option>
                                                                        <option $selected[$op_regeq] value="=~">=~</option>
                                                                        <option $selected[$op_regne] value="!~">!~</option>
                                                                        <option $selected[$op_exst] value="=*">=*</option>
                                                                        <option $selected[$op_nexst] value="!*">!*</option>
                                                                </select>
                                                        </td>
EOM;
                                                break;
                                }
                        } else {
                                print <<<EOM
                                        <tr$advancedField>
                                        <td class="etiquette" colspan="$colspan">
                                        <a href="$help_link" target="help" onclick="window.open('$help_link','help','width=600,height=350,toolbar=no,scrollbars=no,resizable=yes')" title="$l_click_for_help"><font color="blue">$desc</font></a>
EOM;
                                switch ($key) {
                                        case 'Simultaneous-Use' :
                                        case 'Max-All-Session' :
                                        case 'Max-Daily-Session' :
                                        case 'Max-Weekly-Session' :
                                        case 'Max-Monthly-Session' :
                                        case 'Login-Time' :
                                        case 'Expiration' :
                                        case 'Filter-Id' :
                                                echo "<input type=\"hidden\" name=\"$oper_name\" value=\":=\">";
                                                break;
                                        case 'Session-Timeout' :
                                        case 'ChilliSpot-Max-Input-Octets' :
                                        case 'ChilliSpot-Max-Output-Octets' :
                                        case 'ChilliSpot-Max-Total-Octets' :
                                        case 'ChilliSpot-Bandwidth-Max-Up' :
                                        case 'ChilliSpot-Bandwidth-Max-Down' :
                                        case 'WISPr-Redirection-URL' :
                                                echo "<input type=\"hidden\" name=\"$oper_name\" value=\"=\">";
                                                break;
                                        default :
                                                print <<<EOM
                                                        <select name=\"$oper_name\">
                                                                <option $selected[$op_eq] value="=">=</option>
                                                                <option $selected[$op_set] value=":=">:=</option>
                                                                <option $selected[$op_add] value="+=">+=</option>
                                                                <option $selected[$op_eq2] value="==">==</option>
                                                                <option $selected[$op_ne] value="!=">!=</option>
                                                                <option $selected[$op_gt] value=">">&gt;</option>
                                                                <option $selected[$op_ge] value=">=">&gt;=</option>
                                                                <option $selected[$op_lt] value="<">&lt;</option>
                                                                <option $selected[$op_le] value="<=">&lt;=</option>
                                                                <option $selected[$op_regeq] value="=~">=~</option>
                                                                <option $selected[$op_regne] value="!~">!~</option>
                                                                <option $selected[$op_exst] value="=*">=*</option>
                                                                <option $selected[$op_nexst] value="!*">!*</option>
                                                        </select>
EOM;
                                                break;
                                }
                                echo '</td>';
                        }

                        if (isset($member_groups) && $user_type !== 'group') {
                                echo '<td bgcolor="#BEBEBE">';
                                switch ($key){
                                        case 'Simultaneous-Use' :
                                                echo "$grp_simuse";
                                                break;
                                        case 'Login-Time' :
                                                echo "$grp_logtime";
                                                break;
                                        case 'Expiration' :
                                                echo "$grp_exp";
                                                break;
                                        case 'Max-All-Session' :
                                                echo "$grp_maxall";
                                                break;
                                        case 'Session-Timeout' :
                                                echo "$grp_sesstim";
                                                break;
                                        case 'Max-Daily-Session' :
                                                echo "$grp_maxday";
                                                break;
                                        case 'Max-Weekly-Session' :
                                                echo "$grp_maxweek";
                                                break;
                                        case 'Max-Monthly-Session' :
                                                echo "$grp_maxmonth";
                                                break;
                                        case 'ChilliSpot-Max-Input-Octets' :
                                                echo "$grp_maxio";
                                                break;
                                        case 'ChilliSpot-Max-Output-Octets' :
                                                echo "$grp_maxoo";
                                                break;
                                        case 'ChilliSpot-Max-Total-Octets' :
                                                echo "$grp_maxto";
                                                break;
                                        case 'ChilliSpot-Bandwidth-Max-Up' :
                                                echo "$grp_bwup";
                                                break;
                                        case 'ChilliSpot-Bandwidth-Max-Down' :
                                                echo "$grp_bwdown";
                                                break;
                                        case 'WISPr-Redirection-URL' :
                                                echo "$grp_redir";
                                                break;
                                        case 'Filter-Id' :
                                                echo "$grp_filter";
                                                break;
                                        default :
                                                break;
                                }
                                echo '</td>';
                        }

                        echo '<td>';
                        switch ($key) {
                                /*
                                Choix de l'unité jour, heures, minutes ou secondes
                                pour les durées limites max, de session,de journée et de mois
                                */
                                case 'Session-Timeout' :
                                case 'Max-Daily-Session' :
                                        /*valeur d'origine de durée limite */
                                        echo"<input type=\"text\" name=\"$name1\" onfocus=\"this.value=''\" value=\"$val\" size=10>";
                                        /* Choix d'unité*/
                                        echo" <select onchange=\"temps(this,'$name1','edituser')\">
                                                        <option value=\"s\" selected>s</option>
                                                        <option value=\"m\" >m</option>
                                                        <option value=\"H\" >H</option>
                                                </select>";
                                        break;
                                case 'Max-Monthly-Session' :
                                case 'Max-All-Session' :
                                        /*valeur d'origine de durée limite */
                                        echo"<input type=\"text\" name=\"$name1\" onfocus=\"this.value=''\" value=\"$val\" size=10>";
                                        /* Choix d'unité*/
                                        echo" <select onchange=\"temps(this,'$name1','edituser')\">
                                                        <option value=\"s\" selected>s</option>
                                                        <option value=\"m\" >m</option>
                                                        <option value=\"H\" >H</option>
                                                        <option value=\"J\" >J</option>
                                                </select>";
                                        break;
                                case 'Expiration' :
                                        /*Ajout du calendrier pour choisir la date*/
                                        echo"<input id=\"popup_container\" type=\"text\" name=\"$name1\" value=\"$val\" size=\"20\">";
                                        break;
                                case 'Filter-Id' :
                                        if (empty($val)) {
                                                $val = '00000000'; // Set no filters if value is not set
                                        }

                                        if ($val[5] === '1') {
                                                $selected = 'havp_wl';
                                        } else if ($val[6] === '1') {
                                                $selected = 'havp_bl';
                                        } else if ($val[7] === '1') {
                                                $selected = 'havp';
                                        } else {
                                                $selected = 'not_filtered';
                                        }
                                        echo "<select name=\"$name1\">";
                                        echo "<option value=\"00000000\"".(($selected === 'not_filtered') ? ' selected' : '').">$l_filtering_none</option>";
                                        echo "<option value=\"00000001\"".(($selected === 'havp') ? ' selected' : '').">$l_filtering_havp</option>";
                                        echo "<option value=\"00000011\"".(($selected === 'havp_bl') ? ' selected' : '').">$l_filtering_havp_bl</option>";
                                        echo "<option value=\"00000101\"".(($selected === 'havp_wl') ? ' selected' : '').">$l_filtering_havp_wl</option>";
                                        echo "</select>";
                                        break;
                                default :
                                        echo "<input type=\"text\" name=\"$name1\" value=\"$val\" size=\"20\">";
                                        break;
                        }
                        echo '</td>';
                }
        }
        
/*protocole filter*/
print <<<EOM
<tr>
<td class="etiquette" colspan="$colspan">
        <a href="help/protocols_help.html" target=help onclick="window.open('help/protocols_help.html','help','width=600,height=250,toolbar=no,scrollbars=no,resizable=yes')" title="$l_click_for_help"><font color="blue">$l_proto</font></a>
</td>
EOM;
if(isset($member_groups) && $user_type != 'group') {
        echo "<td bgcolor=\"#BEBEBE\">$grp_proto</td>";
}

if ($val[2] === '1') {
        $selected = 'proto_3';
} else if ($val[1] === '1') {
        $selected = 'proto_2';
} else if ($val[0] === '1') {
        $selected = 'proto_1';
} else {
        $selected = 'proto_0';
}
echo "<td width=20>";
echo "<select name='Filter-Proto'>
        <option value=\"00000000\"".(($selected === 'proto_0') ? ' selected' : '').">$l_proto_0</option>
        <option value=\"10000000\"".(($selected === 'proto_1') ? ' selected' : '').">$l_proto_1</option>
        <option value=\"01000000\"".(($selected === 'proto_2') ? ' selected' : '').">$l_proto_2</option>
        <option value=\"00100000\"".(($selected === 'proto_3') ? ' selected' : '').">$l_proto_3</option>
        </select></td>
</tr>";
        
        
if ($user_type != 'group') {
        echo <<<EOM
        <tr>
        <td align=right colspan="$colspan" bgcolor="#d0ddb0">
        $l_group_member<br><font size=-2><i>($l_main_group)</i></font>
        </td>
EOM;
if (isset($member_groups)) {
        echo '<td colspan="2">';
} else {
        echo '<td>';
}


        if (isset($existing_groups)){
                echo '<select size="5" name="edited_groups[]"  OnChange="this.form.group_change.value=1">';
                if ($config['sql_show_all_groups'] == 'true') {
                        foreach ($existing_groups as $group => $count) {
                                if (isset($member_groups[$group]) && ($member_groups[$group] == $group))
                                        echo "<option selected value=\"$group\">$group\n";
                                else if(isset($member_groups[0]) && ($member_groups[0] == $group))
                                        echo "<option selected value=\"$group\">$group\n";
                                else
                                        echo "<option value=\"$group\">$group\n";
                        }
                } else {
                        foreach ($member_groups as $group)
                                echo "<option value=\"$group\">$group\n";
                }
                echo "</select>";
        }
        else{
                echo "<i>$l_no_group</i>";
        }
        
        echo "</td></tr>";
}
echo "</table><br>";
echo "<input type=submit class=button value=$l_change OnClick=\"this.form.change.value=1\">";
echo "<button type=\"button\" id =\"show-advanced-fields\" onclick=\"showAdvancedFields(true)\" style=\"float: right;\">$l_simple_menu</button>";
echo "<button type=\"button\" id =\"hide-advanced-fields\" onclick=\"showAdvancedFields(false)\" style=\"float: right; display: none;\">$l_advanced_menu</button>";
//if ($user_type != 'group'){
//      echo <<<EOM
//<br><br>
//<input type=submit class=button value="Add to Badusers" OnClick="this.form.badusers.value=1">
//<a href="help/badusers_help.html" target=bu_help onclick=window.open("help/badusers_help.html","bu_help","width=600,height=210,toolbar=no,scrollbars=no,resizable=yes") title="BADUSERS Help Page"><font color="blue">&lt;--Help</font></a>
//EOM;
//}
?>
</form>
</td></tr>
</table>
</td></tr>
</table>
</center>
</td></tr>
</TABLE>
</body>
</html>