}
}
$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);
 }
$flickr = new FlickrHA($config->flickr->apiKey, $config->flickr->secret, $config->flickr->tokenKey, $config->flickr->tokenSecret);
$flickrDB = new FlickrDB($flickr, $config->db);
$setName = isset($_REQUEST["setName"]) ? $_REQUEST["setName"] : false;
if (!$setName || !$config->sets[$setName]) {
    die("no set");
}
echo "<p>Delete old...</p>";
$flickrDB->deleteSetPhotos($config->sets[$setName]->setId);
echo "<p>Getting images for set " . $setName . "...</p>";
#$setId = "72157663923690755";
$json = $flickr->getSetPhotos($config->sets[$setName]->setId);
$i = 0;
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>";