summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mbbsd/bbs.c13
-rw-r--r--mbbsd/record.c13
-rw-r--r--sample/pttbbs.conf5
3 files changed, 30 insertions, 1 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index a0385552..659e6544 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -947,6 +947,11 @@ edit_post(int ent, fileheader_t * fhdr, char *direct)
if( currmode & MODE_SELECT )
return DONOTHING;
+#ifdef SAFE_ARTICLE_DELETE
+ if( fhdr->filename[0] == '.' )
+ return DONOTHING;
+#endif
+
setutmpmode(REEDIT);
setdirpath(genbuf, direct, fhdr->filename);
local_article = fhdr->filemode & FILE_LOCAL;
@@ -1833,7 +1838,13 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
getdata(1, 0, msg_del_ny, genbuf, 3, LCECHO);
if (genbuf[0] == 'y') {
strlcpy(currfile, fhdr->filename, sizeof(currfile));
- if (!delete_file(direct, sizeof(fileheader_t), ent, cmpfilename)) {
+ if(
+#ifdef SAFE_ARTICLE_DELETE
+ !safe_article_delete(ent, fhdr, direct)
+#else
+ !delete_file(direct, sizeof(fileheader_t), ent, cmpfilename)
+#endif
+ ) {
int num;
if (currmode & MODE_SELECT) {
/* rocker.011018: 利用reference減低loading */
diff --git a/mbbsd/record.c b/mbbsd/record.c
index e4c2897f..c28a0c6d 100644
--- a/mbbsd/record.c
+++ b/mbbsd/record.c
@@ -400,6 +400,19 @@ int delete_files(char *dirname, int (*filecheck) (), int record){
return ans;
}
+#ifdef SAFE_ARTICLE_DELETE
+int
+safe_article_delete(int ent, fileheader_t *fhdr, char *direct)
+{
+ fileheader_t newfhdr;
+ memcpy(&newfhdr, fhdr, sizeof(fileheader_t));
+ sprintf(newfhdr.title, "(本文已被刪除)");
+ strcpy(newfhdr.filename, ".deleted");
+ substitute_record(direct, &newfhdr, sizeof(newfhdr), ent);
+ return 0;
+}
+#endif
+
int
delete_file(char *dirname, int size, int ent, int (*filecheck) ())
{
diff --git a/sample/pttbbs.conf b/sample/pttbbs.conf
index ff006f90..25e2b250 100644
--- a/sample/pttbbs.conf
+++ b/sample/pttbbs.conf
@@ -119,6 +119,11 @@
/* 使用 rfork()取代 fork() . 目前只在 FreeBSD上有效 */
//#define USE_RFORK
+/* 若定義, 則在刪除看板文章的時候, 僅會在 .DIR 中標明, 並不會將該資料
+ 從 .DIR 中拿掉. 可以避免多項問題 (尤其是熱門看板一堆推薦及編輯時)
+ 須配合使用 (尚未完成) */
+//#define SAFE_ARTICLE_DELETE
+
/* 前進站畫面 */
#define INSCREEN \
"前進站畫面 (請至 pttbbs.conf 修改您的前進站畫面)"