attribute is generic and user values *do not* overwrite default values. The operators in the generic
attribute can be used for that. The same is very difficult to implement for sql, so for now user
values overwrite default values in sql (user edit page).
A lot of code and a lot of files where changed so there may be bugs somewhere.
* Fix a bug in lib/sql/change_passwd.php3 when not using operators.
Bug report from Sheldon Fougere <sfougere@solutioninc.com>
* Add the caller id in the connection status attributes in the show user page
+* Allow for multiple default values. Also add a generic flag in ldap attrmap. If it exists then the
+ attribute is generic and user values *do not* overwrite default values. The operators in the generic
+ attribute can be used for that. The same is very difficult to implement for sql, so for now user
+ values overwrite default values in sql (user edit page).
+ A lot of code and a lot of files where changed so there may be bugs somewhere.
Ver 1.55:
* Update the FAQ about missing attributes from the user/group edit pages and add a few comments
in the configuration files
checkItem Dialup-Lock-Msg radiuslockmsg
checkItem User-Password userpassword
checkItem Regular-Profile radiusProfileDn
-checkItem Check-Item radiusCheckItem
-replyItem Reply-Item radiusReplyItem
+checkItem Check-Item radiusCheckItem generic
+replyItem Reply-Item radiusReplyItem generic
if ($name == 'none')
continue;
$oper_name = $name . '_op';
- $val = ($item_vals["$key"][0] != "") ? $item_vals["$key"][0] : $default_vals["$key"];
+ $val = ($item_vals["$key"][0] != "") ? $item_vals["$key"][0] : $default_vals["$key"][0];
print <<<EOM
<tr>
<td align=right bgcolor="#d0ddb0">
exit();
}
-$monthly_limit = ($item_vals['Max-Weekly-Session'][0] != '') ? $item_vals['Max-Weekly-Session'][0] : $default_vals['Max-Weekly-Session'];
+$monthly_limit = ($item_vals['Max-Weekly-Session'][0] != '') ? $item_vals['Max-Weekly-Session'][0] : $default_vals['Max-Weekly-Session'][0];
$monthly_limit = ($monthly_limit) ? $monthly_limit : $config[counter_default_monthly];
-$weekly_limit = ($item_vals['Max-Weekly-Session'][0] != '') ? $item_vals['Max-Weekly-Session'][0] : $default_vals['Max-Weekly-Session'];
+$weekly_limit = ($item_vals['Max-Weekly-Session'][0] != '') ? $item_vals['Max-Weekly-Session'][0] : $default_vals['Max-Weekly-Session'][0];
$weekly_limit = ($weekly_limit) ? $weekly_limit : $config[counter_default_weekly];
-$daily_limit = ($item_vals['Max-Daily-Session'][0] != '') ? $item_vals['Max-Daily-Session'][0] : $default_vals['Max-Daily-Session'];
+$daily_limit = ($item_vals['Max-Daily-Session'][0] != '') ? $item_vals['Max-Daily-Session'][0] : $default_vals['Max-Daily-Session'][0];
$daily_limit = ($daily_limit) ? $daily_limit : $config[counter_default_daily];
-$session_limit = ($item_vals['Session-Timeout'][0] != '') ? $item_vals['Session-Timeout'][0] : $default_vals['Session-Timeout'];
+$session_limit = ($item_vals['Session-Timeout'][0] != '') ? $item_vals['Session-Timeout'][0] : $default_vals['Session-Timeout'][0];
$session_limit = ($session_limit) ? $session_limit : 'none';
$remaining = 'unlimited time';
$log_color = 'green';
else
$descr = '-';
-$expiration = $default_vals['Expiration'];
+$expiration = $default_vals['Expiration'][0];
if ($item_vals['Expiration'][0] != '')
$expiration = $item_vals['Expiration'][0];
if ($expiration != ''){
}
foreach($show_attrs as $key => $desc){
$name = $attrmap["$key"];
+ $generic = $attrmap[generic]["$key"];
if ($name == 'none')
continue;
unset($vals);
unset($selected);
unset($ops);
+ $def_added = 0;
if ($item_vals["$key"][count]){
for($i=0;$i<$item_vals["$key"][count];$i++){
$vals[] = $item_vals["$key"][$i];
}
}
else{
- $vals[] = $default_vals["$key"];
- $ops[] = ($default_vals["$key"][operator] != '') ? $default_vals["$key"][operator] : '=';
+ if ($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 ($add && $name == $add_attr){
- array_push($vals, $default_vals["$key"]);
- array_push($ops, '=');
+ $vals[] = $default_vals["$key"][0];
+ $ops[] = ($default_vals["$key"][operator][0] != '') ? $default_vals["$key"][operator][0] : '=';
}
$i = 0;
if ($name == 'none')
continue;
$oper_name = $name . '_op';
- $val = ($item_vals["$key"][0] != "") ? $item_vals["$key"][0] : $default_vals["$key"];
+ $val = ($item_vals["$key"][0] != "") ? $item_vals["$key"][0] : $default_vals["$key"][0];
print <<<EOM
<tr>
<td align=right bgcolor="#d0ddb0">
$vars = array( 'Dialup-Access' => 'TRUE','Dialup-Lock-Msg' => '-',
'Max-Weekly-Session' => 0,'Max-Daily-Session' => 0);
foreach($vars as $key => $val){
- $val = ($item_vals["$key"][0] != "") ? $item_vals["$key"][0] : $default_vals["$key"];
+ $val = ($item_vals["$key"][0] != "") ? $item_vals["$key"][0] : $default_vals["$key"][0];
$vars["$key"]=$val;
}
$vars['Dialup-Access'] = ($vars['Dialup-Access'] == 'FALSE') ? 'inactive' : 'active';
if (ereg('^[[:space:]]*#',$val) || ereg('^[[:space:]]*$',$val))
continue;
list($key,$v)=split(":[[:space:]]*",$val);
- $default_vals["$key"]="$v";
+ $default_vals["$key"][0]="$v";
}
if (is_file("../lib/$config[general_lib_type]/defaults.php3"))
include("../lib/$config[general_lib_type]/defaults.php3");
function bytes2str($bytes)
{
$bytes=floor($bytes);
+ if ($bytes > 536870912)
+ $str = sprintf("%5.2f GBs", $bytes/1073741824);
if ($bytes > 524288)
$str = sprintf("%5.2f MBs", $bytes/1048576);
else
{
return $ret;
}
+function check_defaults($val,$op,$def)
+{
+ for($i=0;$i<$def[count];$i++){
+ if ($val == $def[$i] && ($op == '' || $op == $def[operator][$i]))
+ return 1;
+ }
+
+ return 0;
+}
?>
$val=chop($val);
if (ereg('^[[:space:]]*#',$val) || ereg('^[[:space:]]*$',$val))
continue;
- list(,$key,$v)=split('[[:space:]]+',$val);
+ list(,$key,$v,$g)=split('[[:space:]]+',$val);
$v = strtolower($v);
$attrmap["$key"]=$v;
+ $attrmap[generic]["$key"]=$g;
}
$ARR = file("$config[general_extra_ldap_attrmap]");
foreach($ARR as $val){
$val=chop($val);
if (ereg('^[[:space:]]*#',$val) || ereg('^[[:space:]]*$',$val))
continue;
- list(,$key,$v)=split('[[:space:]]+',$val);
+ list(,$key,$v,$g)=split('[[:space:]]+',$val);
$v = strtolower($v);
$attrmap["$key"]=$v;
+ $attrmap[generic]["$key"]=$g;
}
?>
<?php
+require('../lib/functions.php3');
$ds = @ldap_connect($config[ldap_server]);
if ($ds){
$r = @ldap_bind($ds,"$config[ldap_binddn]",$config[ldap_bindpw]);
// if value is the same as the default and the corresponding attribute in ldap does not exist or
// the value is the same as that in ldap then continue
//
- if ( ($val == $default_vals["$key"] && !isset($item_vals["$key"][$j])) ||
- $val == $item_vals["$key"][$j])
+ if ( (check_defaults($val,'',$default_vals["$key"]) && !isset($item_vals["$key"][$j])) || $val == $item_vals["$key"][$j])
continue;
//
// if value is null and ldap attribute does not exist then continue
// if values is the same as the default or if the value is null and the ldap attribute exists
// then delete them
//
- if (($val == $default_vals["$key"] || $val == '') &&
+ if ((check_defaults($val,'',$default_vals["$key"]) || $val == '') &&
isset($item_vals["$key"][$j]))
$del[$attrmap["$key"]][] = $item_vals["$key"][$j];
//
// if value is the same as the default and the corresponding attribute in ldap does not exist or
// the value is the same as that in ldap then continue
//
- if ( $$attrmap["$key"] == $default_vals["$key"])
+ if ( check_defaults($$attrmap["$key"],'',$default_vals["$key"]))
continue;
if ( $$attrmap["$key"] == '')
continue;
$dn = $info[0]['dn'];
if ($dn != ''){
foreach($attrmap as $key => $val){
- if ($info[0]["$val"][0] != '')
- $default_vals["$key"] = $info[0]["$val"][0];
+ if ($info[0]["$val"][0] != ''){
+ if ($attrmap[generic]["$key"] == 'generic'){
+ for($i=0;$i<$info[0]["$val"][count];$i++)
+ $default_vals["$key"][] = $info[0]["$val"][$i];
+ $default_vals["$key"][count] += $info[0]["$val"][count];
+ }
+ else
+ $default_vals["$key"] = $info[0]["$val"];
+ }
}
}
}
$dn3 = $info2[0]['dn'];
if ($dn3 != ''){
foreach($attrmap as $key => $val){
- if ($info2[0]["$val"][0] != '')
- $default_vals["$key"] = $info2[0]["$val"][0];
+ if ($info2[0]["$val"][0] != ''){
+ if (!isset($default_vals["$key"]))
+ $default_vals["$key"] = array();
+ if ($attrmap[generic]["$key"] == 'generic'){
+ for($i=0;$i<$info2[0]["$val"][count];$i++)
+ $default_vals["$key"][] = $info2[0]["$val"][$i];
+ $default_vals["$key"][count] += $info2[0]["$val"][count];
+ }
+ else
+ $default_vals["$key"] = $info2[0]["$val"];
+ }
}
}
}
<?php
+require('../lib/functions.php3');
if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php3"))
include_once("../lib/sql/drivers/$config[sql_type]/functions.php3");
else{
// if value is the same as that in the sql database do nothing
if ($val == $item_vals["$key"][$j])
continue;
- // if value is null and corresponding value exists then delete
- else if (($val == $default_vals["$key"] || $val == '') && isset($item_vals["$key"][$j])){
+ // if value is null or equals the default value and corresponding value exists then delete
+ else if ((check_defaults($val,$op_val,$default_vals["$key"]) || $val == '') && isset($item_vals["$key"][$j])){
$res = @da_sql_query($link,$config,
"DELETE FROM $table WHERE $query_key = '$login' AND Attribute = '$sql_attr';");
if (!$res || !@da_sql_affected_rows($link,$res,$config))
echo "<b>Delete failed for attribute $key: " . da_sql_error($link,$config) . "</b><br>\n";
}
- // if value is null then don't add it
- else if ($val == '')
+ // if value is null or equals the default value then don't add it
+ else if ($val == '' || check_defaults($val,$op_val,$default_vals["$key"]))
continue;
// if value differs from the sql value then update
else{
echo "<b>Invalid operator ($op_val) for attribute $key</b><br>\n";
coninue;
}
- $op_val = ",'$op_val'";
+ $op_val2 = ",'$op_val'";
}
- if ($val == '' || $val == $default_vals["$key"])
+ if ($val == '' || check_defaults($val,$op_val,$default_vals["$key"]))
continue;
$res = @da_sql_query($link,$config,
"INSERT INTO $table (Attribute,Value,GroupName $text)
- VALUES ('$attrmap[$key]','$val','$login' $op_val);");
+ VALUES ('$attrmap[$key]','$val','$login' $op_val2;");
if (!$res || !@da_sql_affected_rows($link,$res,$config))
echo "<b>Query failed for attribute $key: " . da_sql_error($link,$config) . "</b><br>\n";
}
echo "<b>Could not add user to group $Fgroup: " . da_sql_error($link,$config) . "</b><br>\n";
}
if (!$da_abort){
+ if ($Fgroup != '')
+ require('../lib/defaults.php3');
foreach($show_attrs as $key => $attr){
if ($attrmap["$key"] == 'none')
continue;
echo "<b>Invalid operator ($op_val) for attribute $key</b><br>\n";
coninue;
}
- $op_val = ",'$op_val'";
+ $op_val2 = ",'$op_val'";
}
- if ($val == '' || $val == $default_vals["$key"])
+ if ($val == '' || check_defaults($val,$op_val,$default_vals["$key"]))
continue;
$res = @da_sql_query($link,$config,
"INSERT INTO $table (Attribute,Value,UserName $text)
- VALUES ('$attrmap[$key]','$val','$login' $op_val);");
+ VALUES ('$attrmap[$key]','$val','$login' $op_val2);");
if (!$res || !@da_sql_affected_rows($link,$res,$config))
echo "<b>Query failed for attribute $key: " . da_sql_error($link,$config) . "</b><br>\n";
}
foreach($attrmap as $key => $val){
if (isset($tmp[$val])){
if ($use_op)
- if ($tmp[$val][operator][0] != '')
- $default_vals["$key"][operator] = $tmp[$val][operator][0];
+ $default_vals["$key"][operator] = $tmp["$val"][operator];
if ($tmp[$val][0] != '')
- $default_vals["$key"] = $tmp[$val][0];
+ $default_vals["$key"] = $tmp["$val"];
}
}
}