Programming and Scripting :: lighttpd lua query string access



anyone familiar with lighttpd using lua scripts ?

i'm trying to call a lua script by supplying a query string in a link ;

e.g
<a href="goto_date.lua?31-3-2008">1</a>

but don't know how to get to the query string argument(s)

arg[0] only holds the program path
arg[1] is nil

how do i get the date ?  ???

Not sure I understand if this is based on user input or parsing some date variable. Try this yet?
http://www.lua.org/pil/22.1.html

It's an environment variable

Try os.getenv("QUERY_STRING")

Here's an example I have in one of my in-progress cgi scripts
Code Sample
-- break up query string
params=" "..string.gsub(os.getenv("QUERY_STRING"),"&"," ").." "

function get_param(var)
local p=string.gsub(params,".*"..var.."=(.-)%s.*","%1")
-- strip any naughty leading path
p=string.gsub(p,".*/","")
return(p)
end

var_a=get_param("one")
var_b=get_param("two")


This particular function breaks up a string that uses the format
myscript.cgi?one=something&two=somethingelse
The lua script would end up setting var_a="something" and var_b="somethingelse"

tks mikshaw, that's just what i was looking for.
mikshaw wrote:
Quote
Here's an example I have in one of my in-progress cgi scripts


Just curious, did the existing cgi.lua not work for you?

We have had cgi.lua together with sample lua scripts for monkey webserver since before murgaLua.

Next Page...
original here.