summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-04-12 11:19:46 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-04-12 11:19:46 +0800
commit7e0a90828b64bd422f54ac2e6eb15eb4f4749e3a (patch)
treeda60d5af4d6a47f10c994f362404b5f45b38b96e
parentb1608f31a0d106c73f7538c6e4e0c8f9038a0cbf (diff)
downloadpttbbs-7e0a90828b64bd422f54ac2e6eb15eb4f4749e3a.tar
pttbbs-7e0a90828b64bd422f54ac2e6eb15eb4f4749e3a.tar.gz
pttbbs-7e0a90828b64bd422f54ac2e6eb15eb4f4749e3a.tar.bz2
pttbbs-7e0a90828b64bd422f54ac2e6eb15eb4f4749e3a.tar.lz
pttbbs-7e0a90828b64bd422f54ac2e6eb15eb4f4749e3a.tar.xz
pttbbs-7e0a90828b64bd422f54ac2e6eb15eb4f4749e3a.tar.zst
pttbbs-7e0a90828b64bd422f54ac2e6eb15eb4f4749e3a.zip
safe article delete limited to only hot boards (nuser>20)
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1741 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/bbs.c16
-rw-r--r--mbbsd/record.c54
2 files changed, 8 insertions, 62 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index 78d517ca..74500813 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -321,10 +321,10 @@ do_select(int ent, fileheader_t * fhdr, char *direct)
completeboard_permission,
completeboard_getname);
if (bname[0] == '\0' || !(i = getbnum(bname)))
- return FULLUPDATE;
+ return PART_REDRAW;
bh = getbcache(i);
if (!HasPerm(bh))
- return FULLUPDATE;
+ return PART_REDRAW;
strlcpy(bname, bh->brdname, sizeof(bname));
brc_update();
currbid = i;
@@ -334,7 +334,7 @@ do_select(int ent, fileheader_t * fhdr, char *direct)
move(2, 0);
clrtoeol();
outs(err_bid);
- return FULLUPDATE;
+ return PART_REDRAW;
}
setutmpbid(currbid);
@@ -1765,10 +1765,11 @@ del_range(int ent, fileheader_t *fhdr, char *direct)
{
char num1[8], num2[8];
int inum1, inum2;
+ boardheader_t *bp = NULL;
/* 有三種情況會進這裡, 信件, 看板, 精華區 */
if( !(direct[0] == 'h') ){ /* 信件不用 check */
- boardheader_t *bp = getbcache(currbid);
+ bp = getbcache(currbid);
if (strcmp(bp->brdname, "Security") == 0)
return DONOTHING;
}
@@ -1828,7 +1829,7 @@ del_range(int ent, fileheader_t *fhdr, char *direct)
}
}
#ifdef SAFE_ARTICLE_DELETE
- if( direct[0] == 'b' )
+ if(bp && bp->nuser > 20 )
safe_article_delete_range(direct, inum1, inum2);
else
delete_range(direct, inum1, inum2);
@@ -1872,10 +1873,9 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
strlcpy(currfile, fhdr->filename, sizeof(currfile));
if(
#ifdef SAFE_ARTICLE_DELETE
- !safe_article_delete(ent, fhdr, direct)
-#else
- !delete_record(direct, sizeof(fileheader_t), ent)
+ (bp->nuser>20 && !safe_article_delete(ent, fhdr, direct)) ||
#endif
+ !delete_record(direct, sizeof(fileheader_t), ent)
) {
int num;
if (currmode & MODE_SELECT) {
diff --git a/mbbsd/record.c b/mbbsd/record.c
index 21f1b99d..994c8b09 100644
--- a/mbbsd/record.c
+++ b/mbbsd/record.c
@@ -210,59 +210,6 @@ int delete_record(char fpath[], int size, int id)
return delete_records(fpath, size, id, 1);
}
-#if 0
-int
-delete_record(char fpath[], int size, int id)
-{
- nol_t my;
- char abuf[BUFSIZE];
- int fdr, fdw, fd;
- int count;
-
- nolfilename(&my, fpath);
- if ((fd = open(my.lockfn, O_RDWR | O_CREAT | O_APPEND, 0644)) == -1)
- return -1;
-
- flock(fd, LOCK_EX);
-
- if ((fdr = open(fpath, O_RDONLY, 0)) == -1) {
- move(10, 10);
- outs("delete_record failed!!! (open)");
- pressanykey();
- flock(fd, LOCK_UN);
- close(fd);
- return -1;
- }
- if (
- ((fdw = open(my.newfn, O_WRONLY | O_CREAT | O_EXCL, 0644)) == -1) &&
- ((fdw = force_open(my.newfn)) == -1)) {
- flock(fd, LOCK_UN);
- close(fd);
- close(fdr);
- return -1;
- }
- count = 1;
- while (read(fdr, abuf, size) == size) {
- if (id != count++ && (safewrite(fdw, abuf, size) == -1)) {
- unlink(my.newfn);
- close(fdr);
- close(fdw);
- flock(fd, LOCK_UN);
- close(fd);
- return -1;
- }
- }
- close(fdr);
- close(fdw);
- if (Rename(fpath, my.oldfn) == -1 || Rename(my.newfn, fpath) == -1) {
- flock(fd, LOCK_UN);
- close(fd);
- return -1;
- }
- flock(fd, LOCK_UN);
- close(fd);
- return 0;
-}
static char *
title_body(char *title)
@@ -449,7 +396,6 @@ safe_article_delete_range(char *direct, int from, int to)
return 0;
}
-#endif
#endif /* !defined(_BBS_UTIL_C_) */