#!/usr/bin/perl
#  This software was derived from SATAN 1.1.1 by Dan Farmer and Wietse Venema
#  (http://www.porcupine.org/satan).
#
#
# Delete a data base.
#
($_directory) = split(/,/, $html_script_args);
$_directory = $_sara_dir if $_directory eq "";

if ($_directory eq "") {
	print CLIENT <<EOF;
<HTML>
<HEAD>
<TITLE>Error - Missing input </TITLE>
<LINK REV="made" HREF="mailto:sara\@fish.com">
</HEAD>
<BODY>
<H1><IMG WIDTH="150" SRC=$HTML_ROOT/images/sara.gif> Error - Missing input </H1>
<hr>
No data base name was specified .
</BODY>
</HTML>
EOF
	die "\n";
}
if ($_directory =~ /^[0-9]/) {
       print CLIENT <<EOF;
<HTML>
<HEAD>
<TITLE>Error - Illegal Data Base Name </TITLE>
<LINK REV="made" HREF="mailto:satan\@fish.com">
<LINK REV="update" HREF="mailto:sara\@arc.com">
</HEAD>
<BODY>
<H1><IMG WIDTH="150" SRC=$HTML_ROOT/images/sara.gif> Error - Illegal Data Base Name </H1>
<hr>
Data base name must start with an alpha character [a-zA-Z]
</BODY>
</HTML>
EOF
        die "\n";
}
#
# Delete the data base.
#
$sara_data = $_directory;
&find_sara_data();

print CLIENT <<EOF;
<HTML>
<HEAD>
<TITLE>SARA Data Management</TITLE>
<LINK REV="made" HREF="mailto:sara\@fish.com">
</HEAD>
<BODY>
<H1><IMG WIDTH="150" SRC=$HTML_ROOT/images/sara.gif> SARA Data Management</H1>
<HR>
EOF

if (-s "$directory") {
   print CLIENT <<EOF;
<strong>Deleting <i> $directory </i> <p>
<strong>Note:  Directory will not be deleted until you exit SARA!</strong<p>
EOF
   unlink "$directory/facts";
   unlink "$directory/all-hosts";
   unlink "$directory/todo";
   unlink "$directory/history";
   unlink "$directory/report.html";
   rmdir ($directory);
} else {
  print CLIENT <<EOF;
<strong>Could not find <i> $_directory </i><p>
EOF
}

print CLIENT <<EOF;
<hr> <a href=/sara.html> Back to the SARA start page </a>
| <a href=../data/sara_data_form.pl>Back to Data Management</a>
</BODY>
</HTML>
EOF
