diff --git a/acl/edit_sql.cgi b/acl/edit_sql.cgi index 9dd9c85d2..b15dd731e 100755 --- a/acl/edit_sql.cgi +++ b/acl/edit_sql.cgi @@ -1,19 +1,24 @@ #!/usr/local/bin/perl # Show form for an external user / group database +use strict; +use warnings; require './acl-lib.pl'; +our (%in, %text, %config, %access); $access{'sql'} || &error($text{'sql_ecannot'}); &ui_print_header(undef, $text{'sql_title'}, ""); + +my %miniserv; &get_miniserv_config(\%miniserv); print &ui_form_start("save_sql.cgi"); print &ui_table_start($text{'sql_header'}, undef, 2); -($proto, $user, $pass, $host, $prefix, $args) = +my ($proto, $user, $pass, $host, $prefix, $args) = &split_userdb_string($miniserv{'userdb'}); # Build inputs for MySQL backend -@mysqlgrid = ( ); +my @mysqlgrid = ( ); push(@mysqlgrid, $text{'sql_host'}, &ui_textbox("mysql_host", $proto eq "mysql" ? $host : "", 30)); @@ -26,10 +31,10 @@ push(@mysqlgrid, push(@mysqlgrid, $text{'sql_db'}, &ui_textbox("mysql_db", $proto eq "mysql" ? $prefix : "", 30)); -$mysqlgrid = &ui_grid_table(\@mysqlgrid, 2, 100); +my $mysqlgrid = &ui_grid_table(\@mysqlgrid, 2, 100); # Build inputs for PostgreSQL backend -@postgresqlgrid = ( ); +my @postgresqlgrid = ( ); push(@postgresqlgrid, $text{'sql_host'}, &ui_textbox("postgresql_host", $proto eq "postgresql" ? $host : "", 30)); @@ -42,10 +47,10 @@ push(@postgresqlgrid, push(@postgresqlgrid, $text{'sql_db'}, &ui_textbox("postgresql_db", $proto eq "postgresql" ? $prefix : "", 30)); -$postgresqlgrid = &ui_grid_table(\@postgresqlgrid, 2, 100); +my $postgresqlgrid = &ui_grid_table(\@postgresqlgrid, 2, 100); # Build inputs for LDAP backend -@ldapgrid = ( ); +my @ldapgrid = ( ); push(@ldapgrid, $text{'sql_host'}, &ui_textbox("ldap_host", $proto eq "ldap" ? $host : "", 30)); @@ -76,7 +81,7 @@ push(@ldapgrid, push(@ldapgrid, &ui_button($text{'sql_schema'}, undef, 0, "onClick='window.location=\"schema.cgi\"'"), ""); -$ldapgrid = &ui_grid_table(\@ldapgrid, 2, 100); +my $ldapgrid = &ui_grid_table(\@ldapgrid, 2, 100); print &ui_table_row(undef, &ui_radio_table("proto", $proto, diff --git a/acl/save_sql.cgi b/acl/save_sql.cgi index f0c413cdc..d8c6ad6c4 100755 --- a/acl/save_sql.cgi +++ b/acl/save_sql.cgi @@ -1,14 +1,19 @@ #!/usr/local/bin/perl # Save user and group database +use strict; +use warnings; require './acl-lib.pl'; +our (%in, %text, %config, %access); $access{'pass'} || &error($text{'sql_ecannot'}); -&get_miniserv_config(\%miniserv); &ReadParse(); &error_setup($text{'sql_err'}); -$p = $in{'proto'}; +my %miniserv; +&get_miniserv_config(\%miniserv); # Parse inputs +my $p = $in{'proto'}; +my ($host, $user, $pass, $prefix, $args); if ($p eq 'mysql' || $p eq 'postgresql' || $p eq 'ldap') { &to_ipaddress($in{$p."_host"}) || $in{$p."_host"} =~ /^(\S+):(\d+)$/ && &to_ipaddress("$1") || @@ -47,6 +52,7 @@ elsif ($p eq 'ldap') { } # Create and test connection string +my ($str, $err); if ($p) { $str = &join_userdb_string($p, $user, $pass, $host, $prefix, $args); @@ -70,7 +76,7 @@ if ($err && ($p eq "mysql" || $p eq "postgresql")) { print &ui_form_end([ [ undef, $text{'sql_make'} ] ]); print &ui_table_start(undef, undef, 2); - foreach $sql (&userdb_table_sql($str)) { + foreach my $sql (&userdb_table_sql($str)) { print &ui_table_row(undef, "
".&html_escape($sql)."
", 2); }