| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 | 
							- <?php
 
- // +—————————————————————————————————————————————————————————————————————
 
- // | Created by Yunbao
 
- // +—————————————————————————————————————————————————————————————————————
 
- // | Copyright (c) 2013~2022 http://www.yunbaokj.com All rights reserved.
 
- // +—————————————————————————————————————————————————————————————————————
 
- // | Author: https://gitee.com/yunbaokeji
 
- // +—————————————————————————————————————————————————————————————————————
 
- // | Date: 2022-02-17
 
- // +—————————————————————————————————————————————————————————————————————
 
- if (!session_id()) session_start();
 
- class Model_Home extends PhalApi_Model_NotORM {
 
-     protected $live_fields='uid,title,city,stream,pull,thumb,isvideo,type,type_val,anyway,starttime';
 
-      
 
-     
 
- 	/* 轮播 */
 
- 	public function getSlide($where){
 
- 		$rs=DI()->notorm->slide_item
 
- 			->select("image as slide_pic,url as slide_url")
 
- 			->where($where)
 
- 			->order("list_order asc")
 
- 			->fetchAll();
 
- 		foreach($rs as $k=>$v){
 
- 			$rs[$k]['slide_pic']=get_upload_path($v['slide_pic']);
 
- 		}				
 
- 		return $rs;
 
- 	}
 
- 	/* 热门主播 */
 
-     public function getHot($p) {
 
-         if($p<1){
 
-             $p=1;
 
-         }
 
- 		$pnum=50;
 
- 		$start=($p-1)*$pnum;
 
- 		$where=" islive= '1' ";
 
-         
 
-         if($p==1){
 
- 			$_SESSION['hot_starttime']=time();
 
- 			$hotvotes=DI()->notorm->live->where("islive= '1'")->max('hotvotes');
 
- 			$_SESSION['hot_hotvotes']=$hotvotes;
 
- 		}
 
-         
 
- 		if($p>1){
 
- 			$endtime=$_SESSION['hot_starttime'];
 
-             if($endtime){
 
-                 $where.=" and starttime < {$endtime}";
 
-             }
 
-             $hotvotes=$_SESSION['hot_hotvotes'];
 
-             if($hotvotes>0){
 
-                 $where.=" and hotvotes < {$hotvotes}";
 
-             }else{
 
-             	$where.=" and hotvotes = 0";
 
-             }
 
- 		}
 
- 		
 
- 		$result=DI()->notorm->live
 
-                     ->select($this->live_fields.',hotvotes')
 
-                     ->where($where)
 
-                     ->order('hotvotes desc,starttime desc')
 
-                     ->limit($start,$pnum)
 
-                     ->fetchAll();
 
-                     
 
- 		foreach($result as $k=>$v){
 
- 			$v=handleLive($v);     
 
-             $result[$k]=$v;
 
- 		}	
 
- 		if($result){
 
- 			$last=end($result);
 
- 			$_SESSION['hot_starttime']=$last['starttime'];
 
- 			$_SESSION['hot_hotvotes']=$last['hotvotes'];
 
- 		}
 
- 		return $result;
 
-     }
 
- 	
 
- 	
 
- 	
 
- 	
 
- 	
 
- 		
 
- 		/* 搜索 */
 
-     public function search($uid,$key,$p) {
 
-         if($p<1){
 
-             $p=1;
 
-         }
 
- 		$pnum=50;
 
- 		$start=($p-1)*$pnum;
 
- 		$where=' user_type="2" and ( id=? or user_nicename like ? ) and id!=?';
 
- 		if($p!=1){
 
- 			$id=$_SESSION['search'];
 
-             if($id){
 
-                 $where.=" and id < {$id}";
 
-             }
 
- 		}
 
- 		
 
- 		$result=DI()->notorm->user
 
- 				->select("id,user_nicename,avatar,sex,signature,consumption,votestotal")
 
- 				->where($where,$key,'%'.$key.'%',$uid)
 
- 				->order("id desc")
 
- 				->limit($start,$pnum)
 
- 				->fetchAll();
 
- 		foreach($result as $k=>$v){
 
- 			$v['level']=(string)getLevel($v['consumption']);
 
- 			$v['level_anchor']=(string)getLevelAnchor($v['votestotal']);
 
- 			$v['avatar']=get_upload_path($v['avatar']);
 
- 			unset($v['consumption']);
 
-             
 
-             $result[$k]=$v;
 
- 		}				
 
- 		
 
- 		if($result){
 
- 			$last=end($result);
 
- 			$_SESSION['search']=$last['id'];
 
- 		}
 
- 		
 
- 		return $result;
 
-     }
 
-     
 
-     /* 分类下直播 */
 
-     public function getClassLive($liveclassid,$p) {
 
-         if($p<1){
 
-             $p=1;
 
-         }
 
- 		$pnum=50;
 
- 		$start=0;
 
- 		$where=" islive='1' and liveclassid={$liveclassid}";
 
-         
 
- 		if($p!=1){
 
- 			$endtime=$_SESSION['getClassLive_starttime'];
 
-             if($endtime){
 
-                 $where.=" and starttime < {$endtime}";
 
-             }
 
- 			
 
- 		}
 
- 		$last_starttime=0;
 
- 		$result=DI()->notorm->live
 
- 				->select($this->live_fields)
 
- 				->where($where)
 
- 				->order("starttime desc")
 
- 				->limit(0,$pnum)
 
- 				->fetchAll();	
 
- 		foreach($result as $k=>$v){
 
- 			$v=handleLive($v);
 
-             $result[$k]=$v;
 
- 		}		
 
- 		if($result){
 
-             $last=end($result);
 
- 			$_SESSION['getClassLive_starttime']=$last['starttime'];
 
- 		}
 
- 		return $result;
 
-     }
 
- 	
 
-     
 
- 	
 
- }
 
 
  |