summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-04-30 04:42:54 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-04-30 04:42:54 +0800
commitf96e3fe469a9cf18c385e27297d987e80f5af0a5 (patch)
treecdf1ebfc936709efd116e3eeb448e487d639877a
parentb46eb1e0f400514ca8fa7a761711040fdbd7dc6a (diff)
downloadpttbbs-f96e3fe469a9cf18c385e27297d987e80f5af0a5.tar
pttbbs-f96e3fe469a9cf18c385e27297d987e80f5af0a5.tar.gz
pttbbs-f96e3fe469a9cf18c385e27297d987e80f5af0a5.tar.bz2
pttbbs-f96e3fe469a9cf18c385e27297d987e80f5af0a5.tar.lz
pttbbs-f96e3fe469a9cf18c385e27297d987e80f5af0a5.tar.xz
pttbbs-f96e3fe469a9cf18c385e27297d987e80f5af0a5.tar.zst
pttbbs-f96e3fe469a9cf18c385e27297d987e80f5af0a5.zip
1.fix some bug for reference tag
2.add static _mode to cost down select_read's time. Note: getindex is a bad!! funcation...must get ride of that some day. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1892 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/bbs.c163
-rw-r--r--mbbsd/mail.c9
-rw-r--r--mbbsd/read.c20
3 files changed, 53 insertions, 139 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index 194bb972..8136fbcd 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -274,24 +274,27 @@ whereami(int ent, fileheader_t * fhdr, char *direct)
}
static int
-substitute_check(fileheader_t * fhdr)
+substitute_ref_record(char *direct, fileheader_t * fhdr, int ent)
{
fileheader_t hdr;
char genbuf[100];
int num = 0;
/* rocker.011018: 串接模式用reference增進效率 */
- if ((currmode & MODE_SELECT) && (fhdr->money & FHR_REFERENCE)) {
- num = fhdr->money & ~FHR_REFERENCE;
- setbdir(genbuf, currboard);
+ if ((fhdr->money & FHR_REFERENCE) &&
+ (num = fhdr->money & ~FHR_REFERENCE)){
+ setbdir(genbuf, currboard);
get_record(genbuf, &hdr, sizeof(hdr), num);
-
- /* 再這裡要check一下原來的dir裡面是不是有被人動過... */
if (strcmp(hdr.filename, fhdr->filename))
- num = getindex(genbuf, fhdr->filename, sizeof(fileheader_t));
-
- substitute_record(genbuf, fhdr, sizeof(*fhdr), num);
+ {
+ if((num = getindex(genbuf, fhdr->filename)))
+ substitute_record(genbuf, fhdr, sizeof(*fhdr), num);
+ fhdr->money = FHR_REFERENCE | num ; // Ptt: update now!
+ }
+ else
+ substitute_record(genbuf, fhdr, sizeof(*fhdr), num);
}
+ substitute_record(direct, fhdr, sizeof(*fhdr), ent);
return num;
}
static int
@@ -807,7 +810,7 @@ do_generalboardreply(fileheader_t * fhdr)
}
int
-getindex(char *fpath, char *fname, int size)
+getindex(char *fpath, char *fname)
{
#define READSIZE 64 // 8192 / sizeof(fileheader_t)
int fd, i, len, now = 1; /* now starts from 1 */
@@ -933,8 +936,7 @@ reply_post(int ent, fileheader_t * fhdr, char *direct)
static int
edit_post(int ent, fileheader_t * fhdr, char *direct)
{
- int num;
- char fpath[80], fpath0[80];
+ char fpath[80];
char genbuf[200];
fileheader_t postfile;
boardheader_t *bp = getbcache(currbid);
@@ -958,50 +960,15 @@ edit_post(int ent, fileheader_t * fhdr, char *direct)
#endif
setutmpmode(REEDIT);
+ setbpath(fpath, currboard);
+ stampfile(fpath, &postfile);
setdirpath(genbuf, direct, fhdr->filename);
local_article = fhdr->filemode & FILE_LOCAL;
+ Copy(genbuf, fpath);
strlcpy(save_title, fhdr->title, sizeof(save_title));
- /* rocker.011018: 這裡是不是該檢查一下修改文章後的money和原有的比較? */
- if (vedit(genbuf, 0, NULL) != -1) {
- substitute_record(direct, fhdr, sizeof(*fhdr), ent);
- setbpath(fpath, currboard);
- stampfile(fpath, &postfile);
- strlcpy(genbuf, fhdr->filename, sizeof(genbuf));
- setbfile(fpath0, currboard, fhdr->filename);
-
- for(num = 2; genbuf[num] != 0; num++){
- if(genbuf[num] == '.'){
- genbuf[num] = 0;
- break;
- }
- }
-
- sprintf(postfile.filename, "%s.A.%3.3X", genbuf, rand() & 0xFFF);
- setdirpath(fpath, fpath, postfile.filename);
- unlink(fpath);
-
- Rename(fpath0, fpath);
-
- /* rocker.011018: fix 串接模式改文章後文章就不見的bug */
- if ((currmode & MODE_SELECT) && (fhdr->money & FHR_REFERENCE)) {
- fileheader_t hdr;
-
- num = fhdr->money & ~FHR_REFERENCE;
- setbdir(fpath0, currboard);
- get_record(fpath0, &hdr, sizeof(hdr), num);
-
- /* 再這裡要check一下原來的dir裡面是不是有被人動過... */
- if (!strcmp(hdr.filename, fhdr->filename)) {
- strlcpy(hdr.filename, postfile.filename, sizeof(hdr.filename));
- strlcpy(hdr.title, save_title, sizeof(hdr.title));
- substitute_record(fpath0, &hdr, sizeof(hdr), num);
- }
- }
- strlcpy(fhdr->filename, postfile.filename, sizeof(fhdr->filename));
- strlcpy(fhdr->title, save_title, sizeof(fhdr->title));
- brc_addlist(postfile.filename);
- substitute_record(direct, fhdr, sizeof(*fhdr), ent);
+ if (vedit(fpath, 0, NULL) != -1) {
+ Rename(fpath, genbuf);
if (!(currbrdattr & BRD_HIDE) && (!bp->level || (currbrdattr & BRD_POSTMASK)))
do_crosspost(ALLPOST, fhdr, fpath);
}
@@ -1352,9 +1319,7 @@ edit_title(int ent, fileheader_t * fhdr, char *direct)
getdata(b_lines - 1, 0, "確定(Y/N)?[n] ", genbuf, 3, DOECHO);
if ((genbuf[0] == 'y' || genbuf[0] == 'Y') && dirty) {
*fhdr = tmpfhdr;
- substitute_record(direct, fhdr, sizeof(*fhdr), ent);
- /* rocker.011018: 這裡應該改成用reference的方式取得原來的檔案 */
- substitute_check(fhdr);
+ substitute_ref_record(direct, fhdr, ent);
}
return FULLUPDATE;
}
@@ -1366,7 +1331,7 @@ solve_post(int ent, fileheader_t * fhdr, char *direct)
{
if (HAS_PERM(PERM_SYSOP)) {
fhdr->filemode ^= FILE_SOLVED;
- substitute_record(direct, fhdr, sizeof(*fhdr), ent);
+ substitute_ref_record(direct, fhdr, ent);
return PART_REDRAW;
}
return DONOTHING;
@@ -1388,8 +1353,7 @@ recommend_cancel(int ent, fileheader_t * fhdr, char *direct)
#endif
fhdr->recommend = 0;
- substitute_record(direct, fhdr, sizeof(*fhdr), ent);
- substitute_check(fhdr);
+ substitute_ref_record(direct, fhdr, ent);
return FULLUPDATE;
}
static int
@@ -1467,6 +1431,7 @@ do_bid(int ent, fileheader_t * fhdr, boardheader_t *bp, char *direct, struct t
break;
}
bidinfo.flag |= SALE_COMMENTED;
+
substitute_record(fpath, &bidinfo, sizeof(bidinfo), 1);
}
}
@@ -1665,9 +1630,8 @@ mark_post(int ent, fileheader_t * fhdr, char *direct)
inc_goodpost(searchuser(fhdr->owner), -1 * (fhdr->recommend / 10));
}
#endif
-
- substitute_record(direct, fhdr, sizeof(*fhdr), ent);
- substitute_check(fhdr);
+
+ substitute_ref_record(direct, fhdr, ent);
return PART_REDRAW;
}
@@ -1708,31 +1672,6 @@ del_range(int ent, fileheader_t *fhdr, char *direct)
if (*num1 == 'y') {
outmsg("處理中,請稍後...");
refresh();
- if (currmode & MODE_SELECT) {
- int fd, size = sizeof(fileheader_t);
- char genbuf[100];
- fileheader_t rsfh;
- int i = inum1, now;
- if (currstat == RMAIL)
- sethomedir(genbuf, cuser.userid);
- else
- setbdir(genbuf, currboard);
- if ((fd = (open(direct, O_RDONLY, 0))) != -1) {
- if (lseek(fd, (off_t) (size * (inum1 - 1)), SEEK_SET) !=
- -1) {
- while (read(fd, &rsfh, size) == size) {
- if (i > inum2)
- break;
- now = getindex(genbuf, rsfh.filename, size);
- strlcpy(currfile, rsfh.filename, sizeof(currfile));
- delete_record(genbuf, sizeof(fileheader_t), now);
- // cmpfilename);
- i++;
- }
- }
- close(fd);
- }
- }
#ifdef SAFE_ARTICLE_DELETE
if(bp && bp->nuser > 20 )
safe_article_delete_range(direct, inum1, inum2);
@@ -1757,7 +1696,7 @@ static int
del_post(int ent, fileheader_t * fhdr, char *direct)
{
char genbuf[100], newpath[256];
- int not_owned;
+ int num, not_owned;
boardheader_t *bp;
bp = getbcache(currbid);
@@ -1774,6 +1713,10 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
!strcmp(cuser.userid, STR_GUEST))
return DONOTHING;
+ if (currmode & MODE_SELECT) {
+ vmsg("請回到一般模式再刪除文章");
+ return DONOTHING;
+ }
getdata(1, 0, msg_del_ny, genbuf, 3, LCECHO);
if (genbuf[0] == 'y') {
strlcpy(currfile, fhdr->filename, sizeof(currfile));
@@ -1783,26 +1726,6 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
#endif
!delete_record(direct, sizeof(fileheader_t), ent)
) {
- int num;
- if (currmode & MODE_SELECT) {
- /* rocker.011018: 利用reference減低loading */
- fileheader_t hdr;
-
- /* fhdr->money is not real money now, it's a reference instead.
- * see select_read() in read.c */
- num = fhdr->money & ~FHR_REFERENCE;
- setbdir(genbuf, currboard);
- get_record(genbuf, &hdr, sizeof(hdr), num);
-
- /* 再這裡要check一下原來的dir裡面是不是有被人動過... */
- if (strcmp(hdr.filename, fhdr->filename)) {
- num = getindex(genbuf, fhdr->filename, sizeof(fileheader_t));
- get_record(genbuf, &hdr, sizeof(hdr), num);
- }
- /* rocker.011018: 這裡要還原被破壞的money */
- fhdr->money = hdr.money;
- delete_record(genbuf, sizeof(fileheader_t), num);
- }
cancelpost(fhdr, not_owned, newpath);
if(fhdr->filemode & FILE_ANONYMOUS)
@@ -2227,8 +2150,7 @@ push_bottom(int ent, fileheader_t * fhdr, char *direct)
"取消置底公告?(y/N)":
"加入置底公告?(y/N)")!='y') return READ_REDRAW;
fhdr->filemode ^= FILE_BOTTOM;
- if(fhdr->filemode & FILE_BOTTOM
- && ent < getbtotal(currbid) )
+ if(fhdr->filemode & FILE_BOTTOM )
{
sprintf(buf, "%s.bottom", direct);
if(num >= 5)
@@ -2236,7 +2158,9 @@ push_bottom(int ent, fileheader_t * fhdr, char *direct)
vmsg("不得超過 5 篇重要公告 請精簡!");
return READ_REDRAW;
}
+ fhdr->money = ent | FHR_REFERENCE;
append_record(buf, fhdr, sizeof(fileheader_t));
+
}
else
{
@@ -2310,26 +2234,7 @@ good_post(int ent, fileheader_t * fhdr, char *direct)
delta = 1000;
}
}
- substitute_record(direct, fhdr, sizeof(*fhdr), ent);
- /* rocker.011018: 串接模式用reference增進效率 */
- if ((currmode & MODE_SELECT) && (fhdr->money & FHR_REFERENCE)) {
- fileheader_t hdr;
- char genbuf[100];
- int num;
-
- num = fhdr->money & ~FHR_REFERENCE;
- setbdir(genbuf, currboard);
- get_record(genbuf, &hdr, sizeof(hdr), num);
-
- /* 再這裡要check一下原來的dir裡面是不是有被人動過... */
- if (strcmp(hdr.filename, fhdr->filename)) {
- num = getindex(genbuf, fhdr->filename, sizeof(fileheader_t));
- get_record(genbuf, &hdr, sizeof(hdr), num);
- }
- fhdr->money = hdr.money + delta;
-
- substitute_record(genbuf, fhdr, sizeof(*fhdr), num);
- }
+ substitute_ref_record(direct, fhdr, ent);
return FULLUPDATE;
}
diff --git a/mbbsd/mail.c b/mbbsd/mail.c
index 053796a9..f4a53dfa 100644
--- a/mbbsd/mail.c
+++ b/mbbsd/mail.c
@@ -832,7 +832,7 @@ mail_del(int ent, fileheader_t * fhdr, char *direct)
if ((currmode & MODE_SELECT)) {
int index;
sethomedir(genbuf, cuser.userid);
- index = getindex(genbuf, fhdr->filename, sizeof(fileheader_t));
+ index = getindex(genbuf, fhdr->filename);
delete_record(genbuf, sizeof(fileheader_t), index);
}
return DIRCHANGED;
@@ -859,8 +859,7 @@ mail_read(int ent, fileheader_t * fhdr, char *direct)
if ((currmode & MODE_SELECT)) {
int index;
- index = getindex(currmaildir, fhdr->filename,
- sizeof(fileheader_t));
+ index = getindex(currmaildir, fhdr->filename);
substitute_record(currmaildir, fhdr, sizeof(*fhdr), index);
substitute_record(direct, fhdr, sizeof(*fhdr), ent);
} else
@@ -904,7 +903,7 @@ mail_read(int ent, fileheader_t * fhdr, char *direct)
if ((currmode & MODE_SELECT)) {
int index;
- index = getindex(currmaildir, fhdr->filename, sizeof(fileheader_t));
+ index = getindex(currmaildir, fhdr->filename);
substitute_record(currmaildir, fhdr, sizeof(*fhdr), index);
substitute_record(direct, fhdr, sizeof(*fhdr), ent);
} else
@@ -1003,7 +1002,7 @@ mail_mark(int ent, fileheader_t * fhdr, char *direct)
if ((currmode & MODE_SELECT)) {
int index;
- index = getindex(currmaildir, fhdr->filename, sizeof(fileheader_t));
+ index = getindex(currmaildir, fhdr->filename);
substitute_record(currmaildir, fhdr, sizeof(*fhdr), index);
substitute_record(direct, fhdr, sizeof(*fhdr), ent);
} else
diff --git a/mbbsd/read.c b/mbbsd/read.c
index a53be8b0..ab5307b5 100644
--- a/mbbsd/read.c
+++ b/mbbsd/read.c
@@ -300,7 +300,6 @@ thread(keeploc_t * locmem, int stypen)
return new_ln;
}
-
#ifdef INTERNET_EMAIL
static void
mail_forward(fileheader_t * fhdr, char *direct, int mode)
@@ -336,6 +335,7 @@ select_read(keeploc_t * locmem, int sr_mode)
char newdirect[MAXPATHLEN];
char keyword[TTLEN + 1] = "";
char genbuf[MAXPATHLEN], *p;
+ static int _mode = 0;
int len, fd, fr, i, count=0, reference = 0;
fileheader_t *fh = &headers[locmem->crs_ln - locmem->top_ln];
@@ -352,12 +352,22 @@ select_read(keeploc_t * locmem, int sr_mode)
currmode & MODE_SELECT ? "增加條件 標題:":"搜尋標題:",
keyword, TTLEN, DOECHO))
return READ_REDRAW;
- log_file("keyword_search_log", 1, "%s:%s", currboard, keyword);
+#ifdef KEYWORD_LOG
+ log_file("keyword_search_log", 1, "%s:%s\n", currboard, keyword);
+#endif
}
- else if(sr_mode & RS_TITLE)
+ else
+ {
+ if(_mode & sr_mode & (RS_TITLE | RS_NEWPOST)) return DONOTHING;
+ // Ptt: only once for these two modes.
+ if(sr_mode & RS_TITLE)
strcpy(keyword, subject(fh->title));
+ }
- p = strstr(currdirect, "SR");
+ if((p = strstr(currdirect, "SR"))==NULL)
+ _mode = sr_mode;
+ else
+ _mode |= sr_mode;
snprintf(genbuf, sizeof(genbuf), "%s.%X.%X.%X",
p ? p : "SR",
@@ -370,7 +380,7 @@ select_read(keeploc_t * locmem, int sr_mode)
else
setbfile(newdirect, currboard, genbuf);
- if( !(now - dasht(newdirect) > 600) )
+ if( now - dasht(newdirect) < 1200 )
count = dashs(newdirect);
else {
if( (fd = open(newdirect, O_CREAT | O_RDWR, 0600)) == -1 )