当前位置: 首页>>代码示例>>PHP>>正文


PHP loadlib函数代码示例

本文整理汇总了PHP中loadlib函数的典型用法代码示例。如果您正苦于以下问题:PHP loadlib函数的具体用法?PHP loadlib怎么用?PHP loadlib使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了loadlib函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: api_dispatch

function api_dispatch($method)
{
    if (!$GLOBALS['cfg']['enable_feature_api']) {
        api_output_error(999, 'API disabled');
    }
    $method = filter_strict($method);
    $enc_method = htmlspecialchars($method);
    $methods = $GLOBALS['cfg']['api']['methods'];
    if (!$method || !isset($methods[$method])) {
        api_output_error(404, "Method '{$enc_method}' not found");
    }
    $method_row = $methods[$method];
    if (!$method_row['enabled']) {
        api_output_error(404, "Method '{$enc_method}' not found");
    }
    $method_row['name'] = $method;
    # TO DO: check API keys here
    # TO DO: actually check auth here (whatever that means...)
    if ($method_row['requires_auth']) {
        api_auth_ensure_auth($method_row);
    }
    if ($method_row['requires_crumb']) {
        api_auth_ensure_crumb($method_row);
    }
    loadlib($method_row['library']);
    $parts = explode(".", $method);
    $method = array_pop($parts);
    $func = "{$method_row['library']}_{$method}";
    call_user_func($func);
    exit;
}
开发者ID:nilswalk,项目名称:privatesquare,代码行数:31,代码来源:lib_api.php

示例2: api_dispatch

function api_dispatch()
{
    #
    # Output formats
    #
    $format = request_str('format');
    if ($format = request_str('format')) {
        if (in_array($format, $GLOBALS['cfg']['api']['formats']['valid'])) {
            $GLOBALS['cfg']['api']['formats']['current'] = $format;
        } else {
            $format = null;
        }
    }
    if (!$format) {
        $GLOBALS['cfg']['api']['formats']['current'] = $GLOBALS['cfg']['api']['formats']['default'];
    }
    #
    # Can I get a witness?
    #
    if (!$GLOBALS['cfg']['enable_feature_api']) {
        api_output_error(999, 'The API is currently disabled');
    }
    #
    # Is this a valid method?
    #
    $method = request_str('method');
    if (!$method) {
        api_output_error(404, 'Method not found');
    }
    if (!isset($GLOBALS['cfg']['api']['methods'][$method])) {
        api_output_error(404, 'Method not found');
    }
    $method_row = $GLOBALS['cfg']['api']['methods'][$method];
    if (!$method_row['enabled']) {
        api_output_error(404, 'Method not found');
    }
    $lib = $method_row['library'];
    loadlib($lib);
    $method = explode(".", $method);
    $function = $lib . "_" . array_pop($method);
    if (!function_exists($function)) {
        api_output_error(404, 'Method not found');
    }
    #
    # Auth-y bits
    #
    if ($method_row['required_login']) {
        # Please, to write me...
    }
    #
    # Go!
    #
    call_user_func($function);
    exit;
}
开发者ID:netcon-source,项目名称:dotspotting,代码行数:55,代码来源:lib_api.php

示例3: storage_s3_file_store

function storage_s3_file_store($object_id, $data, $more = array())
{
    if ($more['type']) {
        $type = $more['type'];
    } else {
        loadlib('mime_type');
        $type = mime_type_identify($object_id);
    }
    $put = s3_put(storage_s3_bucket(), array('id' => $object_id, 'acl' => 'public-read', 'content_type' => $type, 'data' => $data, 'meta' => array('date-synced' => time())));
    return $put;
}
开发者ID:nilswalk,项目名称:parallel-flickr,代码行数:11,代码来源:lib_storage_s3.php

示例4: flickr_push_subscriptions_is_push_backup

function flickr_push_subscriptions_is_push_backup(&$subscription)
{
    loadlib("flickr_backups");
    $owner = users_get_by_id($subscription['user_id']);
    if (!flickr_backups_is_registered_user($owner)) {
        return 0;
    }
    if (!flickr_backups_is_registered_subscription($subscription)) {
        return 0;
    }
    return 1;
}
开发者ID:nilswalk,项目名称:parallel-flickr,代码行数:12,代码来源:lib_flickr_push_subscriptions.php

示例5: api_privatesquare_venues_checkin

