discovery.action.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | FANWE 直播系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class discoveryCModule extends baseCModule
  10. {
  11. //推荐
  12. public function index()
  13. {
  14. if(!$GLOBALS['user_info']){
  15. $user_id = 0;
  16. }else{
  17. $user_id = intval($GLOBALS['user_info']['id']);
  18. }
  19. $page = intval($_REQUEST['page'])?intval($_REQUEST['page']):1;
  20. $root = array(
  21. 'has_next'=>1,
  22. 'page'=>$page,
  23. 'status'=>1,
  24. 'error'=>''
  25. );
  26. $page_size =20;
  27. $list = load_auto_cache("select_weibo_recommond",array('page'=>$page,'page_size'=>$page_size,'user_id'=>$user_id));
  28. $root['list'] = $list;
  29. if(count($list)==$page_size){
  30. $root['has_next'] = 1;
  31. }else{
  32. $root['has_next'] = 0;
  33. }
  34. api_ajax_return($root);
  35. }
  36. //附近的人
  37. public function nearby_list(){
  38. $page = intval($_REQUEST['page'])?intval($_REQUEST['page']):1;
  39. $xpoint = floatval($_REQUEST['xpoint']);
  40. $ypoint = floatval($_REQUEST['ypoint']);
  41. $type = intval($_REQUEST['type']);
  42. $page_size = 20;
  43. $limit = (($page-1) * $page_size) . "," . $page_size;
  44. $where = '';
  45. if($type>0){
  46. $where = ' and sex = '.$type;
  47. }
  48. $sql = "SELECT u.id as user_id,u.head_image,u.is_authentication,u.nick_name,u.sex,u.city,u.focus_count,u.fans_count,u.xpoint,u.ypoint,getDistance($ypoint,$xpoint,u.ypoint,u.xpoint) as distance FROM ".DB_PREFIX."user u WHERE 1=1 ".$where;
  49. $sql .= " order by getDistance($ypoint,$xpoint,u.ypoint,u.xpoint),u.id desc limit ".$limit;
  50. $list = $GLOBALS['db']->getAll($sql);
  51. foreach($list as $k=>$v){
  52. if($v){
  53. $list[$k]['head_image'] = deal_weio_image($v['head_image']);
  54. }
  55. }
  56. $root = array(
  57. 'list'=>$list,
  58. 'has_next'=>1,
  59. 'page'=>$page,
  60. 'status'=>1,
  61. 'error'=>''
  62. );
  63. if(count($list)==$page_size){
  64. $root['has_next'] = 1;
  65. }else{
  66. $root['has_next'] = 0;
  67. }
  68. api_ajax_return($root);
  69. }
  70. }
  71. ?>