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


PHP Stats::get_cached_place_name方法代码示例

本文整理汇总了PHP中Stats::get_cached_place_name方法的典型用法代码示例。如果您正苦于以下问题:PHP Stats::get_cached_place_name方法的具体用法?PHP Stats::get_cached_place_name怎么用?PHP Stats::get_cached_place_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stats的用法示例。


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

示例1: array

 * Sub-Ajax page, requires AJAX_INCLUDE
 */
if (!defined('AJAX_INCLUDE')) {
    exit;
}
$results = array();
switch ($_REQUEST['action']) {
    case 'geolocation':
        if (AmpConfig::get('geolocation')) {
            if ($GLOBALS['user']->id) {
                $latitude = floatval($_REQUEST['latitude']);
                $longitude = floatval($_REQUEST['longitude']);
                $name = $_REQUEST['name'];
                if (empty($name)) {
                    // First try to get from local cache (avoid external api requests)
                    $name = Stats::get_cached_place_name($latitude, $longitude);
                    if (empty($name)) {
                        foreach (Plugin::get_plugins('get_location_name') as $plugin_name) {
                            $plugin = new Plugin($plugin_name);
                            if ($plugin->load($GLOBALS['user'])) {
                                $name = $plugin->_plugin->get_location_name($latitude, $longitude);
                                if (!empty($name)) {
                                    break;
                                }
                            }
                        }
                    }
                }
                // Better to check for bugged values here and keep previous user good location
                // Someone listing music at 0.0,0.0 location would need a waterproof music player btw
                if ($latitude > 0 && $longitude > 0) {
开发者ID:cheese1,项目名称:ampache,代码行数:31,代码来源:stats.ajax.php

示例2: get_recently_played

 /**
  * get_recently_played
  * This function returns the last X songs that have been played
  * it uses the popular threshold to figure out how many to pull
  * it will only return unique object
  * @param int $user_id
  * @return array
  */
 public static function get_recently_played($user_id = 0)
 {
     $user_id = intval($user_id);
     $sql = "SELECT `object_id`, `user`, `object_type`, `date`, `agent`, `geo_latitude`, `geo_longitude`, `geo_name` " . "FROM `object_count` WHERE `object_type` = 'song' AND `count_type` = 'stream' ";
     if (AmpConfig::get('catalog_disable')) {
         $sql .= "AND " . Catalog::get_enable_filter('song', '`object_id`') . " ";
     }
     if ($user_id) {
         // If user is not empty, we're looking directly to user personal info (admin view)
         $sql .= "AND `user`='{$user_id}' ";
     } else {
         if (!Access::check('interface', '100')) {
             // If user identifier is empty, we need to retrieve only users which have allowed view of personnal info
             $personal_info_id = Preference::id_from_name('allow_personal_info_recent');
             if ($personal_info_id) {
                 $current_user = $GLOBALS['user']->id;
                 $sql .= "AND `user` IN (SELECT `user` FROM `user_preference` WHERE (`preference`='{$personal_info_id}' AND `value`='1') OR `user`='{$current_user}') ";
             }
         }
     }
     $sql .= "ORDER BY `date` DESC ";
     $db_results = Dba::read($sql);
     $results = array();
     while ($row = Dba::fetch_assoc($db_results)) {
         if (empty($row['geo_name']) && $row['latitude'] && $row['longitude']) {
             $row['geo_name'] = Stats::get_cached_place_name($row['latitude'], $row['longitude']);
         }
         $results[] = $row;
         if (count($results) >= AmpConfig::get('popular_threshold')) {
             break;
         }
     }
     return $results;
 }
开发者ID:nioc,项目名称:ampache,代码行数:42,代码来源:song.class.php


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