From eb6081959bf27d4034ca2e5fea3fd112b3d629e5 Mon Sep 17 00:00:00 2001 From: piaip Date: Wed, 9 Nov 2011 08:07:53 +0000 Subject: Add limitation to ziphome. git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5459 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- pttbbs/mbbsd/mail.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/pttbbs/mbbsd/mail.c b/pttbbs/mbbsd/mail.c index 78b7a779..519cf249 100644 --- a/pttbbs/mbbsd/mail.c +++ b/pttbbs/mbbsd/mail.c @@ -920,12 +920,30 @@ mail_all(void) int mail_mbox(void) { - char cmd[100]; - fileheader_t fhdr; + char tagname[PATHLEN]; + char cmd[PATHLEN*2]; + fileheader_t fhdr; + time4_t last_tag = 0; + + setuserfile(tagname, ".zipped_home"); + last_tag = dasht(tagname); + + if (last_tag > 0 && (now - last_tag) < 7 * DAY_SECONDS && + !HasUserPerm(PERM_SYSOP)) { + vmsgf("每週僅可備份一次,離下次還有 %d 天。", + 7 - (now - last_tag) / DAY_SECONDS); + return 0; + } snprintf(cmd, sizeof(cmd), "/tmp/%s.uu", cuser.userid); snprintf(fhdr.title, sizeof(fhdr.title), "%s 私人資料", cuser.userid); - doforward(cmd, &fhdr, 'Z'); + // TODO doforward does not return real execution code... we may need to + // fix it in future. + if (doforward(cmd, &fhdr, 'Z') == 0) { + log_filef(tagname, LOG_CREAT, + "%s %s\n", Cdatelite(&now), cmd); + rotate_text_logfile(tagname, SZ_RECENTLOGIN, 0.2); + } return 0; } -- cgit v1.2.3