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

113 lines
2.7 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
if [ "$*" = "prn-flags" ]; then
i=`getconfig 18 | cut -d" " -f2`
$GENFORM < $SMART_ROOT/forms/prn-flags "$i"
exit;
fi
declare -i i
export `echo $* | sed "s/&/ /g"`
if [ "$*" ]; then
if [ "$DELETE" ]; then
export DELETE=""
nwborm $SERVER_LOGIN -t 3 -o $QUEUE
$0 list x
exit;
elif [ "$EDIT" ]; then
export EDIT=""
COMMAND="`
nwbpvalues $SERVER_LOGIN -t 3 -o $QUEUE -p Q_UNIX_PRINT | \
while read LINE; do
if echo $LINE | grep -q '\['; then
echo "$LINE";
fi;
done | cut -b1-47 | $HEXASC`"
SPOOLDIR="`nwbpvalues $SERVER_LOGIN -t 3 -o $QUEUE -p Q_DIRECTORY`"
$GENFORM < $SMART_ROOT/forms/printer "$QUEUE" "$COMMAND" "$SPOOLDIR"
fi;
fi
case "$1" in
padd )
$GENFORM < $SMART_ROOT/forms/printer
;;
list )
cat<<EOF
<HTML>
<HEAD>
<TITLE>Printers</TITLE>
</HEAD>
<BODY BGCOLOR=#C0C0C0>
<FORM ACTION="/cgi-bin/printer" 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>Printers</FONT></TH>
</TR>
</TABLE>
<TR><TH>Sel<TH>Queue name<TH>Queue ID
`nwbols $SERVER_LOGIN -t 3 | 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=\"QUEUE\" 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/printer?padd">Add print queue</A>
<INPUT TYPE=SUBMIT NAME="EDIT" VALUE="Edit">
<INPUT TYPE=SUBMIT NAME="DELETE" VALUE="Delete">
</TABLE>
</BODY>
</HTML>
EOF
;;
esac