Subversion Repositories ALCASAR

Rev

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

<?php
# Choice of language
$Language = 'en';
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
if($Language == 'fr'){
  $l_title = "Cr&eacute;ation d'un groupe";
  $l_frame_top = "Gestion des groupes";
  $l_frame = "Gestion des groupes";
  $l_group_create = "Cr&eacute;er un groupe";
}
else {
  $l_title = "Create a group";
  $l_frame_top = "Groups admin";
  $l_frame = "Groups admin";
  $l_group_create = "Create a group";
}
require('/etc/freeradius-web/config.php');
if ($show == 1){
        header("Location: group_admin.php?login=$login");
        exit;
}

if ($config[general_lib_type] != 'sql'){
        echo <<<EOM
<title>$l_title</title>
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
<link rel="stylesheet" href="style.css">
</head>
<body>
<center>
<b>This page is only available if you are using sql as general library type</b>
</body>
</html>
EOM;
        exit();
}

require('../lib/attrshow.php');
require('../lib/defaults.php');
require("../lib/$config[general_lib_type]/group_info.php");

if ($config[general_lib_type] == 'sql' && $config[sql_use_operators] == 'true'){
        $colspan=2;
        $show_ops=1;
}else{
        $show_ops = 0;
        $colspan=1;
}
echo "<html><head><title>$l_title</title>";

?>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $config[general_charset]?>">
<link rel="stylesheet" href="/css/style.css">
<script language="javascript" type="text/javascript">
function formControl(){
        var myregex = /[\S]+/gi; //un ou plusieurs caractères non blanc" (tous les caractères sauf espace, retour chariot, tabulation, saut de ligne, saut de page).
        if (myregex.test(document.newgroup.login.value)){
                document.newgroup.create.value=1;
                return true;
        } else {
                alert("Nom du groupe invalide.");//non internationnalisé
                return false;
        }
}
</script>
</head>
<body>
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr><th><? echo "$l_frame_top"; ?></th></tr>
        <tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" 
height="2"></td></tr>
</TABLE>
<TABLE width="100%" border=0 cellspacing=0 cellpadding=1>
        <tr bgcolor="#666666"><td>
        <TABLE width="100%" border=0 cellspacing=0 cellpadding=2>
                <tr><td valign="middle" align="left">
<center>
<table border=0 width=550 cellpadding=1 cellspacing=1>
<tr valign=top>
<td width=340></td>
<td bgcolor="black" width=200>
        <table border=0 width=100% cellpadding=2 cellspacing=0>
        <tr bgcolor="#907030" align=right valign=top><th>
        <font color="white"><? echo "$l_group_create"; ?></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>
   
<?php
if (is_file("../lib/$config[general_lib_type]/group_info.php"))
        include("../lib/$config[general_lib_type]/group_info.php");
if ($create == 1){
        if ($group_exists != "no"){
                echo <<<EOM
<b>Le groupe <i>$login</i> existe d&eacute;j&agrave;.</b>
EOM;
        }
        else{
                if (is_file("../lib/$config[general_lib_type]/create_group.php"))
                        include("../lib/$config[general_lib_type]/create_group.php");
                if (is_file("../lib/$config[general_lib_type]/group_info.php"))
                        include("../lib/$config[general_lib_type]/group_info.php");
        }
}
?>
   <form name="newgroup" method=post>
      <input type=hidden name=create value="0">
      <input type=hidden name=show value="0">
        <table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
<?php
        echo <<<EOM
        <tr>
                <td align=right colspan=$colspan bgcolor="#d0ddb0">
                Groupe(s) d&eacute;j&agrave; cr&eacute;&eacute;(s)
                </td><td>
EOM;
                if (!isset($existing_groups))
                        echo "<b>Aucun groupe d&eacute;j&agrave; cr&eacute;&eacute;</b>\n";
                else{
                        echo "<select name=\"existing_groups\">\n";     
                        foreach ($existing_groups as $group => $count)
                                echo "<option value=\"$group\">$group\n";
                        echo "</select>\n";
                }
        echo <<<EOM
                </td>
        </tr>
        <tr>
                <td align=right colspan=$colspan bgcolor="#d0ddb0">
                Nom du groupe
                </td><td>
                <input type=text name="login" value="$login" size=35>
                </td>
        </tr>
        <tr>
                <td align=right colspan=$colspan bgcolor="#d0ddb0">
                Membres du groupe : s&eacute;par&eacute;s par un espace ou un 'retour chariot'.
                </td><td>
                <textarea name=members cols="15" wrap="PHYSICAL" rows=5></textarea>
                </td>
        </tr>
                
EOM;
        foreach($show_attrs as $key => $desc){
                $name = $attrmap["$key"];
                if ($name == 'none')
                        continue;
                $oper_name = $name . '_op';
                $val = ($item_vals["$key"][0] != "") ? $item_vals["$key"][0] : $default_vals["$key"][0];
                print <<<EOM
<tr>
<td align=right bgcolor="#d0ddb0">
$desc
</td>
EOM;

                if ($show_ops){
                                switch ($key)
                                        {
                                        case 'Simultaneous-Use' : 
                                                echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
                                                break;
                                        case 'Login-Time' : 
                                                echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
                                                break;
                                        case 'Expiration' :
                                                echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
                                                break;
                                        case 'Session-Timeout' :
                                                echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
                                                break;
                                        case 'Max-Daily-Session' :
                                                echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
                                                break;
                                        case 'Max-Weekly-Session' :
                                                echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
                                                break;
                                        case 'Max-Monthly-Session' :
                                                echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
                                                break;
                                        case 'ChilliSpot-Max-Input-Octets' :
                                                echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
                                                break;
                                        case 'ChilliSpot-Max-Output-Octets' :
                                                echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
                                                break;
                                        case 'ChilliSpot-Max-Total-Octets' :
                                                echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
                                                break;
                                        case 'ChilliSpot-Bandwidth-Max-Up' :
                                                echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
                                                break;
                                        case 'ChilliSpot-Bandwidth-Max-Down' :
                                                echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
                                                break;
                                        case 'WISPr-Redirection-URL' :
                                                echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
                                                break;
                                        default :
                                                print <<<EOM
<td>
<select name=$oper_name>
<option $selected[$op_eq] value="=">=
<option $selected[$op_set] value=":=">:=
<option $selected[$op_add] value="+=">+=
<option $selected[$op_eq2] value="==">==
<option $selected[$op_ne] value="!=">!=
<option $selected[$op_gt] value=">">&gt;
<option $selected[$op_ge] value=">=">&gt;=
<option $selected[$op_lt] value="<">&lt;
<option $selected[$op_le] value="<=">&lt;=
<option $selected[$op_regeq] value="=~">=~
<option $selected[$op_regne] value="!~">!~
<option $selected[$op_exst] value="=*">=*
<option $selected[$op_nexst] value="!*">!*
</select>
</td>
EOM;
                                                break;
                                        }
                }
                print <<<EOM
<td>
<input type=text name="$name" value="$val" size=35>
</td>
</tr>
EOM;
        }
echo "</table><BR>";
if ($create == 1)
        echo "<input type=submit class=button value=\"Afficher le groupe\" OnClick=\"this.form.show.value=1\">";
        else
        echo "<input type=submit class=button value=\"Cr&eacute;er\" OnClick=\"return formControl();\">";
?>
<br><br>
</form>
        </td></tr>
</table>
</tr>
</table>
</TD></TR>
</TABLE>
</td></tr>
</TABLE>
</body>
</html>