3 # Display a list of all database users
5 require './mysql-lib.pl';
6 $access{'perms'} == 1 || &error($text{'perms_ecannot'});
7 &ui_print_header(undef, $text{'users_title'}, "", "users");
9 print &ui_form_start("delete_users.cgi");
10 @rowlinks = ( &select_all_link("d", 0),
11 &select_invert_link("d", 0),
12 "<a href='edit_user.cgi?new=1'>$text{'users_add'}</a>" );
13 print &ui_links_row(\@rowlinks);
15 print &ui_columns_start([ "",
19 $mysql_version >= 5 ? ( $text{'users_ssl'} ) : ( ),
20 $text{'users_perms'} ], 100, 0, \@tds);
21 $d = &execute_sql_safe($master_db, "select * from user order by user");
22 %fieldmap = map { $_->{'field'}, $_->{'index'} }
23 &table_structure($master_db, "user");
25 foreach $u (@{$d->{'data'}}) {
27 push(@cols, "<a href='edit_user.cgi?idx=$i'>".
28 ($u->[1] ? &html_escape($u->[1]) : $text{'users_anon'}).
30 push(@cols, $u->[0] eq '' || $u->[0] eq '%' ?
31 $text{'user_any'} : &html_escape($u->[0]));
32 push(@cols, &html_escape($u->[2]));
33 if ($mysql_version >= 5) {
34 $ssl = $u->[$fieldmap{'ssl_type'}];
35 push(@cols, $text{'user_ssl_'.lc($ssl)} || $ssl);
38 for($j=3; $j<=&user_priv_cols()+3-1; $j++) {
39 push(@priv, $text{"users_priv$j"}) if ($u->[$j] eq 'Y');
42 scalar(@priv) == &user_priv_cols() ? $text{'users_all'} :
43 !@priv ? $text{'users_none'} : join(" | ", @priv));
44 print &ui_checked_columns_row(\@cols, \@tds, "d", $u->[0]." ".$u->[1]);
47 print &ui_columns_end();
48 print &ui_links_row(\@rowlinks);
49 print &ui_form_end([ [ "delete", $text{'users_delete'} ] ]);
51 # Unix / MySQL user syncing
53 print &ui_form_start("save_sync.cgi");
54 print "$text{'users_sync'}<p>\n";
55 print &ui_table_start(undef, undef, 2);
58 print &ui_table_row($text{'users_syncwhen'},
59 &ui_checkbox("sync_create", 1, $text{'users_sync_create'},
60 $config{'sync_create'})."<br>\n".
61 &ui_checkbox("sync_modify", 1, $text{'users_sync_modify'},
62 $config{'sync_modify'})."<br>\n".
63 &ui_checkbox("sync_delete", 1, $text{'users_sync_delete'},
64 $config{'sync_delete'}));
67 print &ui_table_row($text{'users_sync_privs'},
68 &ui_select("sync_privs",
69 [ split(/\s+/, $config{'sync_privs'}) ],
70 [ map { [ $_, $text{"user_priv$_"} ] }
71 ( 3 .. &user_priv_cols()+3-1 ) ],
75 print &ui_table_row($text{'users_sync_host'},
76 &ui_opt_textbox("host", $config{'sync_host'}, 30,
77 $text{'users_sync_def'}, $text{'users_sync_sel'}));
79 print &ui_table_end();
80 print &ui_form_end([ [ undef, $text{'save'} ] ]);
82 &ui_print_footer("", $text{'index_return'});