home *** CD-ROM | disk | FTP | other *** search
- #
- # expire old messages
- #
- # This should put into your crontab file to be executed
- # once a day, with output going into a log file.
-
- require "ABSWFBIN/LIBWEBFORUM.PL";
- require "ctime.pl";
-
- select((select(STDOUT), $| = 1)[0]);
-
- open(LS,"ls -l ABSWFSPOOL/*/*/* | cut -f2 -d: | cut -f2- -d' '|")
- || die "Couldn't find ls\n";
-
- $today=&WFDateToNumber(&ctime(time));
-
- print "==============================\n";
- print &ctime(time),"\n";
-
- while(<LS>) {
- chop;
- $file=$_;
- $file=~m@^ABSWFSPOOL/(.*)/(.*)/(.*)$@;
- $forum=$1;
- $subject=$2;
- $message=$3;
- %db=&WFGetFile("$file");
- if (defined($db{"expiry"})) {
- $expiry=$db{"expiry"};}
- else {$expiry="7 days";}
- next if $expiry eq "never";
- $expiry=~ /([0-9]*) days/; $exp=$1;
- $fc=&WFDateToNumber($db{"date"});
- if ($fc+$exp <= $today) {
- print "$forum/$subject/$message created $db{date}, expires after $expiry, has expired\n";
- ;# if you wish to achive messages, rather than
- ;# just delete them, them substitute an archiving
- ;# line here for the unlink one.
- unlink($file);
- ;# if the subject is exhausted, delete it
- rmdir("ABSWFSPOOL/$forum/$subject");}
- }
- close(LS);
-