function api_utils_ensure_pagination_args(&$args)
{
    if ($page = get_int32("page")) {
        $args['page'] = $page;
    }
    if ($per_page = get_int32("per_page")) {
        $args['per_page'] = $per_page;
    }
    if (!$args['page']) {
        $args['page'] = 1;
    }
    if (!$args['per_page']) {
        $args['per_page'] = $GLOBALS['cfg']['api_per_page_default'];
    } else {
        if ($args['per_page'] > $GLOBALS['cfg']['api_per_page_max']) {
            $args['per_page'] = $GLOBALS['cfg']['api_per_page_max'];
        }
    }
    # note the pass by ref
}
function api_flickr_photos_friends_faves()
{
    if (!$GLOBALS['cfg']['enable_feature_flickr_push']) {
        api_output_error(999, "disabled");
    }
    if (!$GLOBALS['cfg']['flickr_push_enable_photos_friends_faves']) {
        api_output_error(999, "disabled");
    }
    $topic_map = flickr_push_topic_map("string keys");
    $topic_id = $topic_map["contacts_faves"];
    $sub = flickr_push_subscriptions_get_by_user_and_topic($GLOBALS['cfg']['user'], $topic_id);
    if (!$sub) {
        api_output_error(999, "no subscription");
    }
    $older_than = get_int32("older_than");
    $rsp = flickr_push_photos_for_subscription($sub, $older_than);
    if (!$rsp['ok']) {
        api_output_error(999, $rsp['error']);
    }
    $out = array('photos' => $rsp['rows']);
    $more = array('inline' => 1);
    api_output_ok($out, $more);
}
Example #3
0
    error_404();
}
$history_url = "user/{$fsq_id}/history/";
login_ensure_loggedin($history_url);
$fsq_user = foursquare_users_get_by_foursquare_id($fsq_id);
if (!$fsq_user) {
    error_404();
}
$owner = users_get_by_id($fsq_user['user_id']);
$is_own = $owner['id'] == $GLOBALS['cfg']['user']['id'] ? 1 : 0;
# for now...
if (!$is_own) {
    error_403();
}
$more = array();
if ($page = get_int32("page")) {
    $more['page'] = $page;
}
if ($when = get_str("when")) {
    $more['when'] = $when;
    $history_url .= urlencode($when) . "/";
    # TO DO: find some better heuristic for this number
    # besides "pull it out of my ass" (20120206/straup)
    $more['per_page'] = 100;
}
$more['inflate_locality'] = 1;
$rsp = privatesquare_checkins_for_user($owner, $more);
# TO DO: oh god...timezones :-(
if ($when) {
    list($start, $stop) = datetime_when_parse($more['when']);
    $GLOBALS['smarty']->assign("when", $when);
<?php

include "../include/init.php";
loadlib("god");
features_ensure_enabled("flickr_push");
loadlib("flickr_push");
loadlib("flickr_backups");
loadlib("flickr_push_photos");
loadlib("flickr_push_subscriptions");
$id = get_int32("id");
$sub = flickr_push_subscriptions_get_by_id($id);
if (!$sub) {
    error_404();
}
$crumb_key = "delete_feed";
$GLOBALS['smarty']->assign("crumb_key", $crumb_key);
if (post_str("delete") && crumb_check($crumb_key)) {
    $feed_rsp = flickr_push_unsubscribe($sub);
    $GLOBALS['smarty']->assign("delete_feed", $feed_rsp);
    if ($feed_rsp['ok']) {
        $sub_rsp = flickr_push_subscriptions_delete($sub);
        $GLOBALS['smarty']->assign("delete_sub", $sub_rsp);
        if ($sub_rsp['ok']) {
            $redir = "{$GLOBALS['cfg']['abs_root_url']}god/push/subscriptions/{$sub['user_id']}/";
            header("location: {$redir}");
            exit;
        }
    }
}
$topic_map = flickr_push_topic_map();
$sub['str_topic'] = $topic_map[$sub['topic_id']];
<?php

include "include/init.php";
loadlib("flickr_users");
loadlib("flickr_photos");
loadlib("flickr_backups");
loadlib("flickr_photos_utils");
loadlib("flickr_urls");
loadlib("flickr_dates");
#
$flickr_user = flickr_users_get_by_url();
$owner = users_get_by_id($flickr_user['user_id']);
$is_own = $owner['id'] == $GLOBALS['cfg']['user']['id'] ? 1 : 0;
$GLOBALS['smarty']->assign("is_own", $is_own);
$is_registered = flickr_backups_is_registered_user($owner);
$GLOBALS['smarty']->assign("is_registered", $is_registered);
#
$more = array('page' => get_int32("page"), 'viewer_id' => $GLOBALS['cfg']['user']['id']);
$with = get_int64('with');
if ($with) {
    $more['with'] = $with;
}
$rsp = flickr_photos_for_user($owner, $more);
$photos = $rsp['rows'];
flickr_photos_utils_assign_can_view_geo($photos, $GLOBALS['cfg']['user']['id']);
$GLOBALS['smarty']->assign_by_ref("owner", $owner);
$GLOBALS['smarty']->assign_by_ref("photos", $photos);
$pagination_url = flickr_urls_photos_user($owner);
$GLOBALS['smarty']->assign("pagination_url", $pagination_url);
$GLOBALS['smarty']->display("page_flickr_photos_user.txt");
exit;
<?php

include "include/init.php";
loadlib("privatesquare_checkins");
loadlib("privatesquare_checkins_utils");
loadlib("foursquare_users");
$fsq_id = get_int32("foursquare_id");
if (!$fsq_id) {
    error_404();
}
$history_url = "user/{$fsq_id}/history/";
login_ensure_loggedin($history_url);
$fsq_user = foursquare_users_get_by_foursquare_id($fsq_id);
if (!$fsq_user) {
    error_404();
}
$owner = users_get_by_id($fsq_user['user_id']);
$is_own = $owner['id'] == $GLOBALS['cfg']['user']['id'] ? 1 : 0;
# for now...
if (!$is_own) {
    error_403();
}
$lat = get_float('latitude');
$lon = get_float('longitude');
if ($lat && $lon) {
    $more = array();
    if (get_float('dist')) {
        $more['dist'] = get_float('dist');
    }
    if (get_str('unit')) {
        $more['unit'] = get_str('unit');
<?php

include "include/init.php";
loadlib("flickr_users");
loadlib("flickr_photos");
loadlib("flickr_faves");
loadlib("flickr_urls");
loadlib("flickr_dates");
#
$viewer = $GLOBALS['cfg']['user'];
$flickr_user = flickr_users_get_by_url();
$owner = users_get_by_id($flickr_user['user_id']);
$is_own = $owner['id'] == $viewer['id'] ? 1 : 0;
$GLOBALS['smarty']->assign("is_own", $is_own);
#
$more = array('viewer_id' => $viewer['id'], 'page' => get_int32("page"));
if ($by_alias = get_str("by_alias")) {
    if ($by_flickr_user = flickr_users_get_by_path_alias($by_alias)) {
        $more['by_owner'] = users_get_by_id($by_flickr_user['user_id']);
    }
} else {
    if ($by_nsid = get_str("by_nsid")) {
        if ($by_flickr_user = flickr_users_get_by_nsid($by_nsid)) {
            $more['by_owner'] = users_get_by_id($by_flickr_user['user_id']);
        }
    } else {
    }
}
$by_owner = isset($more['by_owner']) ? $more['by_owner'] : null;
$faves = flickr_faves_for_user($owner, $more);
$photos = array();
Example #8
0
<?php

include "../include/init.php";
loadlib("god");
$page = ($p = get_int32("page")) ? $p : 1;
$args = array('page' => $page);
$rsp = users_get_users($args);
$users = array();
if ($rsp['ok']) {
    foreach ($rsp['rows'] as $user) {
        # get invite stuff here
        # get subscription stuff here
        $users[] = $user;
    }
    $GLOBALS['smarty']->assign_by_ref("users", $users);
} else {
    $GLOBALS['error']['db_error'] = 1;
    $GLOBALS['error']['details'] = $rsp['error'];
}
$GLOBALS['smarty']->assign("pagination_url", "/god/users/");
$GLOBALS['smarty']->display("page_god_users.txt");
exit;
<?php

#
# $Id$
#
include "include/init.php";
// pagination...
$more = array("page" => get_int32("page"));
$pagination_url = "{$GLOBALS['cfg']['abs_root_url']}recent/sheets/";
$GLOBALS['smarty']->assign("pagination_url", $pagination_url);
// go get sheets
$recent_sheets = sheets_recently_created($GLOBALS['cfg']['user_id'], $more);
$GLOBALS['smarty']->assign_by_ref("recent_sheets", $recent_sheets['sheets']);
// display sheets
$smarty->display('page_recent_sheets.txt');
exit;
<?php

include "include/init.php";
loadlib("flickr_users");
loadlib("flickr_photos");
loadlib("flickr_faves");
loadlib("flickr_urls");
loadlib("flickr_dates");
#
$flickr_user = flickr_users_get_by_url();
$owner = users_get_by_id($flickr_user['user_id']);
#
$more = array('page' => get_int32("page"));
$is_own = $owner['id'] == $GLOBALS['cfg']['user']['id'] ? 1 : 0;
$GLOBALS['smarty']->assign("is_own", $is_own);
$rsp = flickr_contacts_for_user($owner, $more);
$contacts = array();
foreach ($rsp['rows'] as $c) {
    $contact = users_get_by_id($c['contact_id']);
    $contact['count_photos'] = flickr_photos_count_for_user($contact, $GLOBALS['cfg']['user']['id']);
    # $contact['count_photos'] = contacts_get_faves_count($contacts, $GLOBALS['cfg']['user']['id']);
    $contacts[] = $contact;
}
$GLOBALS['smarty']->assign_by_ref("owner", $owner);
$GLOBALS['smarty']->assign_by_ref("contacts", $contacts);
$pagination_url = flickr_urls_contacts_user($owner);
$GLOBALS['smarty']->assign("pagination_url", $pagination_url);
$GLOBALS['smarty']->display("page_flickr_contacts_user.txt");
exit;
Example #11
0
<?php

#
# $Id$
#
include "include/init.php";
#################################################################
$owner = users_ensure_valid_user_from_url();
$smarty->assign_by_ref('owner', $owner);
#################################################################
$page = get_int32('page');
$args = array('page' => $page);
$sheets = sheets_sheets_for_user($owner, $GLOBALS['cfg']['user']['id'], $args);
$counts = sheets_counts_for_user($owner, $GLOBALS['cfg']['user']['id']);
$is_own = $owner['id'] == $GLOBALS['cfg']['user']['id'] ? 1 : 0;
$smarty->assign("is_own", $is_own);
$smarty->assign_by_ref('sheets', $sheets);
$smarty->assign_by_ref('counts', $counts);
$smarty->assign("pagination_url", urls_sheets_for_user($owner));
$smarty->display('page_user_sheets.txt');
exit;