summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pttbbs/mbbsd/bbs.c5
-rw-r--r--pttbbs/util/redir.c27
2 files changed, 23 insertions, 9 deletions
diff --git a/pttbbs/mbbsd/bbs.c b/pttbbs/mbbsd/bbs.c
index 1d32d545..daceef0f 100644
--- a/pttbbs/mbbsd/bbs.c
+++ b/pttbbs/mbbsd/bbs.c
@@ -88,7 +88,7 @@ static int
cp_IsHiddenBoard(const boardheader_t *bp)
{
// rules: see HasBoardPerm().
- if ((bp->brdattr & BRD_HIDE) && (bp->brdattr & BRD_POSTMASK))
+ if ((bp->brdattr & BRD_HIDE) && (bp->brdattr & BRD_POSTMASK))
return 1;
if (bp->level && !(bp->brdattr & BRD_POSTMASK))
return 1;
@@ -1096,9 +1096,10 @@ log_crosspost_in_allpost(const char *brd, const fileheader_t *postfile) {
if (cp_IsHiddenBoard(getbcache(brd_id)))
return;
+ syncnow();
memcpy(&fh, postfile, sizeof(fileheader_t));
fh.filemode = FILE_LOCAL;
- // TODO trust fh.owner?
+ fh.modified = now;
strlcpy(fh.owner, cuser.userid, sizeof(fh.owner));
strlcpy(genbuf, title, len + 1);
if (strlen(title) > len) {
diff --git a/pttbbs/util/redir.c b/pttbbs/util/redir.c
index 93a15d44..9a5f60e8 100644
--- a/pttbbs/util/redir.c
+++ b/pttbbs/util/redir.c
@@ -19,7 +19,7 @@ int in_spam(const fileheader_t *fh) {
int process(FILE *fin, FILE *fout, const char *index_path,
int *pkeep, int remove_spam, int remove_days,
- int remove_deleted) {
+ int remove_deleted, int remove_modified_days) {
char file_path[PATHLEN];
fileheader_t fh;
@@ -35,6 +35,11 @@ int process(FILE *fin, FILE *fout, const char *index_path,
if (!should_remove && remove_spam && in_spam(&fh))
should_remove = 1;
+ if (!should_remove && remove_modified_days > 0 && fh.modified) {
+ if (fh.modified < now - DAY_SECONDS * remove_modified_days)
+ should_remove = 1;
+ }
+
if (!should_remove && remove_days > 0 && strlen(fh.filename) > 2 &&
fh.filename[1] == '.') {
int ts = atoi(fh.filename + 2);
@@ -50,7 +55,7 @@ int process(FILE *fin, FILE *fout, const char *index_path,
if (!fout)
return 1;
- printf("%s: %s %s\n", file_path, fh.filename, fh.title);
+ printf("%s: %s %d %s\n", file_path, fh.filename, fh.modified, fh.title);
unlink(file_path);
num_remove++;
if (!fout)
@@ -81,10 +86,11 @@ int main(int argc, char **argv)
int opt;
int num_keep = 0, num_remove = 0;
FILE *fin;
- int remove_spam = 0, remove_days = 0, remove_deleted = 0;
+ int remove_spam = 0, remove_days = 0, remove_deleted = 0,
+ remove_modified_days = 0;
int verbose = 0;
- while ((opt = getopt(argc, argv, "vsed:")) != -1) {
+ while ((opt = getopt(argc, argv, "vsed:m:")) != -1) {
switch (opt) {
case 's':
remove_spam = 1;
@@ -94,6 +100,10 @@ int main(int argc, char **argv)
remove_days = atoi(optarg);
break;
+ case 'm':
+ remove_modified_days = atoi(optarg);
+ break;
+
case 'e':
remove_deleted = 1;
break;
@@ -108,7 +118,8 @@ int main(int argc, char **argv)
}
}
- if (optind != argc - 1 || remove_days < 0 || optind < 2) {
+ if (optind != argc - 1 || optind < 2 ||
+ remove_days < 0 || remove_modified_days < 0) {
die_usage(myname);
}
@@ -132,7 +143,8 @@ int main(int argc, char **argv)
}
if ((num_remove = process(fin, NULL, index_path, &num_keep,
- remove_spam, remove_days, remove_deleted))) {
+ remove_spam, remove_days, remove_deleted,
+ remove_modified_days))) {
char tmp_index_path[PATHLEN];
FILE *fout;
@@ -145,7 +157,8 @@ int main(int argc, char **argv)
}
rewind(fin);
num_remove = process(fin, fout, index_path, &num_keep,
- remove_spam, remove_days, remove_deleted);
+ remove_spam, remove_days, remove_deleted,
+ remove_modified_days);
fclose(fout);
fclose(fin);
Rename(tmp_index_path, index_path);