#!/bin/sh
EDITOR=nocrack_editor
echo "HTTP/1.1 200 OK"
echo "Date: " `date`
echo "Server: nocracks"
echo "Content-type: text/html"
echo "Connection: close"
echo
echo ""
echo "
"
echo "Page edit"
echo ""
echo ""
if [ "$1" = "" ]; then
echo No parameter supplied
elif [ "$1" = "none" ] ; then
echo no file none to edit
else
echo file=$1 >/tmp/edit.log
file=$1
DOCDIR=
STORYDIR=
for dir in `echo $DOCDIRS | sed 's/:/ /g'`
do
if [ -f $dir/story ] ; then
STORYDIR=$dir
fi
if [ -f $dir/$file ] ; then
DOCDIR=$dir
break
fi
done
echo file2=$file DOCDIR=$DOCDIR >>/tmp/edit.log
if [ "$DOCDIR" != "" ] ; then
FILE=$DOCDIR/$file
$EDITOR $FILE &
elif [ "$STORYDIR" != "" ] ; then
# New file
FILE=$STORYDIR/$file
if [ ! -f $FILE ] ; then
touch $FILE
fi
$EDITOR $FILE &
else
echo No file $file to edit
fi
fi
echo ""
echo ""