home *** CD-ROM | disk | FTP | other *** search
/ Complete Internet Archive / Complete Internet Archive.iso / Web Boards / WebForum_tar(2).Z / WebForum_tar(2) / WebForum / src / expire.pl < prev    next >
Encoding:
Text File  |  1995-01-19  |  1.2 KB  |  44 lines

  1. #
  2. # expire old messages
  3. #
  4. # This should put into your crontab file to be executed 
  5. # once a day, with output going into a log file.
  6.  
  7. require "ABSWFBIN/LIBWEBFORUM.PL";
  8. require "ctime.pl";
  9.  
  10. select((select(STDOUT), $| = 1)[0]);
  11.  
  12. open(LS,"ls -l ABSWFSPOOL/*/*/* | cut -f2 -d: | cut -f2- -d' '|") 
  13. || die "Couldn't find ls\n";
  14.  
  15. $today=&WFDateToNumber(&ctime(time));
  16.  
  17. print "==============================\n";
  18. print &ctime(time),"\n";
  19.  
  20. while(<LS>) {
  21.     chop;
  22.     $file=$_;
  23.     $file=~m@^ABSWFSPOOL/(.*)/(.*)/(.*)$@;
  24.     $forum=$1;
  25.     $subject=$2;
  26.     $message=$3;
  27.     %db=&WFGetFile("$file");
  28.     if (defined($db{"expiry"})) {
  29.         $expiry=$db{"expiry"};}
  30.     else {$expiry="7 days";}
  31.     next if $expiry eq "never";
  32.     $expiry=~ /([0-9]*) days/; $exp=$1;
  33.     $fc=&WFDateToNumber($db{"date"});
  34.     if ($fc+$exp <= $today) {
  35.         print "$forum/$subject/$message created $db{date}, expires after $expiry, has expired\n";
  36.         ;# if you wish to achive messages, rather than
  37.         ;# just delete them, them substitute an archiving
  38.         ;# line here for the unlink one.
  39.         unlink($file);
  40.         ;# if the subject is exhausted, delete it
  41.         rmdir("ABSWFSPOOL/$forum/$subject");}
  42. }
  43. close(LS);
  44.