]> git.entuzijast.net Git - freeradius-dialup-admin.git/commitdiff
Use sql_extra_servers directive when adding users in the badusers table. Add a...
authorkkalev <kkalev>
Mon, 3 Feb 2003 16:15:25 +0000 (16:15 +0000)
committerkkalev <kkalev>
Mon, 3 Feb 2003 16:15:25 +0000 (16:15 +0000)
  to connect to a specific sql host

Changelog
conf/admin.conf
lib/add_badusers.php3
lib/sql/drivers/mysql/functions.php3
lib/sql/drivers/pg/functions.php3

index a831fe37b21fbb645963ce3d89d826daa497216e..69895d7c29bdd2bd2e1bd5074aa33e8de79e8d0c 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -5,6 +5,8 @@ Ver 1.63:
   instead of writing it directly in UUCP format.
 * Call lib/{ldap,sql}/user_info in user_info before displaying any information about the user
 * Add a configuration directive general_charset. Add a language meta tag in all pages
+* Use sql_extra_servers directive when adding users in the badusers table. Add a da_sql_host_connect() function
+  to connect to a specific sql host
 Ver 1.62:
 * Remove one sql query from user_admin which was not needed.
 * Instead of a query like "LIKE 'YYYY-MM-DD%'" use "AcctStopTime >= 'YYYY-MM-DD 00:00:00 AND AcctStopTime
index d89a0085ac445feecac024aed671f824d86df029..610cdfa664a611003e64c1f94581c723df8ad551 100644 (file)
@@ -218,7 +218,7 @@ sql_row_limit: 40
 # Set the sql connect timeout (secs)
 sql_connect_timeout: 3
 # Give a space separated list of extra mysql servers to connect to when
-# logging bad logins
+# logging bad logins or adding users in the badusers table
 #sql_extra_servers: sql2.company.com sql3.company.com
 
 counter_default_daily: 14400
index 2eefab286738e9ceaf08bda3b0f1c82f8260f813..517d8664d37195bfccb4a9adbdc972e04124accc 100644 (file)
@@ -15,15 +15,21 @@ if ($HTTP_SERVER_VARS["PHP_AUTH_USER"] != '')
 if ($msg == '')
        echo "<b>Lock Message should not be empty</b><br>\n";
 else{
-       $link = @da_sql_pconnect($config);
-       if ($link){
-               $r = da_sql_query($link,$config,
-               "INSERT INTO $config[sql_badusers_table] (UserName,Date,Admin,Reason)
-               VALUES ('$login','$date','$admin','$msg');");
-               if (!$r)
-                       echo "<b>SQL Error:" . da_sql_error($link,$config) . "</b><br>\n";
+       $sql_servers = array();
+       if ($config[sql_extra_servers] != '')
+               $sql_servers = explode(' ',$config[sql_extra_servers]);
+       $sql_servers[] = $config[sql_server];
+       foreach ($sql_servers as $server){
+               $link = @da_sql_host_connect($server,$config);
+               if ($link){
+                       $r = da_sql_query($link,$config,
+                       "INSERT INTO $config[sql_badusers_table] (UserName,Date,Admin,Reason)
+                       VALUES ('$login','$date','$admin','$msg');");
+                       if (!$r)
+                               echo "<b>SQL Error:" . da_sql_error($link,$config) . "</b><br>\n";
+               }
+               else
+                       echo "<b>SQL Error: Could not connect to SQL database: $server</b><br>\n";
        }
-       else
-               echo "<b>SQL Error: Could not connect to SQL database</b><br>\n";
 }
 ?>
index 42ce98b1ad085e3536a61699a561cf4f9ec79c6d..2cc539d0a6bcaf0112f5f45ae202739ff2ab20d9 100644 (file)
@@ -1,4 +1,19 @@
 <?php
+function da_sql_host_connect($server,$config)
+{
+       if ($config[sql_use_http_credentials] == 'yes'){
+               global $HTTP_SERVER_VARS;
+               $SQL_user = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
+               $SQL_passwd = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
+       }
+       else{
+               $SQL_user = $config[sql_username];
+               $SQL_passwd = $config[sql_password];
+       }
+
+       return @mysql_connect("$server:$config[sql_port]",$SQL_user,$SQL_passwd);
+}
+
 function da_sql_connect($config)
 {
        if ($config[sql_use_http_credentials] == 'yes'){
@@ -16,8 +31,17 @@ function da_sql_connect($config)
 
 function da_sql_pconnect($config)
 {
-       return @mysql_pconnect("$config[sql_server]:$config[sql_port]",$config[sql_username],
-                               $config[sql_password]);
+       if ($config[sql_use_http_credentials] == 'yes'){
+               global $HTTP_SERVER_VARS;
+               $SQL_user = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
+               $SQL_passwd = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
+       }
+       else{
+               $SQL_user = $config[sql_username];
+               $SQL_passwd = $config[sql_password];
+       }
+
+       return @mysql_pconnect("$config[sql_server]:$config[sql_port]",$SQL_user,$SQL_passwd);
 }
 
 function da_sql_close($link,$config)
index b65e1f380e7a40eeea4a7f729bfe4e981bb048e1..94fadd8f5dd28ba8ca7b341350b8fd5d793ebd94 100644 (file)
@@ -1,4 +1,20 @@
 <?php
+function da_sql_host_connect($server,$config)
+{
+       if ($config[sql_use_http_credentials] == 'yes'){
+               global $HTTP_SERVER_VARS;
+               $SQL_user = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
+               $SQL_passwd = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
+       }
+       else{
+               $SQL_user = $config[sql_username];
+               $SQL_passwd = $config[sql_password];
+       }
+       return @pg_connect("host=$server port=$config[sql_port]
+                       dbname=$config[sql_database] user=$SQL_user
+                       password=$SQL_passwd");
+}
+
 function da_sql_connect($config)
 {
        if ($config[sql_use_http_credentials] == 'yes'){
@@ -17,9 +33,18 @@ function da_sql_connect($config)
 
 function da_sql_pconnect($config)
 {
+       if ($config[sql_use_http_credentials] == 'yes'){
+               global $HTTP_SERVER_VARS;
+               $SQL_user = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
+               $SQL_passwd = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
+       }
+       else{
+               $SQL_user = $config[sql_username];
+               $SQL_passwd = $config[sql_password];
+       }
        return @pg_pconnect("host=$config[sql_server] port=$config[sql_port]
-                       dbname=$config[sql_database] user=$config[sql_username]
-                       password=$config[sql_password]");
+                       dbname=$config[sql_database] user=$SQL_user
+                       password=$SQL_passwd");
 }
 
 function da_sql_close($link,$config)