Guest User

Untitled

a guest
Dec 12th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.05 KB | None | 0 0
  1. <?php
  2. global $_FANWE;
  3. $is_cate = false;
  4. $today_time = getTodayTime();
  5. $day7_time = $today_time - 604800;
  6. $img_width = $_FANWE['request']['width'];
  7. $cate_id = urldecode($_FANWE['request']['cate']);
  8. $sort_field = $_FANWE['request']['sort'];
  9. $page_num = intval($_FANWE['setting']['share_index_page'])?intval($_FANWE['setting']['share_index_page']):30;
  10.  
  11. $is_cate = false;
  12.  
  13. if($cate_id)
  14. {
  15. $is_cate = true;
  16. }
  17.  
  18. if($is_cate)
  19. {
  20.  
  21. $condition .= " AND als.cid = ".$cate_id;
  22. $join_sql = ' LEFT JOIN '.FDB::table('album_share').' AS als ON als.share_id = s.share_id ';
  23. }
  24.  
  25. $audit_index=intval($_FANWE['setting']['audit_index']);
  26. if($audit_index){
  27. $condition .= " AND s.status =1 ";
  28.  
  29. }
  30.  
  31. $page = intval($_REQUEST['p']);
  32. $limit = (($page - 1)*$page_num).",".$page_num;
  33. $next_limit = ($page *$page_num).","."1";
  34. $field = ",(s.create_time > $day7_time) AS time_sort ";
  35. $sort = " ";
  36. if($sort_field == 'collect_count')
  37. {
  38. $sort = " ORDER BY s.collect_count DESC ";
  39. }
  40. else
  41. {
  42. $sort = " ORDER BY s.share_id DESC ";
  43. }
  44.  
  45.  
  46. $sql = 'SELECT DISTINCT(s.share_id),s.uid,s.content,s.collect_count,s.comment_count,s.create_time,s.cache_data ,s.parent_id '.$field.'
  47. FROM '.FDB::table('share').' AS s '.$join_sql.' where s.share_data <> '." 'default' ".$condition .$sort.' LIMIT '.$limit;
  48.  
  49. echo "test11";
  50. $next_sql = 'SELECT DISTINCT(s.share_id),s.uid,s.content,s.collect_count,s.comment_count,s.create_time,s.cache_data ,s.parent_id '.$field.'
  51. FROM '.FDB::table('share').' AS s '.$join_sql.' where s.share_data <> '." 'default' ".$condition .$sort.' LIMIT '.$next_limit;
  52. $hasNextPage = FDB::fetchAll($next_sql);
  53. if($hasNextPage)
  54. {
  55. $is_next = 1;
  56. }
  57. else
  58. {
  59. $is_next = 0;
  60. }
  61.  
  62. $share_list = FDB::fetchAll($sql);
  63. $scale = 1;
  64.  
  65. if($share_list)
  66. {
  67. $share_list = FS('Share')->getShareDetailList($share_list,false,false,false,true,2);
  68.  
  69. $list = array();
  70. $current_user = array();
  71. $current_user['u_url'] = FU('u/index',array('uid'=>$_FANWE['uid']));
  72. $current_user['avt'] = avatar($_FANWE['uid'], 's', $is_src = 1);
  73. $i = 0;
  74.  
  75. foreach($share_list as $k => $v)
  76. {
  77. $list[$i] = $v;
  78. $img = FDB::fetchFirst("select img,img_height,img_width from ".FDB::table("share_photo")." where share_id = ".$v['share_id']." and img <> '' ");
  79.  
  80. $img_url = getImgName($img['img'],$img_width,999,2,true);
  81.  
  82. $list[$i]['share_img'] = $img_url;
  83.  
  84. $list[$i]['height'] = $img['img_height'] * ($img_width / $img['img_width']);
  85.  
  86. $list[$i]['height'] = round($list[$i]['height'] / $scale);
  87.  
  88. $list[$i]['width'] = $img_width;
  89.  
  90. $list[$i]['avt'] = avatar($v['uid'], 's', $is_src = 1);
  91.  
  92. $parent_id = FDB::resultFirst("select parent_id from ".FDB::table("share")." where share_id = ".$v['share_id']);
  93. if($parent_id == 0)
  94. {
  95. $list[$i]['isOriginal'] = 1;
  96. }
  97. else
  98. {
  99. $list[$i]['isOriginal'] = 0;
  100. }
  101. $list[$i]['likeStatus'] = FS('Share')->getIsCollectByUid($v['share_id'],$_FANWE['uid'])?1:0;
  102.  
  103. $list[$i]['isMe'] = $v['uid'] == $_FANWE['uid']?1:0;
  104. $list[$i]['is_relay'] = $v['is_relay'];
  105. //分享评论
  106. $share_comments = FS('Share')->getShareCommentList($v['share_id'],'0,2');
  107. if($share_comments)
  108. {
  109. $share_comments_data = array();
  110. $idxj = 0;
  111. foreach($share_comments as $vv)
  112. {
  113. $share_comments_data[$idxj]['comment_id'] = $vv['comment_id'];
  114. $share_comments_data[$idxj]['parent_id'] = $vv['parent_id'];
  115. $share_comments_data[$idxj]['user_url'] = FU('u/album',array('uid'=>$vv['user']['uid']));
  116. $share_comments_data[$idxj]['user_name'] = $vv['user']['user_name'];
  117. $share_comments_data[$idxj]['avt'] = avatar($vv['uid'], 's', $is_src = 1);
  118. $share_comments_data[$idxj]['comment'] = cutStr($vv['content'],20);
  119. $idxj++;
  120. }
  121. $list[$i]['comments'] = $share_comments_data;
  122. }
  123.  
  124. $list[$i]['share_url'] = FU('note/index',array('sid'=>$v['share_id']));
  125. $list[$i]['u_url'] = FU('u/album',array('uid'=>$v['uid']));
  126. $list[$i]['relay_count'] = FDB::resultFirst("select relay_count from ".FDB::table("share")." where share_id = ".$v['share_id']);
  127. $album_sql = "select a.id,a.title from ".FDB::table('album_share')." as ah left join ".FDB::table('album')." as a on ah.album_id = a.id where ah.share_id = ".$v['share_id'];
  128. $album = FDB::fetchFirst($album_sql);
  129. if($album)
  130. {
  131. $list[$i]['album_title'] = $album['title'];
  132. $list[$i]['is_album'] = 1;
  133. $list[$i]['album_url'] = FU("album/show",array('id'=>$album['id']));
  134. }
  135. else {
  136. $list[$i]['album_title'] = "";
  137. $list[$i]['is_album'] = 0;
  138. $list[$i]['album_url'] = "";
  139. }
  140. $list[$i]['zf_count'] = 10;
  141. $list[$i]['xh_count'] = 20;
  142.  
  143. $list[$i]['user_name'] = FDB::resultFirst("select user_name from ".FDB::table('user')." where uid =".$v['uid']);
  144. $i++;
  145. }
  146.  
  147. //$share['uid'] == $uid
  148. //outputJson(array('list'=>$list,'status'=>1));
  149.  
  150. outputJson(array('result'=>$list,'current_user'=>$current_user,'status'=>1,'hasNextPage'=>$is_next));
  151. }
  152. else {
  153. outputJson(array('status'=>0,'hasNextPage'=>$is_next));
  154. }
  155.  
  156.  
  157.  
  158.  
  159.  
  160. ?>
Add Comment
Please, Sign In to add comment