This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Active sessions
#7
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.


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
Reply


Messages In This Thread
Active sessions - by Thomas - 19.10.2017, 16:34
RE: Active sessions - by Erwin van der Zwart - 19.10.2017, 18:37
RE: Active sessions - by Thomas - 24.10.2017, 16:06
RE: Active sessions - by Erwin van der Zwart - 24.10.2017, 17:07
RE: Active sessions - by Thomas - 24.10.2017, 17:42
RE: Active sessions - by Erwin van der Zwart - 24.10.2017, 20:50
RE: Active sessions - by Thomas - 02.11.2017, 14:12
RE: Active sessions - by admin - 02.11.2017, 14:29
RE: Active sessions - by Thomas - 02.11.2017, 14:55
RE: Active sessions - by Erwin van der Zwart - 02.11.2017, 19:20
RE: Active sessions - by Thomas - 07.11.2017, 14:56
RE: Active sessions - by admin - 08.11.2017, 12:26
RE: Active sessions - by Thomas - 08.11.2017, 17:59
RE: Active sessions - by admin - 09.11.2017, 11:49
RE: Active sessions - by Thomas - 09.11.2017, 15:08

Forum Jump: