#!/usr/bin/awk -f function makeheaders(contenttype, redirect) { printf("HTTP/1.1 302 Found\n"); printf("Location: %s\n\n", redirect); } BEGIN { pics["1-pcb"] = "http://lh6.googleusercontent.com/-CViKf3fOsNY/UBsAAtWchxI/AAAAAAAAMB0/Tl2GPVGHbHc/s400/20120411_121904.jpg"; pics["2-teardrops"] = "http://lh5.googleusercontent.com/-8kt2AIQ0C2o/T3eZMMNZSKI/AAAAAAAALGc/LLAPeUer-Ow/s400/20120331_192438.jpg"; pics["3-raised"] = "http://lh5.googleusercontent.com/-SZ-SD0y4i2k/T3hLi3ddwCI/AAAAAAAALHQ/M0v1mGePCuU/s400/20120401_162834.jpg"; pics["4-rear"] = "http://lh3.googleusercontent.com/-F5Q2bYa45-E/T4N29xeELUI/AAAAAAAALNk/pvodcKSXVDU/s400/20120410_024919.jpg"; pics["5-patashnik"] = "http://lh3.googleusercontent.com/-6FDI8MoYT04/T4w9eLaW4mI/AAAAAAAALSc/Gf1cVKEDuUQ/s400/IMG_7760-sp.jpg"; arg = ENVIRON["QUERY_STRING"]; if (0 != match(arg, "^[a-z0-9\(\)\-\.]+$")) { split(arg, args, "."); key = args[1]; mod = args[2]; if (mod == "") { mod = "s1600"; } uri = pics[key]; if (mod != "") { mod = "/" mod "/"; sub("\/s400\/", mod, uri); } #printf("key=[%s] mod=%s uri=%s", key, mod, uri); makeheaders("text/html", uri); } }