#!/bin/sh echo Content-Type: text/html echo tPLUGIN="Note" NoteCur="current" NoteNew="__NEW__" b_DOIT="Set" b_UNDO="Cancel" DefTEXT="" unescape() { s=$(echo "$1"|sed -e"s/+/ /g") echo -n ${s%%%*} if [ -n "$s" ] && [ "$s" != "${s#*%}" ];then IFS=\% set ${s#*%} unset IFS for i in "$@";do echo -n -e "\\x$(echo $i|dd bs=1 count=2 2>&-)" echo -n ${i#??} done fi } getarch() { D=`date -I` N=0 last="" next=$D while [ -e "$next" ]; do last=$next N=$(( $N+1 )) next="$D"_"$N" done if [ $1 = "last" ]; then echo "$last" elif [ $1 = "next" ]; then echo "$next" fi } if [ ! -d notes ]; then mkdir ./notes fi cd ./notes if [ ! -e $NoteCur ]; then echo $DefTEXT > "./$NoteCur" fi if [ "$REQUEST_METHOD" = "POST" ]; then read QUERY_STRING fi if [ -z "$QUERY_STRING" ]; then last_F="$NoteCur" next_F=$NoteCur n_Text=`cat ./$NoteCur` else IFS=\&;set ${QUERY_STRING%%[^%&=+-:@-_a-z~]*};unset IFS for P in $*;do eval $(echo $P|sed -n '/[A-Za-z_]\+=.*/p');done n_Text=$(unescape $n_Text) next_F=$(unescape $next_F) prev_F=$(unescape $last_F) last_F="$next_F" case "$next_F" in $NoteCur ) if [ "$prev_F" = "$NoteNew" ] || [ "$prev_F" = "$NoteCur" ]; then echo $n_Text > "./$NoteCur" fi n_Text=`cat ./$NoteCur` ;; $NoteNew ) if [ "$prev_F" = "$NoteCur" ]; then nx=`getarch "next"` echo $n_Text > "./$nx" fi next_F=$NoteCur n_Text=$DefTEXT ;; *) if [ "$prev_F" = "$NoteNew" ] || [ "$prev_F" = "$NoteCur" ]; then echo $n_Text > "./$NoteCur" fi n_Text=`cat ./$next_F` ta_parm="readonly class=ro" ;; esac fi cat<
$tPLUGIN