From 87670d8dd83422ca1ad386533b6e26474fe1cc52 Mon Sep 17 00:00:00 2001 From: kkalev Date: Mon, 3 Feb 2003 16:15:25 +0000 Subject: [PATCH] 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 --- Changelog | 2 ++ conf/admin.conf | 2 +- lib/add_badusers.php3 | 24 ++++++++++++++--------- lib/sql/drivers/mysql/functions.php3 | 28 +++++++++++++++++++++++++-- lib/sql/drivers/pg/functions.php3 | 29 ++++++++++++++++++++++++++-- 5 files changed, 71 insertions(+), 14 deletions(-) diff --git a/Changelog b/Changelog index a831fe3..69895d7 100644 --- 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 diff --git a/conf/admin.conf b/conf/admin.conf index d89a008..610cdfa 100644 --- a/conf/admin.conf +++ b/conf/admin.conf @@ -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 diff --git a/lib/add_badusers.php3 b/lib/add_badusers.php3 index 2eefab2..517d866 100644 --- a/lib/add_badusers.php3 +++ b/lib/add_badusers.php3 @@ -15,15 +15,21 @@ if ($HTTP_SERVER_VARS["PHP_AUTH_USER"] != '') if ($msg == '') echo "Lock Message should not be empty
\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 "SQL Error:" . da_sql_error($link,$config) . "
\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 "SQL Error:" . da_sql_error($link,$config) . "
\n"; + } + else + echo "SQL Error: Could not connect to SQL database: $server
\n"; } - else - echo "SQL Error: Could not connect to SQL database
\n"; } ?> diff --git a/lib/sql/drivers/mysql/functions.php3 b/lib/sql/drivers/mysql/functions.php3 index 42ce98b..2cc539d 100644 --- a/lib/sql/drivers/mysql/functions.php3 +++ b/lib/sql/drivers/mysql/functions.php3 @@ -1,4 +1,19 @@