2 if _lib_inc_init ~= nil then return end
7 -- parse STDIN and query_string
8 local _as_stdin_init; -- parsed flag
9 local _as_query_data = {}; -- query data store
10 --local _as_kv_token = "(%w+)=([%w_-%%]+)"
11 local _as_kv_token = "([^&=]+)=([^&=]+)"
12 -- FIXME this MUST work with multi-byte encoded data
14 if _as_stdin_init ~= nil then return _as_query_data end
15 local query_string = os.getenv("QUERY_STRING");
18 if query_string == nil then return _as_query_data end
19 for k, v in string.gfind(query_string, _as_kv_token) do
20 _as_query_data[unescape(k)] = unescape(v);
23 return _as_query_data;
27 local _as_post_data = {}; -- post data store
29 if _as_post_init ~= nil then return _as_post_data end
30 local read = io.read();
33 if read == nil then return _as_post_data end
34 for k, v in string.gfind(read, _as_kv_token) do
35 _as_post_data[unescape(k)] = unescape(v);
41 --[[ all key/value in one
44 return QUERY() .. POST();
48 function show_errmsg()
49 if err_msg ~= nil then print('<div class="err_msg">'..err_msg..'</div>') end
55 require "luasql.mysql";
56 env = assert (luasql.mysql())
57 con = assert (env:connect(CONF_DB.DBN, CONF_DB.USR, CONF_DB.PWD, CONF_DB.SRV), "mysql connect bad")
60 function rows(connection, sql_statement)
61 local cursor = assert(connection:execute(sql_statement))
69 if s == nil then return s end
70 s = string.gsub(s, "+", " ")
71 s = string.gsub(s, "%%(%x%x)", function (h)
72 return string.char(tonumber(h, 16))
78 s = string.gsub(s, "([&=+%c])", function (c)
79 return string.format("%%%02X", string.byte(c))
81 s = string.gsub(s, " ", "+")
88 for k,v in pairs(t) do
89 s = s .. "&" .. escape(k) .. "=" .. escape(v)
91 return string.sub(s, 2) -- remove first `&'
95 -- local _qt = QUERY()
99 -- for _k,_v in pairs(_qt) do _qpt["\"".._k.."\""] = _v end
100 -- for _k,_v in pairs(_qt) do _qpt["\"".._k.."\""] = _v end
102 local _t = myexec("set")
103 string.gsbu(_t, "(.-)=(.-)\n", function(n,v)
105 if(string.sub(n,1,2) == "F_") then _tbl[n] = v end
110 -- private msg store with "XXX_ARCHSS", we need config it when install