summaryrefslogtreecommitdiffhomepage
path: root/libs/nixio/axTLS/www/lua
diff options
context:
space:
mode:
Diffstat (limited to 'libs/nixio/axTLS/www/lua')
-rw-r--r--libs/nixio/axTLS/www/lua/download.lua75
-rw-r--r--libs/nixio/axTLS/www/lua/env.lua26
-rw-r--r--libs/nixio/axTLS/www/lua/overview.lp64
-rw-r--r--libs/nixio/axTLS/www/lua/prepara_sql2.lua31
-rw-r--r--libs/nixio/axTLS/www/lua/test_conc.lua38
-rw-r--r--libs/nixio/axTLS/www/lua/test_cookies.lp13
-rw-r--r--libs/nixio/axTLS/www/lua/test_cookies.lua14
-rw-r--r--libs/nixio/axTLS/www/lua/test_err.lua4
-rw-r--r--libs/nixio/axTLS/www/lua/test_fs.lua23
-rw-r--r--libs/nixio/axTLS/www/lua/test_htk.lua22
-rw-r--r--libs/nixio/axTLS/www/lua/test_lib.lua31
-rw-r--r--libs/nixio/axTLS/www/lua/test_main.html127
-rw-r--r--libs/nixio/axTLS/www/lua/test_main.lp31
-rw-r--r--libs/nixio/axTLS/www/lua/test_main.lua46
-rw-r--r--libs/nixio/axTLS/www/lua/test_session.lua43
-rw-r--r--libs/nixio/axTLS/www/lua/test_sql.lua13
-rw-r--r--libs/nixio/axTLS/www/lua/test_sql2.lua24
-rw-r--r--libs/nixio/axTLS/www/lua/test_variables.lp14
18 files changed, 639 insertions, 0 deletions
diff --git a/libs/nixio/axTLS/www/lua/download.lua b/libs/nixio/axTLS/www/lua/download.lua
new file mode 100644
index 000000000..2ee1a71e9
--- /dev/null
+++ b/libs/nixio/axTLS/www/lua/download.lua
@@ -0,0 +1,75 @@
+#!/usr/local/bin/lua
+
+require"luasocket"
+
+function receive (connection)
+ connection:settimeout(0)
+ local s, status = connection:receive (2^10)
+ if status == "timeout" then
+ coroutine.yield (connection)
+ end
+ return s, status
+end
+
+function download (host, file, outfile)
+ --local f = assert (io.open (outfile, "w"))
+ local c = assert (socket.connect (host, 80))
+ c:send ("GET "..file.." HTTP/1.0\r\n\r\n")
+ while true do
+ local s, status = receive (c)
+ --f:write (s)
+ if status == "closed" then
+ break
+ end
+ end
+ c:close()
+ --f:close()
+end
+
+local threads = {}
+function get (host, file, outfile)
+ print (string.format ("Downloading %s from %s to %s", file, host, outfile))
+ local co = coroutine.create (function ()
+ return download (host, file, outfile)
+ end)
+ table.insert (threads, co)
+end
+
+function dispatcher ()
+ while true do
+ local n = table.getn (threads)
+ if n == 0 then
+ break
+ end
+ local connections = {}
+ for i = 1, n do
+ local status, res = coroutine.resume (threads[i])
+ if not res then
+ table.remove (threads, i)
+ break
+ else
+ table.insert (connections, res)
+ end
+ end
+ if table.getn (connections) == n then
+ socket.select (connections)
+ end
+ end
+end
+
+local url = arg[1]
+if not url then
+ print (string.format ("usage: %s url [times]", arg[0]))
+ os.exit()
+end
+local times = arg[2] or 5
+
+url = string.gsub (url, "^http.?://", "")
+local _, _, host, file = string.find (url, "^([^/]+)(/.*)")
+local _, _, fn = string.find (file, "([^/]+)$")
+
+for i = 1, times do
+ get (host, file, fn..i)
+end
+
+dispatcher ()
diff --git a/libs/nixio/axTLS/www/lua/env.lua b/libs/nixio/axTLS/www/lua/env.lua
new file mode 100644
index 000000000..c4298477b
--- /dev/null
+++ b/libs/nixio/axTLS/www/lua/env.lua
@@ -0,0 +1,26 @@
+-- This file should be executed before any script in this directory
+-- according to the configuration (cgilua/conf.lua).
+
+pcall (cgilua.enablesession)
+
+local put, mkurlpath = cgilua.put, cgilua.mkurlpath
+
+cgilua.addclosefunction (function ()
+ put [[
+<p>
+<small>
+<a href="test_main.html">Main</a>]]
+ for _, test in {
+ { "Get", "test_main.lua", {ab = "cd", ef = "gh"} },
+ { "Cookies", "test_cookies.lua", },
+ { "FileSystem", "test_fs.lua", },
+ { "Libraries", "test_lib.lua", },
+ { "Session", "test_session.lua", },
+ { "Variables", "test_variables.lp", },
+ } do
+ put (string.format (' &middot; <a href="%s">%s</a>',
+ mkurlpath (test[2], test[3]), test[1]))
+ end
+ put [[
+</small>]]
+end)
diff --git a/libs/nixio/axTLS/www/lua/overview.lp b/libs/nixio/axTLS/www/lua/overview.lp
new file mode 100644
index 000000000..4d17002a0
--- /dev/null
+++ b/libs/nixio/axTLS/www/lua/overview.lp
@@ -0,0 +1,64 @@
+<?lua
+-- Tries to load known libraries
+for _, t in ipairs { "lxp", "luasql.postgres", "luasql.mysql", "luasql.oci8", "luasql.sqlite", "luasql.odbc", "socket", "xmlrpc", "soap", "lualdap", "logging", "md5", "zip", "stable", "copas", } do
+ pcall (require, t)
+end
+
+libraries = { "lxp", "luasql", "socket", "xmlrpc", "soap", "lualdap", "logging", "md5", "zip", "stable", "copas", }
+
+local colors = { "#999999", "#CCCCCC", "#FFFFFF", }
+local i = 0
+function color () i = math.mod (i + 1, 3) return colors[i + 1] end
+
+function pack_name (p) return string.gsub (p, "^([^.]+).-", "%1") end
+
+function idx (t, f) return _G[t][f] or _G[t]["_"..f] or "" end
+?>
+<html>
+<head><title>CGILua installation overview</title></head>
+
+<body bgcolor="#FFFFFF">
+<h1>CGILua installation overview</h1>
+
+<table>
+ <tr>
+ <th bgcolor="#999999">Version
+ <th bgcolor="#999999">Copyright
+ <th bgcolor="#999999">Description
+ </tr>
+<?lua
+local support = {
+ { "Lua", "_VERSION" },
+ { "compat-5.1", "_COMPAT51" },
+}
+for _, l in ipairs (support) do bg = color()
+?>
+ <tr>
+ <td bgcolor = "<%= bg %>"><%= tostring(_G[l[2]]) %>
+ <td bgcolor = "<%= bg %>">
+ <td bgcolor = "<%= bg %>">
+ </tr>
+<? end ?>
+ <tr><td colspan="4"></tr>
+<?lua
+local pack = {}
+for i, p in ipairs (libraries) do
+ local s = _G[p]
+ local n = pack_name(p)
+ if type(_G[n]) == "table" and _G[n]._VERSION then
+ pack[n] = true
+ table.insert (pack, n)
+ end
+end
+table.sort (pack)
+for _, p in ipairs (pack) do bg = color() ?>
+ <tr>
+ <td bgcolor = "<%= bg %>"><%= idx(p,"VERSION") %>
+ <td bgcolor = "<%= bg %>"><small><%= idx(p,"COPYRIGHT") %></small>
+ <td bgcolor = "<%= bg %>"><small><%= idx(p,"DESCRIPTION") %></small>
+ </tr>
+<?lua end ?>
+</table>
+
+</body>
+</html>
diff --git a/libs/nixio/axTLS/www/lua/prepara_sql2.lua b/libs/nixio/axTLS/www/lua/prepara_sql2.lua
new file mode 100644
index 000000000..6a37c2fef
--- /dev/null
+++ b/libs/nixio/axTLS/www/lua/prepara_sql2.lua
@@ -0,0 +1,31 @@
+#!/usr/local/bin/lua
+
+MAX_ROWS = arg[1] or 10
+
+require"postgres"
+
+local env = assert (luasql.postgres ())
+local conn = assert (env:connect ("luasql-test", "tomas"))
+
+-- Apaga restos de outros testes.
+conn:execute "drop table t2"
+conn:execute "drop table t1"
+
+-- Criando as tabelas.
+assert (conn:execute [[create table t1 (
+ a int,
+ b int
+)]])
+assert (conn:execute [[create table t2 (
+ c int,
+ d int
+)]])
+
+-- Preenchedo as tabelas.
+for i = 1, MAX_ROWS do
+ local ii = 2*i
+ assert (conn:execute (string.format ([[
+insert into t1 values (%d, %d);
+insert into t2 values (%d, %d);]],
+ ii, i, ii, i)))
+end
diff --git a/libs/nixio/axTLS/www/lua/test_conc.lua b/libs/nixio/axTLS/www/lua/test_conc.lua
new file mode 100644
index 000000000..bbb9be784
--- /dev/null
+++ b/libs/nixio/axTLS/www/lua/test_conc.lua
@@ -0,0 +1,38 @@
+cgilua.htmlheader()
+if ap then
+ local pid, ppid = ap.pid ()
+ if not ppid then
+ ppid = "no parent pid"
+ end
+ cgilua.put ("pid = "..pid.." ("..ppid..")".."\n")
+end
+
+assert(type(stable.get) == "function")
+assert(type(stable.set) == "function")
+
+cgilua.put"stable.pairs = {<br>\n"
+for i, v in stable.pairs () do
+ cgilua.put (i.." = "..tostring(v).."<br>\n")
+end
+cgilua.put"}<br>\n"
+
+local counter = stable.get"counter" or 0
+stable.set ("counter", counter + 1)
+
+local f = stable.get"f"
+if not f then
+ local d = os.date()
+ stable.set ("f", function () return d end)
+else
+ cgilua.put ("f() = "..tostring (f ()))
+end
+
+cgilua.put"<br>\n"
+for i = 1,800 do
+ cgilua.put (i)
+ for ii = 1,1000 do
+ cgilua.put ("<!>")
+ end
+ cgilua.put ("\n")
+end
+cgilua.put ("End")
diff --git a/libs/nixio/axTLS/www/lua/test_cookies.lp b/libs/nixio/axTLS/www/lua/test_cookies.lp
new file mode 100644
index 000000000..932b9c5e9
--- /dev/null
+++ b/libs/nixio/axTLS/www/lua/test_cookies.lp
@@ -0,0 +1,13 @@
+<?lua
+local cookies = require"cgilua.cookies"
+CL_COOKIE = "cgilua_cookie"
+
+local test = cookies.get (CL_COOKIE)
+cookies.sethtml (CL_COOKIE, os.date())
+?>
+
+<h1>Testing Cookies library</h1>
+
+<%= CL_COOKIE%> = <%= tostring(test)%><br>
+Assigning current date to cookie!<br>
+Reload this script to check cookie's value!
diff --git a/libs/nixio/axTLS/www/lua/test_cookies.lua b/libs/nixio/axTLS/www/lua/test_cookies.lua
new file mode 100644
index 000000000..6af935e89
--- /dev/null
+++ b/libs/nixio/axTLS/www/lua/test_cookies.lua
@@ -0,0 +1,14 @@
+local cookies = require"cgilua.cookies"
+CL_COOKIE = "cgilua_cookie"
+
+local test = cookies.get (CL_COOKIE)
+cookies.set (CL_COOKIE, os.date())
+
+cgilua.htmlheader ()
+cgilua.put ([[
+<h1>Testing Cookies library</h1>
+
+]]..CL_COOKIE..' = '..tostring(test)..[[<br>
+Assigning current date to cookie!<br>
+Reload this script to check cookie's value!
+]])
diff --git a/libs/nixio/axTLS/www/lua/test_err.lua b/libs/nixio/axTLS/www/lua/test_err.lua
new file mode 100644
index 000000000..4d6ffc970
--- /dev/null
+++ b/libs/nixio/axTLS/www/lua/test_err.lua
@@ -0,0 +1,4 @@
+cgilua.htmlheader()
+cgilua.put"Oi!"
+--io.write"something\n"
+cgilua.errorlog ("eca", "emerg")
diff --git a/libs/nixio/axTLS/www/lua/test_fs.lua b/libs/nixio/axTLS/www/lua/test_fs.lua
new file mode 100644
index 000000000..566ed8b20
--- /dev/null
+++ b/libs/nixio/axTLS/www/lua/test_fs.lua
@@ -0,0 +1,23 @@
+function link_dir (dir, base)
+ local path = base.."/"..dir
+ local mode = lfs.attributes (path).mode
+ if mode == "directory" then
+ return string.format ('<a href="%s">%s</a>',
+ cgilua.mkurlpath ("test_fs.lua", { dir = path }),
+ dir)
+ else
+ return dir
+ end
+end
+
+cgilua.htmlheader ()
+cgilua.put ("<h1>Testing Filesystem library</h1>\n")
+cgilua.put ("<table>\n")
+cgilua.put ("<tr><td colspan=2>Testing <b>dir</b></td></tr>\n")
+local i = 0
+local dir = cgi.dir or "."
+for file in lfs.dir (dir) do
+ i = i+1
+ cgilua.put ("<tr><td>"..i.."</td><td>"..link_dir(file, dir).."</td></tr>\n")
+end
+cgilua.put ("</table>\n")
diff --git a/libs/nixio/axTLS/www/lua/test_htk.lua b/libs/nixio/axTLS/www/lua/test_htk.lua
new file mode 100644
index 000000000..ac1de6c31
--- /dev/null
+++ b/libs/nixio/axTLS/www/lua/test_htk.lua
@@ -0,0 +1,22 @@
+require"htk"
+
+local a_table = {}
+for i = 1, 20 do
+ local l = {}
+ for j = 1, 20 do
+ table.insert (l, HTK.TD { "cell "..i..","..j })
+ end
+ table.insert (a_table, HTK.TR (l))
+end
+
+cgilua.htmlheader()
+cgilua.put (HTK.HTML {
+ HTK.HEAD { HTK.TITLE { "Titulo da Pagina" } },
+ HTK.BODY {
+ bgcolor = "#FFFFFF",
+ HTK.H1 { "Titulo da Pagina" },
+ HTK.P {},
+ "Uma página qualquer",
+ HTK.TABLE (a_table),
+ }
+})
diff --git a/libs/nixio/axTLS/www/lua/test_lib.lua b/libs/nixio/axTLS/www/lua/test_lib.lua
new file mode 100644
index 000000000..504125372
--- /dev/null
+++ b/libs/nixio/axTLS/www/lua/test_lib.lua
@@ -0,0 +1,31 @@
+local function getfield (t, f)
+ for w in string.gfind(f, "[%w_]+") do
+ if not t then return nil end
+ t = t[w]
+ end
+ return t
+end
+
+function test_lib (libname)
+ local ok, err = pcall (require, libname)
+ if not ok then
+ cgilua.put ("Library <tt><b>"..libname.."</b></tt> not found<br>\n"..
+ err)
+ else
+ cgilua.put ("Library <tt><b>"..libname.."</b></tt><br>\n")
+ local t = getfield (_G, libname)
+ if type(t) ~= "table" then
+ cgilua.put (tostring(t))
+ else
+ for i, v in pairs (t) do
+ cgilua.put ("&nbsp;&nbsp;"..tostring(i).." = "..tostring(v).."<br>\n")
+ end
+ end
+ end
+ cgilua.put ("\n<p>\n")
+end
+
+cgilua.htmlheader ()
+for _, lib in ipairs { "lfs", "socket", "luasql.postgres", "luasql", "lxp", "lxp.lom", "lualdap", "htk", "xmlrpc", "xmlrpc.http" } do
+ test_lib (lib)
+end
diff --git a/libs/nixio/axTLS/www/lua/test_main.html b/libs/nixio/axTLS/www/lua/test_main.html
new file mode 100644
index 000000000..a50dd639c
--- /dev/null
+++ b/libs/nixio/axTLS/www/lua/test_main.html
@@ -0,0 +1,127 @@
+<html>
+<head><title>Test Page</title></head>
+
+<table border>
+ <tr>
+ <th colspan="4"> GET: </td>
+ </tr>
+ <tr>
+ <td>Lua script</td>
+ <td><a href="test_main.lua?field1=ab&field2=cd&field1=ef">module</a></td>
+ </tr>
+ <tr>
+ <td>HTML template</td>
+ <td><a href="test_main.lp?field1=ab&field2=cd&field1=ef">module</a></td>
+ </tr>
+
+ <tr>
+ <th colspan="4"> POST: </td>
+ </tr>
+ <tr>
+ <td colspan="4">
+ <form method="POST" action="">
+ <table>
+ <tr>
+ <td colspan="4">
+ field 1: <input type="text" name="field1"><br>
+ field 2: <input type="text" name="field2"><br>
+ field 3:
+ <input type="checkbox" name="field3" value="op 1">op 1
+ <input type="checkbox" name="field3" value="op 2">op 2
+ <input type="checkbox" name="field3" value="op 3">op 3
+ </td>
+ </tr>
+ <tr>
+ <td>Lua script</td>
+ <td>
+ <a href="javascript:document.forms[0].action='test_main.lua';document.forms[0].submit()">module</a>
+ </td>
+ </tr>
+ <tr>
+ <td>HTML template</td>
+ <td>
+ <a href="javascript:document.forms[0].action='test_main.lp';document.forms[0].submit()">module</a>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </td>
+ </tr>
+
+ <tr>
+ <th colspan="4"> POST (with upload): </td>
+ </tr>
+ <tr>
+ <td colspan="4">
+ <form method="POST" enctype="multipart/form-data" action="">
+ <table>
+ <tr>
+ <td colspan="4">
+ field 1: <input type="text" name="field1"><br>
+ file (binary!): <input type="file" name="file"><br>
+ </td>
+ </tr>
+ <tr>
+ <td>Lua script</td>
+ <td>
+ <a href="javascript:document.forms[1].action='test_main.lua';document.forms[1].submit()">module</a>
+ </td>
+ </tr>
+ <tr>
+ <td>HTML template</td>
+ <td>
+ <a href="javascript:document.forms[1].action='test_main.lp';document.forms[1].submit()">module</a>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </td>
+ </tr>
+ <tr>
+ <th colspan="4"> Cookies: </td>
+ </tr>
+ <tr>
+ <td>Lua script</td>
+ <td><a href="test_cookies.lua">module</a></td>
+ </tr>
+ <tr>
+ <td>HTML template</td>
+ <td><a href="test_cookies.lp">module</a></td>
+ </tr>
+ <tr>
+ <th colspan="4"> Filesystem: </td>
+ </tr>
+ <tr>
+ <td>Lua script</td>
+ <td><a href="test_fs.lua">module</a></td>
+ </tr>
+ <tr>
+ <th colspan="4"> Session: </td>
+ </tr>
+ <tr>
+ <td>Lua script</td>
+ <td><a href="test_session.lua">module</a></td>
+ </tr>
+ <tr>
+ <th colspan="4"> CGI Variables: </td>
+ </tr>
+ <tr>
+ <td>HTML template</td>
+ <td><a href="test_variables.lp">module</a></td>
+ </tr>
+ <tr>
+ <th colspan="4"> Library Overview: </td>
+ </tr>
+ <tr>
+ <td>HTML template</td>
+ <td><a href="overview.lp">module</a></td>
+ </tr>
+ <tr>
+ <th colspan="4"> Concurrency </td>
+ </tr>
+ <tr>
+ <td>Lua script</td>
+ <td><a href="test_conc.lua">module</a></td>
+ </tr>
+</table>
+</html>
diff --git a/libs/nixio/axTLS/www/lua/test_main.lp b/libs/nixio/axTLS/www/lua/test_main.lp
new file mode 100644
index 000000000..917ee1e53
--- /dev/null
+++ b/libs/nixio/axTLS/www/lua/test_main.lp
@@ -0,0 +1,31 @@
+<html>
+<head><title>Embeded Lua Test</title></head>
+
+<body>
+cgi = {
+<?lua
+for i,v in pairs (cgi) do
+ if type(v) == "table" then
+ local vv = "{"
+ for a,b in pairs(v) do
+ vv = string.format ("%s%s = %s<br>\n", vv, a, tostring(b))
+ end
+ v = vv.."}"
+ end
+?>
+<%= i %> = <%= tostring(v) %> <br>
+<%
+end
+%>
+}
+<br>
+Remote address: <%= cgilua.servervariable"REMOTE_ADDR" %>
+<br>
+Is persistent = <%= tostring (SAPI.Info.ispersistent) %>
+<br>
+ap = <?lua= tostring(ap) ?> <br>
+lfcgi = <% = tostring(lfcgi) %> <br>
+<%= (ap and ap.handler()) or "" %> <br>
+
+</body>
+</html>
diff --git a/libs/nixio/axTLS/www/lua/test_main.lua b/libs/nixio/axTLS/www/lua/test_main.lua
new file mode 100644
index 000000000..0e997a2d5
--- /dev/null
+++ b/libs/nixio/axTLS/www/lua/test_main.lua
@@ -0,0 +1,46 @@
+cgilua.htmlheader()
+cgilua.put[[
+<html>
+<head><title>Script Lua Test</title></head>
+
+<body>
+cgi = {
+]]
+
+for i,v in pairs (cgi) do
+ if type(v) == "table" then
+ local vv = "{"
+ for a,b in pairs(v) do
+ vv = string.format ("%s%s = %s<br>\n", vv, a, tostring(b))
+ end
+ v = vv.."}"
+ end
+ cgilua.put (string.format ("%s = %s<br>\n", i, tostring(v)))
+end
+cgilua.put "}<br>\n"
+cgilua.put ("Remote address: "..cgilua.servervariable"REMOTE_ADDR")
+cgilua.put "<br>\n"
+cgilua.put ("Is persistent = "..tostring (SAPI.Info.ispersistent).."<br>\n")
+cgilua.put ("ap="..tostring(ap).."<br>\n")
+cgilua.put ("lfcgi="..tostring(lfcgi).."<br>\n")
+
+-- Checking Virtual Environment
+local my_output = cgilua.put
+cgilua.put = nil
+local status, err = pcall (function ()
+ assert (cgilua.put == nil, "cannot change cgilua.put value")
+end)
+cgilua.put = my_output
+assert (status == true, err)
+
+-- Checking require
+local status, err = pcall (function () require"unknown_module" end)
+assert (status == false, "<tt>unknown_module</tt> loaded!")
+-- assert (package == nil, "Access to <tt>package</tt> table allowed!")
+
+cgilua.put[[
+<p>
+</body>
+</html>
+]]
+cgilua = nil
diff --git a/libs/nixio/axTLS/www/lua/test_session.lua b/libs/nixio/axTLS/www/lua/test_session.lua
new file mode 100644
index 000000000..d97cc4520
--- /dev/null
+++ b/libs/nixio/axTLS/www/lua/test_session.lua
@@ -0,0 +1,43 @@
+cgilua.enablesession ()
+
+function pt (tab)
+ for i, v in pairs (tab) do
+ local vv = v
+ if type(v) == "table" then
+ vv = ""
+ for _i, _v in pairs (v) do
+ vv = vv..string.format ("%s = %q, ", _i, _v)
+ end
+ vv = '{'..vv..'}'
+ end
+ cgilua.put (string.format ("%s = %s<br>\n", tostring (i), tostring (vv)))
+ end
+end
+
+
+if cgi.field then
+ if not cgilua.session.data.field then
+ cgilua.session.data.field = {}
+ end
+ table.insert (cgilua.session.data.field, cgi.field)
+end
+cgilua.htmlheader()
+if cgilua.session then
+ cgilua.put "cgi = {<br>\n"
+ pt (cgi)
+ cgilua.put "}<br>\n"
+ cgilua.put "cgilua.session.data = {<br>\n"
+ pt (cgilua.session.data)
+ cgilua.put "}<br>\n"
+
+ cgilua.put [[<form action="]]
+ cgilua.put (cgilua.mkurlpath"test_session.lua")
+ cgilua.put [[" method="POST">
+ field: <input type="text" name="field" value="]]
+ cgilua.put (cgi.field or "")
+ cgilua.put [["><br>
+ <input type="submit"><br>
+</form>]]
+else
+ cgilua.put "Sessions library is not available or not well configured"
+end
diff --git a/libs/nixio/axTLS/www/lua/test_sql.lua b/libs/nixio/axTLS/www/lua/test_sql.lua
new file mode 100644
index 000000000..085ce978c
--- /dev/null
+++ b/libs/nixio/axTLS/www/lua/test_sql.lua
@@ -0,0 +1,13 @@
+local s = require"luasql.postgres"
+
+local env = assert (luasql.postgres ())
+local conn = assert (env:connect ("luasql-test", "tomas"))
+local cur = assert (conn:execute ("select count(*) from fetch_test"))
+
+cgilua.htmlheader()
+cgilua.put ("Total lines at table fetch_test is "..cur:fetch())
+cgilua.put (string.format ("<br>\n%s == %s<br>\n", tostring(s), tostring(luasql)))
+
+cur:close()
+conn:close()
+env:close()
diff --git a/libs/nixio/axTLS/www/lua/test_sql2.lua b/libs/nixio/axTLS/www/lua/test_sql2.lua
new file mode 100644
index 000000000..a2f6ee12d
--- /dev/null
+++ b/libs/nixio/axTLS/www/lua/test_sql2.lua
@@ -0,0 +1,24 @@
+require"postgres"
+
+local env = assert (luasql.postgres ())
+local conn = assert (env:connect ("luasql-test", "tomas"))
+local cur = assert (conn:execute ("select count(*) from t1"))
+local total = tonumber (cur:fetch())
+cur:close()
+local aleatorio = math.random(total)
+local cur = assert (conn:execute ("select * from t1, t2 where b = d and a != "..2*aleatorio))
+
+cgilua.htmlheader()
+cgilua.put ("Aleatorio = "..aleatorio.."<br>\n")
+
+local a,b,c,d = cur:fetch()
+cgilua.put ("<table>\n")
+while a do
+-- cgilua.put ("<tr><td>",a,"<td>",b,"<td>",c,"<td>",d,"</tr>")
+ a,b,c,d = cur:fetch()
+end
+cgilua.put ("</table>\n")
+
+cur:close()
+conn:close()
+env:close()
diff --git a/libs/nixio/axTLS/www/lua/test_variables.lp b/libs/nixio/axTLS/www/lua/test_variables.lp
new file mode 100644
index 000000000..c1ac332f0
--- /dev/null
+++ b/libs/nixio/axTLS/www/lua/test_variables.lp
@@ -0,0 +1,14 @@
+<table>
+<% for _, var in pairs { "SERVER_SOFTWARE", "SERVER_NAME", "GATEWAY_INTERFACE", "SERVER_PROTOCOL", "SERVER_PORT", "REQUEST_METHOD", "PATH_INFO", "PATH_TRANSLATED", "SCRIPT_NAME", "QUERY_STRING", "REMOTE_HOST", "REMOTE_ADDR", "AUTH_TYPE", "REMOTE_USER", "REMOTE_IDENT", "CONTENT_TYPE", "CONTENT_LENGTH", "HTTP_REFERER", "HTTP_COOKIE", "SCRIPT_FILENAME", "DOCUMENT_ROOT", } do %>
+ <tr><td><%= var %><td>=<td>"<%= cgilua.servervariable(var) or "<i>not defined</i>"%>"</tr>
+<% end %>
+</table>
+
+<p>
+<table>
+<% for _, var in ipairs { "script_file", "script_path", "script_pdir", "script_vdir", "script_vpath", "urlpath", } do %>
+ <tr><td><%= var %><td>=<td>"<%= cgilua[var] %>"</tr>
+<% end %>
+</table>
+
+<p>