// ns:foo=bar -> ns-foo-bar function encodeMachineTagArgument($set_id) { return preg_replace(array("@:@", "@=@"), array("-", "-"), $set_id, 1); } // For creating a link to the page that display an image function makeImageLink($id, $set_id) { // If $set_id is a machine tag, encode it (replacing ':' and '=' with dashes) $set_id = encodeMachineTagArgument($set_id); return "./?id={$id}&set={$set_id}"; } ?> <div id="flickr-galleri"> <?php $flickr = new hdFlickr($api_key, $api_secret, $flickr_username, $mc); if ($flickr->initialize() === FALSE) { die($generic_error_msg); } echo "<!-- Flickr: initialized! -->\n"; if (isset($_GET["id"])) { $img_id = $_GET["id"]; if (($set_id = decodeMachineTagArgument($_GET["set"])) === FALSE) { die("Invalid parameter 'set'"); } include "image.php"; } else { if (isset($_GET["set"])) { if (($set_id = decodeMachineTagArgument($_GET["set"])) === FALSE) { die("Invalid parameter 'set'"); }
} else { if ($argc > 1) { echo "* Forcing refresh of cached data for all photosets and their photos\n"; $force_refresh = TRUE; } } // Connect to memcache, if available $mc = NULL; if (class_exists("Memcache")) { $mc = new Memcache(); if (!@$mc->connect("localhost", 11211)) { $mc = NULL; } } // Initialize API access $flickr = new hdFlickr($api_key, $api_secret, $flickr_username, $mc); if ($flickr->initialize() === FALSE) { die($generic_error_msg); } // Print current statistics $stats = array(); if (($details = $flickr->getStats()) !== FALSE) { foreach ($details as $k => $v) { $stats[] = "{$k}={$v}"; } if ($details["cache_hits"] > 0 && $details["cache_misses"] > 0) { $stats[] = sprintf("hit-ratio=%.2f", 100.0 * $details["cache_hits"] / ($details["cache_hits"] + $details["cache_misses"])); } } else { $stats[] = "N/A"; }