From f5eccbbc9f5cbdb5f134975f15f700c57a2cb8df Mon Sep 17 00:00:00 2001 From: Ilia Rostovtsev Date: Wed, 16 Mar 2022 00:22:54 +0200 Subject: [PATCH] Add better UX --- add.cgi | 6 +++++- add_form.cgi | 4 ++-- index.cgi | 10 +++++++++- lang/en | 3 +++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/add.cgi b/add.cgi index 9aaee6d..a4e8eb4 100755 --- a/add.cgi +++ b/add.cgi @@ -14,6 +14,10 @@ $d && &virtual_server::can_edit_domain($d) || &error($text{'index_ecannot'}); my $pub = &virtual_server::public_html_dir($d); my $cgi = &virtual_server::cgi_bin_dir($d); my $dir; +my $tdir_escaped = $in{'dir_def'} == 1 ? "".&html_escape($text{'add_all'})."" : + $in{'cgi'} ? "".&html_escape("$d->{'cgi_bin_dir'}/$in{'cgi'}")."" : + $in{'dir'} ? "".&html_escape("$d->{'public_html_dir'}/$in{'dir'}")."" : ""; + if ($in{'dir_def'} == 1) { # Whole website $dir = $pub; @@ -85,5 +89,5 @@ my $dirstr = [ $dir, $usersfile, 0, 0, undef ]; push(@dirs, $dirstr); &htaccess_htpasswd::save_directories(\@dirs); -&redirect("index.cgi?dom=$in{'dom'}"); +&redirect("index.cgi?dom=$in{'dom'}&added=1&type=".&urlize($tdir_escaped)); diff --git a/add_form.cgi b/add_form.cgi index 7dd11e4..cbbce92 100755 --- a/add_form.cgi +++ b/add_form.cgi @@ -34,8 +34,8 @@ else { print &ui_table_row(&hlink($text{'add_dir'}, 'add_dir'), &ui_radio_table("dir_def", 1, [ [ 1, $text{'add_all'} ], - [ 0, $text{'add_subdir'}, &ui_textbox("dir", undef, 30) ], - [ 2, $text{'add_subcgi'}, &ui_textbox("cgi", undef, 30) ] ])); + [ 0, $text{'add_subdir'}, &ui_textbox("dir", undef, 40, undef, undef, " placeholder=\"$text{'add_tip_under'} @{["e_escape($d->{'public_html_dir'})]}/\"") ], + [ 2, $text{'add_subcgi'}, &ui_textbox("cgi", undef, 40, undef, undef, " placeholder=\"$text{'add_tip_under'} @{["e_escape($d->{'cgi_bin_dir'})]}/\"") ] ])); # Authentication realm print &ui_table_row(&hlink($text{'add_desc'}, 'add_desc'), diff --git a/index.cgi b/index.cgi index 999853d..35acb4e 100755 --- a/index.cgi +++ b/index.cgi @@ -21,7 +21,15 @@ my @dirs = &htaccess_htpasswd::list_directories(); &ui_print_header($d ? &virtual_server::domain_in($d) : undef, $text{'index_title'}, "", "intro", 0, 1); - +if ($in{'added'}) { + print &ui_alert_box( + &text("index_alert_added_desc", + "@{[&virtual_server::get_webprefix_safe()]}/virtual-server/list_users.cgi?dom=".&urlize($in{'dom'}), + $in{'type'} + ), + "success", undef, 1, $text{'index_alert_added_title'}, 'fa-lock' + ); + } # Build table of directories my @table = ( ); foreach my $dir (@dirs) { diff --git a/lang/en b/lang/en index b137ed2..2c2f61b 100644 --- a/lang/en +++ b/lang/en @@ -10,6 +10,8 @@ index_return=protected directories index_hdir=Entire website index_find=Find Protected Directories index_finddesc=Find other directories under $1 that have been protected manually, so that their allowed users can be managed. +index_alert_added_desc=You can control which users have access to $2 using Edit Users: Mail and FTP Users page. +index_alert_added_title=Protection Enabled! feat_name=Protected web directories feat_edep=The Protected Web Directories module is not installed @@ -39,6 +41,7 @@ add_eclash2=The users file $1 already exists add_eclash3=The protection file $1 already exists and contains the $2 directive add_edesc=No description entered add_esymlink=The protection file $1 is a symbolic link +add_tip_under=i.e. under delete_err=Failed to remove protection delete_enone=None selected