Any suggestions?

    Date: 02/13/06 (PHP Community)    Keywords: php, xml, web

    I was just wondering if anyone had an idea on how to go about this...

    I'm running an iTunes plugin that automatically puts the ID3 info from my currently playing song into an XML file on my website, which I then parse and display using PHP. That's fine.

    It also uploads a thumbnail of that song to a specific directory. Now, playing iTunes for several hours on end leaves me with a folder full of thumbnails. I'd like to write a cron job that deletes all but the currently playing or x most recent thumbnails.

    I can't just wipe out all but the newest x files from the directory, as the XML file is saved there as well (the plugin is non-configurable in this respect), and the plugin uploads artwork for songs that only play for a split second, even if the XML file won't list them. So I can't delete just the x most recent files with a specific naming scheme, I've got to delete all image files except the ones listed in the XML file.

    The problem with that is that the XML file does not list a file extension for the album artwork, and just lists a hash as an ID (which is only a part of the filename used to save the image when uploading). As is, I use a number of if/else statements to determine if a file exists and what file type it is.

    I'm *thinking* that the best way is to collect those album artwork IDs, and unlink() all images that DON'T contain those hash IDs. I'm not sure the best way to go about this though, as while I've got plenty of experience with PHP in certain respects, it's filesystem commands are something I've neglected.

    So, essentially, I'm just wondering if there's an easy PHP file command for collecting files that fall under certain criteria. Any ideas?

    Source: http://community.livejournal.com/php/412289.html

« Need help with updating script || Flock and fopen () with... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home