02.11.2017, 14:12
If someone is interested in then there's working code:
Store the code in your library
Call it in your init script
Call user/sessions.lp in a frame in your visu.
Store the code in your library
Call it in your init script
Call user/sessions.lp in a frame in your visu.
Code:
function ecl_init_sessions()
ls_app=[[<?
local lt_sessions
local ls_out
require('apps')
lt_sessions=db:getall('SELECT login, ip, created FROM user_logs group by login, ip order by Created desc')
ls_out="<html>"
ls_out=ls_out.."<style>\n"
ls_out=ls_out.."table {\n"
ls_out=ls_out.." font-family: arial, sans-serif;\n"
ls_out=ls_out.." border-collapse: collapse;\n"
ls_out=ls_out.." width: 100%;\n"
ls_out=ls_out.."}\n"
ls_out=ls_out.."td, th {\n"
ls_out=ls_out.." border: 1px solid #dddddd;\n"
ls_out=ls_out.." text-align: left;\n"
ls_out=ls_out.." padding: 2px;\n"
ls_out=ls_out.."}\n"
ls_out=ls_out.."tr:nth-child(even) {\n"
ls_out=ls_out.." background-color: #dddddd;\n"
ls_out=ls_out.."}\n"
ls_out=ls_out.."</style>\n"
ls_out=ls_out.."<body><table>"
ls_out=ls_out.."<tr>"
ls_out=ls_out.."<th>Login</th>"
ls_out=ls_out.."<th>IP</th>"
ls_out=ls_out.."<th>Created</th>"
ls_out=ls_out.."</tr>"
for index, value in ipairs(lt_sessions) do
ls_out=ls_out.."<tr>"
ls_out=ls_out.."<td>"..value.login.."</td>"
ls_out=ls_out.."<td>"..value.ip.."</td>"
ls_out=ls_out.."<td>"..os.date("%d.%m.%Y %X",value.created).."</td>"
ls_out=ls_out.."</tr>"
end
ls_out=ls_out.."</table></html></body>"
print(ls_out)
?>]]
io.writefile('/www/user/sessions.lp',ls_app)
end
LM5Lp, firmware: 2018.08.22 and 2021.12.15, FlashSYS v2, ARMv7 Processor rev 5 (v7l), kernel 4.4.151 and 4.4.259