From: kkalev Date: Mon, 26 Jul 2004 21:13:06 +0000 (+0000) Subject: * Add a drop down menu with existing groups in group_new.php3 X-Git-Url: https://git.entuzijast.net/?a=commitdiff_plain;h=6bed9084a35882b9ac26d2bc76b62188e2164664;p=freeradius-dialup-admin.git * Add a drop down menu with existing groups in group_new.php3 * Check for sql in show_groups.php3 * In lib/sql/group_info.php3 if $login is not set, find available groups and place them in $existing_groups along with a count of users per group. Use the functionality in group_new.php3 and show_groups.php3 * Update TODO --- diff --git a/Changelog b/Changelog index 24bf5bd..123b745 100644 --- a/Changelog +++ b/Changelog @@ -5,6 +5,12 @@ Ver 1.75: * Update FAQ about using php with no sql support. * Allow the user to select between viewing FAQ,HOWTO or README in the help page. * Use $_SERVER instead of $HTTP_SERVER_VARS +* Add a drop down menu with existing groups in group_new.php3 +* Check for sql in show_groups.php3 +* In lib/sql/group_info.php3 if $login is not set, find available groups and place them in + $existing_groups along with a count of users per group. Use the functionality in group_new.php3 + and show_groups.php3 +* Update TODO Ver 1.72: * Move the xlat function to a separate file in lib/xlat.php3 * Add a lib/sql/nas_list.php3 to also get the nas list from sql (naslist.conf still works) diff --git a/doc/TODO b/doc/TODO index 2d71d3f..2bea55f 100644 --- a/doc/TODO +++ b/doc/TODO @@ -1,8 +1,6 @@ * Minimize database (ldap,mysql) connections. * Clean up html code to make it smaller * More messages -* Skins -* Other languages in html * Multilanguage support for ldap attributes * Add language attributes in user_new.php3 * Finger facility. Should find a way to make it work with all nases. That will @@ -17,4 +15,6 @@ * Parse the radius dictionary files so that we can show a pull down menu of possible values for various attributes. * Check the sql user code for sql injections -* Also be able to keep username mappings in sql. Create and administration page +* Also be able to keep username mappings in sql. Create an administration page +* Get rid of register_globals. We only need a few user passed variables, we should get those + from the superglobals. diff --git a/htdocs/group_new.php3 b/htdocs/group_new.php3 index fe0d6e1..f3a3673 100644 --- a/htdocs/group_new.php3 +++ b/htdocs/group_new.php3 @@ -22,6 +22,7 @@ EOM; require('../lib/attrshow.php3'); require('../lib/defaults.php3'); +require("../lib/$config[general_lib_type]/group_info.php3"); if ($config[general_lib_type] == 'sql' && $config[sql_use_operators] == 'true'){ $colspan=2; @@ -85,6 +86,22 @@ EOM; + $group){ + $num++; + echo << EOM; - } - } - else - echo "Could not find any groups
\n"; } - else - echo "Database query failed: " . da_sql_error($link,$config) . "
\n"; } else - echo "Could not connect to SQL database
\n"; + echo "Could not find any groups
\n"; ?>
+ Available Groups + +EOM; + if (!isset($existing_groups)) + echo "No groups available\n"; + else{ + echo "\n"; + } + echo << +
Group name diff --git a/htdocs/show_groups.php3 b/htdocs/show_groups.php3 index b652cab..e53711b 100644 --- a/htdocs/show_groups.php3 +++ b/htdocs/show_groups.php3 @@ -20,6 +20,20 @@ else{ EOM; exit(); } +if ($config[general_lib_type] != 'sql'){ + echo <<User Groups + + + + +
+This page is only available if you are using sql as general library type + + +EOM; + exit(); +} ?> User Groups @@ -55,33 +69,23 @@ EOM;
$num $group $num_members
diff --git a/lib/sql/group_info.php3 b/lib/sql/group_info.php3 index fda77a6..0ad59b3 100644 --- a/lib/sql/group_info.php3 +++ b/lib/sql/group_info.php3 @@ -17,25 +17,26 @@ $group_exists = 'no'; unset($item_vals); unset($tmp); unset($group_members); +unset($existing_groups); $link = @da_sql_pconnect($config); if ($link){ - $res = @da_sql_query($link,$config, - "SELECT attribute,value $op FROM $config[sql_groupcheck_table] WHERE groupname = '$login';"); - if ($res){ - if (@da_sql_num_rows($res,$config)) - $group_exists = 'yes'; - while(($row = @da_sql_fetch_array($res,$config))){ - $attr = $row[attribute]; - $val = $row[value]; - if ($use_op){ - $oper = $row[op]; - $tmp["$attr"][operator][]="$oper"; + if ($login == ''){ + $res = @da_sql_query($link,$config, + "SELECT COUNT(*) as counter,groupname FROM $config[sql_usergroup_table] + GROUP BY groupname;"); + if ($res){ + while(($row = @da_sql_fetch_array($res,$config))){ + $name = $row[groupname]; + $existing_groups["$name"] = $row[counter]; } - $tmp["$attr"][]="$val"; - $tmp["$attr"][count]++; + ksort($existing_groups); } + else + echo "Database query failed: " . da_sql_error($link,$config) . "
\n"; + } + else{ $res = @da_sql_query($link,$config, - "SELECT attribute,value $op FROM $config[sql_groupreply_table] WHERE groupname = '$login';"); + "SELECT attribute,value $op FROM $config[sql_groupcheck_table] WHERE groupname = '$login';"); if ($res){ if (@da_sql_num_rows($res,$config)) $group_exists = 'yes'; @@ -46,45 +47,60 @@ if ($link){ $oper = $row[op]; $tmp["$attr"][operator][]="$oper"; } - $tmp["$attr"][] = "$val"; + $tmp["$attr"][]="$val"; $tmp["$attr"][count]++; } - } - else - echo "Database query failed partially: " . da_sql_error($link,$config) . "
\n"; - $res = @da_sql_query($link,$config, - "SELECT username FROM $config[sql_usergroup_table] WHERE groupname = '$login' ORDER BY username;"); - if ($res){ - if (@da_sql_num_rows($res,$config)) - $group_exists = 'yes'; - while(($row = @da_sql_fetch_array($res,$config))){ - $member = $row[username]; - $group_members[] = "$member"; + $res = @da_sql_query($link,$config, + "SELECT attribute,value $op FROM $config[sql_groupreply_table] WHERE groupname = '$login';"); + if ($res){ + if (@da_sql_num_rows($res,$config)) + $group_exists = 'yes'; + while(($row = @da_sql_fetch_array($res,$config))){ + $attr = $row[attribute]; + $val = $row[value]; + if ($use_op){ + $oper = $row[op]; + $tmp["$attr"][operator][]="$oper"; + } + $tmp["$attr"][] = "$val"; + $tmp["$attr"][count]++; + } } - } - else - echo "Database query failed partially: " . da_sql_error($link,$config) . "
\n"; - if (isset($tmp)){ - foreach(array_keys($tmp) as $val){ - if ($val == '') - continue; - $key = $rev_attrmap["$val"]; - if ($key == ''){ - $key = $val; - $attrmap["$key"] = $val; - $attr_type["$key"] = 'replyItem'; - $rev_attrmap["$val"] = $key; + else + echo "Database query failed partially: " . da_sql_error($link,$config) . "
\n"; + $res = @da_sql_query($link,$config, + "SELECT username FROM $config[sql_usergroup_table] WHERE groupname = '$login' ORDER BY username;"); + if ($res){ + if (@da_sql_num_rows($res,$config)) + $group_exists = 'yes'; + while(($row = @da_sql_fetch_array($res,$config))){ + $member = $row[username]; + $group_members[] = "$member"; + } + } + else + echo "Database query failed partially: " . da_sql_error($link,$config) . "
\n"; + if (isset($tmp)){ + foreach(array_keys($tmp) as $val){ + if ($val == '') + continue; + $key = $rev_attrmap["$val"]; + if ($key == ''){ + $key = $val; + $attrmap["$key"] = $val; + $attr_type["$key"] = 'replyItem'; + $rev_attrmap["$val"] = $key; + } + $item_vals["$key"] = $tmp[$val]; + $item_vals["$key"][count] = $tmp[$val][count]; + if ($use_op) + $item_vals["$key"][operator] = $tmp[$val][operator]; } - $item_vals["$key"] = $tmp[$val]; - $item_vals["$key"][count] = $tmp[$val][count]; - if ($use_op) - $item_vals["$key"][operator] = $tmp[$val][operator]; } } - + else + echo "Database query failed: " . da_sql_error($link,$config) . "
\n"; } - else - echo "Database query failed: " . da_sql_error($link,$config) . "
\n"; } else echo "Could not connect to SQL database
\n";