]])
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
thumbnail = string.match(article['content'], "%[img%](.-)%[/img%]") or 'https://wapka-img.zuna.id/37cb83d6.png'
colors = {'red', 'blue', 'green', 'orange'}
randomIndex = math.random(1, #colors)
randomColor = colors[randomIndex]
topicClass = "cat_"..randomColor
category = article['ForumInfo']
user = article['UserInfo']
link = "/view?postid="..article['id'].."&title="..slugVN(article['title'])..".html"
local html = [[