#!/bin/sh # Allow me to add comments to my photographs via the Web # comments are stored in $photo.info datafiles, text only. passwd="d80" echo "Content-type: text/html" echo "" echo "Add Comment Script" echo "
" if [ -z "$QUERY_STRING" ] ; then echo "No photo upon which to comment?" exit 0 fi photo="$QUERY_STRING" # if this condition is true, there's no comment to add yet... if [ -z "$(echo $QUERY_STRING | grep '&')" ] ; then echo "
" echo "" echo "

Notes for $photo

" echo "" echo "

Comment password: " echo "     " echo "
" exit 0 else cmt="$(echo $photo | cut -d\& -f2 | cut -d= -f2)" cmt="$(echo $cmt | sed 's/+/ /g;s/%2C/,/g;s/%3A/:/g;s/%28/(/g;s/%29/)/g')" cmt="$(echo $cmt | sed 's/%21/!/g;s/%3F/?/g;s/%40/@/g;s/%0D//g;s/%0A/ /g')" cmt="$(echo $cmt | sed 's/%22/\"/g' | sed "s/%27/\'/g;")" pwd="$(echo $photo | cut -d\& -f3 | cut -d= -f2)" photo="$(echo $photo | cut -d\& -f1 | cut -d= -f2)" photo="$(echo $photo | sed 's/%2F/\//g')" if [ $pwd != $passwd ] ; then echo "You are apparently not authorized to add comments to this picture." exit 0 fi echo "

Saving comment for $photo.info

" if [ ! -w $photo.info ] ; then echo "
Warning: cannot write to directory/create file. Quit" exit 0 else echo $cmt > $photo.info echo "Comment has been saved." fi exit 0 fi