#!/usr/local/bin/perl
# delete.cgi
# Delete some file or directory

require './file-lib.pl';
$disallowed_buttons{'delete'} && &error($text{'ebutton'});
&ReadParse();
&webmin_log("delete", undef, $in{'file'}, \%in);
&switch_acl_uid_and_chroot();
print "Content-type: text/plain\n\n";
if ($access{'ro'} || !&can_access($in{'file'})) {
	print &text('delete_eaccess', $in{'file'}),"\n";
	exit;
	}
if (-r $in{'file'}) {
	$rv = unlink($in{'file'});
	if (!$rv) { print "$!\n"; }
	else { print "\n"; }
	}
else {
	$out = &backquote_logged("cd / ; rm -rf ".quotemeta($in{'file'})." 2>&1");
	if ($?) { print $out; }
	else { print "\n"; }
	}

