#!/bin/sh
set -x
error()
{
    echo "Content-type: text/html"
    echo ""
    echo "<html><head><title> Error</title></head>"
    echo "<body><h1><center> Request Error</center></h1></body></html>"
    exit 0
}
SEARCH="xsltproc"
ifs=$IFS
IFS="&"
# protections avant l'analyse du QUERY_STRING
if [ "$QUERY_STRING" = "" ]
then
    error
fi
echo "$QUERY_STRING" | grep subtitle | grep year | grep subauthor | grep lang | grep theme | grep =| grep -q \& || error
echo $QUERY_STRING | grep -q \; && error

set $QUERY_STRING
for param in $*
do
	name=`echo $param|cut -d"=" -f1`
	value=`echo $param|cut -d"=" -f2`
	if [ "$value" = "" ]
	then
		value=\"\"
	fi
	SEARCH="$SEARCH -stringparam $name $value"
done
echo "Content-type: text/html"
echo ""
SEARCH="$SEARCH recherche.xsl biblio.xml"
eval $SEARCH

