public static function getUrl($photo, $sizeShort)
 {
     if (!FlickrPhotoHA::hasSize($photo, $sizeShort)) {
         return false;
     } else {
         if ($sizeShort != FlickrPhotoHA::SIZE_ORIGINAL_SHORT) {
             return "http://farm" . $photo->farm . ".staticflickr.com/" . $photo->server . "/" . $photo->id . "_" . $photo->secret . "_" . $sizeShort . ".jpg";
         }
         return "http://farm" . $photo->farm_id . ".staticflickr.com/" . $photo->server_id . "/" . $photo->image_id . "_" . $photo->original_secret . "_" . $sizeShort . ".jpg";
     }
 }
    }
}
$setName = isset($_REQUEST["setName"]) ? $_REQUEST["setName"] : false;
if (!$setName || !$config->sets[$setName]) {
    die("no set");
}
$setId = $config->sets[$setName]->setId;
$data = $flickrDB->getDBSetPhotos($setId);
$template = file_get_contents("../lib/templates/image_template.mustache");
$full_width_template = file_get_contents("../lib/templates/image_template_full_width.mustache");
$html = "";
foreach ($data as $photo) {
    //echo "url:".$photo->url."<br/>";
    $photo->ratioPerc = false;
    $photo->ratio = getImageRatio($photo->original_width, $photo->original_height);
    $photo->url = FlickrPhotoHA::getUrl($photo, FlickrPhotoHA::SIZE_LARGE_SHORT);
    $photo->xlUrl = $photo->xl_source;
    $photo->classes = array();
    if (!is_string($photo->ratio)) {
        $photo->ratioPerc = round(1 / $photo->ratio * 10000) / 100;
        $photo->ratioPerc .= "%";
        $photo->ratio = "x-x";
    }
    $fullwidth = false;
    $photo->hashtags = array();
    if ($photo->comments !== "") {
        $meta = explode(" ", $photo->comments);
        foreach ($meta as $tag) {
            if (strpos($tag, "#") !== false) {
                $photo->hashtags[] = $tag;
            } else {
 public static function addPhotoUrls(&$photo)
 {
     $photo["url_size_" . FlickrPhotoHA::SIZE_SQUARE_SHORT] = FlickrPhotoHA::getUrl($photo, FlickrPhotoHA::SIZE_SQUARE_CODE);
     $photo["url_size_" . FlickrPhotoHA::SIZE_LARGE_SQUARE_SHORT] = FlickrPhotoHA::getUrl($photo, FlickrPhotoHA::SIZE_LARGE_SQUARE_CODE);
     $photo["url_size_" . FlickrPhotoHA::SIZE_THUMBNAIL_SHORT] = FlickrPhotoHA::getUrl($photo, FlickrPhotoHA::SIZE_THUMBNAIL_CODE);
     $photo["url_size_" . FlickrPhotoHA::SIZE_SMALL_SHORT] = FlickrPhotoHA::getUrl($photo, FlickrPhotoHA::SIZE_SMALL_CODE);
     $photo["url_size_" . FlickrPhotoHA::SIZE_SMALL_240_SHORT] = FlickrPhotoHA::getUrl($photo, FlickrPhotoHA::SIZE_SMALL_240_CODE);
     $photo["url_size_" . FlickrPhotoHA::SIZE_SMALL_320_SHORT] = FlickrPhotoHA::getUrl($photo, FlickrPhotoHA::SIZE_SMALL_320_CODE);
     $photo["url_size_" . FlickrPhotoHA::SIZE_MEDIUM_SHORT] = FlickrPhotoHA::getUrl($photo, FlickrPhotoHA::SIZE_MEDIUM_CODE);
     $photo["url_size_" . FlickrPhotoHA::SIZE_MEDIUM_640_SHORT] = FlickrPhotoHA::getUrl($photo, FlickrPhotoHA::SIZE_MEDIUM_640_CODE);
     $photo["url_size_" . FlickrPhotoHA::SIZE_MEDIUM_800_SHORT] = FlickrPhotoHA::getUrl($photo, FlickrPhotoHA::SIZE_MEDIUM_800_CODE);
     $photo["url_size_" . FlickrPhotoHA::SIZE_LARGE_SHORT] = FlickrPhotoHA::getUrl($photo, FlickrPhotoHA::SIZE_LARGE_CODE);
     $photo["url_size_" . FlickrPhotoHA::SIZE_LARGE_1600_SHORT] = FlickrPhotoHA::getUrl($photo, FlickrPhotoHA::SIZE_LARGE_1600_CODE);
     $photo["url_size_" . FlickrPhotoHA::SIZE_ORIGINAL_SHORT] = FlickrPhotoHA::getUrl($photo, FlickrPhotoHA::SIZE_ORIGINAL_CODE);
 }
foreach ($json->photoset->photo as $photo) {
    set_time_limit(20);
    echo "<div>";
    echo "<img src=\"" . FlickrPhotoHA::getUrl($photo, FlickrPhotoHA::SIZE_SMALL_240_SHORT) . "\" />";
    $sizes = $flickr->getPhotoSize($photo);
    //var_dump($sizes);
    $originalSize = FlickrPhotoHA::getOriginalSize($sizes);
    $originalSource = FlickrPhotoHA::getNamedSize(FlickrPhotoHA::SIZE_ORIGINAL, $sizes);
    $xlSource = FlickrPhotoHA::getNamedSize(FlickrPhotoHA::SIZE_LARGE_1600, $sizes);
    if ($originalSource) {
        $originalSource = $originalSource->source;
    }
    if ($xlSource) {
        $xlSource = $xlSource->source;
    }
    $sizes = FlickrPhotoHA::sizeListToValue($sizes);
    echo "<p>Sizes:" . $sizes . "</p>";
    echo "<p>Id:" . $photo->id . "</p>";
    echo "<p>originalSource:" . $originalSource . "</p>";
    echo "<p>xlSource:" . $xlSource . "</p>";
    #$comments = $flickr->getPhotoComments($photo);
    $info = $flickr->getPhotoInfo($photo->id);
    $description = $info->photo->description;
    if (!$description) {
        $description = "";
    } else {
        $description = $description->_content;
    }
    echo "<p>description:" . $description . "</p>";
    if ($description && (strpos($description, "hidden") !== false || strpos($description, "hide") !== false)) {
        $flickrDB->deletePhoto($config->sets[$setName]->setId, $photo);