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.

Export Access Logs
#2
Use this to export to CSV. Then you can upload it to FTP, send via e-mail etc.
Code:
rows = {
  '"date","login","ip","failed"'
}

items = db:getall('SELECT * FROM user_logs ORDER BY id DESC')
for _, item in ipairs(items) do
  date = os.date('%Y.%m.%d %H:%M:%S', item.created)
  failed = toboolean(item.failed)

  rows[ #rows + 1 ] = string.format('%q,%q,%q,%q',
    date,
    item.login or '?',
    item.ip or '?',
    failed and 'yes' or 'no'
  )
end

csv = table.concat(rows, '\n')
Reply


Messages In This Thread
Export Access Logs - by anagno@bluewin.ch - 30.01.2022, 11:02
RE: Export Access Logs - by admin - 31.01.2022, 08:59
RE: Export Access Logs - by anagno@bluewin.ch - 31.01.2022, 17:55

Forum Jump: