I have auto delete mod insalled but instead of deleting a record i wish to change 1 value if it gets older than $remove
So far i have this and it works but it changes the value eveytime someone logs in
Anybody help with what i may missed
sub auto_delete {
# ------------------------------------------
# Change field entry older then $remove # days old.
#
my $remove = 14; # Number of days old.
my $date_field = 2; # Field Position of date field.
my $today = &date_to_unix(&get_date);
my $removeby = $today - ($remove * 86400);
my (@lines, @values);
open (DB, $db_file_name) or &cgierr ("Can't open: $db_file_name. Reason: $!");
if ($db_use_flock) { flock (DB, 1); }
@lines = <DB>;
close DB;
open (DB, ">$db_file_name") or &cgierr ("Can't open: $db_file_name. Reason: $!");
if ($db_use_flock) { flock (DB, 2); }
foreach (@lines) {
next if /^#/;
next if /^\s*$/;
chomp;
@values = &split_decode ($_);
%rec = &array_to_hash(0,@values);
$rec{'hilight'} = '';
print DB &join_encode(%rec);
}
close DB;
}
So far i have this and it works but it changes the value eveytime someone logs in
Anybody help with what i may missed
sub auto_delete {
# ------------------------------------------
# Change field entry older then $remove # days old.
#
my $remove = 14; # Number of days old.
my $date_field = 2; # Field Position of date field.
my $today = &date_to_unix(&get_date);
my $removeby = $today - ($remove * 86400);
my (@lines, @values);
open (DB, $db_file_name) or &cgierr ("Can't open: $db_file_name. Reason: $!");
if ($db_use_flock) { flock (DB, 1); }
@lines = <DB>;
close DB;
open (DB, ">$db_file_name") or &cgierr ("Can't open: $db_file_name. Reason: $!");
if ($db_use_flock) { flock (DB, 2); }
foreach (@lines) {
next if /^#/;
next if /^\s*$/;
chomp;
@values = &split_decode ($_);
%rec = &array_to_hash(0,@values);
$rec{'hilight'} = '';
print DB &join_encode(%rec);
}
close DB;
}