File: upload2.cgi

package info (click to toggle)
usermin-contrib 1.110-3
  • links: PTS
  • area: contrib
  • in suites: sarge
  • size: 1,280 kB
  • ctags: 980
  • sloc: java: 5,979; perl: 1,408; makefile: 106; sh: 4
file content (37 lines) | stat: -rwxr-xr-x 891 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/local/bin/perl
# upload2.cgi
# Rename a file that has already been uploaded

require './file-lib.pl';
$disallowed_buttons{'upload'} && &error($text{'ebutton'});
&header();
&ReadParse();

if ($in{'yes'}) {
	# Put it in place, overwriting any other file
	&webmin_log("upload", undef, $in{'path'});
	&switch_acl_uid();
	if ($access{'ro'} || !&can_access($in{'path'})) {
		print "<p><b>",&text('upload_eperm', $in{'path'}),"</b><p>\n";
		}
	elsif (!open(FILE, ">".&unmake_chroot($in{'path'}))) {
		print "<p><b>",&text('upload_ewrite', $in{'path'}, $!),"</b><p>\n";
		}
	else {
		open(TEMP, $in{'temp'});
		&copydata(TEMP, FILE);
		close(TEMP);
		close(FILE);
		&post_upload($in{'path'}, $in{'dir'}, $in{'zip'});
		}
	unlink($in{'temp'});
	}
else {
	# Just delete the temp file
	&switch_acl_uid();
	unlink($in{'temp'});
	print "<script>\n";
	print "close();\n";
	print "</script>\n";
	}