fixing phlickr's internal php references so it can be used from scripts throughout a filesystem
Phlickr is the PHP5 API for the excellent photo-sharing website Flickr. It works well from what I've seen so far.
One problem though - the various PHP files within the Phlickr API reference each other using relative links i.e. require_once 'Phlickr/API.php', which means that all scripts that use the Phlickr API must be in the directory that contains the Phlickr directory. For me this proved inflexible as I nest my PHP scripts within various directories.
Therefore, I needed to run a substitution on the Phlickr API files in order to make the referenced paths absolute. Here we can use PHP's global $_SERVER['DOCUMENT_ROOT'] variable, which provides the physical filesystem path to the root directory serving up the PHP files. Here's a substitution command I came up with, which should be run within the Phlickr API directory:
find . -name "*.php" | xargs sed -i "s/'Phlickr\\//\$_SERVER['DOCUMENT_ROOT'] . '\\/Phlickr\\//g"
Note: this command works for me in bash - I haven't tried it in other shells.
After the substitution, the Phlickr API should be placed in this root directory, but other scripts that need to access it can be placed in subdirectories
04/09/07 11:31pm
(5 years, 9 months ago)

