Isit possible to let the user enter the Date of Expiry and the script will delete the profile when the date met?
Mar 19, 2000, 7:10 PM
Veteran / Moderator (8669 posts)
Mar 19, 2000, 7:10 PM
Post #52 of 57
Views: 3189
Mar 20, 2000, 8:44 PM
Veteran / Moderator (8669 posts)
Mar 20, 2000, 8:44 PM
Post #54 of 57
Views: 3129
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:
to
You would not need to have a field for the date the record was added.
------------------
JPD
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
Mar 20, 2000, 10:15 PM
User (146 posts)
Mar 20, 2000, 10:15 PM
Post #55 of 57
Views: 3092
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;
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;
Mar 20, 2000, 10:37 PM
Veteran / Moderator (8669 posts)
Mar 20, 2000, 10:37 PM
Post #56 of 57
Views: 3048
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
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