use POSIX;
+@org_argv= @ARGV;
+$needrenew= 0;
+
if ($ARGV[0] eq '--cgi') {
shift @ARGV;
$invokestyle= 'cgi';
+} elsif ($ARGV[0] eq '--expire-noconfirm') {
+ shift @ARGV;
+ $invokestyle= 'maintain';
+} elsif ($ARGV[0] eq '--expire-norenew') {
+ shift @ARGV;
+ $invokestyle= 'maintain';
+ $needrenew= 1;
+} elsif ($ARGV[0] =~ m/^--/) {
+ die "$ARGV[0] ?";
} elsif ($ENV{'SERVER_SOFTWARE'} =~ m/^Lynx/) {
$invokestyle= 'lynxcgi';
} else {
open DEBUG,">&STDERR" or die $!;
} elsif ($invokestyle eq 'lynxcgi') {
open DEBUG,">>debug.txt" or die $!;
-} elsif ($invokestyle eq 'cgi') {
+} elsif ($invokestyle eq 'cgi' || $invokestyle eq 'maintain') {
open DEBUG,">/dev/null" or die $!;
}
-if ($invokestyle eq 'cgi') {
+if ($invokestyle eq 'cgi' || $invokestyle eq 'maintain') {
$scriptdir= shift @ARGV;
$datadir= shift @ARGV;
} else {
$datadir= '.';
}
-if ($invokestyle ne 'manual') {
+if (!($invokestyle eq 'manual' || $invokestyle eq 'maintain')) {
$ct= 'BCP5REGISTRY_CONTENTTYPEDONE';
if (!$ENV{$ct}) {
$|=1;
require 'listdb.pl';
require 'passwords.pl';
-if ($invokestyle ne 'manual') {
+if (!($invokestyle eq 'manual' || $invokestyle eq 'maintain')) {
lock_database();
require 'cgi-lib.pl';
&ReadParse;
$fulldetails= 0;
$justcreated= 0;
$justupdated= 0;
-$needrenew= 0;
$picked= 0;
$listingall= 0;
$passwordsent= 0;
defined($now= time) or die $!;
-if (length $in{'register'}) {
+if ($invokestyle eq 'maintain') {
+
+ lock_database();
+ read_database();
+
+ if ($needrenew) {
+ $threshold_recent= $now - $renew_interval;
+ $threshold_old= $threshold_recent - $expire_norenew;
+ } else {
+ $threshold= $now - $expire_noconfirm;
+ }
+
+ $changed= 0;
+
+ foreach $id (keys %db) {
+ $ent= $db{$id};
+ if ($needrenew) {
+ next unless $ent->{'changed'};
+ next if $ent->{'changed'} >= $threshold_recent;
+ if ($ent->{'changed'} > $threshold_old) {
+ show_entry();
+ send_password();
+ print "sent renewal for $id ($net)\n" or die $!;
+ next;
+ }
+ show_entry();
+ printf("deleted stale %s (%s, %x %x %x)\n",
+ $id, $net, $threshold_recent, $threshold_old,
+ $ent->{'changed'}) or die $!;
+ } else {
+ next if $ent->{'changed'};
+ next if $ent->{'created'} >= $threshold;
+ show_entry();
+ printf("deleted new %s (%s, %x %x)\n",
+ $id, $net, $threshold, $ent->{'created'}) or die $!;
+ }
+ delete $db{$id};
+ $changed= 1;
+ }
+
+ if ($changed) {
+ write_database();
+ }
+ close STDOUT or die $!;
+ exit 0;
+
+} elsif (length $in{'register'}) {
lock_database();
read_database();
From: "@@@adminname@@@" (@@@whose@@@ G-RIN administrator) <@@@adminemail@@@>
-To: "@@@contact@@@" <@@@email@@@>
+To: "@@@contact@@@" <@@@alwaysemail@@@>
@@@if:justcreated@@@
Subject: G-RIN entry @@@net@@@ created, please confirm
Subject: G-RIN entry @@@net@@@ renewal
@@@
The following database entry in the @@@whose@@@ G-RIN
-is now due for renewal. It will be discarded from the database in few
-weeks if you do not confirm it before then.
+is now due for renewal. It will be discarded from the database
+shortly if you do not confirm it before then.
@@@endif:@@@
@@@
@@@endif:@@@
@@@if:needrenew@@@
-You may renew it by using the G-RIN web page or you may simply visit
-the following URL for instant renewal:
+You can renew it by using the G-RIN web page or you may simply
+visit the following URL for instant renewal:
@@@endif:@@@
@@@if:justcreated|needrenew@@@
@@@endif:@@@
@@@if:passwordsent@@@
-You may modify this entry via the G-RIN web page, or you may go
-directly to the view/update page for this entry:
+You can modify this entry via the G-RIN web pages, or you may
+go directly to the view/update page for this entry:
@@@
@@@cgi@@@?view=1&id=@@@id@@@&pw=@@@password@@@
@@@endif:@@@