<?php
/*
'**************************************************************************************************
' 软件名称: 盘锦DJ舞曲网CMS Content Management PjRen.Net
' 版本编号: Version 2.5
' 盘锦舞曲: http://www.pj57.com
' 官方网站: http://www.pjren.net
' 小说网站: http://www.hx39.com
' 0427DJ网: http://www.0427dj.net
' 官方论坛: http://www.tianjiazhen.com
' 版权所有: 盘锦舞曲开发团队    盘锦人(QQ:814006710)
' 郑重声明:
'    1、任何个人或组织不得在未经授权的情况下删除、修改、拷贝本软件及其他副本上一切关于版权的信息；
'    2、盘锦网络事业部保留此软件的法律追究权利
'**************************************************************************************************
*/
//动态读取人气
include_once("../include/label.php");
$id=SafeRequest("id","get","zr");
$ac=SafeRequest("ac","get","zr");
$type=SafeRequest("type","get","zr");
if($ac=='shits'){
		$sql2="select S_Favhits from s_video where S_ID=$id";
		$row2=$db->getRow($sql2);
		if($row2){
			echo "document.write('".$row2['S_Favhits']."');";
			}
}elseif($ac=='xhits'){
		$sql2="select S_Downhits from s_video where S_ID=$id";
		$row2=$db->getRow($sql2);
		if($row2){
			echo "document.write('".$row2['S_Downhits']."');";
			}
}elseif($ac=='rhits'){
		$sql2="select S_Rhits from s_video where S_ID=$id";
		$row2=$db->getRow($sql2);
		if($row2){
			echo "document.write('".$row2['S_Rhits']."');";
			}
}elseif($ac=='zhits'){
		$sql2="select S_Zhits from s_video where S_ID=$id";
		$row2=$db->getRow($sql2);
		if($row2){
			echo "document.write('".$row2['S_Zhits']."');";
			}
}elseif($ac=='yhits'){
		$sql2="select S_Yhits from s_video where S_ID=$id";
		$row2=$db->getRow($sql2);
		if($row2){
			echo "document.write('".$row2['S_Yhits']."');";
			}
}else{
if(($type=='4')||($type=='11')){
	$table="s_article";
}elseif(($type=='1')||($type=='9')){
	$table="s_huodongall";
}elseif(($type=='2')||($type=='10')){
	$table="s_form";
}elseif(($type=='6')||($type=='12')){
	$table="s_topic";
}elseif(($type=='7')||($type=='8')){
	$table="s_users";
}elseif(($type=='3')||($type=='5')){
	$table="s_video";
}	

if($type=='3'){
	$sql="select S_Hits,S_Playtime from s_video where S_ID=$id";
	$row=$db->getrow($sql);
	if($row){
	    $daytime =DateBj("d",$row['S_Playtime'],date('Y-m-d H:i:s'));
	if($daytime==0){
	    $db->query("update s_video set S_Rhits=S_Rhits+1 where S_ID=$id");
	}else{
	    $db->query("update s_video set S_Rhits=1 where S_ID=$id");
	}
	if($daytime < 7){
	    $db->query("update s_video set S_Zhits=S_Zhits+1 where S_ID=$id");
	}else{
	    $db->query("update s_video set S_Zhits=1 where S_ID=$id");
	}
	if($daytime <31){
	    $db->query("update s_video set S_Yhits=S_Yhits+1 where S_ID=$id");
	}else{
	    $db->query("update s_video set S_Yhits=1 where S_ID=$id");
	}
	    $sql="update $table set S_Hits=S_Hits+1,S_Playtime='".date('Y-m-d H:i:s')."' where S_ID=$id";
	    $row=$db->query($sql);
	}
	if(S_Webmode==0){
		$sql2="select S_Hits from $table where S_ID=$id";
		$row2=$db->getRow($sql2);
		if($row2){
			die("function showhits(){document.getElementById('hits_dyn').innerHTML='".$row2['S_Hits']."';}window.onload=function(){showhits();}");
			}
	}
}elseif($type=='8'){
	$sql="select S_Dhits from $table where S_ID=$id";
	$row=$db->getRow($sql);
	if($row){
		die("document.write('".$row['S_Dhits']."');");
	}else{
		die("document.write('error');");
	}	
}elseif($type=='9' or $type=='10' or $type=='11' or $type=='12' or $type=='3'){
	    $sql="update $table set S_Hits=S_Hits+1 where S_ID=$id";
	    $row=$db->query($sql);
}else{
	$sql="select S_Hits from $table where S_ID=$id";
	$row=$db->getRow($sql);
	if($row){
		die("document.write('".$row['S_Hits']."');");
	}else{
		die("document.write('error');");
	}	
}	
}
//播放时间判断
function DateBj ($interval, $date1,$date2) { 
// 得到两日期之间间隔的秒数 
$timedifference = strtotime($date2) -strtotime($date1); 

switch ($interval) { 
case "w": $retval = round($timedifference/604800); break; //得到两日期之间间隔的星期数；
case "d": $retval = round($timedifference/86400); break; //得到两日期之间间隔的日数；
case "h": $retval = round($timedifference/3600); break; //得到两日期之间间隔的小时数；
case "n": $retval = round($timedifference/60); break; //得到两日期之间间隔的分钟数；
case "s": $retval = $timedifference; break; //得到两日期之间间隔的秒数；
} 
return $retval;
} 
?>