💾 Archived View for runjimmyrunrunyoufuckerrun.com › rc › tcp80 captured on 2021-12-17 at 13:26:06.

View Raw

More Information

-=-=-=-=-=-=-

#!/bin/awk -f
BEGIN{
	file = ARGV[3]"/remote"
	ARGC = 0
	getline info <file
	"date -t" | getline
	info = $0" "info
	mime = "text/html; charset=utf-8"
	getline
	method = $1
	url = $2
	info = info" "method" "url
	if(method != "GET" && method != "HEAD"){
		status = "510 Not Implemented"
		body = "<!doctype html><title>510 Not Implemented</title><h1>510 Not Implemented</h1>"
		exit
	}
	if(url == "/index.rss"){
		status = "200 OK"
		mime = "text/xml; charset=utf-8"
		body = "<?xml version=\"1.0\"?><rss version=\"2.0\"><channel><title>runjimmyrunrunyoufuckerrun</title><link>http://runjimmyrunrunyoufuckerrun.com/</link><description>ten most recently modified files</description>"
		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"<item><title>"$2"</title><link>http://runjimmyrunrunyoufuckerrun.com"$2"</link><pubDate>"date"</pubDate></item>"
		}
		body = body"</channel></rss>"
		exit
	}
	sub("^http://[^/]*/?", "/", url)
	sub("[#?].*", "", url)
	gsub("[^/]*/\\.\\.(/|$)", "/", url)
	file = "/usr/umbraticus/www/jimmy"url
	if(system("test -r "file)){
		status = "404 Not Found"
		body = "<!doctype html><title>404 Not Found</title><h1>404 Not Found</h1>"
		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 = "<!doctype html><link href=data:image/gif;base64,R0lGODlhEAAQAPEAAP///wAAABEREf8AACH+IENvbnZlcnRlZCBieSBQbGFuIDkgZnJvbSA8c3RkaW4+ACH5BAQKAP8ALAAAAAAQABAAAAIuhI8YyRDf2BNyhTHcWwd7vEHGBXyk9H0NmXJMCkZlKj/qKl5uIo5RKDv0gkRGAQA7 rel=icon><title>"url"</title><style>ul{list-style-image: url(data:image/gif;base64,R0lGODlhEAAQAPEAAP///wAAABEREf8AACH+IENvbnZlcnRlZCBieSBQbGFuIDkgZnJvbSA8c3RkaW4+ACH5BAQKAP8ALAAAAAAQABAAAAIuhI8YyRDf2BNyhTHcWwd7vEHGBXyk9H0NmXJMCkZlKj/qKl5uIo5RKDv0gkRGAQA7);}</style><ul>"
	while("walk -n1,1 -d -enm "file" | sort" | getline){
		"date -i "$2 | getline date
		body = body"<li>"date" <a href="url $1"/>"$1"/</a>"
	}
	while("walk -n1,1 -f -enms "file" | sort" | getline){
		"date -i "$2 | getline date
		body = body"<li>"date" <a href="url $1">"$1"</a> "$3
	}
	body = body"</ul>"
	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)
		}
	}
}