3 # Display scheduled downloads, plus a form for uploading a file
5 require './updown-lib.pl';
6 &ui_print_header(undef, $text{'index_title'}, "", undef, 0, 1);
12 push(@tabs, [ "download", $text{'index_tabdownload'},
13 "index.cgi?mode=download" ]);
16 push(@tabs, [ "upload", $text{'index_tabupload'},
17 "index.cgi?mode=upload" ]);
20 push(@tabs, [ "fetch", $text{'index_tabfetch'},
21 "index.cgi?mode=fetch" ]);
23 print &ui_tabs_start(\@tabs, "mode", $in{'mode'} || $tabs[0]->[0], 1);
27 # Show form for downloading
28 print &ui_tabs_start_tab("mode", "download");
29 print $text{'index_descdownload'},"<p>\n";
31 print &ui_form_start("download.cgi", "post");
32 print &ui_table_start($text{'index_header1'}, "width=100%", 4);
35 print &ui_table_row($text{'index_urls'},
36 &ui_textarea("urls", undef, 4, 70), 3);
38 # Destination directory
39 print &ui_table_row($text{'index_ddir'},
40 &ui_textbox("dir", $download_dir, 60)." ".
41 &file_chooser_button("dir", 1, $form)."<br>".
42 &ui_checkbox("mkdir", 1, $text{'index_mkdir'}, 0), 3);
45 # Ask for user and group to download as
46 print &ui_table_row($text{'index_user'},
47 &ui_user_textbox("user", $download_user, $form));
49 print &ui_table_row($text{'index_group'},
50 &ui_opt_textbox("group", $download_group, 13,
51 $text{'default'})." ".
52 &group_chooser_button("group", 0, $form));
56 # Download time can be selected, for scheduling with At
57 @now = localtime(time());
58 print &ui_table_row($text{'index_bg'},
59 &ui_radio("bg", 0, [ [ 0, $text{'index_bg0'}."<br>" ],
60 [ 1, $text{'index_bg1'} ] ])." ".
61 &ui_textbox("day", $now[3], 2)."/".
62 &ui_select("month", $now[4],
63 [ map { [ $_, $text{"smonth_".($_+1)} ] }
65 &ui_textbox("year", $now[5]+1900, 4)." ".
66 &date_chooser_button("day", "month", "year", $form)." ".
67 $text{'index_time'}."\n".
68 &ui_textbox("hour", sprintf("%2.2d", $now[2]), 2).":".
69 &ui_textbox("min", sprintf("%2.2d", $now[1]), 2), 3);
71 elsif ($can_background) {
72 # Download must be immediate, but can be backgrounded
73 print &ui_table_row($text{'index_bg'},
74 &ui_radio("bg", 0, [ [ 0, $text{'index_bg0'} ],
75 [ 1, $text{'index_bg1u'} ] ]));
78 # Download is always right now
81 # Email address to notify when done
82 if ($can_schedule || $can_background) {
83 print &ui_table_row($text{'index_email'},
84 &ui_opt_textbox("email", undef, 40,
85 $text{'no'}, $text{'index_emailto'}), 3);
88 print &ui_table_end();
89 print &ui_form_end([ [ undef, $text{'index_down'} ] ]);
92 # Show current list of scheduled or active downloads
93 @downs = grep { &can_as_user($_->{'user'}) } &list_downloads();
95 @tds = $notdone ? ( "width=5" ) : ( );
96 local ($notdone) = grep { !$_->{'complete'} } @downs;
97 print &ui_form_start("cancel.cgi");
98 print &ui_columns_start([
99 $notdone ? ( "" ) : ( ),
100 $text{'index_urls'}, $text{'index_dest'},
101 $text{'index_when'}, $text{'index_user'},
102 $text{'index_prog'} ], 100, 0, \@tds);
103 foreach $d (@downs) {
107 while($url = $d->{"url_$count"}) {
108 print "<br>\n" if ($count);
109 if (length($url) > 70 && $url =~ /^([^:]+:\/\/[^\/]+\/)(.*)(\/[^\/]+)$/) {
110 push(@urls, &html_escape("$1 .. $3"));
113 push(@urls, &html_escape($url));
117 push(@cols, join("<br>\n", @urls));
118 push(@cols, &html_escape($d->{'dir'}));
119 push(@cols, $d->{'time'} ? &make_date($d->{'time'})
120 : $text{'index_imm'});
121 push(@cols, &html_escape($d->{'user'}));
123 push(@cols, "<font color=#ff0000>".
124 ($count > 1 ? &text('index_upto',
125 $d->{'upto'}+1, $count)." " : "").
126 "$d->{'error'}</font>");
127 &delete_download($d);
129 elsif (!defined($d->{'upto'})) {
130 push(@cols, $text{'index_noprog'});
132 elsif ($d->{'complete'}) {
133 push(@cols, "<font color=#00ff00>".
134 "$text{'index_done'} (".
135 &nice_size($d->{'total'}).")</font>");
136 &delete_download($d);
139 push(@cols, ($count > 1 ?
141 $d->{'upto'}+1, $count)." " : "").
142 &nice_size($d->{'got'})." ".
144 "(".int($d->{'got'}*100/$d->{'size'}).
147 if (!$d->{'complete'}) {
148 print &ui_checked_columns_row(\@cols, \@tds,
149 "cancel", $d->{'id'});
152 @cols = ( "", @cols ) if ($notdone);
153 print &ui_columns_row(\@cols, \@tds);
156 print &ui_columns_end();
157 print &ui_form_end($notdone ?
158 [ [ undef, $text{'index_cancel'} ] ] : [ ]);
161 print &ui_tabs_end_tab();
165 # Show form for uploading
166 print &ui_tabs_start_tab("mode", "upload");
167 print $text{'index_descupload'},"<p>\n";
168 local $upid = time().$$;
169 print &ui_form_start("upload.cgi?id=$upid", "form-data", undef,
170 &read_parse_mime_javascript($upid,
171 [ "upload0", "upload1", "upload2", "upload3" ]));
172 print &ui_table_start($text{'index_header2'}, "width=100%", 2);
176 for($i=0; $i<4; $i++) {
177 $utable .= &ui_upload("upload$i")."\n";
178 $utable .= "<br>\n" if ($i%2 == 1);
180 print &ui_table_row($text{'index_upload'}, $utable);
182 # Destination directory
183 print &ui_table_row($text{'index_dir'},
184 &ui_textbox("dir", $upload_dir, 50)." ".
185 &file_chooser_button("dir", 1, $form)." ".
186 &ui_checkbox("mkdir", 1, $text{'index_mkdir'}, 0));
188 if ($can_mode != 3) {
189 # Allow selection of user to save as
190 print &ui_table_row($text{'index_user'},
191 &unix_user_input("user", $upload_user, $form));
193 print &ui_table_row($text{'index_group'},
194 &ui_radio("group_def", $upload_group ? 0 : 1,
195 [ [ 1, $text{'default'} ],
196 [ 0, &unix_group_input("group",
197 $upload_group, $form) ] ]));
201 print &ui_table_row($text{'index_zip'},
203 [ [ 2, $text{'index_zipyes'} ],
205 [ 0, $text{'no'} ] ]));
208 print &ui_table_row($text{'index_email2'},
209 &ui_opt_textbox("email", undef, 40,
210 $text{'no'}, $text{'index_emailto'}), 3);
212 print &ui_table_end();
213 print &ui_form_end([ [ "ok", $text{'index_ok'} ] ]);
215 print &ui_tabs_end_tab();
219 # Show form to download fetch from server to PC
220 print &ui_tabs_start_tab("mode", "fetch");
221 print $text{'index_descfetch'},"<p>\n";
222 print &ui_form_start("fetch.cgi");
223 print &ui_table_start($text{'index_header3'}, "width=100%", 4);
226 print &ui_table_row($text{'index_fetch'},
227 &ui_textbox("fetch", $fetch_file, 50)." ".
228 &file_chooser_button("fetch", 0, $form), 3);
231 print &ui_table_row($text{'index_show'},
232 &ui_yesno_radio("show", $fetch_show));
234 print &ui_table_end();
235 print &ui_form_end([ [ undef, $text{'index_ok2'} ] ]);
237 print &ui_tabs_end_tab();
240 print &ui_tabs_end(1);
242 &ui_print_footer("/", $text{'index'});