-
Notifications
You must be signed in to change notification settings - Fork 0
/
usrlist.lua
86 lines (78 loc) · 1.83 KB
/
usrlist.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
local lfs = require("lfs")
local rs = {}
local count = {}
local name = {}
local function load_name()
local t = {}
local func = loadfile("brg/db/dalian-user-list.db","bt",t)
if func then func() end
name = t.db
end
local function count_usr(k,v)
for k1,v1 in pairs(v) do
count[k] = (count[k] or 0 ) + 1
end
end
local function process_usr(db,str,day)
str = str .. "_no"
if db[str] then
local no = db[str]
rs[no] = rs[no] or {}
rs[no][day] = true
end
end
local function farse_usr(f,day)
local t = {}
local func = loadfile(f,"bt",t)
if func then
func()
local db = t.db or {}
process_usr(db,"N",day)
process_usr(db,"E",day)
process_usr(db,"S",day)
process_usr(db,"W",day)
else
return
end
end
local function ls(path)
for file in lfs.dir(path) do
if file ~="." and file ~= ".." then
local day,round,desk = string.match(file,"^(dl[^-]*)-(%d+)-(%d+)%.db$")
if day and round and desk then
local f = path .. "/" .. file
farse_usr(f,day)
end
end
end
end
ls("brg/db")
load_name()
for k,v in pairs(rs) do
count_usr(k,v)
end
local f = io.open("brg/usr.html","w")
f:write("<head>\n")
--f:write([[ <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" >]])
f:write([[ <meta name="viewport" content="width=device-width,initial-scale=1">]])
f:write("<meta charset=utf-8>\n")
f:write("<title>活动记录</title>\n")
f:write("</head>\n")
f:write("<html>\n")
f:write("<body>\n")
f:write([[<table width="100%" border="2">]])
for k,v in pairs(count) do
f:write("<tr><td>" .. name[k] .. "</td><td>" .. v .. "</td></tr>\n")
end
f:write("</table>")
for k,v in pairs(count) do
f:write("<p>usr@" .. name[k] .. " days=" .. v .. "</p>\n")
f:write("<ul>\n")
for k1,v1 in pairs(rs[k]) do
f:write("<li>" .. k1 .. "</li>")
end
f:write("</ul>\n")
end
f:write("</body>\n")
f:write("</html>\n")
f:close()