#!/usr/local/bin/perl
#!C:\bin\perl\bin\perl.exe
#!/usr/bin/perl/
# use one of the above lines to set the path to perl on your server
##########################################################################################

1;
eval {
	($0 =~ m,(.*)/[^/]+,)   && unshift (@INC, "$1");		# Unix /
	($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1");		# Windows \
	require 5.001;
};

if ($@) {
	print "Content-type: text/plain\n\n";
	print "Error including: $@\n";
	exit;
}

eval { &main; };
if ($@) { &cgierr("fatal error: $@"); }
exit;

##########################################################################################
sub main {
&date;

read(STDIN, $input,$ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $input);
foreach $pair (@pairs) {
	($name, $value) = split(/=/, $pair);
	$name =~ tr/+/ /;
	$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
	$value =~ tr/+/ /;
	$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
	$IN{$name} = $value;
}

if ( $IN{'action'} eq 'apply' ) {
	&setpar;	#save the settings
	&sethtm;	#save the html
	&display;	#refresh the display
	exit;
	}
if ( $IN{'action'} eq 'default' ) {
	&setdef;	#save the settings
	&display;	#refresh the display
	exit;
	}

&display;	#refresh the display
}

#####################################################################
# subroutines
#####################################################################

#####################################################################
# restore defaults
sub setdef {
	open(PAR,">../param14.dat");
	print PAR "method \"sendmail\"\n";  
	print PAR "colortx \"#000000\"\n";  
	print PAR "colorbg \"#ffffff\"\n";
	print PAR "coloral \"#333333\"\n";
	print PAR "colorvl \"#cccccc\"\n";
	print PAR "sizetx \"2\"\n";
	print PAR "nametx \"arial,verdana\"\n";
	print PAR "htmlfoot \"htmlft.txt\"n";
	print PAR "htmlhead \"htmlhd.txt\"\n";
	print PAR "title \"Support Form\"\n";
	print PAR "welcome \"Welcome to the help request form.\"\n";
	print PAR "confirm \"Your submittal has been recorded to a log file.\"\n";
	print PAR "hellotext \"hello14.txt\"\n";
	print PAR "emailstep \"An email message based on your input has been prepared and is ready to be sent.\"\n";
	print PAR "emailsent \"Your message has been mailed.\"\n";
	print PAR "pathcgi \"../cgi-bin\"\n";
	print PAR "pathdata \"../support\"\n";
	print PAR "pathmail \"/usr/sbin/sendmail -t\"\n";
	print PAR "urlcgi \"http://localhost/cgi-bin\"\n";
	print PAR "urldata \"http://localhost/support\"\n";
	print PAR "priority \"1\"\n";
	print PAR "status \"1\"\n";
	print PAR "category \"1\"\n";
	print PAR "products \"Sales,Support,Other\"\n";
	print PAR "message \"Enter your message here.\"\n";
	print PAR "submit \"both\"\n";
	print PAR "mailto \"support\@your-domain.com\"\n";
	print PAR "subject \"www request\"\n";
	print PAR "showip \"yes\"\n";
	close(PAR);

	open(HEAD,">../htmlhd.txt");
	print HEAD "<html>\n";
	print HEAD "<head>\n";
	print HEAD " <title>iTrack Request Form v1.4 (softopia.com)</title>\n";
	print HEAD " <meta NAME=\"Generator\" contents=\"iTrack v1.4 (softopia.com)\">\n";
	print HEAD "</head>\n";
	print HEAD "<body>\n";
	print HEAD " <table width=600>\n";
	close(HEAD);
	
	open(FOOT,">../htmlft.txt");
	print FOOT " </table>\n";
	print FOOT "</body>\n";
	print FOOT "</html>\n";
	close(FOOT);
	
	open(HELLO,">../hello14.txt");
	print HELLO "This email message is confirmation of your form submittal.\n";
	close(HELLO);
}

#####################################################################
# set parameters to the file
sub setpar{
	open(PAR,">../param14.dat");
	print PAR "method \"$IN{'method'}\"  \n";

	print PAR "colortx \"$IN{'colortx'}\"  \n";
	print PAR "colorbg \"$IN{'colorbg'}\"  \n";
	print PAR "coloral \"$IN{'coloral'}\"  \n";
	print PAR "colorvl \"$IN{'colorvl'}\"  \n";
	print PAR "sizetx \"$IN{'sizetx'}\"  \n";
	print PAR "nametx \"$IN{'nametx'}\"  \n";
	print PAR "htmlfoot \"htmlft.txt\" \n";
	print PAR "htmlhead \"htmlhd.txt\" \n";
	print PAR "title \"$IN{'title'}\"  \n";
	print PAR "welcome \"$IN{'welcome'}\"  \n";
	print PAR "confirm \"$IN{'confirm'}\"  \n";
	print PAR "hellotext \"hello14.txt\" \n";
	print PAR "emailstep \"$IN{'emailstep'}\"  \n";
	print PAR "emailsent \"$IN{'emailsent'}\"  \n";

	print PAR "pathcgi \"$IN{'pathcgi'}\"  \n";
	print PAR "pathdata \"$IN{'pathdata'}\"  \n";
	print PAR "pathmail \"$IN{'pathmail'}\"  \n";
	print PAR "urlcgi \"$IN{'urlcgi'}\"  \n";
	print PAR "urldata \"$IN{'urldata'}\"  \n";

	print PAR "priority \"$IN{'priority'}\"  \n";
	print PAR "status \"$IN{'status'}\"  \n";
	print PAR "category \"$IN{'category'}\"  \n";
	print PAR "products \"$IN{'products'}\"  \n";
	print PAR "message \"$IN{'message'}\"  \n";

	print PAR "submit \"$IN{'submit'}\"  \n";
	print PAR "mailto \"$IN{'mailto'}\"  \n";
	print PAR "subject \"$IN{'subject'}\"  \n";
	print PAR "showip \"$IN{'showip'}\"  \n";
		
	close(PAR);
}

#####################################################################
# set html
sub sethtm{
	open(HEAD,">../htmlhd.txt");
	print HEAD $IN{'htmlhead'};
	close(HEAD);
	
	open(FOOT,">../htmlft.txt");
	print FOOT $IN{'htmlfoot'};
	close(FOOT);
	
	open(HELLO,">../hello14.txt");
	print HELLO $IN{'hellotext'};
	close(HELLO);
}

sub display {
	&getpar;
	&gethtm;
	if ( $IN{'action'} eq 'apply' ) {
		$banner = "      Settings Updated\n";
	}
	else {
		$banner = "      Current Settings\n";
	}

	print qq~
<html>
<head>
<title>web interface configure</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META name="resource-type" content="document">
<META name="author" content="itrack\@softopia.com">
<META name="generator" content="iTrack v1.4 (softopia.com)">
</head

<body marginheight="0" topmargin="0" marginwidth="0" leftmargin="0">

<center>
 <table width=640 border=1 cellpadding=5 cellspacing=1 bgcolor=#dddddd>
  <tr>
   <font size=4 face=arial,helvetica>
    <b>
~;
	($ENV{'REMOTE_USER'} or $ENV{'AUTH_USER'}) ?
	($warning = '') :
	($warning = 'WARNING: Directory is not password protected.<br><br>');
	print qq~
     $warning
     iTrack Web Interface Control Panel
     <br><br>
    </b>
   </font>
   <td align=left valign=top height=0>
    <font size=4 face=arial,helvetica>
     <b>
      $banner
     </b>
    </font>
   </td>
  </tr>
 </table>
 
 <form method=post action=conf14.pl>
 &nbsp;
 <table width=640 border=1 cellpadding=5 cellspacing=1 bgcolor=#dddddd>
  <tr>
   <td align=left valign=top height=0>
    <font size=3 face=arial,helvetica>
     <b>
      Look And Feel
     </b>
    </font>
   </td>
  </tr>
 </table>
 <table width=640 border=1 cellpadding=5 cellspacing=1 bgcolor=#dddddd>
  <tr>
   <td width=50% align=left valign=top height=0>
    <font size=2 face=arial,helvetica>
     <b>
      Setting
     </b>
    </font>
   </td>
   <td width=50% align=left valign=top height=0>
    <font size=2 face=arial,helvetica>
     <b>
      Description
     </b>
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <input type=text name=colortx value="$colortx" size=40>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Color of page text
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <input type=text name=colorbg value="$colorbg" size=40>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Page background color
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <input type=text name=coloral value="$coloral" size=40>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Color of link when clicked
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <input type=text name=colorvl value="$colorvl" size=40>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Color of visited links
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <input type=text name=sizetx value="$sizetx" size=40>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Size of page text
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <input type=text name=nametx value="$nametx" size=40>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Text font
    </font>
   </td>
  </tr>

  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <input type=text name=title value="$title" size=40>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Page title
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <input type=text name=welcome value="$welcome" size=40>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Welcome message
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <input type=text name=confirm value="$confirm" size=40>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Message displayed after submittal
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <input type=text name=emailstep value="$emailstep" size=40>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Message explaining next step to send mail
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <input type=text name=emailsent value="$emailsent" size=40>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Message confirmain email has been sent
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <textarea nowrap name=hellotext cols=30 rows=10>
~;
	foreach $linehe (@hello) {
		chop($linehe) if ($linehe =~ /\n$/);
		print "$linehe";
	}
	print "</textarea>\n";
	print qq~
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Introduction paragraph for email messages
     <br><br>
     (will be saved as hello14.txt)
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <textarea nowrap name=htmlhead cols=30 rows=10>
~;
	foreach $linehd (@head) {
		chop($linehd) if ($linehd =~ /\n$/);
		print "$linehd";
	}
	print "</textarea>\n";
	print qq~
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     HTML for top of output
     <br><br>
     (will be saved as htmlhd.txt)
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <textarea nowrap name=htmlfoot cols=30 rows=10>
~;
	foreach $lineft (@foot) {
		chop($lineft) if ($lineft =~ /\n$/);
		print "$lineft";
	}
	print "</textarea>\n";
	print qq~
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     HTML for bottom of output
     <br><br>
     (will be saved as htmlft.txt)
    </font>
   </td>
  </tr>
 </table>
 &nbsp;
 <table width=640 border=1 cellpadding=5 cellspacing=1 bgcolor=#dddddd>
  <tr>
   <td align=left valign=top height=0>
    <font size=3 face=arial,helvetica>
     <b>
      Server Environment
     </b>
    </font>
   </td>
  </tr>
 </table>
 <table width=640 border=1 cellpadding=5 cellspacing=1 bgcolor=#dddddd>
  <tr>
   <td width=50% align=left valign=top height=0>
    <font size=2 face=arial,helvetica>
     <b>
      Setting
     </b>
    </font>
   </td>
   <td width=50% align=left valign=top height=0>
    <font size=2 face=arial,helvetica>
     <b>
      Description
     </b>
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <input type=text name=pathcgi value="$pathcgi" size=40>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Relative path to cgi directory (no trailing slash)
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <input type=text name=pathdata value="$pathdata" size=40>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Relative path to data file directory (no trailing slash)
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <input type=text name=pathmail value="$pathmail" size=40>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Relative path to cgi sendmail.exe or formmail.pl (no trailing slash)
    </font>
   </td>
  </tr>
  
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <select name=method>
      <option selected>$method
      <option>formmail
      <option>sendmail
      <option>wsendmail
     </select>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Type of program used to send email
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <input type=text name=urlcgi value="$urlcgi" size=40>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Full url of cgi directory (no trailing slash)
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <input type=text name=urldata value="$urldata" size=40>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Full url of data directory (no trailing slash)
    </font>
   </td>
  </tr>
 </table>
 &nbsp;
 <table width=640 border=1 cellpadding=5 cellspacing=1 bgcolor=#dddddd>
  <tr>
   <td align=left valign=top height=0>
    <font size=3 face=arial,helvetica>
     <b>
      Defaults For Submittals
     </b>
    </font>
   </td>
  </tr>
 </table>
 <table width=640 border=1 cellpadding=5 cellspacing=1 bgcolor=#dddddd>
  <tr>
   <td width=50% align=left valign=top height=0>
    <font size=2 face=arial,helvetica>
     <b>
      Setting
     </b>
    </font>
   </td>
   <td width=50% align=left valign=top height=0>
    <font size=2 face=arial,helvetica>
     <b>
      Description
     </b>
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <input type=text name=priority value="$priority" size=40>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Priority
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <input type=text name=status value="$status" size=40>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Status
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <input type=text name=category value="$category" size=40>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Category
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <input type=text name=products value="$products" size=40>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Products (comma separated list)
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <input type=text name=message value="$message" size=40>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Default message
    </font>
   </td>
  </tr>
 </table>

 &nbsp;
 <table width=640 border=1 cellpadding=5 cellspacing=1 bgcolor=#dddddd>
  <tr>
   <td align=left valign=top height=0>
    <font size=3 face=arial,helvetica>
     <b>
      Operational Control
     </b>
    </font>
   </td>
  </tr>
 </table>
 <table width=640 border=1 cellpadding=5 cellspacing=1 bgcolor=#dddddd>
  <tr>
   <td width=50% align=left valign=top height=0>
    <font size=2 face=arial,helvetica>
     <b>
      Setting
     </b>
    </font>
   </td>
   <td width=50% align=left valign=top height=0>
    <font size=2 face=arial,helvetica>
     <b>
      Description
     </b>
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <select name=submit>
      <option selected>$submit
      <option>mail
      <option>form
      <option>both
     </select>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Form submittal type
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <select name=showip>
      <option selected>$showip
      <option>yes
      <option>no
     </select>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Show user's IP address on form page
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <input type=text name=mailto value="$mailto" size=40>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Email address to send form to
    </font>
   </td>
  </tr>
  <tr>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     <input type=text name=subject value="$subject" size=40>
    </font>
   </td>
   <td width=50% align=left valign=center height=0>
    <font size=1 face=arial,helvetica>
     Subject line for email messages
    </font>
   </td>
  </tr>
 </table>
 <br>
 <table width=640 border=0 cellpadding=5 cellspacing=1 bgcolor=#ffffff>
  <tr>
   <td width=20% align=center>
    <input type=submit value="Apply Changes">
    <input type=hidden value=apply name=action>
    </form>
   </td>
   <td width=20% align=center>
    <form method=post action=conf14.pl>
     <input type=submit value="Refresh Form">
     <input type=hidden value=refresh name=action>
    </form>
   </td>
   <td width=20% align=center>
    <form method=post action=conf14.pl>
     <input type=submit value="Restore Default">
     <input type=hidden value=default name=action>
    </form>
   </td>
   <td width=20% align=center>
    <form method=post action=sup14.pl>
     <input type=submit value="Try It Now">
    </form>
   </td>
  </tr>
 </table>
</center>

<center>
 <table>
  <!-- FOOTER -->
  <tr>
   <td align=left valign=top>
    <center>
     <font size=1 face=arial,helvetica>
      © 1996-2000 All rights reserved.
      Softopia and iTrack are trademarks of Softopia Development, Inc.
      <br>
      <a href=http://www.softopia.com>www.softopia.com</a>
     </font>
    </center>
   </td>
  </tr>
 </table>
</center>

</body>
</html>

~;

}

#####################################################################
# get parameters from the file
sub getpar {
open(PAR,"<../param14.dat");
@params = <PAR>;
close(PAR);
foreach $line (@params) {
	@option = split(/"/,$line);
	if (@option[0] =~ 'method') {$method = @option[1]}

	if (@option[0] =~ 'colortx') {$colortx = @option[1]}
	if (@option[0] =~ 'colorbg') {$colorbg = @option[1]}
	if (@option[0] =~ 'coloral') {$coloral = @option[1]}
	if (@option[0] =~ 'colorvl') {$colorvl = @option[1]}
	if (@option[0] =~ 'sizetx') {$sizetx = @option[1]}
	if (@option[0] =~ 'nametx') {$nametx = @option[1]}
	if (@option[0] =~ 'pathcgi') {$pathcgi = @option[1]}
	if (@option[0] =~ 'pathdata') {$pathdata = @option[1]}
	if (@option[0] =~ 'pathmail') {$pathmail = @option[1]}
	if (@option[0] =~ 'urlcgi') {$urlcgi = @option[1]}
	if (@option[0] =~ 'urldata') {$urldata = @option[1]}
	if (@option[0] =~ 'htmlfoot') {$htmlfoot = @option[1]}
	if (@option[0] =~ 'htmlhead') {$htmlhead = @option[1]}
	if (@option[0] =~ 'title') {$title = @option[1]}
	if (@option[0] =~ 'welcome') {$welcome = @option[1]}
	if (@option[0] =~ 'confirm') {$confirm = @option[1]}
	if (@option[0] =~ 'emailstep') {$emailstep = @option[1]}
	if (@option[0] =~ 'emailsent') {$emailsent = @option[1]}
	if (@option[0] =~ 'hellotext') {$hellotext = @option[1]}

	if (@option[0] =~ 'priority') {$priority = @option[1]}
	if (@option[0] =~ 'status') {$status = @option[1]}
	if (@option[0] =~ 'category') {$category = @option[1]}
	if (@option[0] =~ 'products') {$products = @option[1]}
	if (@option[0] =~ 'message') {$message = @option[1]}

	if (@option[0] =~ 'submit') {$submit = @option[1]}
	if (@option[0] =~ 'mailto') {$mailto = @option[1]}
	if (@option[0] =~ 'subject') {$subject = @option[1]}

	if (@option[0] =~ 'showip') {$showip = @option[1]}
	}
}
#####################################################################
# get user-defined html for header and footer
sub gethtm {
	open(HD,"<../$htmlhead");
	@head = <HD>;
	close(HD);

	open(FT,"<../$htmlfoot");
	@foot = <FT>;
	close(FT);

	open(HE,"<../$hellotext");
	@hello = <HE>;
	close(HE);

}
#####################################################################
# get the time
sub date {
   ($sec,$min,$hour,$mday,$month,$year) = localtime(time);

   if ($sec < 10) {
      $sec = "0$sec";
   }
   if ($min < 10) {
      $min = "0$min";
   }
   if ($hour < 10) {
      $hour = "0$hour";
   }

   $year = $year + 1900;
   $month = $month + 1;
   $date = "$month-$mday-$year $hour\:$min\:$sec";
   chop($date) if ($date =~ /\n$/);

   $time = time();
   
}

sub cgierr {
    if (!$html_headers_printed) {
        print "Content-type: text/html\n\n";
        $html_headers_printed = 1;
    }
    print "\n\nCGI ERROR\n==========================================\n";
    $_[0]      and print "Error Message       : $_[0]\n";   
    $0         and print "Script Location     : $0\n";
    $]         and print "Perl Version        : $]\n";  
    
    print "\nForm Variables\n-------------------------------------------\n";
    foreach $key (sort keys %in) {
        my $space = " " x (20 - length($key));
        print "$key$space: $in{$key}\n";
    }
    print "\nEnvironment Variables\n-------------------------------------------\n";
    foreach $env (sort keys %ENV) {
        my $space = " " x (20 - length($env));
        print "$env$space: $ENV{$env}\n";
    }
    print "\n</PRE>";
    exit -1;
}
