common.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <?php
  2. /**
  3. *
  4. * @param unknown_type $to_user_id 被查看的人
  5. * @param unknown_type $user_id 查看人
  6. * @return Ambigous <mixed, multitype:number unknown mixed >
  7. */
  8. function get_weibo_userinfo($to_user_id,$user_id=0,$page=1,$page_size=20,$pay_type= array()){
  9. $root = array();
  10. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserFollwRedisService.php');
  11. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  12. if($page==1){
  13. // $user_redis = new UserRedisService();
  14. // $fields = array('id','fans_count','focus_count','is_authentication','authentication_type','nick_name','signature','sex','province','city','head_image',
  15. // 'user_level','v_type','v_explain','v_icon',
  16. // 'is_remind','birthday','job',
  17. // 'is_robot','room_title','is_nospeaking',
  18. // 'show_image','weibo_count','weixin_account','weixin_price','xpoint','ypoint','weibo_money','weibo_refund_money','weibo_photo_img','weibo_chat_price'
  19. // );
  20. //$userinfo = $user_redis->getRow_db($to_user_id,$fields);
  21. $userinfo = $GLOBALS['db']->getRow("select id,fans_count,focus_count,is_authentication,authentication_type,nick_name,signature,sex,province,city,head_image,user_level,v_type,v_explain,v_icon,is_remind,birthday,job,is_robot,room_title,is_nospeaking,show_image,weibo_count,weixin_account,
  22. weixin_price,xpoint,ypoint,weibo_money,weibo_refund_money,weibo_photo_img,weibo_chat_price from ".DB_PREFIX."user where id =$to_user_id");
  23. if($userinfo['id'] === false){
  24. $userinfo['id'] = $user_id;
  25. }
  26. foreach($userinfo as $k=>$v){
  27. if($v===false){
  28. if($k=='city'||$k=='head_image'||$k=='v_explain'||$k=='v_icon'){
  29. $userinfo[$k] = '';
  30. }elseif($k=='user_level'){
  31. $userinfo[$k] = 1;
  32. }
  33. else{
  34. $userinfo[$k] = intval($v);
  35. }
  36. }
  37. }
  38. $userinfo['signature'] = htmlspecialchars_decode($userinfo['signature']);
  39. $userinfo['nick_name'] = htmlspecialchars_decode($userinfo['nick_name']);
  40. $userinfo['user_id'] = $to_user_id;
  41. if($userinfo['show_image']){
  42. $userinfo['show_image'] = unserialize( $userinfo['show_image']);
  43. foreach($userinfo['show_image'] as $k=>$v){
  44. if($v){
  45. $userinfo['show_image'][$k] = array(
  46. 'url'=>get_spec_image($v,100,100,1),
  47. 'is_model'=>0,
  48. 'orginal_url'=>get_spec_image($v)
  49. );
  50. }
  51. }
  52. }else{
  53. $userinfo['show_image'] = array();
  54. }
  55. $userinfo['head_image'] = deal_weio_image($userinfo['head_image'],'head_image');
  56. if($userinfo['weibo_photo_img']){
  57. $userinfo['weibo_photo_img'] = get_spec_image($userinfo['weibo_photo_img'],320,180,1);
  58. }else{
  59. $userinfo['weibo_photo_img'] = '';
  60. }
  61. if($user_id==$to_user_id){
  62. $root['is_admin'] = 1;
  63. $root['is_edit_weixin'] = 1;
  64. $root['is_show_money'] = 1;
  65. $root['is_show_talk'] = 0;
  66. $root['is_show_ds'] = 0;
  67. $userinfo['money'] = $userinfo['weibo_money'];
  68. $now=get_gmtime();
  69. $create_time_1=to_date($now,'Y-m-d');
  70. $create_time_1=to_timespan($create_time_1);
  71. $create_time_2=$create_time_1+24*3600;
  72. $today_money = $GLOBALS['db']->getOne("select sum(money) from ".DB_PREFIX."payment_notice where to_user_id = ".$user_id." and is_paid = 1 and create_time >$create_time_1 and create_time<$create_time_2 ");
  73. $userinfo['today_money'] = floatval($today_money);
  74. $userinfo['has_focus'] = 0;
  75. $userinfo["has_weixin"] = 0;
  76. $userinfo['weibo_chatprice_hadpay'] = 1;
  77. }else{
  78. $root['is_admin'] = 0;
  79. $root['is_edit_weixin'] = 0;
  80. $root['is_show_money'] = 0;
  81. $root['is_show_talk'] = 1;
  82. $root['is_show_ds'] = 1;
  83. $userinfo['weibo_chatprice_hadpay'] = 0;;
  84. //关注
  85. $userfollw_redis = new UserFollwRedisService($user_id);
  86. if ($userfollw_redis->is_following($to_user_id)){
  87. $userinfo['has_focus'] = 1;//0:未关注;1:已关注
  88. }else{
  89. $userinfo['has_focus'] = 0;//0:未关注;1:已关注
  90. }
  91. $userinfo["has_weixin"] = 0;
  92. //是否支付过微信
  93. if($user_id>0){
  94. // $weixin_pay = $GLOBALS['db']->getOne("select order_id from ".DB_PREFIX."payment_notice where user_id = ".$user_id." and is_paid =1 and type_cate = 'weixin' and to_user_id = ".$to_user_id);
  95. // if($weixin_pay){
  96. // $userinfo['weibo_chatprice_hadpay'] = 1;
  97. // }
  98. $weixin_pay = $GLOBALS['db']->getOne("select sum(money) from ".DB_PREFIX."payment_notice where user_id = ".$user_id." and is_paid =1 and type_cate = 'reward' and to_user_id = ".$to_user_id);
  99. if($weixin_pay >= $userinfo['weibo_chat_price']){
  100. $userinfo['weibo_chatprice_hadpay'] = 1;
  101. }
  102. }
  103. }
  104. $root['user'] = $userinfo;
  105. }
  106. $root['is_focus'] = 0;
  107. if($to_user_id==$user_id) {
  108. $list = load_auto_cache("select_weibo_list", array('page' => $page, 'page_size' => $page_size, 'user_id' => $user_id));
  109. }else{
  110. $list = load_auto_cache("select_weibo_other_list", array('page' => $page, 'page_size' => $page_size, 'to_user_id' => $to_user_id));
  111. if($user_id>0){
  112. $pay_digg_list = load_auto_cache("select_user_pay_list",array('page'=>$page,'page_size'=>$page_size,'user_id'=>$user_id));
  113. $order_list_array = $pay_digg_list['order'];
  114. $diggs_array = $pay_digg_list['digg'];
  115. //$root['is_focus'] = 0;
  116. $user_redis = new UserFollwRedisService($user_id);
  117. $root['is_focus'] = intval( $user_redis->is_following($to_user_id));
  118. }else{
  119. $order_list_array = array();
  120. $diggs_array = array();
  121. }
  122. foreach($list as $k=>$v){
  123. if(in_array($v['weibo_id'],$diggs_array)){
  124. $list[$k]['has_digg'] = 1;
  125. }
  126. if($user_id !=$v['user_id']){
  127. $list[$k]['is_top'] = 0;
  128. }
  129. if($v['price']>0&&in_array($v['type'],$pay_type)){
  130. if(in_array($v['weibo_id'],$order_list_array)){
  131. $is_pay =1;
  132. }else{
  133. $is_pay =0;
  134. }
  135. if($list[$k]['images_count']>0){
  136. $images = $list[$k]['images'] ;
  137. foreach($images as $k1=>$v1){
  138. if($v1['is_model']){
  139. if($is_pay){
  140. $images[$k1]['url'] = deal_weio_image($v1['url']);
  141. $images[$k1]['is_model'] = 0;
  142. $images[$k1]['orginal_url'] = get_spec_image($v1['url']);
  143. }else{
  144. $images[$k1]['url'] = deal_weio_image($v1['url'],$v['type'],1);
  145. $images[$k1]['orginal_url'] = '';
  146. }
  147. }
  148. }
  149. $list[$k]['images'] = $images;
  150. }
  151. }
  152. }
  153. }
  154. if(count($list)==$page_size){
  155. $root['has_next'] = 1;
  156. }else{
  157. $root['has_next'] = 0;
  158. }
  159. $root['list'] = $list;
  160. $root['page'] = $page;
  161. $root['status'] = 1;
  162. $root['error'] = 0;
  163. return $root;
  164. }
  165. function time_tran($the_time)
  166. {
  167. $now_time = to_date(NOW_TIME,"Y-m-d H:i:s");
  168. $now_time = to_timespan($now_time);
  169. $show_time = to_timespan($the_time);
  170. $dur = $now_time - $show_time;
  171. if ($dur < 0) {
  172. return to_date($show_time,"Y-m-d");
  173. } else {
  174. if ($dur < 60) {
  175. return $dur . '秒前';
  176. } else {
  177. if ($dur < 3600) {
  178. return floor($dur / 60) . '分钟前';
  179. } else {
  180. if ($dur < 86400) {
  181. return floor($dur / 3600) . '小时前';
  182. } else {
  183. if ($dur < 2592000) {//30天内
  184. return floor($dur / 86400) . '天前';
  185. } else {
  186. return to_date($show_time,"Y-m-d");
  187. }
  188. }
  189. }
  190. }
  191. }
  192. }
  193. function get_file_oss_url($url){
  194. if($url){
  195. $pos = strpos($url, $GLOBALS['distribution_cfg']['OSS_DOMAIN']);
  196. $httppos = strpos($url, 'http');
  197. if ($pos === false && $httppos === false) {
  198. $url = str_replace("./public/", "/public/", $url);
  199. return $GLOBALS['distribution_cfg']['OSS_DOMAIN'] . $url;
  200. }else{
  201. return $url;
  202. }
  203. }
  204. }
  205. function deal_weio_image($url,$type='',$is_mode=0){
  206. if($type==''){
  207. return get_spec_image($url,200,200,1);
  208. }
  209. if($is_mode==0){
  210. switch($type){
  211. case 'photo_info':
  212. return get_spec_image($url,375,210,1);
  213. break;
  214. case 'video':
  215. if (defined('OPEN_SVIDEO_MODULE') && OPEN_SVIDEO_MODULE) {
  216. return get_spec_image($url,250,250,1);
  217. } else {
  218. return get_spec_image($url,250,140,1);
  219. }
  220. break;
  221. case 'video_info':
  222. return get_spec_image($url,375,210,1);
  223. break;
  224. case 'head_image':
  225. return get_spec_image($url,300,300,1);
  226. break;
  227. default:
  228. return get_spec_image($url,200,200,1);
  229. break;
  230. }
  231. }else{
  232. switch($type){
  233. case 'photo_info':
  234. return get_spec_image($url,375,210,1,30,15);
  235. break;
  236. case 'video_info':
  237. return get_spec_image($url,375,210,1,30,15);
  238. break;
  239. default:
  240. return get_spec_image($url,200,200,1,30,15);
  241. break;
  242. }
  243. }
  244. }