Files
ioccc/1998/dlowe/pootify.cgi.sh
Cody Boone Ferguson 10b5b47466 Update 1998/dlowe - add scripts + formatting
The following scripts were added:

- try.sh: a fun use of the program.
- pootify.sh: a local pootifier that downloads a web page (or use a
local file) and either changes it to text or writes html which can be
viewed in a local browser.
- pootify.cgi.sh: a CGI version that the judges added but made to use
bash(1) and pass shellcheck(1). There is an issue that is known with
this and the 'Historical remarks' discusses this in more detail as well
as how to use the pootify.sh and pootify.cgi.sh scripts.

The README.md file has been formatted as well.
2023-11-13 06:08:26 -08:00

26 lines
582 B
Bash
Executable File

#!/usr/bin/env bash
#
# pootify.cgi.sh - a sample CGI pootifier
#
POOT="./dlowe"
LYNX="lynx"
ECHO="echo"
EXPR="expr"
${ECHO} "Content-type: text/html"
${ECHO}
QUERY_STRING="$1"
if [[ -z "${QUERY_STRING}" ]]; then
${ECHO} "QUERY_STRING not found"
else
URL="$(${EXPR} "$QUERY_STRING" : '[Uu][Rr][Ll]=\(.*\)')"
if [[ -z "${URL}" ]]; then
${ECHO} "No URL given in QUERY_STRING"
elif [[ X"$(${EXPR} "${URL}" : '[Ff][Ii][Ll][Ee]:')" != X0 ]]; then
${ECHO} "file: based URLs are not allowed"
else
${LYNX} -restrictions=all -source "${URL}" | ${POOT}
fi
fi