From 3c7016ef719a310c480daca489d03bdd44ed4fba Mon Sep 17 00:00:00 2001 From: the lemons Date: Mon, 7 Feb 2022 22:59:53 -0600 Subject: start tracking the pages the user has visited --- zzcxz.cgi | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/zzcxz.cgi b/zzcxz.cgi index 088cb8f..48b10f1 100755 --- a/zzcxz.cgi +++ b/zzcxz.cgi @@ -33,7 +33,8 @@ local function html_encode(x) return escaped end -local function parse_qs(str) +local function parse_qs(str,sep) + sep = sep or '&' local function decode(str, path) local str = str if not path then @@ -45,7 +46,7 @@ local function parse_qs(str) end local values = {} - for key,val in str:gmatch(string.format('([^%q=]+)(=*[^%q=]*)', '&', '&')) do + for key,val in str:gmatch(string.format('([^%q=]+)(=*[^%q=]*)', sep, sep)) do local key = decode(key) local keys = {} key = key:gsub('%[([^%]]*)%]', function(v) @@ -91,6 +92,8 @@ local function parse_qs(str) return values end +local cookies = env "HTTP_COOKIE" and parse_qs(env "HTTP_COOKIE","; ") or {} + local function redirect(to) return "", { status = '303 see other', @@ -120,7 +123,7 @@ local base = template [[
$content