作者s890510.bbs@bbs.cs.ntou.edu.tw (有變胖趨勢的皮卡.. 看板: itoc
標題[功能] 重新計算推文數
時間網際時空 (2008/08/16 Sat 05:48:09)
這之程式主要是用來說剛做完redir後,
造成原始推文數字的消失,
這之程式主要是拿來做一個重新計算的功能!
(缺點是要一篇一篇做...XD)
: post.c post_rescore(xo) 在 post_score()之後加上
static int
post_rescore(xo)
XO *xo;
{
int start_quote, counta, countb, pos, cur;
HDR *hdr;
char fpath[64], *reason, buf[ANSILINELEN], *reasona;
FILE *fpr;
if (!HAS_PERM(PERM_SYSOP)) /* 限制儘站長可做此功能 */
return XO_NONE;
reason = "[31m"; //這是取推文的色碼去做處理(可自行作修改)
reasona = "[32m"; //這是取呸文的色碼去做處理(可自行作修改)
counta = 0;
countb = 0;
hdr = (HDR *) xo_pool + (xo->pos - xo->top);
hdr_fpath(fpath, xo->dir, hdr);
if (!(fpr = fopen(fpath, "r")))
return XO_FOOT;
start_quote = 0;
while (fgets(buf, sizeof(buf), fpr))
{
if (!start_quote)
{
if (!strcmp(buf, "--\n"))
start_quote = 1;
}
else
{
if (strstr(buf, reason))
{
counta++;
}
else if (strstr(buf, reasona))
{
countb++;
}
}
}
fclose(fpr);
pos = xo->pos;
if((!(counta == 0) && !(countb == 0)) || (!(counta == 0) && (countb == 0))
|| ((counta == 0) && !(countb == 0)))
{
cur = pos - xo->top;
hdr = (HDR *) xo_pool + cur;
hdr->xmode |= POST_SCORE; /* 原文可能無評分 */
hdr->score = 0;
hdr->score = counta-countb;
currchrono = hdr->chrono;
rec_put(xo->dir, hdr, sizeof(HDR), xo->key == XZ_XPOST ? hdr->xid : pos,
cmpchrono);
move(3 + cur, 7);
outc(post_attr(hdr));
}
return pos + 1 + XO_MOVE;
}
: post.c post_cb[]
#ifdef HAVE_SCORE
'%', post_score,
+ 'K', post_rescore, //重新計算推文數 快速鍵可自設!
#endif
--
╭┼ Origin: 海大資工˙網際時空 bbs.cs.ntou.edu.tw
┼┘ Author: s890510 從 118-165-216-143.dynamic.hinet.net 發表