<?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(!eregi($_SERVER['SERVER_NAME'],$_SERVER['HTTP_REFERER'])){exit('QQ:848769359');}
include_once("../lib/cs_conn.php");
include_once("../lib/cs_common.php");
$ac=CS_Request('ac');
$usera=CS_Request('usera');
$userb=CS_Request('userb');
$userpass=CS_Request('userpass');
$content=filter(CS_Request('content'));
$content=iconv("gb2312","utf-8",$content);


	$showstr="";
	global $db;

if($ac=="gbook"){
     if(!isset($_COOKIE["cs_name"])){
          if(empty($userb)) exit('Err_100');
          if(empty($userpass)) exit('Err_101');
          $row=$db->getrow("Select * from ".Getdbname('user')." where CS_Name='".$userb."' and CS_Pass='".md5($userpass)."'");
          if(!$row)  exit('Err_102');
     }
     if(empty($content)) exit('Err_103');
     if(empty($usera)) exit('Err_000');
     if(DateDiff($_SESSION['gbooktime'],date("Y-m-d H:i:s"))<16) exit('Err_104');

	$sql="insert into ".Getdbname('gbook')." (CS_Usera,CS_Userb,CS_Neir,CS_AddTime) values ('".$usera."','".$_COOKIE["cs_name"]."','".$content."','".date('Y-m-d H:i:s')."')";
	if($db->query($sql)){
                $_SESSION['gbooktime']=date("Y-m-d H:i:s");
             exit('Err_105');
        }else{
             exit('Err_106');
        }
}elseif($ac=="gbooklist"){
	$sql="select * from ".Getdbname('gbook')." where CS_Usera='".$usera."' order by cs_id desc";
	$rs=$db->query($sql);
	$num=$db->num_rows($rs);
	$nums=10;
	if($num<$nums){
		$j=$num;
	}else{
		$j=$nums;
	}
	for($i=0;$i<$j;$i++){
		$row=$db->fetch_array($rs);
                $cs_uid=getuser('uid',$row['CS_Userb']);

                $showstr.="<dl class=\"msg_list\">";
                $showstr.="<dt><a target=\"_blank\" href=\"".userlink('index',$cs_uid)."\"><img width=\"48\" height=\"48\" src=\"".getuser('pic',$row['CS_Userb'])."\" alt=\"".$row['CS_Userb']."\"></a></dt>";
                $showstr.="<dd>";
                $showstr.="    <div class=\"msg_tit\"><span class=\"lt\"><a href=\"".userlink('index',$cs_uid)."\">".$row['CS_Userb']."</a><em>".$row["CS_AddTime"]."</em></span></div>";
                $showstr.="    <div class=\"msg_view\"><br>".facehtml(stripslashes(html_entity_decode($row['CS_Neir'])))."</div>";
                $showstr.="</dd>";
                $showstr.="</dl>";
        }
  echo escape($showstr);

}elseif($ac=="gz"){
     if(!isset($_COOKIE["cs_name"])) exit('Err_100');
     if($_COOKIE["cs_name"]==$usera) exit('Err_101');

     $gzid=$db->getone("select cs_id from ".Getdbname('fans')." where cs_userb='".$_COOKIE["cs_name"]."'");
     if($gzid) exit('Err_000');

	$sql="insert into ".Getdbname('fans')." (CS_Usera,CS_Userb,CS_AddTime) values ('".$usera."','".$_COOKIE["cs_name"]."','".date('Y-m-d H:i:s')."')";
	if($db->query($sql)){
             exit('Err_102');
        }else{
             exit('Err_103');
        }

}

function filter($str){
	$KeyArr=explode(',','http://,www,胡锦涛,温家宝,尻,屌,操你,干死你,贱人,狗娘,婊子,表子,靠你,叉你,叉死,插你,插死,干你,干死,日你,日死,鸡巴,睾丸,包皮,龟头,屄,赑,妣,肏,奶子,奶头,阴毛,阴道,阴茎,叫床,强奸,爱液,性高潮,做爱,性交,口交,肛交,3P');
	for($i=0;$i<count($KeyArr);$i++){
		$str=CS_ReplaceStr($str,$KeyArr[$i],"**");
	}
	return $str;
}
