Gossamer Forum
Home : Products : DBMan : Installation :

delete records after a specific time?

(Page 3 of 3)
> >
Quote Reply
Re: delete records after a specific time? In reply to
Isit possible to let the user enter the Date of Expiry and the script will delete the profile when the date met?
Quote Reply
Re: delete records after a specific time? In reply to
Probably. I would have to go over the whole thing again to know. It's been a long time since I looked at this code.


------------------
JPD





Quote Reply
Re: delete records after a specific time? In reply to
thks JPDeni ! think most ppl would love to have that mod
Quote Reply
Re: delete records after a specific time? In reply to
You could use Eliot's autodelete script, which is at http://anthrotech.com/...bman/mods/delete.txt .

You'll just have to make a few changes.

Instead of the "RemoveAd" field being the number of days for the record to stay in the database, make it be the date that the record will be deleted.

Change the following line:

Code:
if ($today > (&date_to_unix($values[$dateadded_field]) + (86400 * $values[$removeby_field]))) {

to

Code:
if ($today >= (&date_to_unix($values[$removeby_field])) {

You would not need to have a field for the date the record was added.




------------------
JPD





Quote Reply
Re: delete records after a specific time? In reply to
I got this Illegal division by zero at C:\InetPub\website\xxx\cgi-bin\xxx\delete.cgi line 92.


below is the code from delete.cgi

# Database Script Path...Same as what is in the db.cgi file

$db_script_path = '.';

# Required Files to make this file work.

require "default.cfg";

# Change to the correct field number

my $removeby_field = 15;

# Change to the correct field number

my $dateadded_field = 14;

my $today = &date_to_unix(&get_date);
my (@lines, @values);

print "Content-type: text/plain\n\n";
open (DB, $db_script_path/$db_file_name) or ("Can't open: $db_script_path/$db_file_name. Reason: $!");
if ($db_use_flock) {
flock (DB, 1);
}
@lines = <DB>;
close DB;

open (DB, ">$db_script_path/$db_file_name") or ("Can't open: $db_script_path/$db_file_name. Reason: $!");
if ($db_use_flock) {
flock (DB, 2);
}
foreach (@lines) {
next if /^#/;
next if /^\s*$/;
chomp;
@values = &split_decode ($_);
print "Comparing: '$today' vs '$values[$removeby_field]' ... \n";
if ($today >= (&date_to_unix($values[$removeby_field]))) {
print "Record(s) Deleted\n";
next;
}
print DB $_, "\n";
}
close DB;
Quote Reply
Re: delete records after a specific time? In reply to
It's probably due to the following code:

open (DB, $db_script_path/$db_file_name)

You should be able to change it to

open (DB, $db_file_name)

There are 4 places in the script that you'll need to change. If you have a "Replace" function in your text editor, replace

$db_script_path/$db_file_name

with

$db_file_name

The script path shouldn't be necessary, since the $db_file_name has the path defined in the .cfg file.


------------------
JPD





Quote Reply
Re: delete records after a specific time? In reply to
It Works! thanks alot!
> >