#!/usr/bin/perl
#
  do "acqPATHs.pl";
  $str = $ENV{"QUERY_STRING"};
  ($dir, $log) = split(/\+/, $str);
  $log =~ s/[^\.\w]+//g; $log =~ s/\.\.+/./g;
  $log =~ s/^\.+//; $log =~ s/\.+$//;
  if ($dir ne "") { $dir .= "/"; }
  $path = "$DATAPATH/$dir$log";
  print "Content-type: text/html; charset=iso-8859-1\n\n";
#
  $htmlbody =<<EOM;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<link rel="stylesheet" type="text/css" href="/AMXS/amxs.css">
<title>AMXS newlog2</title>
<script type="text/javascript">
<!--
function SelLog() {
  parent.Ftop.document.FM.log.value = "__LOG__";
  parent.Fhid.document.FM.log.value = "__LOG__";
  parent.Ftop.document.FM.fnm.value = "";
  parent.Fhid.document.FM.fnm.value = "";
  location.replace("/AMXS/forms/blank.html");
}
function cancel() {
  location.replace("/AMXS/forms/blank.html");
}
//-->
</script>
</head>
<body bgcolor="ivory" style="margin: 4px 7px;">
<form name="FM">
<hr>
EOM
  $htmlbody =~ s/__LOG__/$log/g;
  print $htmlbody;
#
  if (-e $path) {
    print "<font color=\"red\"><b>ERROR:</b></font>\n";
    print " file \"$dir$log\" already exists. &nbsp;\n";
    print '<input type="button" value="cancel" onclick="cancel()"><br>', "\n";
  } elsif (open(OUT, "> $path")) {
    close(OUT);
    print "New File \"$dir$log\" was created successfully. &nbsp;\n";
    print '<input type="button" value="OK" onclick="SelLog()"><br>', "\n";
  } else {
    print "<font color=\"red\"><b>ERROR:</b></font>\n";
    print " failed to create file \"$dir$log\". &nbsp;\n";
    print '<input type="button" value="cancel" onclick="cancel()"><br>', "\n";
  }
#
  print "</form>\n</body>\n</html>\n";
  exit(0);
