#!/usr/local/bin/perl
# edit_gmime_type.cgi
# Display a form for editing a MIME type from the global list

require './apache-lib.pl';
&ReadParse();
$access{'global'}==1 || &error($text{'mime_ecannot'});
if (defined($in{'line'})) {
	&header($text{'mime_edit'}, "");
	open(MIME, $in{'file'});
	for($i=0; $i<=$in{'line'}; $i++) {
		$line = <MIME>;
		}
	close(MIME);
	$line =~ s/#.*$//;
	$line =~ /^\s*(\S+)\s*(.*)$/;
	$type = $1; @exts = split(/\s+/, $2);
	}
else {
	&header($text{'mime_add'}, "");
	}
print "<hr>\n";

print "<form method=post action=save_gmime_type.cgi>\n";
print "<input type=hidden name=file value=$in{'file'}>\n";
if ($type) {
	print "<input type=hidden name=line value=$in{'line'}>\n";
	}
print "<table border>\n";
print "<tr $tb> <td colspan=2><b>$text{'mime_header'}</b></td> </tr>\n";
print "<tr $cb> <td><b>$text{'mime_type'}</b></td>\n";
print "<td><input name=type size=40 value=\"$type\"></td> </tr>\n";
print "<tr $cb> <td valign=top><b>$text{'mime_ext'}</b></td>\n";
print "<td><textarea name=exts rows=5 cols=15>",join("\n", @exts),
      "</textarea></td> </tr>\n";
print "</table><br>\n";
print "<input type=submit value=\"$text{'save'}\"></form>\n";

print "<hr>\n";
&footer("edit_global.cgi?type=6", $text{'global_return'});

