Rev 2402 | Rev 2505 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log
<?php
# $Id: group_new.php 2424 2017-10-11 21:50:39Z 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['Status-Open-Required']) && isset($_POST['Filter-Id']))
{
$filterId = (int)$_POST['Filter-Id'];
$FilterProto = (int)$_POST['Filter-Proto'];
$statusOpenRequired = (int)($_POST['Status-Open-Required'].'000');
$filterId = $filterId+$FilterProto+$statusOpenRequired;
$_POST['Filter-Id'] = str_pad($filterId, 8, '0', STR_PAD_LEFT);
}
if (isset($_POST['Status-Open-Required'])) {
if ($_POST['Status-Open-Required'] === '1') {
$_POST['Idle-Timeout'] = '600'; // 10 minutes
} else {
$_POST['Idle-Timeout'] = '';
}
$_POST['Idle-Timeout_op'] = '=';
}
require('/etc/freeradius-web/config.php');
if (!isset ($create)) $create=0;
if (!isset ($login)) $login='';
if (!isset ($selected)) $selected=array();
require('../lib/attrshow.php');
require('../lib/defaults.php');
require("../lib/$config[general_lib_type]/group_info.php");
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();
}
if (false && /* Hide operator column */ $config['general_lib_type'] == 'sql' && $config['sql_use_operators'] == 'true'){
$colspan=2;
$show_ops=1;
include_once("../lib/operators.php");
if(!isset($selected[$op_eq])) $selected[$op_eq] = '';
}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>New group</title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $config['general_charset']?>">
<link rel="stylesheet" href="/css/style.css">
<link rel="stylesheet" type="text/css" href="/css/epoch_styles.css" />
<script type="text/javascript" src="/js/epoch_classes.js"></script>
<script type="text/javascript" src="/js/fonctions.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'));
};
/*Fin calendrier*/
</script>
<script type="text/javascript">
function showAdvancedFields(show) {
var form = document.forms['newgroup'];
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><? echo "$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=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=750 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><i>$login</i> $l_already_exist</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");
}
}
if ($create == 0){
?>
<form name="newgroup" method="post" class="">
<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 class="etiquette" colspan=$colspan>
$l_created_groups
</td><td>
EOM;
if (!isset($existing_groups))
echo "<b>$l_group_empty</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 class="etiquette" colspan=$colspan>
$l_group_name
</td><td>
<input type=text name="login" value="$login" size=35>
</td>
</tr>
<tr>
<td class="etiquette" colspan=$colspan>
$l_group_members
</td><td>
<textarea name=members cols="50" wrap="PHYSICAL" rows=5></textarea>
</td>
</tr>
EOM;
foreach($show_attrs as $key => $desc){
if ($key === 'Idle-Timeout') continue;
$name = $attrmap["$key"];
if ($name == 'none')
continue;
$oper_name = $name . '_op';
if(isset($item_vals["$key"][0]) && $item_vals["$key"][0] != ''){
$val = $item_vals["$key"][0];
} else if(isset($default_vals["$key"][0])) {
$val = $default_vals["$key"][0];
} else {
$val = '';
}
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=250,toolbar=no,scrollbars=no,resizable=yes')" title="$l_click_for_help"><font color="blue">$desc</font></a>
</td>
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' :
echo "<td><select name=\"$oper_name\"><option $selected[$op_eq] value=\":=\">:=";
break;
case 'Filter-Id' :
echo "<td><select name=\"$oper_name\"><option $selected[$op_eq] 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 "<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=">">>
<option $selected[$op_ge] value=">=">>=
<option $selected[$op_lt] value="<"><
<option $selected[$op_le] value="<="><=
<option $selected[$op_regeq] value="=~">=~
<option $selected[$op_regne] value="!~">!~
<option $selected[$op_exst] value="=*">=*
<option $selected[$op_nexst] value="!*">!*
</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' :
echo "<input type=\"hidden\" name=\"$oper_name\" value=\":=\">";
break;
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=">">></option>
<option $selected[$op_ge] value=">=">>=</option>
<option $selected[$op_lt] value="<"><</option>
<option $selected[$op_le] value="<="><=</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>';
}
/*
Ajout du choix d'unité (pour les durées limites de session, journée et de mois)
et d'un calendrier pour la date d'expiration
Sauf dans le cas de la visualisation
*/
echo '<td>';
if ($create == 0) {
switch ($name){
/*
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=\"$name\" onfocus=\"this.value=''\" value=\"$val\" size=10>";
/* Choix d'unité*/
echo" <select name=\"$name"."_opt"."\" onchange=\"temps(this,'$name','newgroup')\">
<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=\"$name\" onfocus=\"this.value=''\" value=\"$val\" size=10>";
/* Choix d'unité*/
echo" <select name=\"$name"."_opt"."\" onchange=\"temps(this,'$name','newgroup')\">
<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=\"$name\" value=\"$val\" size=\"20\">";
break;
case 'Filter-Id' :
echo "<select name='Filter-Id'>";
echo "<option value=\"\">$l_filtering_none</option>";
echo "<option value=\"00000001\">$l_filtering_havp</option>";
echo "<option value=\"00000011\">$l_filtering_havp_bl</option>";
echo "<option value=\"00000101\">$l_filtering_havp_wl</option>";
echo "</select>";
break;
default :
echo "<input type=\"text\" name=\"$name\" value=\"$val\" size=\"20\">";
break;
}
}
/*fin Ajout*/
}
/*Network protocole filtering*/
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>
<td width=20>
EOM;
echo" <select name='Filter-Proto'>
<option value=\"00000000\" selected>$l_proto_0</option>
<option value=\"10000000\" >$l_proto_1</option>
<option value=\"01000000\" >$l_proto_2</option>
<option value=\"00100000\" >$l_proto_3</option>
</select></td></tr>";
// User need to keep status page open
print <<<EOM
<tr>
<td class="etiquette" colspan="$colspan">
<a href="help/statusOpenRequired_help.html" target=help onclick="window.open('help/statusOpenRequired_help.html','help','width=600,height=250,toolbar=no,scrollbars=no,resizable=yes')" title="$l_click_for_help"><font color="blue">$l_statusOpenRequired</font></a>
</td>
EOM;
echo "<td width=20>
<label><input type=\"radio\" name=\"Status-Open-Required\" value=\"0\" checked>$l_yes</label>
<label><input type=\"radio\" name=\"Status-Open-Required\" value=\"1\">$l_no</label>
</select></td>
</tr>";
echo "</table><BR>";
}
if ($create == 1)
echo "<br/><center><a href=\"group_admin.php?login=$login\">$l_show_profile</a></center>";
else {
echo "<input type=submit class=button value=\"$l_create\" OnClick=\"return formControl('newgroup');\">";
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>";
}
?>
<br><br>
</form>
</td></tr>
</table>
</tr>
</table>
</center>
</TD></TR>
</TABLE>
</td></tr>
</TABLE>
</body>
</html>