<?php
include "../../include/conn.php";
include "../../include/function.php";
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 
header("Cache-Control: no-cache, must-revalidate"); 
header("Pragma: no-cache");
if(!eregi($_SERVER['SERVER_NAME'],$_SERVER['HTTP_REFERER'])){exit();}
$ac=SafeRequest("action","get");
if($ac=="goodbad"){
	global $db;
	$S_ID=SafeRequest("id","get");
	$sql="Select * from s_video where S_ID=".$S_ID."";
	if($row=$db->Getrow($sql)){
		$S_ID=$row['S_ID'];
		$OuHits=$row['S_Apex'];
		$OdHits=$row['S_Tread'];
		$nCount=$row['S_Apex']+$row['S_Tread'];
		if($OuHits==$OdHits){
			$uHits="50";
			$dHits="50";
		}else{
			$uHits=$OuHits/$nCount*100;
			$dHits=$OdHits/$nCount*100;
		}
	}
	$showstr="";
	$showstr=$showstr."<div class=\"diggbox digg_good\" onClick=\"up_down($S_ID, 'good')\" onfocus=\"this.blur()\" onmousemove=\"this.style.backgroundPosition='left bottom';\" onmouseout=\"this.style.backgroundPosition='left top';\" >";
	$showstr=$showstr."<div class=\"digg_act\">好听</div>";
	$showstr=$showstr."<div class=\"digg_num\">($OuHits)</div>";
	$showstr=$showstr."<div class=\"digg_percent\">";
	$showstr=$showstr."<div class=\"digg_percent_bar\"><span style=\"width:$uHits%\"></span></div>";
	$showstr=$showstr."<div class=\"digg_percent_num\">$uHits%</div>";
	$showstr=$showstr."</div></div>";
	$showstr=$showstr."<div class=\"diggbox digg_good\" onClick=\"up_down($S_ID, 'bad')\" onfocus=\"this.blur()\" onmousemove=\"this.style.backgroundPosition='right bottom';\" onmouseout=\"this.style.backgroundPosition='right top';\">";
	$showstr=$showstr."<div class=\"digg_act\">难听</div>";
	$showstr=$showstr."<div class=\"digg_num\">($OdHits)</div>";
	$showstr=$showstr."<div class=\"digg_percent\">";
	$showstr=$showstr."<div class=\"digg_percent_bar\"><span style=\"width:$dHits%\"></span></div>";
	$showstr=$showstr."<div class=\"digg_percent_num\">$dHits%</div>";
	$showstr=$showstr."</div></div>";
	echo escape($showstr);
	//echo $showstr;
}elseif($ac=="doHits"){
	global $db;
	$S_ID=SafeRequest("id","get");
	$dowhat=SafeRequest("dowhat","get");
	if($dowhat=="good"){	
		$sql="update s_video set S_Apex=S_Apex+1 where S_ID=".$S_ID."";
	}else{
		$sql="update s_video set S_Tread=S_Tread+1 where S_ID=".$S_ID."";
        }
        $cookies="doHits_dj_$S_ID";
	if($_COOKIE[$cookies]=="yes"){
		echo escape("Err_145");
	}else{
		setcookie($cookies,"yes",time()+86400);
		if($db->query($sql)){}
        }
}elseif($ac=="doUserFav"){
	global $db;
	$S_ID=SafeRequest("id","get");
	$sql="select * from s_usersc where S_Djid='".$S_ID."' order by s_addtime desc";
	$rs=$db->query($sql);
	$num=$db->num_rows($rs);
	if($num==0) echo "";
	$nums=12;
	if($num<$nums){
		$j=$num;
	}else{
		$j=$nums;
	}
	$showstr="";
	for($i=0;$i<$j;$i++){
		$row=$db->fetch_array($rs);
		$upic=$db->getrow("select * from s_users where S_Name='".$row["S_User"]."'");
	$showstr=$showstr."<li><a title=进入".$row["S_User"]."的个人主页看看 href=".userlink("index",$row["S_User"])." target=web><img src=".piclink("logo",$upic["S_Logo"],"big")." onerror=\"javascript:this.src='/images/nopic.gif'\"><p>".$row["S_User"]."</p></a></li>";
	}
	echo escape($showstr);
	//echo $showstr;
}elseif($ac=="doUserDown"){
	global $db;
	$S_ID=SafeRequest("id","get");
	$sql="select * from s_down where S_Djid='".$S_ID."' order by s_addtime desc";
	$rs=$db->query($sql);
	$num=$db->num_rows($rs);
	if($num==0) echo "";
	$nums=18;
	if($num<$nums){
		$j=$num;
	}else{
		$j=$nums;
	}
	$showstr="";
	for($i=0;$i<$j;$i++){
		$row=$db->fetch_array($rs);
		$upic=$db->getrow("select * from s_users where S_Name='".$row["S_User"]."'");
           if(substr($upic["S_Logo"],0,7)=="/0792dj"){
                 $S_Logo="http://www.pj57.com/upload/userlogo/big".$upic["S_Logo"];
           }else{
                 $S_Logo="/upload/userlogo/big".$upic["S_Logo"];
           }
	$showstr=$showstr."<li><a title=进入".$row["S_User"]."的个人主页看看 href=".userlink("index",$row["S_User"])." target=web><img src=".piclink("logo",$upic["S_Logo"],"big")." onerror=\"javascript:this.src='/images/nopic.gif'\"><p>".$row["S_User"]."</p></a></li>";
	}
	echo escape($showstr);
	//echo $showstr;
}
?>