summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/pttstruct.h1
-rw-r--r--mbbsd/announce.c16
-rw-r--r--mbbsd/bbs.c20
-rw-r--r--mbbsd/var.c2
-rw-r--r--sample/pttbbs.conf3
5 files changed, 38 insertions, 4 deletions
diff --git a/include/pttstruct.h b/include/pttstruct.h
index 4ba8f16b..43d66582 100644
--- a/include/pttstruct.h
+++ b/include/pttstruct.h
@@ -218,6 +218,7 @@ typedef struct boardheader_t {
#define BRD_GUESTPOST 002000000 /* guest能 post */
#define BRD_COOLDOWN 004000000 /* 冷靜 */
#define BRD_CPLOG 010000000 /* 自動留轉錄記錄 */
+#define BRD_NOFASTRECMD 020000000 /* 禁止快速推文 */
#define BRD_LINK_TARGET(x) ((x)->postexpire)
#define GROUPOP() (currmode & MODE_GROUPOP)
diff --git a/mbbsd/announce.c b/mbbsd/announce.c
index 6d52212f..f8332c02 100644
--- a/mbbsd/announce.c
+++ b/mbbsd/announce.c
@@ -2,12 +2,18 @@
#include "bbs.h"
/* copy temp queue operation -------------------------------------- */
+
+/* TODO
+ * change this to char* instead of char[]
+ */
typedef struct {
char copyfile[PATHLEN];
char copytitle[TTLEN + 1];
char copyowner[IDLEN + 2];
} CopyQueue ;
+#define COPYQUEUE_COMMON_SIZE (10)
+
static CopyQueue *copyqueue;
static int allocated_copyqueue = 0, used_copyqueue = 0, head_copyqueue = 0;
@@ -34,13 +40,21 @@ int copyqueue_append(CopyQueue *pcq)
if(head_copyqueue == used_copyqueue)
{
// empty queue, happy happy reset
+ if(allocated_copyqueue > COPYQUEUE_COMMON_SIZE)
+ {
+ // let's reduce it
+ allocated_copyqueue = COPYQUEUE_COMMON_SIZE;
+ copyqueue = (CopyQueue*)realloc( copyqueue,
+ allocated_copyqueue * sizeof(CopyQueue));
+ }
head_copyqueue = used_copyqueue = 0;
}
used_copyqueue ++;
if(used_copyqueue > allocated_copyqueue)
{
- allocated_copyqueue = used_copyqueue + 10; // half page
+ allocated_copyqueue =
+ used_copyqueue + COPYQUEUE_COMMON_SIZE; // half page
copyqueue = (CopyQueue*) realloc (copyqueue,
sizeof(CopyQueue) * allocated_copyqueue);
if(!copyqueue)
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index 52c71923..3c12308f 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -1858,6 +1858,13 @@ recommend(int ent, fileheader_t * fhdr, const char *direct)
vmsg("您權限不足, 無法推薦!");
return FULLUPDATE;
}
+ if ( (bp->brdattr & BRD_NOFASTRECMD) &&
+ (now - lastrecommend < FASTRECMD_LIMIT))
+ {
+ vmsg("本板禁止快速連續推文,請再等 %d 秒",
+ (FASTRECMD_LIMIT - now+lastrecommend));
+ return FULLUPDATE;
+ }
#ifdef SAFE_ARTICLE_DELETE
if (fhdr->filename[0] == '.') {
vmsg("本文已刪除");
@@ -2560,7 +2567,7 @@ b_changerecommend(int ent, const fileheader_t * fhdr, const char *direct)
bp = getbcache(currbid);
while(!finished) {
- move(b_lines - 6, 0); clrtobot();
+ move(b_lines - 7, 0); clrtobot();
outs(MSG_SEPERATOR);
outs("\n目前看板設定:\n");
prints( " " ANSI_COLOR(1;36) "h" ANSI_RESET
@@ -2579,6 +2586,11 @@ b_changerecommend(int ent, const fileheader_t * fhdr, const char *direct)
#else
optCmds[0] = "";
#endif
+ prints( " " ANSI_COLOR(1;36) "f" ANSI_RESET
+ " - %s " ANSI_RESET "快速連推文章\n",
+ ((bp->brdattr & BRD_NORECOMMEND) ||
+ (bp->brdattr & BRD_NOFASTRECMD)) ?
+ ANSI_COLOR(1)"不可":"可以");
#ifdef USE_AUTOCPLOG
prints( " " ANSI_COLOR(1;36) "x" ANSI_RESET
" - 轉錄文章時 %s " ANSI_RESET "自動記錄\n",
@@ -2594,7 +2606,7 @@ b_changerecommend(int ent, const fileheader_t * fhdr, const char *direct)
return FULLUPDATE;
}
- switch(tolower(getans("請按 h/r%s%s 改變設定,其它鍵結束: ",
+ switch(tolower(getans("請按 h/r%s/f%s 改變設定,其它鍵結束: ",
optCmds[0], optCmds[1])))
{
#ifdef USE_AUTOCPLOG
@@ -2618,6 +2630,10 @@ b_changerecommend(int ent, const fileheader_t * fhdr, const char *direct)
bp->brdattr ^= BRD_NORECOMMEND;
touched = 1;
break;
+ case 'f':
+ bp->brdattr ^= BRD_NOFASTRECMD;
+ touched = 1;
+ break;
#ifndef OLDRECOMMEND
case 'b':
if(bp->brdattr & BRD_NORECOMMEND)
diff --git a/mbbsd/var.c b/mbbsd/var.c
index fb6c707c..9c917204 100644
--- a/mbbsd/var.c
+++ b/mbbsd/var.c
@@ -72,7 +72,7 @@ const char * const str_permboard[] = {
#else
"轉錄記錄(本站無效)", /* BRD_CPLOG */
#endif
- "沒想到",
+ "禁止快速推文", /* BRD_NOFASTRCMD */
"沒想到",
"沒想到",
"沒想到",
diff --git a/sample/pttbbs.conf b/sample/pttbbs.conf
index 27b48713..48183613 100644
--- a/sample/pttbbs.conf
+++ b/sample/pttbbs.conf
@@ -185,6 +185,9 @@
/* 若定義, 則使用舊式推文 */
#define OLDRECOMMEND
+/* 定義幾秒內算快速推文 */
+#define FASTRECMD_LIMIT (90)
+
/* 若定義, 可設定轉錄自動在原文留下記錄 */
#define USE_AUTOCPLOG