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.

User Access Log on Vis
#1
Hi, is there a way to display the user access logs in a frame on a vis page.
Only want to show user accounts and exclude ADMIN logins
Reply
#2
Via .lp file:
Code:
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <link rel="stylesheet" href="/apps/css/bootstrap.css">
</head>
<body>
<table class="table table-striped">
<tr>
  <th>Date/time</th>
  <th>Login</th>
  <th>Name</th>
  <th>IP</th>
</tr>
<?
require('apps')

items = db:getall([[
  SELECT user_logs.*, users.name
  FROM user_logs
  JOIN users ON user_logs.login=users.login
  ORDER BY user_logs.id DESC
  LIMIT 50
]])

for _, item in ipairs(items) do
  cls = toboolean(item.failed) and 'danger' or 'success'
  datetime = os.date('%Y.%m.%d %H:%M:%S', item.created)
?>
<tr class="<?=cls?>">
  <td><?=datetime?></td>
  <td><?=escape(item.login)?></td>
  <td><?=escape(item.name)?></td>
  <td><?=escape(item.ip)?></td>
</tr>
<? end ?>
</table>
</body>
</html>
Reply
#3
(06.05.2022, 08:26)admin Wrote: Via .lp file:
Code:
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <link rel="stylesheet" href="/apps/css/bootstrap.css">
</head>
<body>
<table class="table table-striped">
<tr>
  <th>Date/time</th>
  <th>Login</th>
  <th>Name</th>
  <th>IP</th>
</tr>
<?
require('apps')

items = db:getall([[
  SELECT user_logs.*, users.name
  FROM user_logs
  JOIN users ON user_logs.login=users.login
  ORDER BY user_logs.id DESC
  LIMIT 50
]])

for _, item in ipairs(items) do
  cls = toboolean(item.failed) and 'danger' or 'success'
  datetime = os.date('%Y.%m.%d %H:%M:%S', item.created)
?>
<tr class="<?=cls?>">
  <td><?=datetime?></td>
  <td><?=escape(item.login)?></td>
  <td><?=escape(item.name)?></td>
  <td><?=escape(item.ip)?></td>
</tr>
<? end ?>
</table>
</body>
</html>
 Many thanks for your help
Reply
#4
Hello
how does the full code looks like?
BR,
Best Regards,
Reply
#5
It is the full code (:
Reply
#6
(07.05.2022, 18:22)Erwin van der Zwart Wrote: It is the full code (:

Aha 
Seems I miss how to use it Smile
should I have something like this at the beginning or its done in another way

dst = '/www/user/accesslog.lp'

io.writefile(dst, [[..... accesss log code....

]])
Best Regards,
Reply
#7
Well this code is enabling you to automatically write it to a file on the FTP server, but you could have also just manually upload the code as a .lp file to the FTP server...
Reply


Forum Jump: