phpcms 近期项目总结

$this->comment_db = pc_base::load_model('comment_model');   

$this->comment_db->table_name=$this->comment_db->db_tablepre."comment_data_1";   //重定义表名

 

//获取用户头像
$v2['avatar'] = get_memberavatar($vm['phpssouid']);

      

 

	if( from_weixin() ){		//判断是否是从威信端接入
		$jssdk = $this->_js_sdk();				//实例化类
		$sign_package = $jssdk->getSignPackage();		//调用获取微信签名的方法
		}else{
		  $sign_package = array('signature'=>false);	
		}

 

//查询收藏数量
            $this->coll = pc_base::load_model('favorite_model');
            $my_coll_num=$this->coll->select(array('userid'=>$userid),'*','','id desc');
            if ($my_coll_num) {
                //var_dump($my_coll_num);exit;
                foreach ($my_coll_num as $s => $sv) {
                    if ($sv['type']=="yp") {
                        $s_res=$this->yp->get_one(array("id"=>$sv['tid'],"catid"=>$sv['catid']));
                        if (!$s_res) {
                            unset($my_coll_num[$s]);
                        }
                    }
                    if ($sv['type']=="tv") {
                        $s_res=$this->db->get_one(array("id"=>$sv['tid'],"catid"=>$sv['catid']));
                        if (!$s_res) {
                            unset($my_coll_num[$s]);
                        }
                    }
                    
                }
                    $my_coll_num=count($my_coll_num);
            }else{
                $my_coll_num=0;
            }                                             //收藏数

 

   //浏览历史纪录
 private function _history($data){
       //     echo 1111;//exit;
      if(!$data || !is_array($data))
      {
        return false;
      }
      //判断cookie类里面是否有浏览记录
      if(param::get_cookie('history')){
        $history = unserialize(param::get_cookie('history'));
        array_unshift($history, $data); //在浏览记录顶部加入
        /* 去除重复记录 */
        $rows = array();
        foreach ($history as $v){
                                            //var_dump($v);exit;
          if(in_array($v, $rows)){
            continue;
          }
          $rows[] = $v;
        }
        /* 如果记录数量多余10则去除 */
        while (count($rows) > 10)
        {
          array_pop($rows); //弹出
        }
         param::set_cookie('history',serialize($rows),time()+3600*24*30,'/');
       
        return true;
        
      }
      else
      {
        $history = serialize(array($data));
        param::set_cookie('history',$history,time()+3600*24*30,'/');
        return true;
      }
    
    }

 

 

//展示最近四个浏览记录	

       $history=param::get_cookie('history');
            $history=unserialize($history);
            $history_four=array();
            $history_four[0]=$history[0];
            if ($history[1]) {
                $history_four[1]=$history[1];
            }
            if ($history[2]) {
                $history_four[2]=$history[2];
            }
            
            if ($history[3]) {
                $history_four[3]=$history[3];
            }
    foreach ($history_four as $kh => $vh) {
				if (!preg_match("/^\d+$/",$vh["id"]) && !preg_match("/^\d+$/",$vh['catid'])) {
				continue;
			}  //校验是否是乱码是否为空

				if ($vh["type"]=="tv") {
					$history_four[$kh]=$this->db->union_listinfo($this->db->db_tablepre.'longdTV',$this->db->db_tablepre.'longdTV_data','*'," m.id='".$vh['id']."' and m.catid='".$vh['catid']."'",'inputtime desc','m.id=s.id');
					if ($history_four[$kh]) {
						$history_four[$kh][0]["zjr"]=$history_four[$kh][0]['tv_zjr'];
						$history_four[$kh][0]["time"]=$history_four[$kh][0]['tv_time'];
						$history_four[$kh][0]["url"]="?m=wap&c=vedio&a=show&catid=".$vh["catid"]."&id=".$vh['id'];
					}
				};
				if($vh["type"]=="yp"){
					$history_four[$kh]=$this->yp->union_listinfo($this->yp->db_tablepre.'longdyp',$this->yp->db_tablepre.'longdyp_data','*'," m.id='".$vh['id']."' and m.catid='".$vh['catid']."'",'inputtime desc','m.id=s.id');
					if ($history_four[$kh]) {  //如果查询不到结果就不会有下面三个字段
						$history_four[$kh][0]["zjr"]=$history_four[$kh][0]['yp_zjr'];
						$history_four[$kh][0]["time"]=$history_four[$kh][0]['yp_time'];
						$history_four[$kh][0]["url"]="?m=wap&c=vedio&a=show_yp&catid=".$vh["catid"]."&id=".$vh['id'];
					}
				}

				if ($vh["type"]!="tv"&&$vh["type"]!="yp") {  //没有这个字段就销毁数组里这个键值对
					unset($history_four[$kh]);
				}

				if ($history_four[$kh][0]["readpoint"]=="0") {
					$history_four[$kh][0]["readpoint"]="免费";
				}elseif($history_four[$kh][0]["readpoint"]>0){
					$history_four[$kh][0]["readpoint"]="会员";
				}

			}
		
			foreach ($history_four as $n => $nu) {      //发现为空的就销毁当前键值对
					if ($nu[0]['url']=="") {
					unset($history_four[$n]);
				
				}
				
			}
			$history_four=array_values($history_four);  //重置键值

 

ajax 请求切换歌
    public function prev_one_yp(){
        $catid=$_GET['catid'];
        $id=$_GET['id'];
        $weizhi=$_GET['weizhi'];
        $category = $this->categorys[$catid];
        
        $modelid = $category['modelid'];
        $res_lm=$this->ca->get_one("catid=".$catid,"*");         //查询当前音频所在栏目的信息

        $sql="select m.*,s.* from v9_longdyp m left join v9_longdyp_data s on m.id=s.id where catid=".$catid;
        $res_yp=$this->yp ->query($sql);
        foreach ($res_yp as $key => $value) {
            $ress[$key]=$value;
        }
        // echo "<pre>";
        //var_dump($ress);exit;

        foreach ($ress as $k => $vv) {
            if ($vv['id']==$id  && $weizhi=="prev") {
        
                if ($k-1>=0) {
                    $vxx['id']=$ress[$k-1]['id'];
                    $vxx['catid']=$ress[$k-1]['catid'];
                    echo json_encode($vxx);
                }else{
                    $vxx="1";
                    echo json_encode($vxx);
                }
                
            }elseif ($vv['id']==$id && $weizhi=="next") {
                
                if (count($ress)>$k+1) {
                    $vxx['id']=$ress[$k+1]['id'];
                    $vxx['catid']=$ress[$k+1]['catid'];
                    echo json_encode($vxx);

                }else{
                    
                    $vxx="1";
                    echo json_encode($vxx);
                }
                
            }
        }
    }

 

   //日志
    public function do_log4php($data,$func){
        require_once(LOG4PHP_DIR . '/LoggerManager.php'); //加载日志类库
        $logger = LoggerManager::getLogger('vedio');
        $logger->debug("Entering wap module vedio class $func function:");
        $logger->debug("data: " . json_encode($data));
        // $logger->debug("json: " . json_encode($data));
        // $logger->debug("GET: " . json_encode($_GET));
        // $logger->debug("POST: " . json_encode($_POST));
        $logger->debug("Exit wap module vedio class $func function!");
        LoggerManager::shutdown();
    }
   

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值