5 require './file-lib.pl';
6 $disallowed_buttons{'upload'} && &error($text{'ebutton'});
8 &ReadParse(\%getin, "GET");
10 &ReadParseMime($upload_max, \&read_parse_mime_callback, [ $upid ]);
12 $realdir = &unmake_chroot($in{'dir'});
13 if (!$in{'file_filename'}) {
14 print "<p><b>$text{'upload_efile'}</b><p>\n";
16 elsif (!-d $realdir) {
17 print "<p><b>$text{'upload_edir'}</b><p>\n";
19 elsif ($running_as_root && !defined(getpwnam($in{'user'}))) {
20 print "<p><b>$text{'upload_euser'}</b><p>\n";
23 $in{'file_filename'} =~ /([^\\\/]+)$/;
24 $path = "$in{'dir'}/$1";
25 $realpath = "$realdir/$1";
27 # File exists .. ask the user if he is sure
28 &switch_acl_uid($running_as_root ? $in{'user'} : undef);
30 &open_tempfile(TEMP, ">$temp");
31 if ($dostounix == 1 && $in{'dos'}) {
32 $in{'file'} =~ s/\r\n/\n/g;
34 &print_tempfile(TEMP, $in{'file'});
35 &close_tempfile(TEMP);
37 print &ui_form_start("upload2.cgi");
38 foreach $i (keys %prein) {
39 print &ui_hidden($i, $prein{$i});
41 print &ui_hidden("dir", $in{'dir'});
42 print &ui_hidden("path", $path);
43 print &ui_hidden("temp", $temp);
44 print &ui_hidden("zip", $in{'zip'});
45 print &ui_hidden("user", $in{'user'});
46 print &text('upload_already', "<tt>$path</tt>"),"<p>\n";
47 print &ui_form_end([ [ "yes", $text{'yes'} ],
48 [ "no", $text{'no'} ] ]);
53 # Go ahread and do it!
54 &webmin_log("upload", undef, $path);
55 &switch_acl_uid($running_as_root ? $in{'user'} : undef);
56 if ($access{'ro'} || !&can_access($path)) {
57 print "<p><b>",&text('upload_eperm', $path),"</b><p>\n";
59 elsif (-l $path && !&must_follow($realpath)) {
60 print "<p><b>",&text('upload_elink', $path),"</b><p>\n";
62 elsif (!&open_tempfile(FILE, ">$realpath", 1)) {
63 print "<p><b>",&text('upload_ewrite', $path, $!),"</b><p>\n";
66 if ($dostounix == 1 && $in{'dos'}) {
67 $in{'file'} =~ s/\r\n/\n/g;
69 &print_tempfile(FILE, $in{'file'});
70 &close_tempfile(FILE);
71 &post_upload($path, $in{'dir'}, $in{'zip'});