#!/usr/local/bin/perl
# index.cgi
# Display scheduled downloads, plus a form for uploading a file
require './updown-lib.pl';
&ui_print_header(undef, $text{'index_title'}, "", undef, 0, 1);
$form = 0;
if ($can_download) {
# Show form for downloading
print "
\n";
$form++;
# Show current list of scheduled or active downloads
@downs = grep { &can_as_user($_->{'user'}) } &list_downloads();
if (@downs) {
local ($notdone) = grep { !$_->{'complete'} } @downs;
print "\n";
$form++;
}
}
if ($can_upload) {
# Show form for uploading
print "\n" if ($can_download);
local $upid = time().$$;
print &ui_form_start("upload.cgi?id=$upid", "form-data", undef,
&read_parse_mime_javascript($upid,
[ "upload0", "upload1", "upload2", "upload3" ]));
print &ui_table_start($text{'index_header2'}, "width=100%", 2);
# Upload fields
$utable = "";
for($i=0; $i<4; $i++) {
$utable .= &ui_upload("upload$i")."\n";
$utable .= " \n" if ($i%2 == 1);
}
print &ui_table_row($text{'index_upload'}, $utable);
# Destination directory
print &ui_table_row($text{'index_dir'},
&ui_textbox("dir", $upload_dir, 50)." ".
&file_chooser_button("dir", 1, $form)." ".
&ui_checkbox("mkdir", 1, $text{'index_mkdir'}, 0));
if ($can_mode != 3) {
# Allow selection of user to save as
print &ui_table_row($text{'index_user'},
&unix_user_input("user", $upload_user, $form));
print &ui_table_row($text{'index_group'},
&ui_radio("group_def", $upload_group ? 0 : 1,
[ [ 1, $text{'default'} ],
[ 0, &unix_group_input("group",
$upload_group, $form) ] ]));
}
# Unzip files
print &ui_table_row($text{'index_zip'},
&ui_radio("zip", 0,
[ [ 2, $text{'index_zipyes'} ],
[ 1, $text{'yes'} ],
[ 0, $text{'no'} ] ]));
print &ui_table_end();
print &ui_form_end([ [ "ok", $text{'index_ok'} ] ]);
$form++;
}
if ($can_fetch) {
# Show form to download fetch from server to PC
print "\n" if ($can_download || $can_upload);
print "\n";
$form++;
}
&ui_print_footer("/", $text{'index'});