#!/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"; print "\n"; print "\n"; print "
$text{'index_header1'}
\n"; print "\n"; print "\n"; print "\n"; print "\n"; if ($can_mode != 3) { # Ask for user and group to download as print "\n"; print "\n"; print "\n"; printf "\n"; } if ($can_schedule) { # Download time can be selected, for scheduling with At print "\n", $now[2], $now[1]; } elsif ($can_background) { # Download must be immediate, but can be backgrounded print "
$text{'index_urls'}
$text{'index_ddir'} ", &file_chooser_button("dir", 1, $form); print " $text{'index_mkdir'}\n"; print "
$text{'index_user'}",&unix_user_input("user", $download_user, $form), "$text{'index_group'} %s\n", $download_group ? "" : "checked", $text{'default'}; printf "\n", $download_group ? "checked" : ""; printf &unix_group_input("group", $download_group, $form), "
$text{'index_bg'} \n"; print " $text{'index_bg0'}
\n"; print " $text{'index_bg1'}\n"; @now = localtime(time()); printf "/", $now[3]; print "/"; printf "\n", $now[5] + 1900; print &date_chooser_button("day", "month", "year", $form),"\n"; print "$text{'index_time'}\n"; printf ":
$text{'index_bg'} \n"; print " $text{'index_bg0'}
\n"; print " $text{'index_bg1u'}\n"; } else { # Download is always right now } print "
\n"; 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"; print "\n"; print " ", $notdone ? "" : "", " ", " ", " ", " ", "\n"; foreach $d (@downs) { print "\n"; if (!$d->{'complete'}) { printf "\n", $d->{'id'}; } elsif ($notdone) { print "\n"; } print "\n"; printf "\n", $d->{'dir'}; print "\n"; printf "\n", $d->{'user'}; print "\n"; print "\n"; } print "

$text{'index_urls'}$text{'index_dest'}$text{'index_when'}$text{'index_user'}$text{'index_prog'}

\n"; local $count = 0; while($url = $d->{"url_$count"}) { print "
\n" if ($count); if (length($url) > 70 && $url =~ /^([^:]+:\/\/[^\/]+\/)(.*)(\/[^\/]+)$/) { print "$1 .. $3"; } else { print $url; } $count++; } print "
%s", $d->{'time'} ? &make_date($d->{'time'}) : $text{'index_imm'},"%s"; if ($d->{'error'}) { print "\n"; if ($count > 1) { print &text('index_upto', $d->{'upto'}+1, $count),"\n"; } print "$d->{'error'}\n"; &delete_download($d); } elsif (!defined($d->{'upto'})) { print $text{'index_noprog'}; } elsif ($d->{'complete'}) { print "$text{'index_done'} (", &nice_size($d->{'total'}),")\n"; &delete_download($d); } else { if ($count > 1) { print &text('index_upto', $d->{'upto'}+1, $count),"\n"; } local $sz = &nice_size($d->{'got'}); print "$sz\n"; if ($d->{'size'}) { print "(".int($d->{'got'}*100/$d->{'size'}). "%)\n"; } } print "
\n"; print "\n" if ($notdone); 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"; print "\n"; print "\n"; print "
$text{'index_header3'}
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
$text{'index_fetch'}\n"; print &ui_textbox("fetch", $fetch_file, 50),"\n", &file_chooser_button("fetch", 0, $form); print "
$text{'index_show'}",&ui_yesno_radio("show", $fetch_show),"
\n"; print "
\n"; $form++; } &ui_print_footer("/", $text{'index'});