function api_privatesquare_venues_checkin()
{
    $venue_id = post_str("venue_id");
    $status_id = post_int32("status_id");
    if (!$venue_id) {
        api_output_error(999, "Missing venue ID");
    }
    if (!isset($status_id)) {
        api_output_error(999, "Missing status ID");
    }
    $fsq_user = foursquare_users_get_by_user_id($GLOBALS['cfg']['user']['id']);
    $checkin = array('user_id' => $GLOBALS['cfg']['user']['id'], 'venue_id' => $venue_id, 'status_id' => $status_id);
    # where am I?
    $venue = foursquare_venues_get_by_venue_id($venue_id);
    if (!$venue) {
        $rsp = foursquare_venues_archive_venue($venue_id);
        if ($rsp['ok']) {
            $venue = $rsp['venue'];
        }
    }
    if ($venue) {
        $checkin['locality'] = $venue['locality'];
        $checkin['latitude'] = $venue['latitude'];
        $checkin['longitude'] = $venue['longitude'];
    }
    # check to see if we're checking in to 4sq too
    if ($broadcast = post_str("broadcast")) {
        $method = 'checkins/add';
        $args = array('oauth_token' => $fsq_user['oauth_token'], 'venueId' => $venue_id, 'broadcast' => $broadcast);
        $more = array('method' => 'POST');
        $rsp = foursquare_api_call($method, $args, $more);
        if ($rsp['ok']) {
            $checkin['checkin_id'] = $rsp['rsp']['checkin']['id'];
        }
        # on error, then what?
    }
    if ($GLOBALS['cfg']['enable_feature_weather_tracking']) {
        loadlib("weather_google");
        $rsp = weather_google_conditions($checkin['latitude'], $checkin['longitude']);
        if ($rsp['ok']) {
            $conditions = $rsp['conditions'];
            $conditions['source'] = $rsp['source'];
            $checkin['weather'] = json_encode($conditions);
        }
    }
    $rsp = privatesquare_checkins_create($checkin);
    if (!$rsp['ok']) {
        api_output_error(999, "Check in failed");
    }
    $out = array('checkin' => $rsp['checkin']);
    api_output_ok($out);
}
开发者ID:nilswalk,项目名称:privatesquare,代码行数:52,代码来源:lib_api_privatesquare_venues.php

示例6: _cache_do_remote

function _cache_do_remote($method, $key, $data = null)
{
    $engine = trim($GLOBALS['cfg']['cache_remote_engine']);
    if (!$engine) {
        return array('ok' => 0, 'error' => 'Remote caching is not enabled');
    }
    $remote_lib = "cache_{$engine}";
    $remote_func = "cache_{$engine}_{$method}";
    $args = $data ? array($key, $data) : array($key);
    loadlib($remote_lib);
    $rsp = call_user_func_array($remote_func, $args);
    $rsp['cache_key'] = $key;
    $rsp['cache'] = $engine;
    return $rsp;
}
开发者ID:jacques,项目名称:flamework,代码行数:15,代码来源:lib_cache.php

示例7: flickr_photos_update_photo

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;
}
开发者ID:nilswalk,项目名称:parallel-flickr,代码行数:48,代码来源:lib_flickr_photos.php

示例8: enplacify_uri

function enplacify_uri($uri)
{
    foreach ($GLOBALS['cfg']['enplacify'] as $service => $data) {
        foreach ($data['uris'] as $pattern) {
            if (!preg_match($pattern, $uri)) {
                continue;
            }
            $service_lib = "enplacify_{$service}";
            $service_func = "enplacify_{$service}_uri";
            loadlib($service_lib);
            $rsp = call_user_func_array($service_func, array($uri));
            return $rsp;
        }
    }
    return array('ok' => 0, 'error' => 'failed to locate any valid services for URL');
}
开发者ID:netcon-source,项目名称:dotspotting,代码行数:16,代码来源:lib_enplacify.php

示例9: flickr_photos_metadata_fetch

function flickr_photos_metadata_fetch(&$photo, $inflate = 0)
{
    loadlib("flickr_api");
    loadlib("flickr_users");
    $flickr_user = flickr_users_get_by_user_id($photo['user_id']);
    $method = 'flickr.photos.getInfo';
    $args = array('photo_id' => $photo['id'], 'auth_token' => $flickr_user['auth_token']);
    $more = array();
    if (!$inflate) {
        $more['raw'] = 1;
    }
    $rsp = flickr_api_call($method, $args, $more);
    if ($rsp['ok']) {
        $data = $inflate ? $rsp['rsp'] : $rsp['body'];
        $rsp = okay(array('data' => $data));
    }
    return $rsp;
}
开发者ID:nilswalk,项目名称:parallel-flickr,代码行数:18,代码来源:lib_flickr_photos_metadata.php

示例10: api_auth_ensure_auth

function api_auth_ensure_auth(&$method, $key_row = null)
{
    $type = $GLOBALS['cfg']['api_auth_type'];
    $auth_lib = "api_auth_{$type}";
    $auth_func = "api_auth_{$type}_has_auth";
    try {
        loadlib($auth_lib);
    } catch (Exception $e) {
        return 0;
    }
    if (!function_exists($auth_func)) {
        return 0;
    }
    $rsp = call_user_func_array($auth_func, array($method, $key_row));
    if (!$rsp['ok']) {
        api_output_error($rsp['error_code'], $rsp['error']);
    }
    return $rsp;
}
开发者ID:whosonfirst,项目名称:flamework-api,代码行数:19,代码来源:lib_api_auth.php

示例11: flickr_photos_permissions_can_view_photo

