31.01.2022, 08:59
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')