115 lines
3.0 KiB
Bash
115 lines
3.0 KiB
Bash
#!/bin/sh
|
|
#
|
|
# CGI-script for creating the main menu for SMArT
|
|
#
|
|
# Copyright 2000 Wilmer van der Gaast (lintux@lintux.cx)
|
|
#
|
|
|
|
# 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
|
|
|
|
if [ "$1" = "detached" ]; then
|
|
MENU="$2"
|
|
LANG="$3";
|
|
else
|
|
echo Content-Type: text/html
|
|
echo;
|
|
fi
|
|
|
|
if [ "$SMART_CONFIGURED" != "yes" ]; then
|
|
cat << EOF
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>Error: SMArT not configured yet</TITLE>
|
|
</HEAD>
|
|
<BODY BGCOLOR=#C0C0C0>
|
|
SMArT has not been configured yet, please click
|
|
<A HREF="/cgi-bin/general?smart" TARGET=OPTS>here</A> to view the SMArT
|
|
configuration menu, and then please click <A HREF="/cgi-bin/menu?main">here</A>
|
|
to reload the menu.
|
|
<P>Enabling the password prompt is <STRONG>strongly</STRONG> recommended,
|
|
because it's easily possible to find the <TT>SUPERVISOR</TT> password using
|
|
this program, so please turn it on. After switching it on, and pressing OK,
|
|
your browser will ask you for the login/password you want to use with SMArT.<BR>
|
|
Note that this password does not have to be the same as the
|
|
<TT>root</TT>-password or the <TT>SUPERVISOR</TT>-password/etc.
|
|
</BODY>
|
|
</HTML>
|
|
EOF
|
|
exit 1;
|
|
fi
|
|
|
|
checkparams $*
|
|
|
|
if [ "$1" != "detached" ]; then
|
|
for LANG in `getlangs` en; do
|
|
if [ -e "$SMART_ROOT/menus/$1/index.$LANG" ]; then
|
|
$0 detached "$1" "$LANG" < $SMART_ROOT/menus/$1/index.$LANG
|
|
exit;
|
|
fi;
|
|
done;
|
|
fi
|
|
|
|
declare -i i; i=0
|
|
|
|
read TITLE
|
|
COPYRIGHT=`echo $TITLE | cut -d, -f2-`
|
|
TITLE=`echo $TITLE | cut -d, -f1`
|
|
|
|
cat << EOF
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>$TITLE</TITLE>
|
|
</HEAD>
|
|
<BODY BGCOLOR=#C0C0C0>
|
|
<TABLE BORDER>
|
|
<TR>
|
|
<TH BGCOLOR=$HEADER_BACK ALIGN=LEFT COLSPAN=2>
|
|
<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>$TITLE</FONT></TH>
|
|
</TR>
|
|
</TABLE>
|
|
<TR>
|
|
EOF
|
|
read LINE
|
|
while [ "$LINE" ]; do
|
|
SUBMENU=`echo $LINE | cut -d, -f1`
|
|
DIR=`echo $LINE | cut -d, -f2`
|
|
for FILE in $SMART_ROOT/menus/$MENU/$DIR/*.$LANG; do
|
|
cat $FILE | \
|
|
{ read LINE
|
|
echo \<TD VALIGN=TOP\>\<FONT SIZE=+1\>$SUBMENU\</FONT\>
|
|
echo \<TD VALIGN=TOP\>\<A HREF=\"/cgi-bin/`echo $LINE | cut -d, -f2`\" \
|
|
TARGET=OPTS\>`echo $LINE | cut -d, -f1`\</A\>
|
|
echo -n \<TR\>\<TD COLSPAN=2\>
|
|
cat
|
|
echo \<TR\>;
|
|
}
|
|
done
|
|
read LINE;
|
|
done
|
|
cat << EOF
|
|
<TH COLSPAN=2>$COPYRIGHT
|
|
</TABLE>
|
|
</BODY>
|
|
</HTML>
|
|
EOF
|
|
|