From 3f7954f8e1c2274e4b6f1b794bc36a908f28afce Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 30 Apr 2023 22:29:09 -0500 Subject: Initial commit --- lighttpd.conf | 10 +++++++++ makefile | 2 ++ yawp.sh | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 lighttpd.conf create mode 100644 makefile create mode 100755 yawp.sh diff --git a/lighttpd.conf b/lighttpd.conf new file mode 100644 index 0000000..53765a6 --- /dev/null +++ b/lighttpd.conf @@ -0,0 +1,10 @@ +server.document-root = "/home/acdw/src/yawp" +server.port = 3030 +server.username = "acdw" +server.groupname = "acdw" + +index-file.names = ( "index.html", "yawp.sh" ) + +server.modules += ( "mod_cgi", "mod_rewrite" ) +cgi.assign = ( ".sh" => "" ) +url.rewrite-if-not-file = ( "" => "/yawp.sh${url.path}${qsa}" ) \ No newline at end of file diff --git a/makefile b/makefile new file mode 100644 index 0000000..efb10b9 --- /dev/null +++ b/makefile @@ -0,0 +1,2 @@ +serve: yawp.sh lighttpd.conf + lighttpd -D -f lighttpd.conf diff --git a/yawp.sh b/yawp.sh new file mode 100755 index 0000000..b74febb --- /dev/null +++ b/yawp.sh @@ -0,0 +1,71 @@ +#!/bin/sh +# yawp! + +crlf() { # crlf < INPUT + ## Convert LF to CRLF + sed 's/$/ /g' +} + +http_response() { # http_response [STATUS:-200 OK] < CONTENT + cat <
$(env) +$(cat | tee /dev/shm/yawp) +
+
+$(form_decode < /dev/shm/yawp)
+
+EOF +} + +form_decode() { # form_decode << INPUT (application/x-www-form-urlencoded) + # TODO: multipart/form-data ..? + awk '/%[0-9A-Fa-f][0-9A-Fa-f]/ { + while (s = match($0, "%[0-9A-Fa-f][0-9a-fA-F]") > 0) { + chr = ""; + hexdigits = "0123456789abcdef"; + value = 16 * (index(hexdigits,tolower(substr($0,RSTART+1,1))) - 1); + value += index(hexdigits,tolower(substr($0,RSTART+2,1))) - 1; + chr = sprintf("%c", value); + value = 0; + $0 = substr($0, 1, RSTART - 1) chr substr($0, RSTART + RLENGTH); + } +} +{gsub(/+/," ");gsub(/&/,"\n");print} +' +} + +new_post() { + http_response < +YAWP! +
+ +
+ +
+EOF +} + +display_posts() { + debug_env +} + +main "$@" -- cgit 1.4.1-21-gabe81