#!/usr/bin/perl
###############################################################################
# Copyright 2009-2013, Way to the Web Limited
# URL: http://www.configserver.com
# Email: sales@waytotheweb.com
###############################################################################
# start main
use strict;
use File::Find;
use Fcntl qw(:DEFAULT :flock);
use Sys::Hostname qw(hostname);
use IPC::Open3;
use File::Copy;
use Digest::MD5;

our ($script, $script_da, $images, %FORM, $myv, %in);

my ($childin, $childout);
my $pid = open3($childin, $childout, $childout, "/usr/sbin/cxs --version");
my @data = <$childout>;
waitpid ($pid, 0);
chomp @data;
if ($data[0] =~ /v(.*)$/) {$myv = $1}

$script = "/cxs/index.cgi";
$images = "/cxs/images";

print "Content-type: text/html\r\n\r\n";

do '../web-lib.pl';      
&init_config();         
&ReadParse();
%FORM = %in;

print <<EOF;
<!DOCTYPE html>
<HTML>
<HEAD>
<TITLE>ConfigServer Security & Firewall</TITLE>
</HEAD>
<BODY>
EOF
unless ($FORM{action} eq "tailcmd" or $FORM{action} eq "logtailcmd") {
	print "<img src='images/cxs_small.png' align='absmiddle' /> <b style='font-size: 16px'>ConfigServer Exploit Scanner - cxs v$myv</b>";
}

do "/etc/cxs/cxsui.pl";
print "</BODY>\n</HTML>\n";

1;
