#!/usr/local/bin/perl
# view.cgi
# Display a file for editing

require './custom-lib.pl';
&ReadParse();
@cmds = &list_commands();
$edit = $cmds[$in{'idx'}];
$edit->{'edit'} && &can_run_command($edit) || &error($text{'edit_ecannot'});

# Show the editor window
&header($text{'view_title'}, "");
print "<center><font size=+1>",$edit->{'edit'},"</font></center>\n";
print "<hr>\n";

print "<form action=save.cgi method=post enctype=multipart/form-data>\n";
print "<input type=hidden name=idx value='$in{'idx'}'>\n";
print "<textarea rows=20 cols=80 name=data>";
$file = $edit->{'edit'};
if ($file !~ /^\// && $module_info{'usermin'}) {
	@uinfo = getpwnam($remote_user);
	$file = "$uinfo[7]/$file";
	}
open(FILE, $file);
while(<FILE>) { print; }
close(FILE);
print "</textarea><br>\n";
print "<input type=submit value='$text{'save'}'></form>\n";

print "<hr>\n";
&footer("", $text{'index_return'});

