diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-09-15 01:41:38 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-09-15 01:41:38 +0800 |
commit | c2c6dc08697a405d769e26c561ee1275b70862fa (patch) | |
tree | bbd563760662f859c7ea1952e10e411edb66da95 | |
parent | 716c986c2b967e0268eb0397b7c1805926b991c0 (diff) | |
download | pttbbs-c2c6dc08697a405d769e26c561ee1275b70862fa.tar pttbbs-c2c6dc08697a405d769e26c561ee1275b70862fa.tar.gz pttbbs-c2c6dc08697a405d769e26c561ee1275b70862fa.tar.bz2 pttbbs-c2c6dc08697a405d769e26c561ee1275b70862fa.tar.lz pttbbs-c2c6dc08697a405d769e26c561ee1275b70862fa.tar.xz pttbbs-c2c6dc08697a405d769e26c561ee1275b70862fa.tar.zst pttbbs-c2c6dc08697a405d769e26c561ee1275b70862fa.zip |
new recommendation style: (#undef GUESTRECOMMEND)
record date/time.
IP is omitted because article owner may modify it.
If guest is allowed to recommend, then use old
style recommendation log to keep IP info.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3167 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | include/common.h | 2 | ||||
-rw-r--r-- | mbbsd/bbs.c | 69 | ||||
-rw-r--r-- | sample/pttbbs.conf | 3 |
3 files changed, 53 insertions, 21 deletions
diff --git a/include/common.h b/include/common.h index cc5e6980..e9c5fdec 100644 --- a/include/common.h +++ b/include/common.h @@ -133,6 +133,8 @@ #define YEA 1 /* Booleans (Yep, for true and false) */ #define NA 0 +#define STREQU 0 /* for strcmp */ + /* 好友關係 */ #define IRH 1 /* I reject him. */ #define HRM 2 /* He reject me. */ diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index dad56f0a..bda267b1 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -2014,7 +2014,7 @@ static int recommend(int ent, fileheader_t * fhdr, const char *direct) { struct tm *ptime = localtime4(&now); - char buf[200], msg[53]; + char buf[PATHLEN], msg[STRLEN]; #ifndef OLDRECOMMEND static const char *ctype[3] = { "推", "噓", "→" @@ -2045,7 +2045,12 @@ recommend(int ent, fileheader_t * fhdr, const char *direct) vmsg("抱歉, 禁止推薦或競標"); return FULLUPDATE; } - if (!CheckPostPerm() || bp->brdattr & BRD_VOTEBOARD || fhdr->filemode & FILE_VOTE) { + if ( !CheckPostPerm() || + bp->brdattr & BRD_VOTEBOARD || +#ifndef GUESTRECOMMEND + strcmp(cuser.userid, STR_GUEST) == STREQU || +#endif + fhdr->filemode & FILE_VOTE) { vmsg("您權限不足, 無法推薦!"); return FULLUPDATE; } @@ -2118,12 +2123,20 @@ recommend(int ent, fileheader_t * fhdr, const char *direct) if(type > 2 || type < 0) type = 0; + maxlength = 78 - 3 /* lead */ - 6 /* date */ - 1 /* space */ - +#ifdef GUESTRECOMMEND + 15; /* IP */ +#else + 6; /* time */ +#endif + #ifdef OLDRECOMMEND - maxlength = 51 - strlen(cuser.userid); + maxlength -= 2; /* '推' */ + maxlength -= strlen(cuser.userid); sprintf(buf, "%s %s:", "→" , cuser.userid); -#else - maxlength = 53 - strlen(cuser.userid); +#else + maxlength -= strlen(cuser.userid); sprintf(buf, "%s %s:", ctype[type], cuser.userid); #endif @@ -2135,35 +2148,49 @@ recommend(int ent, fileheader_t * fhdr, const char *direct) if(getans("確定要%s嗎? 請仔細考慮[y/N]: ", ctype[type]) != 'y') return FULLUPDATE; #else + { char ans[3]; sprintf(buf+strlen(buf), ANSI_COLOR(7) "%-*s" - ANSI_RESET " 確定嗎?[y/N]: ", maxlength, msg); + ANSI_RESET " 確定[y/N]:", maxlength, msg); if(!getdata(b_lines, 0, buf, ans, sizeof(ans), LCECHO) || ans[0] != 'y') return FULLUPDATE; } #endif + STATINC(STAT_RECOMMEND); + { + /* build tail first. */ + char tail[STRLEN]; + +#ifdef GUESTRECOMMEND + snprintf(tail, sizeof(tail), + "%15s %02d/%02d", + fromhost, ptime->tm_mon+1, ptime->tm_mday); +#else + snprintf(tail, sizeof(tail), + " %02d/%02d %02d:%02d", + ptime->tm_mon+1, ptime->tm_mday, + ptime->tm_hour, ptime->tm_min); +#endif + #ifdef OLDRECOMMEND - snprintf(buf, sizeof(buf), - ANSI_COLOR(1;31) "→ " ANSI_COLOR(33) "%s" - ANSI_RESET ANSI_COLOR(33) ":%-*s" ANSI_RESET - "推%15s %02d/%02d\n", - cuser.userid, maxlength, msg, - fromhost, ptime->tm_mon + 1, ptime->tm_mday); + snprintf(buf, sizeof(buf), + ANSI_COLOR(1;31) "→ " ANSI_COLOR(33) "%s" + ANSI_RESET ANSI_COLOR(33) ":%-*s" ANSI_RESET + "推%s\n", + cuser.userid, maxlength, msg, tail); #else - snprintf(buf, sizeof(buf), - "%s%s " ANSI_COLOR(33) "%s" ANSI_RESET ANSI_COLOR(33) - ":%-*s" ANSI_RESET "%15s %02d/%02d\n", - ctype_attr2[type], ctype[type], - cuser.userid, - maxlength, - msg, - fromhost, - ptime->tm_mon + 1, ptime->tm_mday); + snprintf(buf, sizeof(buf), + "%s%s " ANSI_COLOR(33) "%s" ANSI_RESET ANSI_COLOR(33) + ":%-*s" ANSI_RESET "%s\n", + ctype_attr2[type], ctype[type], cuser.userid, + maxlength, msg, tail); #endif + } + do_add_recommend(direct, fhdr, ent, buf, type); #ifdef ASSESS diff --git a/sample/pttbbs.conf b/sample/pttbbs.conf index d1a16a96..3f85bb7e 100644 --- a/sample/pttbbs.conf +++ b/sample/pttbbs.conf @@ -193,6 +193,9 @@ /* 若定義, 則使用舊式推文 */ #define OLDRECOMMEND +/* 若定義, 則 guest 可推文,格式變為 IP+日期 */ +#define GUESTRECOMMEND + /* 定義幾秒內算快速推文 */ #define FASTRECMD_LIMIT (90) |