Gossamer Forum
Home : General : Perl Programming :

Deleting from file based on expiration date...

Quote Reply
Deleting from file based on expiration date...
Hi,

I'm attempting to write a membership script in which access to password protected areas expires after a specified period of time.

Users register and their info is save to a file. Here is an example:

username:a28eA62qa0DyA:12-16-99:ted:tedd@ted.net:945339114:2:asdf main:houston, tx aasdf

The above format is username, password, date registered, first name, email, expiration date ($expires), address, city state zip

I calculate the expiration date based on the following:
$membershiplength = 30;
$expires = time() + 86400 * $membershiplength;

My problem is writing the code that will delete the user data from the file when access has expired.

Any samples or help would be appreciated!!!!

Thanks,

Tim
Quote Reply
Re: Deleting from file based on expiration date... In reply to
There is a delete records script in the DBMAN Section of the Resource Center. Feel free to use it as a template for your script.

Regards.

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Deleting from file based on expiration date... In reply to
Thanks! I'll take a look.

Tim
Quote Reply
Re: Deleting from file based on expiration date... In reply to
if you have mysql..

$expire = 86400 * $membershiplength;

then a query of..

DELETE FROM TABLE WHERE UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(Created) > $expire

jerry