function api_flickr_photos_geo_correctLocation()
{
    $flickr_user = api_utils_flickr_ensure_token_perms($GLOBALS['cfg']['user'], 'write');
    $photo_id = post_int64("photo_id");
    $photo = _api_flickr_photos_geo_get_photo($photo_id);
    $old_woeid = $photo['woeid'];
    $new_woeid = post_int32("woeid");
    if (!$new_woeid) {
        api_output_error(999, "Missing WOE ID");
    }
    if ($old_woeid == $new_woeid) {
        api_output_error(999, "Nothing to correct!");
    }
    # validate WOE ID preemptively?
    $method = "flickr.photos.geo.correctLocation";
    $args = array('photo_id' => $photo['id'], 'woe_id' => $new_woeid, 'auth_token' => $flickr_user['auth_token']);
    $rsp = flickr_api_call($method, $args);
    if (!$rsp['ok']) {
        api_output_error(999, $rsp['error']);
    }
    $update = array('woeid' => $new_woeid);
    $rsp = flickr_photos_update_photo($photo, $update);
    if (!$rsp['ok']) {
        api_output_error(999, $rsp['error']);
    }
    # throw an error if this fails? feels like overkill...
    $correction = array('photo_id' => $photo['id'], 'user_id' => $photo['user_id'], 'old_woeid' => $old_woeid, 'new_woeid' => $new_woeid);
    flickr_photos_geo_corrections_create($correction);
    #
    $place = flickr_places_get_by_woeid($new_woeid);
    $out = array('photo_id' => $photo_id, 'woeid' => $new_woeid, 'place' => $place);
    api_output_ok($out);
}
function flickr_photos_import_photo($photo, $more = array())
{
    log_info("get ready to import a photo...");
    $user = flickr_users_ensure_user_account($photo['owner'], $photo['ownername']);
    if (!$user || !$user['id']) {
        return not_okay("failed to retrieve user (photo owner)");
    }
    $photo = _flickr_photos_import_prepare_photo($user, $photo);
    # log_info("photo..." . var_export($photo, 1));
    # TO DO: error handling...
    if ($_photo = flickr_photos_get_by_id($photo['id'])) {
        log_info("update photo {$photo['id']}");
        # TO DO: make this less stupid...
        unset($photo['id']);
        flickr_photos_update_photo($_photo, $photo);
        $photo = flickr_photos_get_by_id($_photo['id']);
    } else {
        log_info("add photo {$photo['id']}");
        $rsp = flickr_photos_add_photo($photo);
        if (!$rsp['ok']) {
            log_info("FAILED to add photo {$photo['id']} :" . var_export($rsp, 1));
            return $rsp;
        }
        flickr_photos_lookup_add($photo['id'], $photo['user_id']);
    }
    flickr_photos_import_photo_files($photo, $more);
    # exif data
    # why did I do this? (20111206/straup)
    # $more = array(
    # 	'force' => 1,
    # );
    if ($hasexif = flickr_photos_exif_has_exif($photo, $more)) {
        $update = array('hasexif' => 1);
        $rsp = flickr_photos_update_photo($photo, $update);
        # technically we'll have the old last_update date
        # but that shouldn't be a problem (20111121/straup)
        if ($rsp['ok']) {
            $photo = array_merge($photo, $update);
        }
    }
    # things that depend on solr (move to a separate function?)
    if ($GLOBALS['cfg']['enable_feature_solr']) {
        flickr_photos_search_index_photo($photo);
    }
    if ($GLOBALS['cfg']['enable_feature_solr'] && $GLOBALS['cfg']['enable_feature_places']) {
        if ($photo['woeid'] && $GLOBALS['cfg']['places_prefetch_data']) {
            flickr_places_get_by_woeid($photo['woeid']);
        }
    }
    # go!
    return okay(array('photo' => $photo));
}
function check_photo($row, $more = array())
{
    $photo = flickr_photos_get_by_id($row['id']);
    $more = array('force' => 1);
    $hasexif = flickr_photos_exif_has_exif($photo, $more);
    # echo "photo {$photo['id']} has exif: {$hasexif}\n";
    if ($hasexif) {
        $update = array('hasexif' => 1);
        $rsp = flickr_photos_update_photo($photo, $update);
        if (!$rsp['ok']) {
            echo "ack! failed to update {$photo['id']}: {$rsp['error']}\n";
        }
    }
}