'Expiring" Data

8 views
Skip to first unread message

Warren Michelsen

unread,
Aug 6, 2010, 1:46:43 PM8/6/10
to Web Authoring List
I have a php driven site that stores data on a temporary basis but, after a week, no longer needs the data or the links to expired data.

The data submit form writes the data to a data file that is included into the ViewData form. It also adds a link into a links files. So, it writes: [serial]data.php to contain the data and then writes one line to "DataList.incl" adding a link to the newly submitted data.

The ViewData form includes DataList.incl containing the links to the various data files themselves.

<a href="ViewData.html?serial=45176">45176</a><br>
<a href="ViewData.html?serial=45177">45177</a><br>
<a href="ViewData.html?serial=45178">45178</a><br>
<a href="ViewData.html?serial=45179">45179</a><br>
<a href="ViewData.html?serial=45180">45180</a><br>
<a href="ViewData.html?serial=45181">45181</a><br>
<a href="ViewData.html?serial=45182">45182</a><br>

Basically, I'm looking for a way to "expire" both the data files and links after a week or so.

It's easy enough to write a script to delete the old data files but the links in DataList.incl are another matter. I could tag the links with a date tag (YYYYMMDD) or something but would need another script to periodically parse DataList.incl and delete lines with data tags older than a week.

That is, I could write link lines in DataList.incl like:
<a href="ViewData.html?serial=45182">45182</a><br><!--20100805-->

Then, once a day, run a script that deletes [serial]data.php files where the create date is older than a week and then parses DataList.incl to remove those lines with date tags a week old.

Are any of you currently "expiring" files and links like this?


Assuming that I go ahead and tag each link with YYYYMMDD, can removal of old links within DataList.incl be done with php or will that require Perl or some such?



Scout

unread,
Aug 7, 2010, 10:39:16 PM8/7/10
to Web Authoring
Hey Mikey! Why don't you store the serial numbers in a database table
along with an expiration date? Then build your form dynamically after
selecting all the serials which have expiration dates after today (or
yesterday.)

-scout
Reply all
Reply to author
Forward
0 new messages