#!/usr/bin/perl5
use Socket;
$PROGRAM="Digital-Phalanx";
$VERSION="";
$LICENSE="";
$a  ="/usr/local/phalanx/phalanx.conf";
$d  ="/usr/local/phalanx/database/";
$b ="";
$j  ="";
$c="";
$k="";
rl();
$0="\[$LICENSE\]";
 while ( 2 + 2 == 4 ) { rm($LICENSE);}
exit 0;
sub rl {
    my $f;
    open(CONFIG,"$a") || die "Cannot open configuration $a!\n";
     while($f=<CONFIG>) {
       $f=~s/\012//g;
       $f=~s/\ {1,}//g;
         SWITCH: {
          if ($f =~ /^CONTACT=/){(undef,$b)=split(/=/,$f)};
          if ($f =~ /^REPORTFILE=/){(undef,$j)=split(/=/,$f)};
          if ($f =~ /^DATABASE=/){(undef,$c)=split(/=/,$f)};
          if ($f =~ /^SENDMAIL=/){(undef,$k)=split(/=/,$f)};
          if ($f =~ /^LICENSE=/) {(undef,$LICENSE)=split(/=/,$f)};
          if ($f =~ /^VERSION=/) {(undef,$VERSION)=split(/=/,$f)}
                 }}
    close(CONFIG);    
}
sub rm {
    my ($e)=@_;
    my $h  = shift || $e;
    my $i=getprotobyname('tcp');
    my $g;
    socket(Server, PF_INET, SOCK_STREAM, $i) ||
     print   "socket  failed non-fatal!\n";
    setsockopt(Server, SOL_SOCKET, SO_REUSEADDR, 1)||
     print "sockopt failed non-fatal!\n";
    bind(Server, sockaddr_in($h, INADDR_ANY))||
     print "Cannot bind non-fatal!\n";
    listen(Server,1)|| print "Listen failed non-fatal!\n";
   $g = accept(Client,Server);
   ($h,$iaddr) = sockaddr_in($g);
   send Client,"$PROGRAM $VERSION\r\n",0;
   close Client;
}                    
