summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-04-09 12:17:35 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-04-09 12:17:35 +0800
commit5f4c0ce8c7d09a05b86097ad923bcbd84cc3d9c3 (patch)
treee19965f3c6c0cf7acaed3949117f3e66ec2a39b1
parent0fcff566e893ab1046e7319fe436ea6b1bb93e05 (diff)
downloadpttbbs-5f4c0ce8c7d09a05b86097ad923bcbd84cc3d9c3.tar
pttbbs-5f4c0ce8c7d09a05b86097ad923bcbd84cc3d9c3.tar.gz
pttbbs-5f4c0ce8c7d09a05b86097ad923bcbd84cc3d9c3.tar.bz2
pttbbs-5f4c0ce8c7d09a05b86097ad923bcbd84cc3d9c3.tar.lz
pttbbs-5f4c0ce8c7d09a05b86097ad923bcbd84cc3d9c3.tar.xz
pttbbs-5f4c0ce8c7d09a05b86097ad923bcbd84cc3d9c3.tar.zst
pttbbs-5f4c0ce8c7d09a05b86097ad923bcbd84cc3d9c3.zip
- bbs: fixed: BM can skip PostRestriction check for x-crosspost.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4106 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--include/config.h8
-rw-r--r--mbbsd/announce.c10
-rw-r--r--mbbsd/bbs.c27
-rw-r--r--mbbsd/cache.c15
-rw-r--r--mbbsd/mail.c18
-rw-r--r--mbbsd/talk.c2
6 files changed, 42 insertions, 38 deletions
diff --git a/include/config.h b/include/config.h
index a8f5a0b2..62fcfcf5 100644
--- a/include/config.h
+++ b/include/config.h
@@ -77,6 +77,14 @@
#define BN_FOREIGN BBSMNAME "Foreign"
#endif
+#ifndef BN_DELETED
+#define BN_DELETED "deleted"
+#endif
+
+#ifndef BN_JUNK
+#define BN_JUNK "junk"
+#endif
+
/* Environment */
#ifndef RELAY_SERVER_IP /* 寄站外信的 mail server */
#define RELAY_SERVER_IP "127.0.0.1"
diff --git a/mbbsd/announce.c b/mbbsd/announce.c
index 65a02ed2..7f92a37a 100644
--- a/mbbsd/announce.c
+++ b/mbbsd/announce.c
@@ -808,7 +808,7 @@ a_delete(menu_t * pm)
if (delete_record(buf, FHSZ, pm->now + 1) == -1)
return;
- setbpath(buf, "deleted");
+ setbpath(buf, BN_DELETED);
stampfile(buf, &backup);
strlcpy(backup.owner, cuser.userid, sizeof(backup.owner));
strlcpy(backup.title,
@@ -818,7 +818,7 @@ a_delete(menu_t * pm)
snprintf(cmd, sizeof(cmd),
"mv -f %s %s", fpath, buf);
system(cmd);
- setbdir(buf, "deleted");
+ setbdir(buf, BN_DELETED);
append_record(buf, &backup, sizeof(backup));
} else if (dashd(fpath)) {
getdata(b_lines - 1, 1, "您確定要刪除整個目錄嗎(Y/N)?[N] ", ans,
@@ -828,7 +828,7 @@ a_delete(menu_t * pm)
if (delete_record(buf, FHSZ, pm->now + 1) == -1)
return;
- setapath(buf, "deleted");
+ setapath(buf, BN_DELETED);
stampdir(buf, &backup);
snprintf(cmd, sizeof(cmd),
@@ -841,9 +841,9 @@ a_delete(menu_t * pm)
pm->header[pm->now - pm->page].title + 2,
sizeof(backup.title) - 3);
- /* merge setapath(buf, "deleted"); setadir(buf, buf); */
+ /* merge setapath(buf, BN_DELETED); setadir(buf, buf); */
snprintf(buf, sizeof(buf), "man/boards/%c/%s/" FN_DIR,
- 'd', "deleted");
+ 'd', BN_DELETED);
append_record(buf, &backup, sizeof(backup));
} else { /* Ptt 損毀的項目 */
getdata(b_lines - 1, 1, "您確定要刪除此損毀的項目嗎(Y/N)?[N] ",
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index 86443d6c..05aa4e21 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -375,9 +375,13 @@ CheckPostPerm(void)
int CheckPostRestriction(int bid)
{
boardheader_t *bp;
- if ((currmode & MODE_BOARD) || HasUserPerm(PERM_SYSOP))
+ if (HasUserPerm(PERM_SYSOP))
return 1;
assert(0<=bid-1 && bid-1<MAX_BOARD);
+
+ // XXX currmode 是目前看板不是 bid...
+ if (is_BM_cache(bid))
+ return 1;
bp = getbcache(bid);
// check first-login
@@ -652,7 +656,7 @@ cancelpost(const fileheader_t *fh, int by_BM, char *newpath)
if(!fh->filename[0]) return;
setbfile(fn1, currboard, fh->filename);
if ((fin = fopen(fn1, "r"))) {
- brd = by_BM ? "deleted" : "junk";
+ brd = by_BM ? BN_DELETED : BN_JUNK;
memcpy(&postfile, fh, sizeof(fileheader_t));
setbpath(newpath, brd);
@@ -1715,7 +1719,7 @@ cp_IsHiddenBoard(boardheader_t *bp)
static int
cross_post(int ent, fileheader_t * fhdr, const char *direct)
{
- char xboard[20], fname[80], xfpath[80], xtitle[80];
+ char xboard[20], fname[PATHLEN], xfpath[PATHLEN], xtitle[80];
char inputbuf[10], genbuf[200], genbuf2[4];
fileheader_t xfile;
FILE *xptr;
@@ -1728,6 +1732,13 @@ cross_post(int ent, fileheader_t * fhdr, const char *direct)
if (bp && (bp->brdattr & BRD_VOTEBOARD) )
return FULLUPDATE;
+ setbfile(fname, currboard, fhdr->filename);
+ if (!dashf(fname))
+ {
+ vmsg("檔案已不存在。");
+ return FULLUPDATE;
+ }
+
#ifdef USE_AUTOCPLOG
// anti-crosspost spammers
//
@@ -1774,16 +1785,16 @@ cross_post(int ent, fileheader_t * fhdr, const char *direct)
xbid = getbnum(xboard);
assert(0<=xbid-1 && xbid-1<MAX_BOARD);
- // check target postperm
- if (!CheckPostRestriction(xbid))
+ if (xbid == currbid)
{
- vmsg("你不夠資深喔! (可在目的看板內按 i 查看限制)");
+ vmsg("同板不需轉錄。");
return FULLUPDATE;
}
- if (xbid == currbid)
+ // check target postperm
+ if (!CheckPostRestriction(xbid))
{
- vmsg("同板不需轉錄。");
+ vmsg("你不夠資深喔! (可在目的看板內按 i 查看限制)");
return FULLUPDATE;
}
diff --git a/mbbsd/cache.c b/mbbsd/cache.c
index 060e5dd7..0ca1d740 100644
--- a/mbbsd/cache.c
+++ b/mbbsd/cache.c
@@ -864,13 +864,16 @@ void buildBMcache(int bid) /* bid starts from 1 */
int is_BM_cache(int bid) /* bid starts from 1 */
{
assert(0<=bid-1 && bid-1<MAX_BOARD);
- --bid;
+ int *pbm = SHM->BMcache[bid-1];
// XXX hard coded MAX_BMs=4
- if( currutmp->uid == SHM->BMcache[bid][0] ||
- currutmp->uid == SHM->BMcache[bid][1] ||
- currutmp->uid == SHM->BMcache[bid][2] ||
- currutmp->uid == SHM->BMcache[bid][3] ){
- cuser.userlevel |= PERM_BM;
+ if( currutmp->uid == pbm[0] ||
+ currutmp->uid == pbm[1] ||
+ currutmp->uid == pbm[2] ||
+ currutmp->uid == pbm[3] )
+ {
+ // auto enable BM permission
+ if (!HasUserPerm(PERM_BM))
+ cuser.userlevel |= PERM_BM;
return 1;
}
return 0;
diff --git a/mbbsd/mail.c b/mbbsd/mail.c
index a5cff5dd..545027ca 100644
--- a/mbbsd/mail.c
+++ b/mbbsd/mail.c
@@ -1422,24 +1422,6 @@ mail_cross_post(int ent, fileheader_t * fhdr, const char *direct)
char genbuf[200];
char genbuf2[4];
-#if 0
- // 除非有人明白為何要先 ChekPostPerm 並修復,
- // 否則先 disable 這段 code - 目前常造成 crash。
- //
- // XXX (will crash sometimes because currborad is not defined yet)
- // 麻煩 in2 來修復這裡: 確認轉錄為何要先 CheckPostPerm
- if (!currboard || currboard[0] == 0)
- {
- enter_board(DEFAULT_BOARD);
- }
- assert(0<=ent-1 && ent-1<MAX_BOARD);
-
- if (!CheckPostPerm()) {
- vmsg("對不起,您目前無法轉錄文章!");
- return FULLUPDATE;
- }
-#endif
-
move(2, 0);
clrtoeol();
if (postrecord.times > 1)
diff --git a/mbbsd/talk.c b/mbbsd/talk.c
index 229a4803..199bd639 100644
--- a/mbbsd/talk.c
+++ b/mbbsd/talk.c
@@ -827,7 +827,7 @@ my_write(pid_t pid, const char *prompt, const char *id, int flag, userinfo_t * p
#endif
))
{
- snprintf(buf, sizeof(buf), "丟給 %s : %s [Y/n]?", destid, msg);
+ snprintf(buf, sizeof(buf), "丟 %s: %s [Y/n]?", destid, msg);
getdata(0, 0, buf, genbuf, 3, LCECHO);
if (genbuf[0] == 'n') {