#!/bin/awk -f BEGIN{ file = ARGV[3]"/remote" ARGC = 0 getline info runjimmyrunrunyoufuckerrunhttp://runjimmyrunrunyoufuckerrun.com/ten most recently modified files" while("walk -f -emp /usr/umbraticus/www/jimmy | sort -rn | sed '10q;s,/usr/umbraticus/www/jimmy,,'" | getline){ "date -mu "$1 | getline date body = body""$2"http://runjimmyrunrunyoufuckerrun.com"$2""date"" } body = body"" exit } sub("^http://[^/]*/?", "/", url) sub("[#?].*", "", url) gsub("[^/]*/\\.\\.(/|$)", "/", url) file = "/usr/umbraticus/www/jimmy"url if(system("test -r "file)){ status = "404 Not Found" body = "404 Not Found

404 Not Found

" exit } if(system("test -d "file)){ status = "200 OK" m["gif"] = "image/gif" m["it"] = "audio/it" m["jpg"] = "image/jpeg" m["mod"] = "audio/mod" m["mp3"] = "audio/mpeg" m["ogg"] = "audio/ogg" m["pdf"] = "application/pdf" m["png"] = "image/png" m["ps"] = "application/postscript" m["tgz"] = "application/gzip" m["html"] = "text/html; charset=utf-8" mime = file sub(/.*\./, "", mime) mime = m[mime] if(!mime) mime = "text/plain; charset=utf-8" exit } if(!match(url, "/$")) url = url"/" status = "200 OK" body = ""url"" exit } END{ print info" "status >>"/sys/log/www" if(body) size = length(body) else "walk -es "file | getline size print "HTTP/1.1 "status"\r\nConnection: close\r\nContent-Length: " \ size "\r\nContent-Type: "mime"\r\nServer: awk\r\n\r" if(method == "GET"){ if(body) print body else{ fflush() system("cat "file) } } }