SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2003
    Location
    Phoenix, AZ.
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Managing dynamically generated files - suggestions

    Ok long story short, I have no choice but to write my dynamically generated html to a new file and redirect the user to this "temporary" html doc.

    Looking for suggestions on how to manage & organize & clean up these "temporary" pages as to not get out of hand. Cron is not available.

    Don't want to have to recreate the wheel here unless I have to.

    Thanks,
    Garrett

  2. #2
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Location
    Swindon, UK
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what do you mean by manage, organise and clean up? Do you want them to be kept a certain amount of time, or are they one shot files?

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2003
    Location
    Phoenix, AZ.
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    basically they are one shot, but I'd like them to be available for a certain amount of time, in case a browser is not closed or a back button is used.

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2003
    Location
    Phoenix, AZ.
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK well I tried to make a long story short, but basically my situation is...

    I'm writing a custom front-end for a client who uses Yahoo! Small Business for his Store. The store builder is pretty restrictive in what it can do. Since Yahoo! serves up his product catalog in XML, I've written a PHP class to parse the XML file, selecting the information needed, either by product ID or by category and generates the HTML using the Yahoo! store tags.

    Yahoo! store tag example
    Code:
    <!--#ystore_catalog id="sc071307dv" field="name" -->
    Problem is as I just found out, is that Yahoo! only propogates the store tags in files with an .html extension, so my files with a .php extension don't work.

    A quick solution to this is to write the dynamically generated html from the php script to a new file with a .html extension and redirect. It works and it's a quick solution to Yahoo!'s shortcummings.

    My question is now I have these one shot files, how best to organize and clean them up, more than likely by running a script manually once a day, since cron is not available.

    I'm looking for suggestions on organizing them and removing them, like I said I hate to recreate the wheel and want to know from anybody who's had similar one shot files deals with them. Or if you see any oversights in my thinking please point it out.

    -Garrett

  5. #5
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Location
    Swindon, UK
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, well, pages only need to really be removed when a new page is being created, so could you not timestamp each one (eg 12345667.html, 123768823.html), and then, each time PHP generates a new file, it goes through the directory and deletes any file more than say, an hour old (using the timestamp filename). I cant see it being that slow, as keeping it maintained should keep the numbers of files that need deleting in a single shot down.

    The code would look something like
    PHP Code:
    if ($handle opendir('dir/to/files')) {
        while (
    false !== ($file readdir($handle))) {
            if (
    $file != "." && $file != "..") {
                
    $file explode(".",$file);
                if (
    $file[0] < (time() -3600)){
                   
    unlink("dir/to/files/$file[0].html")
                }
            }
        }
        
    closedir($handle);

    This is just a quick thrashout and isn't tested, but it gives you an idea of what I mean - then it can be put at the top of your php page, and whenever a user requests an html page be created, it can trim down the old ones


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •