Logic Machine Forum
User Access Log on Vis - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: User Access Log on Vis (/showthread.php?tid=4028)



User Access Log on Vis - sjfp - 03.05.2022

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


RE: User Access Log on Vis - admin - 06.05.2022

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>



RE: User Access Log on Vis - sjfp - 06.05.2022

(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


RE: User Access Log on Vis - khalil - 07.05.2022

Hello
how does the full code looks like?
BR,


RE: User Access Log on Vis - Erwin van der Zwart - 07.05.2022

It is the full code (:


RE: User Access Log on Vis - khalil - 08.05.2022

(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....

]])


RE: User Access Log on Vis - Erwin van der Zwart - 09.05.2022

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...