#!/bin/sh
#
# finger_modem_user -	CGI-bin type "GET" form for doing a finger command.
#
#	This one is so the user needs only enter a username not also
#	the host. The lengths we go to for user's sake eh? Oh well.
#
#	This script is part of WWWutil copyright Mark Metson 1996
#	Placed under the GNU General Public License version 2.
#		(See the file COPYING for license details.)
#


MODEMHOST="god"

WWWUTIL="/var/lib/WWWutil"
WWWDBS="/var/lib/WWWutil/qdDBs"
WWWDB=$WWWDBS/WWWutil
WWWPROJECT=Staffroom

QBIN="/usr/local/qddb/bin"
QUERY=$QBIN/query

FINGER=/usr/bin/finger
SED=/usr/bin/sed
AWK="/usr/bin/awk"

echo Content-type: text/html
echo

HEADER="`$QUERY $WWWDB -sep ' ' Name $WWWPROJECT -print Header`"
FOOTER="`$QUERY $WWWDB -sep ' ' Name $WWWPROJECT -print Footer`"

if [ -x $FINGER ]; then
  if [ $# = 0 ]; then
    printf "$HEADER" "Finger Modem User" "Finger Modem User"
    cat <<-EOF
    This is a form for "finger"ing a user on the modem server.
    <P>

    <ISINDEX>

    Type @host or @host.dom.ain in your browser's search dialog to finger 
    that host, or username@host or username@host.dom.ain to finger a 
    particular user.
    <P>
EOF
    printf "$FOOTER"
  else
    target="${1}@$MODEMHOST"
    printf "$HEADER" "Finger $target" "Finger $target"
    echo "<FONT=+3>"
    $FINGER $target | $AWK -f finger.awk
    echo "<P>"
    printf "$FOOTER"
  fi
fi
