Files
mars-smart/root/cgi-bin/group.in
2026-04-21 02:12:28 +02:00

151 lines
3.6 KiB
Bash

#!/bin/sh
#
# CGI-script for userlist editting (Using bindery tools)
#
# 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 [ "$2" != "x" ]; then
echo Content-Type: text/html
echo;
fi
checkrefer
checkparams $*
checkbind
declare -i i
export `echo $* | sed "s/&/ /g"`
if [ "$*" ]; then
if [ "$DELETE" ]; then
export DELETE=""
nwborm $SERVER_LOGIN -t 2 -o $GROUP
$0 list x
exit;
elif [ "$EDIT" ]; then
export EDIT=""
FULLNAME="`nwbpvalues $SERVER_LOGIN -t 2 -o $GROUP -p IDENTIFICATION`"
i=0; for g in `{ nwbols $SERVER_LOGIN -t 1; nwbols $SERVER_LOGIN -t 2; } | \
cut -d" " -f1`; do i=$i+1; done
{ nwbols $SERVER_LOGIN -t 1
nwbols $SERVER_LOGIN -t 2;
} | sort | sort +1 |
{ echo C,x,Group managers,$i
read LINE
while [ "$LINE" ]; do
NAME=`echo $LINE | cut -d" " -f1`
TYPE=`echo $LINE | cut -d" " -f3`
echo -n T$TYPE\_$NAME,$NAME \(
case "$TYPE" in
0001 ) echo user\) ;;
0002 ) echo group\) ;;
esac
read LINE;
done;
} | $REPLACE $SMART_ROOT/forms/group | $GENFORM "$GROUP" "$FULLNAME" `
{ nwbols $SERVER_LOGIN -t 1
nwbols $SERVER_LOGIN -t 2;
} | sort | sort +1 | cut -d" " -f1 | \
{ read GRP
while [ "$GRP" ]; do
if [ "\`nwbpvalues $SERVER_LOGIN -t 2 -o $GROUP -p OBJ_SUPERVISORS | \
grep $GRP\`" = "$GRP" ]; then
echo -n "1 ";
else
echo -n "0 ";
fi
read GRP;
done;
}`
fi;
fi
case "$1" in
gadd )
i=0; for g in `{ nwbols $SERVER_LOGIN -t 1; nwbols $SERVER_LOGIN -t 2; } | \
cut -d" " -f1`; do i=$i+1; done
{ nwbols $SERVER_LOGIN -t 1
nwbols $SERVER_LOGIN -t 2;
} | sort | sort +1 |
{ echo C,x,Group managers,$i
read LINE
while [ "$LINE" ]; do
NAME=`echo $LINE | cut -d" " -f1`
TYPE=`echo $LINE | cut -d" " -f3`
echo -n T$TYPE\_$NAME,$NAME \(
case "$TYPE" in
0001 ) echo user\) ;;
0002 ) echo group\) ;;
esac
read LINE;
done;
} | $REPLACE $SMART_ROOT/forms/group | $GENFORM
;;
list )
cat<<EOF
<HTML>
<HEAD>
<TITLE>Group list</TITLE>
</HEAD>
<BODY BGCOLOR=#C0C0C0>
<FORM ACTION="/cgi-bin/group" METHOD=GET>
<TABLE BORDER>
<TR>
<TH COLSPAN=3 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>Groups</FONT></TH>
</TR>
</TABLE>
<TR>
<TH>Sel
<TH>Group name
<TH>NetWare group ID
`nwbols $SERVER_LOGIN -t 2 | sort +1 | {
read LINE
i=0
while [ -n "$LINE" ]; do
i=i+1
NAME=\`echo $LINE | cut -d" " -f1\`
echo -n \<TR\>
echo -n \<TD\>\<INPUT TYPE=RADIO NAME=\"GROUP\" VALUE=\"$NAME\"\>
echo -n \<TD\>
echo -n $NAME
echo -n \<TD\>
echo $LINE | cut -d" " -f2
read LINE
done;
}`
<TR>
<TD COLSPAN=3 ALIGN=CENTER>
<A HREF="/cgi-bin/group?gadd">Add group</A>
<INPUT TYPE=SUBMIT NAME="EDIT" VALUE="Edit">
<INPUT TYPE=SUBMIT NAME="DELETE" VALUE="Delete">
</TABLE>
</BODY>
</HTML>
EOF
;;
esac