include('luascripts')
fid = {27278}
local post_check, post_check_list, post_check_stats = api.post_info({forumid=fid})
post_total = tonumber(post_check_stats['total'])
per = 10
page_max = math.floor(post_total / per)
if post_total % per ~= 0 then
page_max = page_max + 1
end
p = tonumber(req.get.page) or 1
if p < 1 then
p = 1
end
if p > page_max then
p = page_max
end
st = p * per - per
function slice(tbl, first, last, step)
local sliced = {}
for i = first or 1, last or #tbl, step or 1 do
sliced[#sliced + 1] = tbl[i]
end
return sliced
end
local post_check1, post_list, post_stats = api.post_info({limit=post_total,forumid=fid,order="new"})
--table.insert(post_list,1,post_list[0])
if post_total > 0 then
for loopindex, article in ipairs(slice(post_list,st,st+per-1)) do
user = article['UserInfo']
local html = [[ ]]
print(html)
end
print(paging('category/27278?page=',p,page_max))
else
print([[
]])
end
print("")