]> git.entuzijast.net Git - freeradius-dialup-admin.git/commitdiff
In lib/sql/defaults.php3 instead of doing a select for each group the user
authorkkalev <kkalev>
Sun, 8 Sep 2002 13:24:19 +0000 (13:24 +0000)
committerkkalev <kkalev>
Sun, 8 Sep 2002 13:24:19 +0000 (13:24 +0000)
belongs to, do one select with a where in () caluse.

Changelog
lib/sql/defaults.php3

index 2802c9f6185c8846246cfa944034d8841d4b77db..3457a9ccfcdbe1f8789a76585fd39638e18b4bf0 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,4 @@
-Ver 1.60:
+Ver 1.59:
 * Small html fixes in user_edit.php3 and password.php3
 * Show number of failed logins in the last 7 days in the user admin page
 * Show date in the user/server test page
@@ -40,6 +40,8 @@ Ver 1.60:
 * Fix a few bugs
 * Remove the auto password generator from the user edit page. It has no meaning since the password is not
   shown
+* In lib/sql/defaults.php3 instead of doing a select for each group the user belongs to, do one select with
+  a where in () caluse.
 Ver 1.55:
 * Update the FAQ about missing attributes from the user/group edit pages and add a few comments
   in the configuration files
index 9b9a47d130681bb9ba23aeeb1773ba49f4385e79..c0a85e6eb3cf86ed1feb8f71c092bc5e054f1cef 100644 (file)
@@ -31,10 +31,28 @@ if ($login != ''){
                                        $member_groups[] = $row[GroupName];
                        }
                        if (isset($member_groups)){
-                               foreach ($member_groups as $group){
+                               $in = '(';
+                               foreach ($member_groups as $group)
+                                       $in .= "'$group',";
+                               $in = substr($in,0,-1);
+                               $in .= ')';     
+                               $res = @da_sql_query($link,$config,
+                               "SELECT Attribute,Value $op FROM $config[sql_groupcheck_table]
+                               WHERE GroupName IN $in;");
+                               if ($res){
+                                       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]++;
+                                       }
                                        $res = @da_sql_query($link,$config,
-                                       "SELECT Attribute,Value $op FROM $config[sql_groupcheck_table]
-                                       WHERE GroupName = '$group';");
+                                       "SELECT Attribute,Value $op FROM $config[sql_groupreply_table]
+                                       WHERE GroupName IN $in;");
                                        if ($res){
                                                while(($row = @da_sql_fetch_array($res,$config))){
                                                        $attr = $row[Attribute];
@@ -43,46 +61,31 @@ if ($login != ''){
                                                                $oper = $row[op];
                                                                $tmp["$attr"][operator][]="$oper";
                                                        }
-                                                       $tmp["$attr"][]="$val";
+                                                       $tmp["$attr"][] = "$val";
                                                        $tmp["$attr"][count]++;
                                                }
-                                               $res = @da_sql_query($link,$config,
-                                               "SELECT Attribute,Value $op FROM $config[sql_groupreply_table]
-                                               WHERE GroupName = '$group';");
-                                               if ($res){
-                                                       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 "<b>Database query failed partially: " . da_sql_error($link,$config) . "</b><br>\n";
                                        }
                                        else
-                                               echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\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;
-                                                       }
-                                                       if (!isset($default_vals["$key"]) || $overwrite_defaults){
-                                                               if ($use_op)
-                                                                       $default_vals["$key"][operator] = $tmp["$val"][operator];
-                                                               if ($tmp[$val][0] != '')
-                                                                       $default_vals["$key"] = $tmp["$val"];
-                                                       }
+                                               echo "<b>Database query failed partially: " . da_sql_error($link,$config) . "</b><br>\n";
+                               }
+                               else
+                                       echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\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;
+                                               }
+                                               if (!isset($default_vals["$key"]) || $overwrite_defaults){
+                                                       if ($use_op)
+                                                               $default_vals["$key"][operator] = $tmp["$val"][operator];
+                                                       if ($tmp[$val][0] != '')
+                                                               $default_vals["$key"] = $tmp["$val"];
                                                }
                                        }
                                }