<?php
//动态读取人气
include_once("../include/conn.php");
include_once("../include/function.php");
$id = intval($_GET['id']);
$type = intval($_GET['type']);
if (!$id || !$type) {
	exit("document.write('error');");	
}
switch($type){
	case 3:
	case 4:
		$sql='select S_Hits from '.($type==4 ? 's_article' : 's_video').' where S_ID='.$id;
		$hits=$db->getOne($sql);
		$db->query('update '.($type==4 ? 's_article' : 's_video').' set S_Hits=S_Hits+1,S_HitsDay=S_HitsDay+1,S_HitsMon=S_HitsMon+1,S_HitsWeek=S_HitsWeek+1 where S_ID='.$id);
		exit("function showhits(){document.getElementById('hits_dyn').innerHTML='".$hits."';}window.onload=function(){showhits();}");
		break;
	case 6:
		$sql='update s_topic set S_Hits=S_Hits+1 where S_ID='.$id;
		$db->query($sql);
		exit('document.write("");');
		break;
	case 7://获取视频顶和踩的数据
		$tab = intval($_GET['system']==2) ? 's_article' : 's_video';
		$sql='select S_Apex,S_Tread from '.$tab.' where S_ID='.$id;
		$hits=$db->getrow($sql);
		exit($hits ? implode(',', $hits) : 'document.write("0,0");');
		break;
	case 8:
		if(!isset($_COOKIE['ding_'.$id])){
			$tab = intval($_GET['system']==2) ? 's_article' : 's_video';
			$sql='update '.$tab.' set S_Apex=S_Apex+1 where S_ID='.$id;
		  	$row=$db->query($sql);
		  	setcookie('ding_'.$id,1,time()+3600);
		  	exit('ok');		
		}else{
			exit('err');
		}
		break;
	case 9:
		if(!isset($_COOKIE['ding_'.$id])){
			$tab = intval($_GET['system']==2) ? 's_article' : 's_video';
			$sql='update '.$tab.' set S_Tread=S_Tread+1 where S_ID='.$id;
		  	$row=$db->query($sql);
		  	setcookie('ding_'.$id,1,time()+3600);
		  	exit('ok');		
		}else{
			exit('err');
		}
		break;
	default:
		exit;		
	break;
}
?>