Handle hostnames with upper-case letters
[webmin.git] / mailboxes / slideshow.cgi
1 #!/usr/local/bin/perl
2 # Show a page containing all image attachments
3
4 require './mailboxes-lib.pl';
5
6 # Get the mail
7 &ReadParse();
8 &can_user($in{'user'}) || &error($text{'mail_ecannot'});
9 @folders = &list_user_folders($in{'user'});
10 $folder = $folders[$in{'folder'}];
11 @mail = &mailbox_list_mails($in{'idx'}, $in{'idx'}, $folder);
12 $mail = $mail[$in{'idx'}];
13 &parse_mail($mail);
14 @sub = split(/\0/, $in{'sub'});
15 $subs = join("", map { "&sub=".&urlize($_) } @sub);
16 foreach $s (@sub) {
17         # We are looking at a mail within a mail ..
18         local $amail = &extract_mail($mail->{'attach'}->[$s]->{'data'});
19         &parse_mail($amail);
20         $mail = $amail;
21         }
22
23 # Find image attachments
24 @attach = @{$mail->{'attach'}};
25 @attach = &remove_body_attachments($mail, \@attach);
26 @attach = &remove_cid_attachments($mail, \@attach);
27 @iattach = grep { $_->{'type'} =~ /^image\// } @attach;
28
29 &popup_header($text{'slide_title'});
30
31 $n = 0;
32 foreach $a (@iattach) {
33         # Navigation links
34         print "<hr>" if ($n > 0);
35         print "<a name=image$n></a>\n";
36         @links = ( );
37         if ($a eq $iattach[0]) {
38                 push(@links, $text{'slide_prev'});
39                 }
40         else {
41                 push(@links, "<a href='#image".($n-1)."'>".
42                              "$text{'slide_prev'}</a>");
43                 }
44         if ($a eq $iattach[$#iattach]) {
45                 push(@links, $text{'slide_next'});
46                 }
47         else {
48                 push(@links, "<a href='#image".($n+1)."'>".
49                              "$text{'slide_next'}</a>");
50                 }
51         push(@links, "<b>$a->{'filename'}</b>") if ($a->{'filename'});
52         print &ui_links_row(\@links),"<br>\n";
53
54         # Actual image
55         print "<img src='detach.cgi?idx=$in{'idx'}".
56               "&folder=$in{'folder'}&attach=$a->{'idx'}&user=".
57               &urlize($in{'user'})."$subs'><br>\n";
58         $n++;
59         }
60
61 &popup_footer();
62