#!/bin/sh
#
# CGI-script for general settings in nwserv.conf
#
# Copyright 2000 Wilmer van der Gaast (lintux@dds.nl)
#

#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

. $WEBSERVE_ROOT/cgi-bin/functions
. $WEBSERVE_ROOT/smart.conf

echo Content-Type: text/html
echo

checkrefer
checkparams $*

case $* in
	logwhat )
		CURRENT=`getconfig 10[0-9] | sort | cut -d" " -f2`
		$GENFORM < $SMART_ROOT/forms/logwhat $CURRENT
;;
	logfiles )
		NORMAL=`getconfig 201 | cut -d" " -f2`
		ROUTES=`getconfig 301 | cut -d" " -f2`
		$GENFORM < $SMART_ROOT/forms/logfiles $NORMAL $ROUTES
;;
	viewlog )
		cat << EOF
<HTML>
<HEAD>
<TITLE>Viewer log</TITLE>
</HEAD>
<BODY BGCOLOR=#C0C0C0>
<TABLE BORDER>
<TR>
<TH COLSPAN=2 BGCOLOR=$HEADER_BACK ALIGN=LEFT>
<TABLE BORDER=0 FRAME=0 CELLSPACING=0 CELLPADDING=0>
<TR>
<TD><IMG SRC="/smart_icon.jpg"></TD>
<TD><FONT COLOR=$HEADER_BACK>-</FONT></TD>
<TH><FONT COLOR=$HEADER_FORE>View log</FONT></TH>
</TR>
</TABLE>
<TR>
<TH COLSPAN=2>MARS_NWE keeps two log files, a normal log file and a routing
log file. Which one do you want to see?
<TR>
<TH><A HREF="/cgi-bin/logging?nwservlog">nwserv.log</A>
<TD>The normal log file, some startup information
<TR>
<TH><A HREF="/cgi-bin/logging?routeslog">routes.log</A>
<TD>The routing log file, some information about the IPX-devices, updated
regularly
</TABLE>
</BODY>
</HTML>
EOF
;;
	nwservlog )
		echo \<HTML\>
		echo \<HEAD\>
		echo \<TITLE\>MARS_NWE server log\</TITLE\>
		echo \</HEAD\>
		echo \<BODY BGCOLOR=\#C0C0C0\>
		echo \<TABLE BORDER\>
		echo \<TR\>
		echo \<TH BGCOLOR=$HEADER_BACK ALIGN=LEFT\>
		echo \<TABLE BORDER=0 FRAME=0 CELLSPACING=0 CELLPADDING=0\>
		echo \<TR\>
		echo \<TD\>\<IMG SRC=\"/smart_icon.jpg\"\>\</TD\>
		echo \<TD\>\<FONT COLOR=$HEADER_BACK\>-\</FONT\>\</TD\>
		echo \<TH\>\<FONT COLOR=$HEADER_FORE\>nwserv.log\</FONT\>\</TH\>
		echo \</TR\>
		echo \</TABLE\>                  
		echo \<TR\>
		echo \<TD\>
		echo \<PRE\>
		cat `getconfig 201 | cut -d" " -f2`
		echo \</PRE\>
		echo \<TR\>
		echo \<TH\>
		echo \<A HREF=\"/cgi-bin/logging?viewlog\"\>Logfiles index\</A\>
		echo \</TABLE\>
		echo \</BODY\>
		echo \</HTML\>
;;
	routeslog )
		echo \<HTML\>
		echo \<HEAD\>
		echo \<TITLE\>MARS_NWE router log\</TITLE\>
		echo \</HEAD\>
		echo \<BODY BGCOLOR=\#C0C0C0\>
		echo \<TABLE BORDER\>
		echo \<TR\>
		echo \<TH BGCOLOR=$HEADER_BACK ALIGN=LEFT\>
		echo \<TABLE BORDER=0 FRAME=0 CELLSPACING=0 CELLPADDING=0\>
		echo \<TR\>
		echo \<TD\>\<IMG SRC=\"/smart_icon.jpg\"\>\</TD\>
		echo \<TD\>\<FONT COLOR=$HEADER_BACK\>-\</FONT\>\</TD\>
		echo \<TH\>\<FONT COLOR=$HEADER_FORE\>nwserv.log\</FONT\>\</TH\>
		echo \</TR\>
		echo \</TABLE\>                  
		echo \<TR\>
		echo \<TD\>
		echo \<PRE\>
		cat `getconfig 301 | cut -d" " -f2`
		echo \</PRE\>
		echo \<TR\>
		echo \<TH\>
		echo \<A HREF=\"/cgi-bin/logging?viewlog\"\>Logfiles index\</A\>
		echo \</TABLE\>
		echo \</BODY\>
		echo \</HTML\>
;;
	log-flags )
		declare -i CURRENT E202 E202_1 E202_2 E302 E302_1 E302_2
		E200="`getconfig 200 | cut -d" " -f2`"
		E202="`getconfig 202 | cut -d" " -f2`"
		E300="`getconfig 300 | cut -d" " -f2`"
		E302="`getconfig 302 | cut -d" " -f2`"
		E202_1="$E202 & 1"				
		E202_2="$E202 & 2"
		E302_1="$E302 & 1"				
		E302_2="$E302 & 2"
		$GENFORM < $SMART_ROOT/forms/log-flags "$E200" "$E202_1" "$E202_2" "$E300" "$E302_1" "$E302_2"
;;
esac