function flickr_photos_permissions_can_view_photo(&$photo, $viewer_id = 0, $more = array())
{
    if ($viewer_id && $photo['user_id'] == $viewer_id) {
        return 1;
    }
    $perms_map = flickr_photos_permissions_map();
    $perms = $perms_map[$photo['perms']];
    if (!$viewer_id && $perms == 'public') {
        return 1;
    }
    if ($perms == 'public') {
        return 1;
    }
    if ($contact = flickr_contacts_get_contact($photo['user_id'], $viewer_id)) {
        $rel_map = flickr_contacts_relationship_map();
        $str_rel = $rel_map[$contact['rel']];
        if ($perms == 'friends' || $perms == 'family') {
            return $str_rel == $perms ? 1 : 0;
        }
        if ($perms == 'friends and family') {
            return in_array($str_rel, array('friends', 'family')) ? 1 : 0;
        }
    }
    # Note: this is predicated on the assumption that the user
    # actually has permissions to view the photo otherwise the
    # backup/import code would not have downloaded the photo; the
    # problem is not a flickr permissions issue but due to the
    # fact that the photo owner is not a registered parallel-flickr
    # user and hence their contact list is not present.
    # (20120607/straup)
    if ($viewer_id && isset($more['allow_if_is_faved'])) {
        loadlib("flickr_faves");
        $viewer = users_get_by_id($viewer_id);
        if (flickr_faves_is_faved_by_user($viewer, $photo['id'])) {
            return 1;
        }
    }
    return 0;
}
开发者ID:nilswalk,项目名称:parallel-flickr,代码行数:39,代码来源:lib_flickr_photos_permissions.php

示例12: foursquare_venues_archive_venue

function foursquare_venues_archive_venue($venue_id)
{
    loadlib("foursquare_users");
    loadlib("foursquare_api");
    loadlib("reverse_geoplanet");
    $fsq_user = foursquare_users_random_user();
    $method = "venues/{$venue_id}";
    $args = array('oauth_token' => $fsq_user['oauth_token']);
    $rsp = foursquare_api_call($method, $args);
    if (!$rsp['ok']) {
        return $rsp;
    }
    $data = $rsp['rsp']['venue'];
    $lat = $data['location']['lat'];
    $lon = $data['location']['lng'];
    $venue = array('venue_id' => $data['id'], 'name' => $data['name'], 'latitude' => $lat, 'longitude' => $lon, 'data' => json_encode($data));
    # might be better/easier to geocode string place names (20120121/straup)
    $geo_rsp = reverse_geoplanet($lat, $lon, $GLOBALS['cfg']['reverse_geoplanet_remote_endpoint']);
    if ($geo_rsp['ok']) {
        $venue['locality'] = $geo_rsp['data']['locality'];
    }
    return foursquare_venues_add_venue($venue);
}
开发者ID:nilswalk,项目名称:privatesquare,代码行数:23,代码来源:lib_foursquare_venues.php

示例13: loadlib

<?php

#
# $Id$
#
loadlib("maps");
#################################################################
function png_export_dots(&$dots, $more = array())
{
    $defaults = array('width' => 1024, 'height' => 768);
    $more = array_merge($defaults, $more);
    list($map, $img) = maps_image_for_dots($dots, $more);
    if (!$img) {
        return null;
    }
    imagepng($img, $more['path']);
    imagedestroy($img);
    return $more['path'];
}
#################################################################
开发者ID:netcon-source,项目名称:dotspotting,代码行数:20,代码来源:lib_png.php

示例14: loadlib

<?php

include "include/init.php";
loadlib("flickr_places");
loadlib("flickr_photos_places");
loadlib("flickr_photos_geo");
if (!$GLOBALS['cfg']['enable_feature_solr'] || !$GLOBALS['cfg']['enable_feature_places']) {
    error_disabled();
}
$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_by_ref("owner", $owner);
$GLOBALS['smarty']->assign("is_own", $is_own);
#
$woeid = get_int32("woeid");
if (!$woeid) {
    error_404();
}
$place = flickr_places_get_by_woeid($woeid);
if (!$place) {
    error_404();
}
$placetypes = flickr_places_valid_placetypes();
$hier = array();
# put this in _get_by_woeid? probably...
foreach ($placetypes as $type) {
    if (isset($place[$type])) {
        $woeid = $place[$type]['woeid'];
        $parts = explode(",", $place[$type]['_content']);
        $name = trim($parts[0]);
开发者ID:nilswalk,项目名称:parallel-flickr,代码行数:31,代码来源:flickr_photos_user_place.php

示例15: api_keys_delete

function api_keys_delete(&$key, $reason = '')
{
    loadlib("api_oauth2_access_tokens");
    $rsp = api_oauth2_access_tokens_delete_for_key($key);
    if (!$rsp['ok']) {
        return $rsp;
    }
    $update = array('deleted' => time());
    return api_keys_update($key, $update);
}
开发者ID:whosonfirst,项目名称:flamework-api,代码行数:10,代码来源:lib_api_keys.php


注:本文中的loadlib函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。