summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/bbs.c13
-rw-r--r--mbbsd/record.c13
2 files changed, 25 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) ())
{