#!/bin/sh # GR general address finder. (c) Steve Braham # # This combines the functionality of the original GRpeople, # GRjournal and GRaddress programs into one. It works as follows: # # POST mode: when called via POST, the CGI variable file is checked # to see which type of search should be made, and the other # variables are then parsed to build the search. # # GET mode: Can be called with or without a QUERY string. In either # case, the search file is picked up from the extra path info, # PATH_INFO. If called without a QUERY, the routine returns # a simple form for an ISINDEX request. If called with a QUERY, # a search is performed with basic defaults for the other # parameters (case insensitive, simple mode, best match to within # 3 errors). a GET without an extra path provides general information # and links to the path specific modes. # # Awk scripts to do the database to HTML conversion are kept # in the GR directory # emailfile="/usr/local/lib/addresses/grpersons" mailfile="/usr/local/lib/addresses/grplaces.search" getquery="/usr/local/http/support/extra/getQuery" unescape="/usr/local/http/support/unescape" wagrep="/usr/local/http/support/extra/wagrep" people="/usr/local/http/GR/people.awk" address="/usr/local/http/GR/address.awk" journal="/usr/local/http/GR/journal.awk" servers="/usr/local/http/GR/servers.awk" pages="/usr/local/http/GR/pages.awk" #.. Output header # cat << EOM Content-type: text/html EOM # if it's a POST, expand out the form if [ "$REQUEST_METHOD" = "POST" ]; then # grab form data and parse it to environment variables # #.. Strip the variables out from the query string, # and assign them into the environment, prefixed by 'QS_' # # o getQuery ensures that # - POST is fetched properly # - all dangerous characters are escaped # # o awk ensures that # - all variables passed have legal names # - special characters are not interpreted by sh # eval `$getquery | awk ' BEGIN{RS="&";FS="="} $1~/^[a-zA-Z][a-zA-Z0-9_]*$/ { printf "QS_%s=%c%s%c\n",$1,39,$2,39}' ` # Parse the expanded data to actual search parameters # Exact or Best Match? case $QS_match in best) bm=1; sea="$wagrep -B -y -u";; exact) bm=0; sea="$wagrep -u";; *) bm=1; sea="$wagrep -B -y -u";; esac # Set error range if best match if [ $bm -eq 1 ]; then if [ -z "$QS_l" ]; then sea="$sea -3" else sea="$sea -$QS_l$" fi fi # Set word mode if [ "$QS_wm" = "word" ]; then sea="$sea -w" fi # Case sensitivity case $QS_case in sensitive) ;; insensitive) sea="$sea -i" ;; *) sea="$sea -i" ;; esac # Set search type. (regex or plain) case $QS_method in advanced) ;; simple) sea="$sea -k" ;; *) sea="$sea -k" ;; esac # # Check to see what kind of GET we have else if [ -z "$QUERY_STRING" ]; then # ok, we handle usage information requests first # Generic bit: cat <Basic GR Gateway

General Relativity Addresses

This is a simple interface into the General Relativity mailing address list. This service is provided by the QMW Relativity group, and the list is kept by Malcolm MacCallum. Searches performed via this gateway will be case-insensitive, and best matches with up to three errors will be returned. Only simple searches will work.
EOM case $PATH_INFO in /people) cat <

To search for the e-mail address of a person, simply type your text into the dialog box. You also have other options. EOM ;; /address) cat <

To search for the postal address of an institution, simply type your text into the dialog box. You also have other options. EOM ;; /journal) cat <

To search for the e-mail address of a journal or group, simply type your text into the dialog box. You also have other options. EOM ;; /servers) cat <

To search for the snail mail addresses, and URLs, of sites with WWW accessible servers, simply type text into the dialog box. We have a complete list of servers available. You also have other options. EOM ;; /pages) cat <

To search for people with WWW Homepages, simply type text into the dialog box. You also have other options. EOM ;; *) cat <

Options

You can also read details about our search engine. EOM ;; esac cat < Try our form-based search, or go back to HyperSpace
EOM ls -l $emailfile|awk '{ print "E-mail database last modified on "$5" "$6" "$7"."}' echo "In case of problems, contact:
The Web Master (theoryweb@physics.ubc.ca)
or, for software problems, the author:
Steve Braham (S.P.Braham@qmw.ac.uk)
" exit fi # OK, it's a GET, but we have a search to do. Set defaults QS_search=`$getquery` sea="$wagrep -3 -i -u -B -y -k" case $PATH_INFO in /people) QS_w="People";; /address) QS_w="Address";; /journal) QS_w="Journal";; /servers) QS_w="Servers";; /pages) QS_w="Pages";; *) QS_w="Error";; esac fi # OK, we're ready for a search! # Unescape search string, carefully, so that it can be used by # awk in HTML output allpars=`$unescape -e "$QS_search"` # Output title information cat <GR Address search output

Search Results

EOM #ok, do it case $QS_w in People) $sea "$QS_search" $emailfile |fgrep -v "ZZ"|awk -F\& -f $people allpars="$allpars" ;; Address) $sea "$QS_search" $mailfile | awk -F\& -f $address allpars="$allpars" ;; Journal) $sea "$QS_search" $emailfile |fgrep "ZZ"|awk -F\& -f $journal allpars="$allpars" ;; Servers) $sea "$QS_search" $mailfile | awk -F\& -f $servers allpars="$allpars" ;; Pages) $sea "$QS_search" $emailfile |fgrep -v "ZZ"| awk -F\& -f $pages allpars="$allpars" ;; *) echo "Sorry-invalid search type." ;; esac cat < You can now try a new search, or go back to HyperSpace
EOM ls -l $emailfile|awk '{ print "Database last modified on "$5" "$6" "$7"."}' echo "In case of problems, contact:
The Web Master (theoryweb@physics.ubc.ca)
or, for software problems, the author:
Steve Braham (S.P.Braham@qmw.ac.uk)
"