#!/usr/local/bin/perl
# save.cgi
# Write data to a file

require './file-lib.pl';
$p = $ENV{'PATH_INFO'};
&webmin_log("save", undef, $p) if ($access{'uid'});
&switch_acl_uid();
print "Content-type: text/plain\n\n";
read(STDIN, $buf, $ENV{'CONTENT_LENGTH'});
&lock_file($p);
if ($access{'ro'} || !&can_access($p)) {
	print &text('edit_eaccess', $p),"\n";
	}
elsif (!open(FILE, ">$p")) {
	print "$!\n";
	}
else {
	print FILE $buf;
	close(FILE);
	&unlock_file($p);
	print "\n";
	print &file_info_line($p),"\n";
	&webmin_log("save", undef, $p) if (!$access{'uid'});
	}

