diff --git a/mailbox/delete_mail.cgi b/mailbox/delete_mail.cgi index c2cf2420..82054407 100755 --- a/mailbox/delete_mail.cgi +++ b/mailbox/delete_mail.cgi @@ -10,8 +10,9 @@ our (%text, %in, %userconfig, %gconfig); require './mailbox-lib.pl'; &ReadParse(); my @ids = sort { $a <=> $b } split(/\0/, $in{'d'}); -my @folders = &list_folders(); -my $folder = $folders[$in{'folder'}]; +my @folders = &list_folders_sorted(); +my ($folder) = grep { $_->{'index'} == $in{'folder'} } @folders; +$folder || &error($text{'view_efolder'}); my $r = time().$$; my @delmail; diff --git a/mailbox/detach.cgi b/mailbox/detach.cgi index 37f9dbdc..4d4a4808 100755 --- a/mailbox/detach.cgi +++ b/mailbox/detach.cgi @@ -11,8 +11,9 @@ use Socket; require './mailbox-lib.pl'; &ReadParse(); -my @folders = &list_folders(); -my $folder = $folders[$in{'folder'}]; +my @folders = &list_folders_sorted(); +my ($folder) = grep { $_->{'index'} == $in{'folder'} } @folders; +$folder || &error($text{'view_efolder'}); my $mail = &mailbox_get_mail($folder, $in{'id'}, 0); $mail || &error($text{'view_egone'}); &parse_mail($mail); diff --git a/mailbox/detachall.cgi b/mailbox/detachall.cgi index 176d136b..eef45126 100755 --- a/mailbox/detachall.cgi +++ b/mailbox/detachall.cgi @@ -10,8 +10,9 @@ require './mailbox-lib.pl'; &error_setup($text{'detachall_err'}); &ReadParse(); -my @folders = &list_folders(); -my $folder = $folders[$in{'folder'}]; +my @folders = &list_folders_sorted(); +my ($folder) = grep { $_->{'index'} == $in{'folder'} } @folders; +$folder || &error($text{'view_efolder'}); my $mail = &mailbox_get_mail($folder, $in{'id'}, 0); $mail || &error($text{'view_egone'}); &parse_mail($mail); diff --git a/mailbox/search_form.cgi b/mailbox/search_form.cgi index 1f728e9e..7cb0ed93 100755 --- a/mailbox/search_form.cgi +++ b/mailbox/search_form.cgi @@ -10,8 +10,9 @@ our $search_folder_id; require './mailbox-lib.pl'; &ReadParse(); -my @folders = &list_folders_sorted(); +my @folders = &list_folders_sorted(); my ($folder) = grep { $_->{'index'} == $in{'folder'} } @folders; +$folder || &error($text{'view_efolder'}); &set_module_index($in{'folder'}); &ui_print_header(undef, $text{'sform_title'}, ""); diff --git a/mailbox/send_mail.cgi b/mailbox/send_mail.cgi index 30a0da06..1cae5b63 100755 --- a/mailbox/send_mail.cgi +++ b/mailbox/send_mail.cgi @@ -19,8 +19,9 @@ foreach my $k (keys %in) { $in{$k} = join("\0", @{$in{$k}}) if ($k !~ /^attach\d+/); } &set_module_index($in{'folder'}); -my @folders = &list_folders(); -my $folder = $folders[$in{'folder'}]; +my @folders = &list_folders_sorted(); +my ($folder) = grep { $_->{'index'} == $in{'folder'} } @folders; +$folder || &error($text{'view_efolder'}); &error_setup($text{'send_err'}); if (!$in{'subject'}) { if ($userconfig{'force_subject'} eq 'error') { diff --git a/mailbox/slideshow.cgi b/mailbox/slideshow.cgi index d9dde6b5..0b8fa0fa 100755 --- a/mailbox/slideshow.cgi +++ b/mailbox/slideshow.cgi @@ -10,8 +10,9 @@ require './mailbox-lib.pl'; # Get the mail &ReadParse(); -my @folders = &list_folders(); -my $folder = $folders[$in{'folder'}]; +my @folders = &list_folders_sorted(); +my ($folder) = grep { $_->{'index'} == $in{'folder'} } @folders; +$folder || &error($text{'view_efolder'}); my $mail = &mailbox_get_mail($folder, $in{'id'}, 0); $mail || &error($text{'view_egone'}); &parse_mail($mail); diff --git a/mailbox/sort.cgi b/mailbox/sort.cgi index 20bd4afe..6c8188a3 100755 --- a/mailbox/sort.cgi +++ b/mailbox/sort.cgi @@ -8,8 +8,9 @@ our %in; require './mailbox-lib.pl'; &ReadParse(); -my @folders = &list_folders(); +my @folders = &list_folders_sorted(); my ($folder) = grep { $_->{'index'} == $in{'folder'} } @folders; +$folder || &error($text{'view_efolder'}); &save_sort_field($folder, $in{'field'}, $in{'dir'}); #Return in JSON format if needed diff --git a/mailbox/virtualize.cgi b/mailbox/virtualize.cgi index 519f9a6d..ae7ceeb6 100755 --- a/mailbox/virtualize.cgi +++ b/mailbox/virtualize.cgi @@ -19,7 +19,9 @@ my $folder = { 'type' => 6, foreach my $k (keys %in) { if ($k =~ /^idx_(\d+)$/) { my ($idx, $fidx) = split(/\s+/, $in{$k}, 2); - $folder->{'members'}->[$1] = [ $folders[$fidx], $idx ]; + my ($folder) = grep { $_->{'index'} == $fidx } @folders; + $folder || &error($text{'view_efolder'}); + $folder->{'members'}->[$1] = [ $folder, $idx ]; } } &save_folder($folder);