#!/bin/sh -
#
# (c) SPDsoft December 12, 1995
# Updated Tue Jul 29 21:08:35 METDST 1997
#
umask 022
PATH=/bin:/usr/bin
TEMP=/tmp/`basename $0`.$$
TEMP_D=/tmp/`basename $0`_d.$$
trap "rm -f $TEMP $TEMP_D; exit" 0 1 2 3 15
echo Content-type: text/html
echo
if [ "$QUERY_STRING" = "" ]; then
cat << EOM
Zaragoza University Phone Numbers
Zaragoza
University Phone numbers
You can search here for the phone number of every single person who works
at the Zaragoza University. (3046 entries!)
#include <std_disclaimer.h>
This search engine uses the data provided by the Computing Center
to general public.
This information may not be accurated; you may want to try the
search engine provided by the
Computing Center
Problems with this form? e-mail to
spd@www.cps.unizar.es
BTW,
if you want the original data base compressed with gzip,
here you are.
EOM
else
cat << EOM
Search results
EOM
error=false
IFS="&"
a=`cat /pub/www/whois/counter`
a=`expr $a + 1`
echo $a > /pub/www/whois/counter
#
# default query
#
what="name"
crit="contains"
#
# actual query
#
#for field in $QUERY_STRING
#do
# fname=`echo "$field" | awk -F= '{print $1}'`
# fvalue=`echo "$field" | sed -e "s/${fname}=//" | tr '+' ' ' | /users/server/www/usr/aux-bin/htd `
#
# case "$fname" in
#
# crit)
# crit="$fvalue"
# ;;
#
# name)
# name="$fvalue"
# if [ "$name" = "" ]
# then
# echo 'Type a name, please
'
# error=true
# fi
# ;;
#
# what)
# what="$fvalue"
# ;;
#
# *)
# echo "Error: Incorrect URL ( $fname )
"
# error=true
# ;;
#
# esac
#
#done
CGIPARSE="/users/server/www/usr/aux-bin/cgiparse"
for var in crit name what
do
value="`$CGIPARSE -1 -value $var 2>/dev/null`"
case $? in
0)
value=`echo "$value" | tr -d '[\001-\037]"\`#;\177'`
eval "$var=\"$value\""
;;
*)
error=true
echo "Error: Incorrect URL ( $var )
"
esac
done
if [ "$name" = "" ]
then
echo 'Type a name, please
'
error=true
fi
if ( ( $error ) )
then
echo
echo "I'm sorry, you entered wrong data
"
echo 'Try again, please...
'
echo
else
echo 'Search results:
'
echo '
'
cat << EOM
Numbers with 4 figures are extensions of the central number of
the Zaragoza University:
976 761000
If you are calling from the outside of Spain, you must dial first
34. Full numbers are obtained by dialing 976
before the 6 figure numbers.
These are the results of the
EOM
echo $a "search since Nov. 15, 1999:
"
name=`echo "$name" | tr '[:lower:]' '[:upper:]' | tr '\361' '\321'`
case "$what" in
"phone"*)
case "$crit" in
"contains")
search=".* .* .* .*$name"
;;
"is exactly")
search=".* .* .* ${name}$"
;;
"begins with"|*)
search=".* .* .* ${name}"
;;
esac
;;
"ext"*)
case "$crit" in
"contains")
search=".* .* .*$name"
;;
"is exactly")
search=".* .* ${name} "
;;
"begins with"|*)
search=".* .* ${name}"
;;
esac
;;
"name"|*)
case "$crit" in
"contains")
search=" .*$name"
;;
"is exactly")
search=" \(.*[ ]1*\)*${name}[ ]"
;;
"begins with"|*)
search=" \(.*[ ]1*\)*${name}"
;;
esac
;;
esac
rm -f $TEMP $TEMP_D
grep "$search" /pub/www/whois/Telefonos.txt 2>/dev/null | sort > $TEMP
lines=`wc -l $TEMP | awk '{print $1}'`
case "$lines" in
"0")
echo "I'm sorry, didn't find $name
"
;;
*)
echo "I've found $lines" \\c
if [ "$lines" = "1" ]
then
echo match
else
echo matches
fi
echo "
"
awk -F' ' '{print $1}' $TEMP | uniq | tee $TEMP_D | \
/users/server/www/usr/aux-bin/tolower | \
sed -e 's/ Y / y /g' -e 's/De /de /g' -e 's/ E / y /g' | \
awk -F' ' '{printf ("- %s",$1,$1)}'
echo "
"
cat $TEMP_D | (
while read line
do
lineu=`echo "$line" | \
/users/server/www/usr/aux-bin/tolower | \
sed -e 's/ Y / y /g' -e 's/De /de /g' -e 's/ E / e /g' `
echo "
"
grep "^$line" $TEMP | \
/users/server/www/usr/aux-bin/tolower | \
awk -F' ' '{printf ("- %s: %s, %s",$2,$3,$4)}'
echo "
"
done
)
;;
esac
fi
cat << EOM
EOM
fi