Home.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. // +—————————————————————————————————————————————————————————————————————
  3. // | Created by Yunbao
  4. // +—————————————————————————————————————————————————————————————————————
  5. // | Copyright (c) 2013~2022 http://www.yunbaokj.com All rights reserved.
  6. // +—————————————————————————————————————————————————————————————————————
  7. // | Author: https://gitee.com/yunbaokeji
  8. // +—————————————————————————————————————————————————————————————————————
  9. // | Date: 2022-04-30
  10. // +—————————————————————————————————————————————————————————————————————
  11. session_start();
  12. class Model_Home extends PhalApi_Model_NotORM {
  13. /* 搜索 */
  14. public function search($uid,$key,$p) {
  15. $pnum=50;
  16. $start=($p-1)*$pnum;
  17. $where=' user_type="2" and user_status=1 and ( id=? or user_nicename like ?) and id!=?';
  18. if($p!=1){
  19. $id=$_SESSION['search'];
  20. $where.=" and id < {$id}";
  21. }
  22. $result=DI()->notorm->user
  23. ->select("id,user_nicename,avatar,avatar_thumb,sex,signature,province,city,birthday,age")
  24. ->where($where,$key,'%'.$key.'%',$uid)
  25. ->order("id desc")
  26. ->limit($start,$pnum)
  27. ->fetchAll();
  28. foreach($result as $k=>$v){
  29. $result[$k]['isattention']=(string)isAttention($uid,$v['id']);
  30. $result[$k]['avatar']=get_upload_path($v['avatar']);
  31. $result[$k]['avatar_thumb']=get_upload_path($v['avatar_thumb']);
  32. if($v['age']<0){
  33. $result[$k]['age']="年龄未填写";
  34. }else{
  35. $result[$k]['age'].="岁";
  36. }
  37. if($v['city']==""){
  38. $result[$k]['city']="城市未填写";
  39. }
  40. $result[$k]['praise']=getPraises($v['id']);
  41. $result[$k]['fans']=getFans($v['id']);
  42. $result[$k]['follows']=getFollows($v['id']);
  43. unset($result[$k]['consumption']);
  44. }
  45. if($result){
  46. $last=array_slice($result,-1,1);
  47. $_SESSION['search']=$last[0]['id'];
  48. }
  49. return $result;
  50. }
  51. public function videoSearch($uid,$key,$p) {
  52. $pnum=50;
  53. $start=($p-1)*$pnum;
  54. $where="v.isdel=0 and v.status=1";
  55. $where.=" and (v.title like '%".$key."%' or u.user_nicename like '%".$key."%')";
  56. $prefix= DI()->config->get('dbs.tables.__default__.prefix');
  57. $result=DI()->notorm->user_video
  58. ->queryAll("select v.*,u.user_nicename,u.avatar from {$prefix}user_video v left join {$prefix}user u on v.uid=u.id where {$where} order by v.addtime desc limit {$start},{$pnum}");
  59. //敏感词树
  60. $tree=trieTreeBasic();
  61. foreach ($result as $k => $v) {
  62. $v=handleVideo($uid,$v,$tree);
  63. $result[$k]=$v;
  64. }
  65. return $result;
  66. }
  67. }