コード例 #1
0
function api_oauth2_grant_tokens_purge_cache(&$token)
{
    $cache_keys = array("oauth2_grant_token_{$token['code']}", "oauth2_grant_token_uk_{$token['user_id']}_{$token['api_key_id']}");
    foreach ($cache_keys as $key) {
        cache_unset($key);
    }
}
コード例 #2
0
function dots_search_extras_remove_dot(&$dot)
{
    $enc_id = AddSlashes($dot['id']);
    $sql = "DELETE FROM DotsSearchExtras WHERE dot_id='{$enc_id}'";
    $rsp = db_write($sql);
    if ($rsp['ok']) {
        $cache_key = "dots_search_extras_{$dot['id']}";
        cache_unset($cache_key);
    }
    return $rsp;
}
コード例 #3
0
function dots_lookup_update(&$dot, &$update)
{
    $cache_key = "dots_lookup_{$dot['id']}";
    cache_unset($cache_key);
    $hash = array();
    foreach ($update as $key => $value) {
        $hash[$key] = AddSlashes($value);
    }
    $enc_id = AddSlashes($dot['id']);
    $where = "dot_id={$enc_id}";
    return db_update('DotsLookup', $update, $where);
}
コード例 #4
0
function users_update_user(&$user, $update)
{
    foreach ($update as $k => $v) {
        $update[$k] = AddSlashes($v);
    }
    $rsp = db_update('Users', $update, "id={$user['id']}");
    if (!$rsp['ok']) {
        return $rsp;
    }
    $cache_key = "user_{$user['id']}";
    cache_unset($cache_key);
    return $rsp;
}
コード例 #5
0
ファイル: lib_users.php プロジェクト: whosonfirst/flamework
function users_update_user(&$user, $update)
{
    $hash = array();
    foreach ($update as $k => $v) {
        $hash[$k] = AddSlashes($v);
    }
    $ret = db_update_accounts('users', $hash, "id={$user['id']}");
    if (!$ret['ok']) {
        return $ret;
    }
    cache_unset("USER-{$user['id']}");
    return array('ok' => 1);
}
コード例 #6
0
function flickr_photos_metadata_refresh(&$photo)
{
    $rsp = flickr_photos_metadata_fetch($photo);
    if ($rsp['ok']) {
        $meta = flickr_photos_metadata_path($photo);
        # don't look now but we're calling private functions
        # loadlib("flickr_photos_import");
        # _flickr_photos_import_store($meta, $rsp['data']);
        $cache_key = "photos_meta_{$photo['id']}";
        cache_unset($cache_key);
    }
    return $rsp;
}
コード例 #7
0
function flickr_photos_update_photo(&$photo, $update)
{
    $cache_key = "photo_{$photo['id']}";
    #
    $lookup = flickr_photos_lookup_photo($photo['id']);
    if (!$lookup) {
        return;
    }
    $user = users_get_by_id($lookup['user_id']);
    $cluster_id = $user['cluster_id'];
    $enc_id = AddSlashes($photo['id']);
    $where = "id={$enc_id}";
    # see also: git:parallel-flickr/solr/conf/schema.xml
    $solr_fields = array('perms', 'geoperms', 'geocontext', 'media', 'latitude', 'longitude', 'accuracy', 'woeid', 'datetaken', 'dateupload', 'title', 'description');
    $solr_update = 0;
    $hash = array();
    foreach ($update as $k => $v) {
        $hash[$k] = AddSlashes($v);
        if (in_array($k, $solr_fields)) {
            $solr_update++;
        }
    }
    $rsp = db_update_users($cluster_id, 'FlickrPhotos', $hash, $where);
    if (!$rsp['ok']) {
        return $rsp;
    }
    cache_unset($cache_key);
    if ($GLOBALS['cfg']['enable_feature_solr'] && $solr_update) {
        $photo = flickr_photos_get_by_id($photo['id']);
        # This is a quick hack that may become permanent. Basically
        # we need to refetch the data in flickr.photos.getInfo in
        # order to update the solr db. Normally the _index_photo pulls
        # this information from disk; the files having been written
        # by the bin/backup_photos.php script. As I write this the www
        # server does not have write permissions on the static photos
        # directory. If it did, this whole problem would go away and in
        # the end that may be the simplest possible solution. Until then
        # we'll fetch the (meta) data directly from the API and force
        # feed it to the search indexer. If you're wondering: Yes, it means
        # that the local solr db and the actual JSON dump of photos.getInfo
        # will be out of sync but that will sort itself out the next
        # time bin/backup_photos.php is run (20111231/straup)
        loadlib("flickr_photos_metadata");
        $meta = flickr_photos_metadata_fetch($photo, 'inflate');
        flickr_photos_search_index_photo($photo, $meta);
    }
    return $rsp;
}
コード例 #8
0
function foursquare_users_update_user(&$foursquare_user, $update)
{
    $hash = array();
    foreach ($update as $k => $v) {
        $hash[$k] = AddSlashes($v);
    }
    $enc_id = AddSlashes($foursquare_user['user_id']);
    $where = "user_id='{$enc_id}'";
    $rsp = db_update('FoursquareUsers', $hash, $where);
    if ($rsp['ok']) {
        $foursquare_user = array_merge($foursquare_user, $update);
        # $cache_key = "foursquare_user_{$foursquare_user['foursquare_id']}";
        # cache_unset($cache_key);
        $cache_key = "foursquare_user_{$foursquare_user['user_id']}";
        cache_unset($cache_key);
    }
    return $rsp;
}
コード例 #9
0
function import_import_file(&$user, &$file, $more = array())
{
    if (!import_is_valid_mimetype($file, $more)) {
        return array('error' => 'invalid_mimetype', 'ok' => 0);
    }
    # Parse the file
    $process_rsp = import_process_file($file);
    if (!$process_rsp['ok']) {
        return $process_rsp;
    }
    #
    # store the data
    #
    $fingerprint = md5_file($file['path']);
    $label = $more['label'] ? $more['label'] : $process_rsp['label'];
    $import_more = array('return_dots' => $more['return_dots'], 'dots_index_on' => $more['dots_index_on'], 'label' => $label, 'mark_all_private' => $more['mark_all_private'], 'mime_type' => $file['type'], 'fingerprint' => $fingerprint, 'simplified' => $process_rsp['simplified'] ? 1 : 0);
    $import_rsp = import_process_data($user, $process_rsp['data'], $import_more);
    if (!$import_rsp['ok']) {
        return $import_rsp;
    }
    #
    # Hello new thing
    #
    $cache_key = "sheets_lookup_fingerprint_{$fingerprint}";
    cache_unset($cache_key);
    #
    # store the actual file?
    #
    if ($GLOBALS['cfg']['enable_feature_import_archive']) {
        loadlib("archive");
        $archive_rsp = archive_store_file($file, $import_rsp['sheet']);
        # throw an error if archiving fails?
    }
    #
    # happy happy
    #
    return $import_rsp;
}
コード例 #10
0
function api_keys_purge_cache(&$key)
{
    $cache_keys = array("api_key_id_{$key['id']}", "api_key_key_{$key['api_key']}");
    foreach ($cache_keys as $cache_key) {
        cache_unset($cache_key);
    }
}
コード例 #11
0
function api_oauth2_access_tokens_fetch_site_token($user = null)
{
    $now = time();
    $site_token = api_oauth2_access_tokens_get_site_token($user);
    if ($site_token && $site_token['expires'] <= $now) {
        $rsp = api_oauth2_access_tokens_delete($site_token);
        if ($rsp['ok']) {
            $user_id = $user ? $user['id'] : 0;
            $cache_key = "oauth2_access_token_site_{$user_id}";
            cache_unset($cache_key);
        }
        $site_token = null;
    }
    # TO DO: error handling / reporting
    if (!$site_token) {
        $rsp = api_oauth2_access_tokens_create_site_token($user);
        $site_token = $rsp['token'];
    }
    return $site_token;
}
コード例 #12
0
function invite_codes_delete(&$invite)
{
    $enc_code = AddSlashes($invite['code']);
    $sql = "DELETE FROM InviteCodes WHERE code='{$enc_code}'";
    $rsp = db_write('InviteCodes', $sql);
    if ($rsp['ok']) {
        $keys = array("invite_codes_code_{$invite['code']}", "invite_codes_email_{$invite['email']}");
        foreach ($keys as $k) {
            cache_unset($k);
        }
    }
    return $rsp;
}
コード例 #13
0
function flickr_users_path_aliases_update(&$path_alias, &$update)
{
    $insert = array();
    foreach ($update as $k => $v) {
        $insert[$k] = AddSlashes($v);
    }
    $enc_alias = AddSlashes($path_alias['path_alias']);
    $where = "path_alias='{$enc_alias}'";
    $rsp = db_update('FlickrUsersPathAliases', $update, $where);
    if ($rsp['ok']) {
        $cache_key = "flickr_users_path_alias_{$path_alias['path_alias']}";
        cache_unset($cache_key);
    }
    return $rsp;
}
コード例 #14
0
function dots_delete_dot(&$dot, $more = array())
{
    #
    # Update the search and extras table (check to see that
    # we haven't already done this, for example if we're in
    # the process of deleting a user or a sheet)
    #
    if (!isset($more['skip_update_search'])) {
        $search_rsp = dots_search_remove_dot($dot);
        if (!$search_rsp['ok']) {
            # What?
        }
        $extras_rsp = dots_search_extras_remove_dot($dot);
        if (!$extras_rsp['ok']) {
            # What?
        }
    }
    #
    # Okay. Let's start deleting the dot itself!
    #
    $user = users_get_by_id($dot['user_id']);
    $enc_id = AddSlashes($dot['id']);
    $sql = "DELETE FROM Dots WHERE id='{$enc_id}'";
    $rsp = db_write_users($user['cluster_id'], $sql);
    if (!$rsp['ok']) {
        return $rsp;
    }
    if (!isset($more['skip_update_sheet'])) {
        $sheet = sheets_get_sheet($dot['sheet_id']);
        $rsp2 = sheets_update_dot_count_for_sheet($sheet);
        $rsp['update_sheet_count'] = $rsp2['ok'];
    }
    #
    # Update the extras table
    #
    $extras_rsp = dots_search_extras_remove_dot($dot);
    if (!$extras_rsp['ok']) {
        # What?
    }
    #
    # Update the lookup table
    #
    $lookup_update = array('deleted' => time());
    $lookup_rsp = dots_lookup_update($dot, $lookup_update);
    if (!$lookup_rsp['ok']) {
        # What?
    }
    #
    if ($rsp['ok']) {
        $cache_keys = array("dot_{$dot['id']}", "dot_bookends_{$dot['id']}", "dot_bookends_{$dot['id']}_public", "dots_for_sheet_{$dot['sheet_id']}", "dots_for_sheet_{$dot['sheet_id']}_public", "dots_count_for_sheet_{$dot['sheet_id']}", "sheet_extent_{$dot['sheet_id']}", "sheet_extent_{$dot['sheet_id']}_public");
        foreach ($cache_keys as $key) {
            cache_unset($key);
        }
    }
    return $rsp;
}
コード例 #15
0
function sheets_update_sheet(&$sheet, $update)
{
    $user = users_get_by_id($sheet['user_id']);
    $enc_id = AddSlashes($sheet['id']);
    $where = "id='{$enc_id}'";
    foreach ($update as $k => $v) {
        $update[$k] = AddSlashes($v);
    }
    $update['last_modified'] = time();
    $rsp = db_update_users($user['cluster_id'], 'Sheets', $update, $where);
    if ($rsp['ok']) {
        $cache_keys = array("sheet_{$sheet['id']}");
        foreach ($cache_keys as $key) {
            cache_unset($key);
        }
        export_cache_purge_sheet($sheet);
    }
    return $rsp;
}
コード例 #16
0
ファイル: user.php プロジェクト: iwarsong/seavpn
/**
 * 设置当前会话离线
 */
function user_offline_bysid($sid)
{
    cache_unset("sid_{$sid}");
    return true;
}
コード例 #17
0
function _flickr_push_subscriptions_purge_cache_keys(&$subscription)
{
    $secret_key = "flickr_push_subscriptions_secret_{$subscription['secret_url']}";
    $topic_key = "flickr_push_subscriptions_user_{$subscription['user_id']}_{$subscription['topic_id']}";
    if ($topic_args = $subscription['topic_args']) {
        $topic_key .= "#" . md5($topic_args);
    }
    $user_key = "flickr_push_subscriptions_for_user_{$subscription['user_id']}";
    $cache_keys = array($secret_key, $topic_key, $user_key);
    foreach ($cache_keys as $k) {
        cache_unset($k);
    }
}