<?php
# Name: PHP版程氏音乐CMS管理系统 v3.0
# Author: 程氏<web@chshcms.com> [QQ:848769359]
# Homepage:http://www.chshcms.cn/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 
header("Cache-Control: no-cache, must-revalidate"); 
header("Pragma: no-cache");
if(@empty($_SERVER['HTTP_REFERER'])){exit('QQ:848769359');}
include_once("../lib/cs_conn.php");
include_once("../lib/cs_common.php");
$type=CS_Request('type');
$id=CS_Request('id');
$ac=CS_Request('ac');
$op=CS_Request('op');

if(empty($id)) exit();
$nums=0;

global $db;
if($ac=='dt'){  //动态人气
    switch($type){
	case 'dance':
		$sql="select * from ".Getdbname('dance')." where CS_ID=$id";
		$row=$db->getrow($sql);
		if($row){
                    if($op=='hits'){
                       $nums=$row['CS_Hits'];
                    }elseif($op=='yhits'){
                       $nums=$row['CS_Yhits'];
                    }elseif($op=='zhits'){
                       $nums=$row['CS_Zhits'];
                    }elseif($op=='rhits'){
                       $nums=$row['CS_Rhits'];
                    }elseif($op=='shits'){
                       $nums=$row['CS_Shits'];
                    }elseif($op=='xhits'){
                       $nums=$row['CS_Xhits'];
                    }elseif($op=='dhits'){
                       $nums=$row['CS_Dhits'];
                    }elseif($op=='chits'){
                       $nums=$row['CS_Chits'];
                    }
		}
	break;
	case 'news':
		$sql="select * from ".Getdbname('dance')." where CS_ID=$id";
		$row=$db->getrow($sql);
		if($row){
                       $nums=$row['CS_Hits'];
		}
	break;
	case 'topic':
		$sql="select * from ".Getdbname('dance')." where CS_ID=$id";
		$row=$db->getrow($sql);
		if($row){
                    if($op=='hits'){
                       $nums=$row['CS_Hits'];
                    }elseif($op=='yhits'){
                       $nums=$row['CS_Yhits'];
                    }elseif($op=='zhits'){
                       $nums=$row['CS_Zhits'];
                    }elseif($op=='rhits'){
                       $nums=$row['CS_Rhits'];
                    }
		}
	break;
    }
    exit("document.write('".$nums."');");
}else{
    switch($type){
	case 'dance':
		$sql="select * from ".Getdbname('dance')." where CS_ID=$id";
		$row=$db->getrow($sql);
		if($row){
                       $daytime =DateBj("d",$row['CS_PlayTime'],date('Y-m-d H:i:s'));
		    if($daytime==0){
	  	       $db->query("update ".Getdbname('dance')." set CS_Rhits=CS_Rhits+1 where CS_ID=$id");
		    }else{
	   	       $db->query("update ".Getdbname('dance')." set CS_Rhits=1 where CS_ID=$id");
		    }
		    if($daytime < 7){
	   	       $db->query("update ".Getdbname('dance')." set CS_Zhits=CS_Zhits+1 where CS_ID=$id");
		    }else{
	   	       $db->query("update ".Getdbname('dance')." set CS_Zhits=1 where CS_ID=$id");
		    }
		    if($daytime <31){
	  	        $db->query("update ".Getdbname('dance')." set CS_Yhits=CS_Yhits+1 where CS_ID=$id");
		    }else{
	   	       $db->query("update ".Getdbname('dance')." set CS_Yhits=1 where CS_ID=$id");
		    }
	    	       $sql="update ".Getdbname('dance')." set CS_Hits=CS_Hits+1,CS_PlayTime='".date('Y-m-d H:i:s')."' where CS_ID=$id";
	    	       $row=$db->query($sql);
		}
		break;
	case 'news':
		$sql="select * from ".Getdbname('news')." where CS_ID=$id";
		$row=$db->getrow($sql);
		if($row){
	    	       $sql="update ".Getdbname('news')." set CS_Hits=CS_Hits+1 where CS_ID=$id";
	    	       $row=$db->query($sql);
		}
		break;
	case 'topic':
		$sql="select * from ".Getdbname('topic')." where CS_ID=$id";
		$row=$db->getrow($sql);
		if($row){
                       $daytime =DateBj("d",$row['CS_Looktime'],date('Y-m-d H:i:s'));
		    if($daytime==0){
	  	       $db->query("update ".Getdbname('topic')." set CS_Rhits=CS_Rhits+1 where CS_ID=$id");
		    }else{
	   	       $db->query("update ".Getdbname('topic')." set CS_Rhits=1 where CS_ID=$id");
		    }
		    if($daytime < 7){
	   	       $db->query("update ".Getdbname('topic')." set CS_Zhits=CS_Zhits+1 where CS_ID=$id");
		    }else{
	   	       $db->query("update ".Getdbname('topic')." set CS_Zhits=1 where CS_ID=$id");
		    }
		    if($daytime <31){
	  	        $db->query("update ".Getdbname('topic')." set CS_Yhits=CS_Yhits+1 where CS_ID=$id");
		    }else{
	   	       $db->query("update ".Getdbname('topic')." set CS_Yhits=1 where CS_ID=$id");
		    }
	    	       $sql="update ".Getdbname('topic')." set CS_Hits=CS_Hits+1,CS_LookTime='".date('Y-m-d H:i:s')."' where CS_ID=$id";
	    	       $row=$db->query($sql);
		}
		break;
    }
}
?>
