Beispiel #1
0
     $u = $flickr->people_getInfo($u['id']);
     $template->assign(array('username' => $u['username'], 'profile_url' => $u['profileurl'], 'logout_url' => FLICKR_ADMIN . '-import&action=logout', 'list_albums_url' => FLICKR_ADMIN . '-import&action=list_albums', 'import_all_url' => FLICKR_ADMIN . '-import&action=list_all'));
     break;
     // list user albums
 // list user albums
 case 'list_albums':
     // all albums
     $albums = $flickr->photosets_getList($u['id']);
     $total_albums = $albums['total'];
     $albums = $albums['photoset'];
     foreach ($albums as &$album) {
         $album['U_LIST'] = FLICKR_ADMIN . '-import&action=list_photos&album=' . $album['id'];
     }
     unset($album);
     // not classed
     $wo_albums = $flickr->photos_getNotInSet(NULL, NULL, NULL, NULL, 'photos', NULL, NULL, 1);
     if ($wo_albums['photos']['total'] > 0) {
         $albums[] = array('id' => 'not_in_set', 'title' => l10n('Pictures without album'), 'description' => null, 'photos' => $wo_albums['photos']['total'], 'U_LIST' => FLICKR_ADMIN . '-import&action=list_photos&album=not_in_set');
     }
     $template->assign(array('total_albums' => $total_albums, 'albums' => $albums));
     break;
     // list photos of an album
 // list photos of an album
 case 'list_photos':
     $self_url = FLICKR_ADMIN . '-import&action=list_photos&album=' . $_GET['album'];
     $flickr_prefix = 'flickr-' . $u['username'] . '-';
     $flickr_root_url = $flickr->urls_getUserPhotos($u['id']);
     // pagination
     if (isset($_GET['start'])) {
         $page['start'] = intval($_GET['start']);
     } else {
Beispiel #2
0
        }
        if (!is_null($url)) {
            $dir = escapeshellarg("photos/{$set['title']}");
            $filename = parse_url($url, PHP_URL_PATH);
            // Only download if file does not exist...
            if (!file_exists("photos/{$set['title']}/{$filename}")) {
                shell_exec("cd {$dir}; /usr/bin/curl -O {$url}");
            }
        }
        // This helps stop the Flickr API from getting angry
        sleep(1);
    }
}
// Download all photos not in a set
echo "### No Set\n";
$photos = $f->photos_getNotInSet();
foreach ($photos['photos']['photo'] as $photo) {
    $url = null;
    $sizes = $f->photos_getSizes($photo['id']);
    foreach ($sizes as $size) {
        if ($size['label'] == 'Original') {
            $url = $size['source'];
        }
    }
    if (isset($url)) {
        @mkdir("photos/No Set", 0777, true);
        $dir = escapeshellarg("photos/No Set");
        shell_exec("cd {$dir}; /usr/bin/curl -O {$url}");
    }
}
echo "Done!\n";