diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2010-11-18 18:44:15 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2010-11-18 18:44:15 +0800 |
commit | c3367722772e1cde28591104b731b603ab5e4b84 (patch) | |
tree | 0bb6450d6c6439cd1d2bd627960383f6cff578db | |
parent | 7ee33bed8bf280145bb10f5a691e3a43674f8924 (diff) | |
download | pttbbs-c3367722772e1cde28591104b731b603ab5e4b84.tar pttbbs-c3367722772e1cde28591104b731b603ab5e4b84.tar.gz pttbbs-c3367722772e1cde28591104b731b603ab5e4b84.tar.bz2 pttbbs-c3367722772e1cde28591104b731b603ab5e4b84.tar.lz pttbbs-c3367722772e1cde28591104b731b603ab5e4b84.tar.xz pttbbs-c3367722772e1cde28591104b731b603ab5e4b84.tar.zst pttbbs-c3367722772e1cde28591104b731b603ab5e4b84.zip |
only alert for certain period.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5265 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | pttbbs/util/toplazyBM.c | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/pttbbs/util/toplazyBM.c b/pttbbs/util/toplazyBM.c index ac2b0dec..af26f8b1 100644 --- a/pttbbs/util/toplazyBM.c +++ b/pttbbs/util/toplazyBM.c @@ -10,6 +10,17 @@ extern int numboards; #define LAZY_BM_LIMIT_DAYS (90) #endif +#ifndef LAZY_BM_MIN_ALERT_DAYS +#define LAZY_BM_MIN_ALERT_DAYS (8) +#endif + +enum { + ALERT_MIN = 1, + ALERT_INFO, + ALERT_WARN, + ALERT_CRITICAL, +}; + boardheader_t allbrd[MAX_BOARD]; typedef struct lostbm { char bmname[IDLEN + 1]; @@ -25,6 +36,25 @@ typedef struct BMarray{ } BMArray; BMArray bms[5]; +int need_alert(int days) { + // alerts will be sent at: + // LAZY_BM_MIN_ALERT_DAYS(8), + // LAZY_BM_LIMIT_DAYS/2 (45), + // LAZY_BM_LIMIT_DAYS*2/3 (60), + // LAZY_BM_LIMIT_DAYS*5/6 (75), + // LAZY_BM_LIMIT_DAYS + if (days == LAZY_BM_MIN_ALERT_DAYS) + return ALERT_MIN; + if (days == LAZY_BM_LIMIT_DAYS/2 || + days == LAZY_BM_LIMIT_DAYS*2/3 || + days == LAZY_BM_LIMIT_DAYS*5/6) + return ALERT_INFO; + if (days >= LAZY_BM_LIMIT_DAYS) + return ALERT_CRITICAL; + if (days >= LAZY_BM_LIMIT_DAYS - 2) + return ALERT_WARN; + return 0; +} int bmlostdays_cmp(const void *va, const void *vb) { @@ -104,9 +134,10 @@ int main(int argc, char *argv[]) if (diff < 0) diff = 0; - if (diff >= 45 * 86400 - && !(xuser.userlevel & PERM_SYSOPHIDE) - && !(xuser.userlevel & PERM_SYSOP)) { + if (need_alert(diff / 86400) && + !(xuser.userlevel & PERM_SYSOPHIDE) && + !(xuser.userlevel & PERM_SYSOP)) + { strlcpy(lostbms[j].bmname, p, sizeof(bms[index].bmname)); lostbms[j].title = allbrd[i].brdname; lostbms[j].ctitle = allbrd[i].title; @@ -185,11 +216,8 @@ int main(int argc, char *argv[]) lostdays = lostbms[i].lostdays; - if (lostdays != LAZY_BM_LIMIT_DAYS/2 && - lostdays != LAZY_BM_LIMIT_DAYS*2/3 && - lostdays != LAZY_BM_LIMIT_DAYS*5/6 && - lostdays <= LAZY_BM_LIMIT_DAYS) - continue; + if (need_alert(lostdays) < ALERT_WARN) + continue; sprintf(genbuf, BBSHOME "/home/%c/%s", lostbms[i].bmname[0], lostbms[i].bmname); |