<?php session_start();
include_once("conn/conn.php");
include_once("config.php");
include_once("top.php");
	$ll_sqlstr="select * from tb_video where tb_video_id=".$_GET[video_id]."";
	$ll_rst = $conn->execute($ll_sqlstr);
	$array=$ll_rst->GetRows();
if($array[0][tb_video_auditing]==0){
echo "您播放的视频未通过审核，不能播放，对不起！";
}else{
	//更新播放次数
	$update="update tb_video set tb_video_play=tb_video_play+1 where tb_video_id='".$_GET[video_id]."'";
	$c_rst = $conn->execute($update);
	//查询指定要播放的视频文件
	$l_sqlstr="select * from tb_video where tb_video_id=".$_GET[video_id]."";
	$l_rst = $conn->execute($l_sqlstr);
	$array=$l_rst->GetRows();
	$smarty->assign("video",$array);

	$video_id1=$_GET[video_id]-1;
	$l1_sqlstr="select * from tb_video where tb_video_id='$video_id1'";
	$l1_rst = $conn->execute($l1_sqlstr);
	$array1=$l1_rst->GetRows();
	$smarty->assign("video1",$array1);

	$video_id2=$_GET[video_id]+1;
	$l2_sqlstr="select * from tb_video where tb_video_id='$video_id2'";
	$l2_rst = $conn->execute($l2_sqlstr);
	$array2=$l2_rst->GetRows();
	$smarty->assign("video2",$array2);


	$i_sqlstr="select * from tb_video_type ";
	$i_rst = $conn->execute($i_sqlstr);
	$arraysi=$i_rst->GetRows();
	$smarty->assign("video_type",$arraysi);


//获取更多相关视频
require("splitword.php");			//进行分词处理
require("common/function.php");		//过滤标点
if($_GET){
$keyword=urldecode($_GET[video_name]);			//获取内容
}

$yuan=trim($keyword);
$tt= $yuan;

$str=gl($tt);

$sp = new SplitWord();
$sp->SplitRMM($str);
$tt=$sp->SplitRMM($str);
//$sp->Clear();

$str=array(" ","");				//定义一个数组
	$cc=str_replace($str,"",$tt);	//去掉字符串中的空格
	if(substr($cc,0,2)=="、"){
		$cc= substr($cc,2);			//去掉前面的“、”符号
	}
	if(substr($cc,-2,2)=="、"){
		$cc= substr($cc,0,-2);		//去掉后面的“、”符号
	}
	
	if(substr($cc,0,2)=="、" && substr($cc,-2,2)=="、"){
		$a= substr($cc,2);			//去掉前面的“、”符号
		$cc= substr($a,0,-2);		//去掉后面的“、”符号
	}
		$newstr = explode("、",$cc);			//应用explode()函数将字符串转换成数组
		
		if(count($newstr)==1){					//如果数组的元素个数为1个，则按单个条件进行查询
	$ls_sqlstr="select * from tb_video where tb_video_name like '%".$newstr[0]."%' limit 5";
	$ls_rst = $conn->execute($ls_sqlstr);
	$arrayll=$ls_rst->GetRows();
	$smarty->assign("videos",$arrayll);
		}else{

		for($j=0;$j<count($newstr);$j++){
			$sql1.=" tb_video_name like '%".trim($newstr[$j])."%'"." or";	
		}
		$sql1=substr($sql1,0,-3);				//去掉最后一个“or”		
		$ls_sqlstr="select * from tb_video where".$sql1." limit 5";

	$ls_rst = $conn->execute($ls_sqlstr);
	$arrayll=$ls_rst->GetRows();
	$smarty->assign("videos",$arrayll);

}

	$smarty->assign("tb_video_date",date("Y-m-d H:i:s"));	//获取当前时间

	if($_SESSION[name]==""){					//判断是否是会员登录
		$smarty->assign("name","F");
		$smarty->assign("name1","无名");
	}else{
		$smarty->assign("name2",$_SESSION[name]);
	}




	//获取有关该视频的评论信息
	$p_sqlstr="select * from tb_video_discuss where tb_video_id=".$_GET[video_id]."";
	$p_rst = $conn->execute($p_sqlstr);
	$arrays=$p_rst->GetRows();
	$total1=count($arrays);			//统计评论的次数
	//实现评论的分页输出
	if(empty($_GET[pages])==true || is_numeric($_GET[pages])==false){
		$page1=1;
	}else{
		$page1=intval($_GET[pages]);
	}
	if($total1==0){		//判断数据是否为空
		$smarty->assign("discuss_false","F");
	}else{ 
		$pagesize1=5;	//每页显示5条数据
	if($total1<$pagesize1){
		$pagecount1=1;
	}else{
		if($total1%$pagesize1==0){
			$pagecount1=intval($total1/$pagesize1);
		}else{
			$pagecount1=intval($total1/$pagesize1)+1;
		} 
	}
	$smarty->assign("total1",$total1);			//通过assign方法将数组$array中的数据写入到total1中      
	$smarty->assign("pagesize1",$pagesize1);	//通过assign方法将数组$array中的数据写入到pagesize1中      
	$smarty->assign("page1",$page1);			//通过assign方法将数组$array中的数据写入到page1中      
	$smarty->assign("pagecount1",$pagecount1);	//通过assign方法将数组$array中的数据写入到pagecount1中      
	}
	//读取评论数据表中的数据
	$d_sqlstr="select * from tb_video_discuss where tb_video_id=".$_GET[video_id]." order by tb_discuss_id desc";
	$d_rst = $conn->SelectLimit($d_sqlstr,$pagesize1,($page1-1)*$pagesize1);
	$arrayes=$d_rst->GetRows();
	$smarty->assign("discuss",$arrayes);

	$smarty->display("look.tpl");	
}
?>