From 8545883d676207a4f0ed01079aa8fccfa1e31c7a Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Wed, 8 Jan 2020 10:34:12 +0000 Subject: add search_cgi example --- search_cgi | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 search_cgi (limited to 'search_cgi') diff --git a/search_cgi b/search_cgi new file mode 100644 index 0000000..624ad2e --- /dev/null +++ b/search_cgi @@ -0,0 +1,31 @@ +#!/bin/sh + +echo "Content-type: text/html\n\n" + +query="${QUERY_STRING}" + + +echo "
Search for:
" +echo "" +echo "" +echo "
" + + +terms=$(echo "${query}" | tr '&' '\n' | grep -E "^query" | sed -E 's/^query=//') + + +if [ -z "$terms" ]; then + exit 0 +else + search=$(echo "$terms" | sed -E 's/\%20/ /g') + res=$(./search_repo ./ $search ) + if [ -z "$res" ]; then + echo "

No results for \"$search\":" + exit 0; + else + echo "

Results for \"$search\"" + for r in $res; do + echo "

$r
\n" + done + fi +fi -- cgit v1.2.3