$in{'day'}, $in{'month'}, $in{'year'}-1900) };
$@ && &error($text{'download_edate2'});
}
+if (defined($in{'email_def'}) && !$in{'email_def'}) {
+ # Validate email
+ $in{'email'} =~ /\S/ || &error($text{'download_eemail'});
+ $download{'email'} = $in{'email'};
+ }
# Create the directory if needed
if (!-d $download{'dir'} && $in{'mkdir'}) {
if (!$can_schedule) {
# Just run this script right now
- system("$atjob_cmd $download{'id'} >/dev/null 2>&1 </dev/null &");
+ &execute_command("$atjob_cmd $download{'id'} &");
}
else {
# Create an At job to do the download
# Download is always right now
}
+ # Email address to notify when done
+ if ($can_schedule || $can_background) {
+ print &ui_table_row($text{'index_email'},
+ &ui_opt_textbox("email", undef, 40,
+ $text{'no'}, $text{'index_emailto'}), 3);
+ }
+
print &ui_table_end();
print &ui_form_end([ [ undef, $text{'index_down'} ] ]);
$form++;
index_descdownload=This form allows you to download files or web pages from HTTP or FTP URLs to the system running Webmin. The download can be done immediately, or scheduled for some time in the future.
index_descupload=This page allows you to upload one or more files from the PC on which your web browser runs to the system running Webmin.
index_descfetch=This page is for downloading a file from the system running Webmin for display in your browser or saving on the same system.
+index_email=Send email when downloads are done?
+index_emailto=Yes, to address
upload_title=Upload Files
upload_err=Failed to upload files
fetch_eaccess=You are not allowed to download files from $1
fetch_ezip=A directory cannot be downloaded unless the <tt>zip</tt> command is installed
fetch_eroot=The root directory cannot be downloaded!
+
+email_downmsg=The following download has completed :
+email_downurl=URL: $1
+email_downerr=Error message: $1
+email_downpath=Destination filename: $1
+email_downsize=Downloaded size: $1
+email_subjectd=Download complete
}
unlink($path) if ($error);
&switch_uid_back();
+ if ($down->{'email'}) {
+ # Send email when done
+ local $msg = $text{'email_downmsg'}."\n\n";
+ $msg .= &text('email_downurl', $_[0]->{"url_$i"})."\n";
+ if ($error) {
+ $msg .= &text('email_downerr', $error)."\n";
+ }
+ else {
+ local @st = stat($path);
+ $msg .= &text('email_downpath', $path)."\n";
+ $msg .= &text('email_downsize',&nice_size($st[7]))."\n";
+ }
+ &send_email_notification(
+ $down->{'email'}, $text{'email_subjectd'}, $msg);
+ }
return $error if ($error);
push(@{$_[2]}, $path);
}
}
}
+# send_email_notification(address, subject, message)
+# Send email when some download or upload is complete
+sub send_email_notification
+{
+local ($to, $subject, $msg) = @_;
+if ($module_info{'usermin'}) {
+ &foreign_require("mailbox", "mailbox-lib.pl");
+ local $from = &mailbox::get_preferred_from_address();
+ &mailbox::send_text_mail($from, $to, undef, $subject, $msg);
+ }
+else {
+ &foreign_require("mailboxes", "mailboxes-lib.pl");
+ local $from = &mailboxes::get_from_address();
+ &mailboxes::send_text_mail($from, $to, undef, $subject, $msg);
+ }
+}
+
1;