<?php
include "../include/conn.php";
include "../include/function.php";
include "../include/userset.php";
include "../include/emailadd.php";
if(S_Ucmode==1){
include_once("../config.uc.php");
include_once("../client/client.php");
}
ob_start();
//允许动作
$dos = array('qqjiechu', 'qqadd', 'fs', 'activation', 'message', 'login', 'passgo', 'logout', 'qqlogin', 'reg', 'sjvip', 'lostpasswd', 'passxg', 'zl', 'friend', 'pic', 'gbook', 'blog', 'msg', 'music', 'zu', 'pay',  'down', 'fav', 'tg', 'payreceive', 'change', 'savechange', 'box', 'article', 'topic');

//获取变量
$ac=SafeRequest("ac","get","zr");
$op=SafeRequest("op","get","zr");
$id=SafeRequest("id","get","zr");
$ac = (!empty($ac) && in_array($ac, $dos))?$ac:'tg';
include "skins/function_common.php";
//会员推广
if($ac=="tg"){return TG();}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gbk" />
<meta http-equiv="x-ua-compatible" content="ie=7" />
<title>首页 - <?php echo $chsh_username?> - <?php echo S_SiteDomain?> - Powered by chshdjcms Dance</title>
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="stylesheet" href="css/main.css" type="text/css" media="all" />
<link rel="stylesheet" href="css/user.css" type="text/css" media="all" />
<link rel="stylesheet" href="css/register.css" type="text/css" media="all" />
</head>
<body>
<div class="top">
	<div class="logo"><a href="<?php echo S_SiteDomain?>/" target="_blank"></a></div>
	<div class="nav">
		<ul>
			<li><a href="<?php echo S_SiteDomain?>/" target="list">首页</a></li>
							<li><a href="?ac=home">个人中心</a></li>
				<li><a href="<?php echo userlink("index",$chsh_username)?>" target="_blank">我的主页</a></li>
				<li><a href="?ac=online">在线会员</a></li>
					</ul>
					<div class="msgText"><a href="?ac=message" target="_blank">通知</a></div>
			<div id="msgTips" style="display:none;" ></div>
				<div class="user">
			<div class="face">
				<img id="header-avatar" src="<?php echo piclink("logo",$chsh_web_logo,"big")?>" onerror="this.onerror=null;this.src='<?php echo S_SiteDomain?>/user/images/avatar/noface_small.gif'" width="30" height="30" />
			</div>
			<div class="info">
				<a href="<?php echo userlink("index",$chsh_username)?>" ><?php echo $chsh_username?></a>			</div>
			<div class="info">
				<a href="?ac=edit">个人设置</a>&nbsp;|&nbsp;<a href="<?php echo S_SiteDomain?>/user/do.php?ac=logout">退出</a>			</div>
		</div>
	</div>
</div>
<div class="user">
	<div class="defaultHome">
	<div class="defaultHomeMain">
<?php
//验证登陆
if($ac=="login"){
	$s_username=SafeRequest("username","post","zr");
	$s_password=SafeRequest("password","post");
	$s_passworduc=$s_password;
	$s_logintime=date('Y-m-d H:i:s');
	$s_loginip=$_SERVER['REMOTE_ADDR'];
	$cookietime=SafeRequest("cookietime","post");
	if(!IsNul($cookietime)){$cookietime=86400;}
	if($s_username==""){
		showmessage("对不起，用户名不能为空，请重新登录！",$_SERVER['HTTP_REFERER'],0);
	}elseif($s_password==""){
		showmessage("对不起，密码不能为空，请重新登录！",$_SERVER['HTTP_REFERER'],0);
	}else{
		$s_password=Md5($s_password);
		global $db;
		$sqlj= "select s_id from s_users where s_name='".$s_username."'";
        	$s_id= $db->Getone($sqlj);
		if($s_id==""){
	                //--------------------------- Ucenter ---------------------------
			if(S_Ucmode==1){
			//从UC中获得UC用户ID
			$ucid = uc_get_user($s_username);
			// 获得后激活帐号
			if($ucid[0]>0) {
			$_SESSION["uid"]=$ucid[0];
			$_SESSION["username"]=$ucid[1];
			$_SESSION["email"]=$ucid[2];
			$_SESSION["password"]=$s_password;
                             showmessage("对不起，该用户未在本站激活,请先激活帐号！","index.php?ac=activation",0);
			}
                        }
	                //--------------------------- Ucenter ---------------------------
                }
		$sql= "select s_id from s_users where s_name='".$s_username."' and s_password='".$s_password."'";
        	$s_id= $db->Getone($sql);
		if($s_id){
			$db->query("update s_users set S_LogNum=S_LogNum+1,S_LogIP ='".$s_loginip."',S_LogTime='".$s_logintime."' where s_id='".$s_id."'");
			$row=$db ->Getrow("select s_id,s_name,s_password,S_State,S_Email from s_users where s_id=".$s_id."");
			if($row["S_State"]==1){
				showmessage("对不起，此账号已被锁定，请和管理员联系！",$_SERVER['HTTP_REFERER'],0);
			}else{
			  if(S_LoginFun==1){
			    if(isset($_COOKIE["LoginIP"])){
			    }else{
				setcookie("LoginIP",$s_loginip,time()+3600);	
			    }
			    $LoginIP=$_COOKIE["LoginIP"];
			    $tishi="b";
			    if($s_loginip==$LoginIP) $tishi=="a";
			    if($tishi=="b"){
					setcookie("LoginIP",$LoginIP.",".$IP,time()+3600);
					$db->query("update s_users set S_Coin=S_Coin+".S_LoginPoints." where s_id='".$s_id."'");
                            $tishiname="每天登入一次系统给你增加".S_LoginPoints."点";
			    }
                          }

	//--------------------------- Ucenter ---------------------------
			if(S_Ucmode==1){
			//从UC中获得UC用户ID
			$ucid = uc_get_user($row["s_name"]);
			// 获得后同步登陆
			if($ucid[0]>0) {
				echo uc_user_synlogin($ucid[0]);
			}
			}
	//--------------------------- Ucenter ---------------------------
				setcookie("s_id",$row["s_id"],time()+$cookietime,'/',ymurl(S_SiteDomain));
				setcookie("s_name",$row["s_name"],time()+$cookietime,'/',ymurl(S_SiteDomain));
				showmessage("登录成功了，现在引导您进入会员中心！".$tishiname."","space.php?ac=home",1);
			}
		}else{
			showmessage("对不起，用户名或密码错误，请重新登录！",$_SERVER['HTTP_REFERER'],0);
		}
	}
//帮定QQID登陆
}elseif($ac=="qqadd"){
	$s_username=SafeRequest("name","post","zr");
	$s_password=SafeRequest("password","post");
	$s_passworduc=SafeRequest("password","post");
	$S_Email=SafeRequest("mail","post");
	$s_qqid=SafeRequest("qqid","post");
	$s_logintime=date('Y-m-d H:i:s');
	$s_loginip=$_SERVER['REMOTE_ADDR'];
	$cookietime=SafeRequest("cookietime","post");
	if(!IsNul($cookietime)){$cookietime=86400;}
	if($s_qqid==""){
		showmessage("参数错误，请重新使用QQ登入！",$_SERVER['HTTP_REFERER'],0);
	}elseif($s_username==""){
		showmessage("对不起，用户名不能为空，请重新输入！",$_SERVER['HTTP_REFERER'],0);
	}elseif($s_password==""){
		showmessage("对不起，密码不能为空，请重新输入！",$_SERVER['HTTP_REFERER'],0);
	}elseif($S_Email==""){
		showmessage("对不起，油箱不能为空，请重新输入！",$_SERVER['HTTP_REFERER'],0);
	}else{
		$s_password=Md5($s_password);
		global $db;
		$sqlj= "select s_id from s_users where s_name='".$s_username."'";
        	$s_id= $db->Getone($sqlj);
		if($s_id==""){
	                //--------------------------- Ucenter ---------------------------
			if(S_Ucmode==1){
			//从UC中获得UC用户ID
			$ucid = uc_get_user($s_username);
			// 获得后激活帐号
			if($ucid[0]>0) {
			$_SESSION["uid"]=$ucid[0];
			$_SESSION["username"]=$ucid[1];
			$_SESSION["email"]=$ucid[2];
			$_SESSION["password"]=$s_password;
                             showmessage("对不起，该用户未在本站激活,请先激活帐号！","index.php?ac=activation",0);
			}
			}
	                //--------------------------- Ucenter ---------------------------
                }
		$sql= "select s_id from s_users where s_name='".$s_username."'";
        	$s_id= $db->Getone($sql);
		if($s_id){
			$row=$db ->Getrow("select s_id,s_name,s_password,S_State from s_users where s_name='".$s_username."'");
                        if($row["s_password"]!=$s_password){
                                 showmessage("对不起，密码错误！",$_SERVER['HTTP_REFERER'],0);
                        }else{
			      $db->query("update s_users set S_LogNum=S_LogNum+1,S_LogIP ='".$s_loginip."',S_LogTime='".$s_logintime."',S_Qqid='".$s_qqid."' where s_id='".$s_id."'");
                        }
		}else{
		        $sql="insert into s_users (S_Name,S_PassWord,S_Email,S_RealName,S_City,S_Sex,S_CreateTime,S_Type) values ('".$s_username."','".$s_password."','".$S_Email."','".$s_username."','未知',1,'".date('Y-m-d H:i:s')."',1)";
		        $db->query($sql);
		}
			$row=$db ->Getrow("select s_id,s_name,s_password,S_State from s_users where s_name='".$s_username."'");
			if($row["S_State"]==1){
				showmessage("对不起，此账号已被锁定，请和管理员联系！",$_SERVER['HTTP_REFERER'],0);
			}else{
			  if(S_LoginFun==1){
			    if(isset($_COOKIE["LoginIP"])){
			    }else{
				setcookie("LoginIP",$s_loginip,time()+3600);	
			    }
			    $LoginIP=$_COOKIE["LoginIP"];
			    $tishi="b";
			    if($LoginIP==$s_loginip) $tishi="a";
			    if($tishi=="b"){
					setcookie("LoginIP",$LoginIP.",".$IP,time()+3600);
					$db->query("update s_users set S_Coin=S_Coin+".S_LoginPoints." where s_name='".$s_username."'");
                            $tishiname="每天登入一次系统给你增加".S_LoginPoints."点";
			    }
                         }
	//--------------------------- Ucenter ---------------------------
			if(S_Ucmode==1){
			//从UC中获得UC用户ID
			$ucid = uc_get_user($row["s_name"]);
			// 获得后同步登陆
			if($ucid[0]>0) {
				echo uc_user_synlogin($ucid[0]);
			}
			}
	//--------------------------- Ucenter ---------------------------
				setcookie("s_id",$row["s_id"],time()+$cookietime,'/',ymurl(S_SiteDomain));
				setcookie("s_name",$row["s_name"],time()+$cookietime,'/',ymurl(S_SiteDomain));
				showmessage("恭喜您，帮定成功了，现在引导您进入会员中心！".$tishiname."","space.php?ac=home",1);
			}
	}
//QQID登陆
}elseif($ac=="qqlogin"){
	$s_logintime=date('Y-m-d H:i:s');
	$s_loginip=$_SERVER['REMOTE_ADDR'];
	$cookietime=SafeRequest("cookietime","post");
	if(!IsNul($cookietime)){$cookietime=86400;}
		global $db;
		$sql= "select s_id from s_users where s_qqid='".$_SESSION["openid"]."'";
        	$s_id= $db->Getone($sql);
		if($s_id){
			$db->query("update s_users set S_LogNum=S_LogNum+1,S_LogIP ='".$s_loginip."',S_LogTime='".$s_logintime."' where s_id='".$s_id."'");
			$row=$db ->Getrow("select s_id,s_name,s_password,S_State from s_users where s_id=".$s_id."");
			if($row["S_State"]==1){
				showmessage("对不起，此账号已被锁定，请和管理员联系！",$_SERVER['HTTP_REFERER'],0);
			}else{
			  if(S_LoginFun==1){
			    if(isset($_COOKIE["LoginIP"])){
			    }else{
				setcookie("LoginIP",$s_loginip,time()+3600);	
			    }
			    $LoginIP=$_COOKIE["LoginIP"];
			    $tishi="b";
			    if($s_loginip==$LoginIP) $tishi=="a";
			    if($tishi=="b"){
					setcookie("LoginIP",$LoginIP.",".$IP,time()+3600);
					$db->query("update s_users set S_Coin=S_Coin+".S_LoginPoints." where s_id='".$s_id."'");
                            $tishiname="每天登入一次系统给你增加".S_LoginPoints."点";
			    }
                           }
	//--------------------------- Ucenter ---------------------------
			if(S_Ucmode==1){
			//从UC中获得UC用户ID
			$ucid = uc_get_user($row["s_name"]);
			// 获得后同步登陆
			if($ucid[0]>0) {
				echo uc_user_synlogin($ucid[0]);
			}
			}
	//--------------------------- Ucenter ---------------------------
				setcookie("s_id",$row["s_id"],time()+$cookietime,'/',ymurl(S_SiteDomain));
				setcookie("s_name",$row["s_name"],time()+$cookietime,'/',ymurl(S_SiteDomain));
				showmessage("登录成功了，现在引导您进入会员中心！".$tishiname."","space.php?ac=home",1);
			}
		}else{
			showmessage("对不起，您还没有帮定，请先帮定用户名！","index.php?ac=reg&op=qqlogin",0);
		}
//退出登陆
}elseif($ac=="logout"){
	$username=SafeRequest("name","get","filter");
	setcookie("s_id","",time()-1,'/',ymurl(S_SiteDomain));
	setcookie("s_name","",time()-1,'/',ymurl(S_SiteDomain));

	//--------------------------- Ucenter ---------------------------
			if(S_Ucmode==1){
			//从UC中获得UC用户ID
			$ucid = uc_get_user($username);
			// 获得后同步退出登陆
			if($ucid[0]>0) {
				echo uc_user_synlogout($ucid[0]);
			}
			}
	//--------------------------- Ucenter ---------------------------
	showmessage("你已安全退出了！","index.php",1);
//用户注册
}elseif($ac=="reg"){
	global $db;
	if(S_VipReg==0){ showmessage("出错了，本站暂不开放新会员注册。",$_SERVER['HTTP_REFERER'],0); }
	$seccode=SafeRequest("Code","post");
	$S_Name=SafeRequest("loginName","post","filter");
	$S_RealName=SafeRequest("nickname","post","filter");
	$S_PassWord=SafeRequest("password","post");
	$S_PassWord2=SafeRequest("password2","post");
	if($S_password<>$S_password2){showmessage("出错了，两次密码不一样。",$_SERVER['HTTP_REFERER'],0);}
	$S_password=Md5($S_PassWord2);
	$S_Email=SafeRequest("email","post");
	$S_QQ=SafeRequest("qq","post");
	$S_Logo=$_SESSION["picurl_50"];
	$S_Sex=SafeRequest("sex","post");
	$S_province=SafeRequest("province","post");
	$S_city=SafeRequest("city_tmp","post");
	$S_City=$S_province."-".$S_city;
	$S_CreateTime=date('Y-m-d H:i:s');
	if(!IsNul($S_Logo)) $S_Logo="";

	$content= S_MailContent."<br>";
	$content = $content."   ".$S_Name.",您好！欢迎您加入".S_SiteName."   以下是您的注册信息：<br>";
	$content = $content."用户名：".$S_Name."   密码：".$S_PassWord2."   请牢记你的密码！<br>";
        
	if(!IsNul($seccode)||!IsNul($S_Name)||!IsNul($S_RealName)||!IsNul($S_PassWord)||!IsNul($S_Email)||!IsNul($S_QQ)||!IsNul($S_City)){ showmessage("出错了，请把信息填写完整!",$_SERVER['HTTP_REFERER'],0); }
	if($_SESSION["codes"]!=$seccode){
		showmessage("出错了，验证码不正确，请重新填写。",$_SERVER['HTTP_REFERER'],0);
	}else{
		$userid=$db->getOne("select s_id from s_users where s_name='".$S_Name."'");
		if($userid){showmessage("出错了，用户已存在不能重复申请。",$_SERVER['HTTP_REFERER'],0);}
		$userEmail=$db->getOne("select s_id from s_users where s_Email='".$S_Email."'");
		if($userEmail){showmessage("出错了，该Email已存在不能重复使用。",$_SERVER['HTTP_REFERER'],0);}

	//--------------------------- Ucenter ---------------------------
	if(S_Ucmode==1){
	$uid=uc_user_register($S_Name,$S_PassWord2,$S_Email);
	if($uid <= 0)
	{
		if($uid == -1)
		{
			showmessage("出错了，UC用户名不合法。",$_SERVER['HTTP_REFERER'],0);
		} 
		elseif($uid == -2)
		{
			showmessage("出错了，UC用户名包含要允许注册的词语。",$_SERVER['HTTP_REFERER'],0);
		} 
		elseif($uid == -3)
		{
			showmessage("出错了，UC用户名已经存在。",$_SERVER['HTTP_REFERER'],0);
		}
		elseif($uid == -4)
		{
			showmessage("出错了，UCEmail 格式有误。",$_SERVER['HTTP_REFERER'],0);
		}
		elseif($uid == -5)
		{
			showmessage("出错了，UCmail 不允许注册。",$_SERVER['HTTP_REFERER'],0);
		}
		elseif($uid == -6)
		{
			showmessage("出错了，UC该 Email 已经被注册。",$_SERVER['HTTP_REFERER'],0);
		} 
		else
		{
			showmessage("出错了，UC该错误未定义。",$_SERVER['HTTP_REFERER'],0);
		}
	}
        }

                $s_uid=$uid;
		$sql="insert into s_users (S_Name,S_Logo,S_PassWord,S_QQ,S_Email,S_RealName,S_City,S_Sex,S_CreateTime,S_Type) values ('".$S_Name."','".$S_Logo."','".$S_password."','".$S_QQ."','".$S_Email."','".$S_RealName."','".$S_City."',".$S_Sex.",'".$S_CreateTime."',1)";
		if($db->query($sql)){
				//发消息通知
				$s_xid=0;
				$s_nameb="系统消息";
				$s_namea=$S_Name;
				$s_content=S_MailContent;
				$s_addtime=date('Y-m-d H:i:s');
				$sql="insert into s_xiaoxi (S_Xid,S_Nameb,S_Namea,S_Content,S_Addtime) values (".$s_xid.",'".$s_nameb."','".$s_namea."','".$s_content."','".$s_addtime."')";
				if($db->query($sql)){}
		  if(S_YjMode=="1"){	//判断是否发送邮件
                      $smtp =   new smtp(S_Smtp,'25',true,S_Mailuser,S_Mailpass,S_Mail); 
                      $send=$smtp->sendmail($S_Email,S_Mail,S_MailContent,$content,'HTML');
                      if($send==1){
                         showmessage("恭喜您，注册成功了,注册信息已经发送直您的邮箱，现在引导您进入登录前页面。","index.php",1);
		      }else{
		         showmessage("恭喜您，注册成功了，现在引导您进入登录前页面。","index.php",1);
		      }
		  }else{
		         showmessage("恭喜您，注册成功了，现在引导您进入登录前页面。","index.php",1);
		  }
		}else{
		showmessage("会员注册失败。",$_SERVER['HTTP_REFERER'],0);
		}
	}
//用户激活
}elseif($ac=="activation"){
	global $db;
	if(S_VipReg==0){ showmessage("出错了，本站暂不开放新会员注册。",$_SERVER['HTTP_REFERER'],0); }
	$seccode=SafeRequest("Code","post");
	$S_Name=$_SESSION["username"];
	$s_uid=$_SESSION["uid"];
	$S_RealName=$_SESSION["username"];
	$S_PassWord=$_SESSION["password"];
	$S_Email=$_SESSION["email"];
	$S_QQ='12345678';
	$S_Logo='';
	$S_Sex=1;
	$S_City='未知';
	$S_CreateTime=date('Y-m-d H:i:s');
	$S_UseDate=date('Y-m-d H:i:s');
	$S_ChangeTime=date('Y-m-d H:i:s');
	$S_Coin=S_GiftPoints;
	$S_UseType=0;
	$S_Type=1;
	if(!IsNul($seccode)){ showmessage("出错了，请填写验证码!",$_SERVER['HTTP_REFERER'],0); }
	if($_SESSION["codes"]!=$seccode){
		showmessage("出错了，验证码不正确，请重新填写。",$_SERVER['HTTP_REFERER'],0);
	}else{
		$userid=$db->getOne("select s_id from s_users where s_name='".$S_Name."'");
		if($userid){showmessage("出错了，用户已存在不能重复申请。",$_SERVER['HTTP_REFERER'],0);}
		$userEmail=$db->getOne("select s_id from s_users where s_Email='".$S_Email."'");
		if($userEmail){showmessage("出错了，该Email已存在不能重复使用。",$_SERVER['HTTP_REFERER'],0);}
		$sql="insert into s_users (S_Name,S_Logo,S_PassWord,S_QQ,S_Email,S_UseType,S_Coin,S_CreateTime,S_RealName,S_City,S_Sex,S_Type,S_Question,S_Answer,S_UseDate,S_ChangeTime,S_Uid) values ('".$S_Name."','".$S_Logo."','".$S_PassWord."','".$S_QQ."','".$S_Email."',".$S_UseType.",".$S_Coin.",'".$S_CreateTime."','".$S_RealName."','".$S_City."',".$S_Sex.",".$S_Type.",'000000','000000','".$S_UseDate."','".$S_ChangeTime."','".$s_uid."')";
		if($db->query($sql)){
			if(s_fsmessage=="yes"){
				//发消息通知
				$s_xid=0;
				$s_nameb="系统消息";
				$s_namea=$S_Name;
				$s_content=s_bodymessage;
				$s_addtime=date('Y-m-d H:i:s');
				$sql="insert into s_xiaoxi (S_Xid,S_Nameb,S_Namea,S_Content,S_Addtime) values (".$s_xid.",'".$s_nameb."','".$s_namea."','".$s_content."','".$s_addtime."')";
				if($db->query($sql)){}
			}
		showmessage("恭喜您，激活成功了，现在引导您进入登录前页面。","index.php",1);
		}else{
		showmessage("激活失败。",$_SERVER['HTTP_REFERER'],0);
		}
	}
//解除QQ绑定
}elseif($ac=="qqjiechu"){
	global $db;
	if((!$userlogin==true)){showmessage("出错了，请登陆后再操作。","index.php",0);}
	$db->query("update s_users set S_Qqid='' where s_name='".$chsh_username."'");
		showmessage("恭喜您，QQ登入绑定解除成功。",$_SERVER['HTTP_REFERER'],1);

//取回密码
}elseif($ac=="lostpasswd"){
	$s_username=SafeRequest("username","post","zr");
	$S_MailContent="密码找回邮件";
	if($s_username==""){
		showmessage("出错了，登陆帐号不能为空。",$_SERVER['HTTP_REFERER'],0);
	}else{
	
		global $db;
		$sql= "select s_id from s_users where s_name='".$s_username."'";
        	$s_id= $db->Getone($sql);
		if($s_id){
			$row=$db ->Getrow("select * from s_users where s_id=".$s_id."");
                        $Yzm="".rand(1000,9999)."";
                        $Xyzm=passport_encrypt($Yzm,S_UserKey);
                        $CsYzm=md5($Yzm.$s_username);
                        setcookie("Cs_PassKey",$CsYzm,time()+1800);
                        $Fhurl=S_SiteDomain.S_SitePath."user/?ac=passgo&u=".passport_encrypt($s_username,S_UserKey)."&key=".$Xyzm;
	                $content = "".$s_username.",您好！<br>您刚刚在".S_SiteName."找回了您的登入密码，<br>请点击以下连接进行修改您的密码,有效时间为30分钟,过期无效!<br><br><br/><a href='".$Fhurl."'>".$Fhurl."</a><br>如果无法打开请复制粘贴到浏览器打开";
                            $smtp =   new smtp(S_Smtp,'25',true,S_Mailuser,S_Mailpass,S_Mail); 
                            $send=$smtp->sendmail($row["S_Email"],S_Mail,$S_MailContent,$content,'HTML');
                                     if($send==1){
                                     	$db->query("update s_users set s_password='".$s_passwords."' where s_id='".$s_id."'");
		                              showmessage("恭喜您，密码已经发送您的邮箱,现在引导您进入登录前页面。","index.php",1);
		                     }else{
		                              showmessage("抱歉，邮件发送失败，请联系管理员！","index.php",1);
		                     }
		}else{
			showmessage("出错了，你输入的登陆帐号不存在，请重新填写。",$_SERVER['HTTP_REFERER'],0);
		}
	}
//找回密码修改
}elseif($ac=="passgo"){
	global $db;
	$s_usname=SafeRequest("username","post","zr");
	$s_pass1=SafeRequest("pass","post");
	$s_pass2=SafeRequest("pass1","post");
	if($s_pass1==""){showmessage("出错了，新密码不能为空",$_SERVER['HTTP_REFERER'],0);}
	if($s_pass1!=$s_pass2){showmessage("出错了，两次密码不一直。",$_SERVER['HTTP_REFERER'],0);}
        $s_newpwd=md5($s_pass2);
	$db->query("update s_users set s_password='".$s_newpwd."' where s_name='".$s_usname."'");
		setcookie("s_password",$s_newpwd1,time()+315360000,"/",ymurl(S_SiteDomain));

		showmessage("恭喜您，密码修改成功。","index.php",1);

//修改密码
}elseif($ac=="passxg"){
	if((!$userlogin==true)){showmessage("出错了，请登陆后再操作。","index.php",0);}
	$s_password=SafeRequest("password","post");
	$s_passworduc=SafeRequest("password","post");
	$s_newpwd=SafeRequest("new_pwd","post");
	$s_newpwd1=SafeRequest("new_pwd1","post");
	if(!IsNul($s_password)){showmessage("出错了，请填写旧密码。",$_SERVER['HTTP_REFERER'],0);}
	if(!IsNul($s_newpwd)){showmessage("出错了，请填写新密码。",$_SERVER['HTTP_REFERER'],0);}
	if(!IsNul($s_newpwd1)){showmessage("出错了，请填写确认密码。",$_SERVER['HTTP_REFERER'],0);}
	if($s_newpwd<>$s_newpwd1){showmessage("出错了，两次密码不一样。",$_SERVER['HTTP_REFERER'],0);}
	$s_password=Md5($s_password);
	$s_newpwd1=Md5($s_newpwd1);
	if($s_password<>$chsh_userpwd){
	showmessage("出错了，旧密码错误。",$_SERVER['HTTP_REFERER'],0);
	}else{
	global $db;
	$db->query("update s_users set s_password='".$s_newpwd1."' where s_name='".$chsh_username."'");
		setcookie("s_password",$s_newpwd1,time()+315360000,"/",ymurl(S_SiteDomain));
	   //--------------------------- Ucenter ---------------------------
	   if(S_Ucmode==1){
             $ucresult = uc_user_edit($chsh_username, $s_passworduc, $s_newpwd);
             if($ucresult  <= 0) {
		showmessage("恭喜您，本站密码修改成功。",$_SERVER['HTTP_REFERER'],1);
             }else{
		showmessage("恭喜您，修改密码成功已经同步到UC。",$_SERVER['HTTP_REFERER'],1);
             }
	    }
		showmessage("恭喜您，本站密码修改成功。",$_SERVER['HTTP_REFERER'],1);
        }
//修改资料
}elseif($ac=="zl"){
	if((!$userlogin==true)){showmessage("出错了，请登陆后再操作。","index.php",0);}
	$s_nicheng=SafeRequest("nicheng","post","zr");
	$s_sex=SafeRequest("sex","post");
	$s_question=SafeRequest("question","post","zr");
	$s_answer=SafeRequest("answer","post","zr");
	$s_city=SafeRequest("city","post");
	$S_Qianm=SafeRequest("s_qianm","post","zr");
	$s_qq=SafeRequest("qq","post");
	$s_email=SafeRequest("email","post");
	if(!IsNul($s_nicheng)||!IsNul($s_question)||!IsNul($s_answer)||!IsNul($s_city)||!IsNul($s_qq)||!IsNul($s_email)){showmessage("出错了，请把资料填写完整。",$_SERVER['HTTP_REFERER'],0);}
	global $db;
	$sql="update s_users set S_Qianm='".$S_Qianm."',S_Question='".$s_question."',S_Answer='".$s_answer."',S_Sex='".$s_sex."',S_City='".$s_city."',S_QQ='".$s_qq."',S_Email='".$s_email."',S_RealName='".$s_nicheng."' where S_name='".$chsh_username."'";
	if($db->query($sql)){
		showmessage("恭喜您，资料修改成功。",$_SERVER['HTTP_REFERER'],1);
	}else{
		showmessage("抱歉，资料修改失败。",$_SERVER['HTTP_REFERER'],1);
		}
//升级包月
}elseif($ac=="savechange"){
	if((!$userlogin==true)){showmessage("出错了，请登陆后再操作。","index.php",0);}
	global $db;
	$S_Name=$chsh_username;
	$S_UseType=SafeRequest("S_UseType","post");
	if($S_Name==""){
		showmessage("出错了。",$_SERVER['HTTP_REFERER'],1);	
	}
	$sqlv="select * from s_users where S_Name='".$S_Name."'";
	$resultv=$db->query($sqlv);
	if($rowv=$db->fetch_array($resultv)){
		if($rowv["S_UseType"]==0){//转月
			if($rowv["S_Coin"]<S_TGChange){
				showmessage("对不起，您的点数不够转换！",$_SERVER['HTTP_REFERER'],1);	
			}else{
				$NewCoin=$rowv["S_Coin"]%S_TGChange;
				$NewDate=date('Y-m-d H:I:s',mktime(0,0,0,date('m'),date('d')+30,date('Y')));
				$sqlv="update s_users set S_Coin=".$NewCoin.",S_UseDate='".$NewDate."',S_ChangeTime='".date('Y-m-d')."',S_UseType=1 where S_Name='".$S_Name."'";
				$db->query($sqlv);
				showmessage("升级成功!您的包月到期时间为:".$NewDate.",剩余点数为:".$rowv["S_Coin"]%S_TGChange."!",$_SERVER['HTTP_REFERER'],1);	
			}
                }else{
		       showmessage("出错了,您已经是包月会员了！",$_SERVER['HTTP_REFERER'],1);
                }
	}else{
		showmessage("出错了！",$_SERVER['HTTP_REFERER'],1);	
	}
//消息对话
}elseif($ac=="msg"){
	if((!$userlogin==true)){showmessage("出错了，请登陆后再操作。","index.php",0);}
	global $db;
	//删除
	if($op=="del"){
	if(!IsNul($id)){ showmessage("出错了，请不要提交非法参数。",$_SERVER['HTTP_REFERER'],3); }
		$sql="select * from s_xiaoxi where S_namea='".$chsh_username."' and s_id=$id";
		if($row=$db->Getrow($sql)){
		$db->query("delete from s_xiaoxi where S_ID=$id and s_namea='".$chsh_username."'");
		showmessage("恭喜您，删除成功。",$_SERVER['HTTP_REFERER'],3);
		}else{
		showmessage("出错了，请不要试图删除别人的数据。",$_SERVER['HTTP_REFERER'],3);
		}
		$db->query("delete from s_xiaoxi where S_ID=$id and s_namea='".$chsh_username."'");
		showmessage("恭喜您，删除成功。",$_SERVER['HTTP_REFERER'],3);
	//删除全部消息
	}elseif($op=="delall"){
		$db->query("delete from s_xiaoxi where s_namea='".$chsh_username."'");
		showmessage("恭喜您，消息全部删除成功。",$_SERVER['HTTP_REFERER'],3);
	//全部设为已读
	}elseif($op=="duall"){
		$db->query("update s_xiaoxi set s_did=1 where s_namea='".$chsh_username."'");
		showmessage("恭喜您，消息已经全部设置为已读。",$_SERVER['HTTP_REFERER'],3);
	//删除对话消息
	}elseif($op=="dell"){
	if(!IsNul($id)){ showmessage("出错了，请不要提交非法参数。",$_SERVER['HTTP_REFERER'],3); }
		$db->query("delete from s_xiaoxi where S_ID=$id or s_vid='".$id."'");
		showmessage("恭喜您，全部删除对话成功。",$_SERVER['HTTP_REFERER'],3);
	//发布对话
	}elseif($op=="dh"){
	$s_content=SafeRequest("S_Content","post","zr");
	$s_vid=SafeRequest("vid","post");
	$s_namea=SafeRequest("name","post","zr");
	$s_addtime=date('Y-m-d H:i:s');
	$s_xid=2;
	$s_nameb=$chsh_username;
	if(!IsNul($s_vid)){ showmessage("出错了，参数出错。",$_SERVER['HTTP_REFERER'],0); }
	if(!IsNul($s_content)){ showmessage("出错了，请填写回复类容。",$_SERVER['HTTP_REFERER'],0); }
	$db->query("update s_xiaoxi set s_vid='".$s_vid."' where s_id=$s_vid");
				$sqlx="insert into s_xiaoxi (S_Xid,S_Nameb,S_Namea,S_Content,S_Addtime,S_Vid) values (".$s_xid.",'".$s_nameb."','".$s_namea."','".$s_content."','".$s_addtime."','".$s_vid."')";
				if($db->query($sqlx)){
				showmessage("回复成功，请等待对方验证。",$_SERVER['HTTP_REFERER'],0);
				}else{
				showmessage("抱歉，回复失败。",$_SERVER['HTTP_REFERER'],0);
				}
	}elseif($op=="add"){
	$s_content=SafeRequest("content","get","zr");
	$s_namea="系统消息";
	$s_addtime=date('Y-m-d H:i:s');
	if(!IsNul($s_content)){ showmessage("出错了，请填写类容。",$_SERVER['HTTP_REFERER'],0); }
	$s_xid=0;
	$s_nameb=$chsh_username;
				$sqlx="insert into s_xiaoxi (S_Xid,S_Nameb,S_Namea,S_Content,S_Addtime) values (".$s_xid.",'".$s_nameb."','".$s_namea."','".$s_content."','".$s_addtime."')";
				if($db->query($sqlx)){
				showmessage("发送成功。","javascript:history.go(-1);",0);
				}else{
				showmessage("抱歉，发送失败。","javascript:history.go(-1);",0);
				}
	}elseif($op=="add1"){
	$s_content=SafeRequest("content","get","zr");
	$s_namea=SafeRequest("S_Namea","get","zr");
	$s_addtime=date('Y-m-d H:i:s');
	if($s_namea==$chsh_username){ showmessage("出错了，请不要给自己发送消息！",$_SERVER['HTTP_REFERER'],0); }
	if(!IsNul($s_content)){ showmessage("出错了，请填写类容。","javascript:history.go(-1);",0); }
	$s_xid=0;
	$s_nameb=$chsh_username;
				$sqlx="insert into s_xiaoxi (S_Xid,S_Nameb,S_Namea,S_Content,S_Addtime) values (".$s_xid.",'".$s_nameb."','".$s_namea."','".$s_content."','".$s_addtime."')";
				if($db->query($sqlx)){
				showmessage("发送成功。","javascript:history.go(-1);",0);
				}else{
				showmessage("抱歉，发送失败。","javascript:history.go(-1);",0);
				}
	}
//删除下载记录
}elseif($ac=="down"){
	global $db;
	if((!$userlogin==true)){showmessage("出错了，请登陆后再操作。","index.php",0);}
	if(!IsNul($id)){ showmessage("出错了，请不要提交非法参数。",$_SERVER['HTTP_REFERER'],3); }
	if($op=="del"){
		$sql="select * from S_down where S_User='".$chsh_username."' and s_id=$id";
		if($row=$db->Getrow($sql)){
		$db->query("delete from S_down where s_id=$id");
		$db->query("delete from s_dt where S_djid='".$row['S_Djid']."' and s_xid=2 and s_user='".$chsh_username."'");
		showmessage("恭喜您，删除成功。",$_SERVER['HTTP_REFERER'],3);
		}else{
		showmessage("出错了，请不要试图删除别人的数据。",$_SERVER['HTTP_REFERER'],3);
		}
	}elseif($op=="delall"){
		$db->query("delete from s_dt where s_xid=2 and s_user='".$chsh_username."'");
		showmessage("恭喜您，删除成功。",$_SERVER['HTTP_REFERER'],3);
		}
//收藏
}elseif($ac=="fav"){
	global $db;
	if((!$userlogin==true)){showmessage("出错了，请登陆后再操作。","index.php",0);}
	if(!IsNul($id)){ showmessage("出错了，请不要提交非法参数。",$_SERVER['HTTP_REFERER'],3); }
	if($op=="del"){
		$sql="select * from S_usersc where S_User='".$chsh_username."' and s_id=$id";
		if($row=$db->Getrow($sql)){
		$db->query("delete from S_usersc where s_id=$id");
		$db->query("delete from s_dt where S_djid='".$row['S_Djid']."' and s_xid=3 and s_user='".$chsh_username."'");
		showmessage("恭喜您，删除成功。",$_SERVER['HTTP_REFERER'],3);
		}else{
		showmessage("出错了，请不要试图删除别人的数据。",$_SERVER['HTTP_REFERER'],3);
		}
	}else{
                //检测数据是否存在
		$sql="select s_id,s_classid,s_name from s_video where S_ID=$id";
		if($row=$db->Getrow($sql)){
		$s_ids= $db->Getone("select s_id from s_usersc where S_djid='".$row['s_id']."' and s_user='".$chsh_username."'");
                if($s_ids){showmessage("出错了，您已经收藏过了".$row['s_name']."。",$_SERVER['HTTP_REFERER'],3);}
				$db->query("update s_video set S_Favhits=S_Favhits+1 where S_ID=$id");
				//入库
				$S_Name=$row['s_name'];
				$S_User=$chsh_username;
				$S_Djid=$row['s_id'];
				$S_Classid=$row['s_classid'];
				$S_Addtime=date('Y-m-d H:i:s');
				global $db;
				$sqlhya="insert into s_usersc (S_Name,S_Djid,S_Classid,S_User,S_Addtime) values ('".$S_Name."',".$S_Djid.",".$S_Classid.",'".$S_User."','".$S_Addtime."')";
				if($db->query($sqlhya)){
				//产生动态
				$S_Djid=$S_Djid;
				$S_Xid=3;
				$S_Name=$S_Name;
				$S_Classid=$S_Classid;
				$S_User=$chsh_username;
				$S_Addtime=date('Y-m-d H:i:s');
				$sqldt="insert into s_dt (S_Name,S_Djid,S_Classid,S_User,S_Xid,S_Addtime) values ('".$S_Name."',".$S_Djid.",".$S_Classid.",'".$S_User."',".$S_Xid.",'".$S_Addtime."')";
				if($db->query($sqldt)){}
				showmessage("恭喜您，收藏<font color='red'>".$S_Name."</font>成功。",$_SERVER['HTTP_REFERER'],3);
				}else{
				showmessage("抱歉，收藏 <font color='red'>".$S_Name."</font> 失败。","index.php",3);
				}
		}else{
		showmessage("出错了，你收藏的数据不存在。",$_SERVER['HTTP_REFERER'],3);
		}
	}


//成为粉丝
}elseif($ac=="fs"){
	global $db;
	if((!$userlogin==true)){showmessage("出错了，请登陆后再操作。","http://www.pjren.net/user/index.php",0);}
	if($op=="add"){
		//检测会员是否存在
	if(!IsNul($id)){ showmessage("出错了，请不要提交非法参数。",$_SERVER['HTTP_REFERER'],0); }
		if($id==$chsh_userid){showmessage("出错了，您不能成为自己的粉丝。",$_SERVER['HTTP_REFERER'],0);}
		$sql="select S_ID,S_Name from s_users where S_ID=$id";
		if($row=$db->Getrow($sql)){
		$s_ids= $db->Getone("select s_id from s_fs where S_namea='".$row['S_Name']."' and s_nameb='".$chsh_username."'");
                if($s_ids){showmessage("出错了，您已经是".$row['S_Name']."的粉丝了。",$_SERVER['HTTP_REFERER'],0);}
				//入库
				$S_Nameb=$chsh_username;
				$S_Namea=$row['S_Name'];
				$sqlhy="insert into s_fs (S_Namea,S_Nameb) values ('".$S_Namea."','".$S_Nameb."')";
				if($db->query($sqlhy)){
				//产生验证消息
				$s_xid=3;
				$s_cid=0;
				$s_nameb=$chsh_username;
				$s_namea=$row['S_Name'];
				$s_content="".$chsh_username."成为您的粉丝!";
				$s_addtime=date('Y-m-d H:i:s');
				$sqlx="insert into s_xiaoxi (S_Xid,S_Nameb,S_Namea,S_Content,S_Addtime) values (".$s_xid.",'".$s_nameb."','".$s_namea."','".$s_content."','".$s_addtime."')";
				if($db->query($sqlx)){}
				showmessage("恭喜您，您已经成了".$S_Namea."的粉丝。",$_SERVER['HTTP_REFERER'],0);
				}else{
				showmessage("抱歉， 操作失败了。","index.php",0);
				}
		}else{
		showmessage("出错了，你选择的会员不存在。",$_SERVER['HTTP_REFERER'],0);
		}
	}

//添加好友
}elseif($ac=="friend"){
	global $db;
	if((!$userlogin==true)){showmessage("出错了，请登陆后再操作。","http://www.pjren.net/user/index.php",0);}
	if($op=="del"){
	if(!IsNul($id)){ showmessage("出错了，请不要提交非法参数。",$_SERVER['HTTP_REFERER'],3); }
        	$s_id= $db->Getone("select s_id from s_friend where s_namea='".$chsh_username."' and s_id=$id");
		if(!$s_id){
		showmessage("出错了，请不要试图删除别人的数据。",$_SERVER['HTTP_REFERER'],3);
		}
		$db->query("delete from s_friend where s_id=$id");
		$db->query("delete from s_xiaoxi where s_xid=1 and s_nameb='".$chsh_username."' and s_namea='".$$row['s_nameb']."'");
		showmessage("恭喜您，删除好友成功。",$_SERVER['HTTP_REFERER'],3);
	}elseif($op=="zu"){
	$s_zu=SafeRequest("s_zu","post","filter");
	$s_name=SafeRequest("s_name","post","filter");
		$db->query("update s_friend set S_zu=$s_zu where s_nameb='".$s_name."' and s_namea='".$chsh_username."'");
		showmessage("恭喜您，进行的操作完成了。",$_SERVER['HTTP_REFERER'],0);
	}elseif($op=="yz"){
	$name=SafeRequest("id","get");
	if(!IsNul($id)){ showmessage("出错了，请不要提交非法参数。",$_SERVER['HTTP_REFERER'],3); }
		$db->query("update s_friend set S_Lock=1 where s_namea='".$id."' and s_nameb='".$chsh_username."'");
		$db->query("update s_xiaoxi set s_did=1,s_cid=1 where s_nameb='".$id."' and s_namea='".$chsh_username."'");
		showmessage("恭喜您，进行的操作完成了。",$_SERVER['HTTP_REFERER'],3);
	}elseif($op=="add"){
		//检测会员是否存在
	if(!IsNul($id)){ showmessage("出错了，请不要提交非法参数。",$_SERVER['HTTP_REFERER'],3); }
		if($id==$chsh_userid){showmessage("出错了，您不能加自己为好友。",$_SERVER['HTTP_REFERER'],3);}
		$sql="select S_ID,S_Name from s_users where S_ID=$id";
		if($row=$db->Getrow($sql)){
		$s_ids= $db->Getone("select s_id from s_friend where S_nameb='".$row['S_Name']."' and s_namea='".$chsh_username."'");
                if($s_ids){showmessage("出错了，您已经填加了".$row['S_Name']."为好友,或者对方没有验证。",$_SERVER['HTTP_REFERER'],3);}
				//入库
				$S_Namea=$chsh_username;
				$S_Nameb=$row['S_Name'];
				$S_Zu=0;
				$S_Lock=0;
				$sqlhy="insert into s_friend (S_Namea,S_Nameb,S_Zu,S_Lock) values ('".$S_Namea."','".$S_Nameb."',".$S_Zu.",".$S_Lock.")";
				if($db->query($sqlhy)){
				//产生验证消息
				$s_xid=3;
				$s_cid=0;
				$s_nameb=$chsh_username;
				$s_namea=$row['S_Name'];
				$s_content="".$chsh_username."填加您为好友!";
				$s_addtime=date('Y-m-d H:i:s');
				$sqlx="insert into s_xiaoxi (S_Xid,S_Nameb,S_Namea,S_Content,S_Addtime) values (".$s_xid.",'".$s_nameb."','".$s_namea."','".$s_content."','".$s_addtime."')";
				if($db->query($sqlx)){}
				showmessage("好友请求已经发送，请等待对方验证中。",$_SERVER['HTTP_REFERER'],3);
				}else{
				showmessage("抱歉，添加 <font color='red'>".$row['S_Name']."好友</font> 失败。","index.php",3);
				}
		}else{
		showmessage("出错了，你添加的好友不存在。",$_SERVER['HTTP_REFERER'],3);
		}
	}

//专集
}elseif($ac=="topic"){
	if((!$userlogin==true)){showmessage("出错了，请登陆后再操作。","index.php",0);}
	global $db;
	$S_Name=SafeRequest("S_Name","post","zr");
	$S_Pic=SafeRequest("S_Pic","post");
	$S_Content=SafeRequest("S_Content","post","zr");
	$S_Cname=SafeRequest("S_Cname","post");
	$S_Keywords=SafeRequest("S_Keywords","post");
	$S_Remark=substr($S_Content,0,50);
	$S_AddTime=date('Y-m-d H:i:s');
	$S_IsHide=1;
	  $topicid=$db->getOne("select s_id from s_topic where s_name='".$S_Name."'");
	  if($topicid){showmessage("出错了，该专集名已经存在，请换个名字！",$_SERVER['HTTP_REFERER'],0);}
	  $Cuid=$db->getOne("select s_id from s_topic where S_AliasName='".$S_Cname."'");
	  if($Cuid){showmessage("出错了，该英文别名已经存在，请换个英文名字！",$_SERVER['HTTP_REFERER'],0);}
		$sql="Insert s_topic (S_Name,S_Keywords,S_AliasName,S_Pic,S_Template,S_Remark,S_Content,S_SystemID,S_AddTime,S_IsHide) values ('".$S_Name."','".$S_Keywords."','".$S_Cname."','".$S_Pic."','vodtopic.html','".$S_Remark."','".$S_Content."',1,'".$S_AddTime."',".$S_IsHide.")";
		if($db->query($sql)){
			showmessage("恭喜您，专集<font color='red'>".$S_Name."</font>发布成功,请等待管理员审核!","space.php?ac=topic",0);
		}else{
			showmessage("抱歉，专集<font color='red'>".$S_Name."</font>发布失败!","space.php?ac=topic",0);	
		}
//填加舞曲
}elseif($ac=="music"){
	if((!$userlogin==true)){showmessage("出错了，请登陆后再操作。","index.php",0);}
	global $db;
	$S_Name=SafeRequest("S_Name","post","zr");
	$S_ClassID=SafeRequest("S_ClassID","post");
	$S_Author=SafeRequest("S_Author","post","zr");
	$S_Source=SafeRequest("S_Source","post");
	$S_Vdata=SafeRequest("S_Vdata","post");
	$S_Remark=SafeRequest("S_Vdata","post");
	$S_Topic=SafeRequest("S_Topic","post");
	$S_Content=SafeRequest("S_Content","post","zr");
	$S_Templay=SafeRequest("S_Templay","post");
	$S_Direct=$chsh_username;
	$S_Reco=0;
	$S_AddTime=date('Y-m-d H:i:s');
	$S_Pic=0;
	$S_IsEnd=0;
	$S_IsHide=1;
	$S_Hits=0;
	$S_Keywords1=$S_Name;
	$S_Server=0;
	$S_PurView=0;
	if(S_DjaddFun==1){
        $tishiname=",审核通过系统自动为您增加".S_DjaddPoints."点";
        }
        if(S_Djopen==0) $S_IsHide=0; //不用审核
	if(!IsNul($S_Name)||!IsNul($S_ClassID)||!IsNul($S_Source)||!IsNul($S_Vdata)||!IsNul($S_Templay)||!IsNul($S_Direct)){ showmessage("出错了，请把信息填写完整!",$_SERVER['HTTP_REFERER'],0); }
	$s_ids= $db->Getone("select s_id from s_video where S_name='".$S_Name."' and s_vdata='".$S_Vdata."'");
        if($s_ids){showmessage("出错了，此舞曲已经存在。",$_SERVER['HTTP_REFERER'],0);}
				//入库
		$sql="Insert s_video (S_Name,S_Color,S_Remark,S_ClassID,S_Topic,S_Pic,S_Author,S_Content,S_Reco,S_IsEnd,S_Source,S_Vdata,S_Hits,S_Direct,S_Keywords,S_AddTime,S_AddPath,S_PurView,S_Templay,S_IsHide) values ('".$S_Name."','".$S_Color."','".$S_Remark."',".$S_ClassID.",".$S_Topic.",'".$S_Pic."','".$S_Author."','".$S_Content."',".$S_Reco.",".$S_IsEnd.",'".$S_Source."','".$S_Vdata."',".$S_Hits.",'".$S_Direct."','".$S_Keywords1."','".$S_AddTime."','".$S_Server."','".$S_PurView."','".$S_Templay."','".$S_IsHide."')";
		if($db->query($sql));
		$sql1="Select S_ID from S_Video where S_Name='".$S_Name."'";
		$row=$db->getrow($sql1);
				if($row){
				//产生动态
				$S_Djid=$row["S_ID"];
				$S_Xid=1;
				$S_Name=$S_Name;
				$S_Classid=$S_ClassID;
				$S_User=$chsh_username;
				$S_Addtime=date('Y-m-d H:i:s');
				$sqldt="insert into s_dt (S_Name,S_Djid,S_Classid,S_User,S_Xid,S_Addtime) values ('".$S_Name."',".$S_Djid.",".$S_Classid.",'".$S_User."',".$S_Xid.",'".$S_Addtime."')";
				if($db->query($sqldt));
                                   if(S_Djopen==0){
				           showmessage("恭喜您，舞曲<font color='red'>".$S_Name."</font>发布成功，".$tishiname."。","space.php?ac=music",0);
                                   }else{
				           showmessage("恭喜您，舞曲<font color='red'>".$S_Name."</font>发布成功，请等待管理员审核".$tishiname."。","space.php?ac=music",0);
                                   }
				}else{
				showmessage("抱歉，舞曲 <font color='red'>".$S_Name."</font> 入库失败。",$_SERVER['HTTP_REFERER'],0);
				}

//发表文章
}elseif($ac=="article"){
	if((!$userlogin==true)){showmessage("出错了，请登陆后再操作。","index.php",0);}
	global $db;
	$S_ID=SafeRequest("id","get");
	$S_Name=SafeRequest("S_Name","post","zr");
	$S_ClassID=SafeRequest("S_ClassID","post");
	$S_Author=SafeRequest("S_Author","post","zr");
	$S_Source=SafeRequest("S_Source","post");
	$S_Content=SafeRequest("S_ConTent","post","zr");
	if(!IsNul($S_Remark)) $S_Remark=cnsubstr($S_Content,100);
	$S_Color = "";
	$S_Topic=0;
	$S_Reco=0;
	$S_AddTime=date('Y-m-d H:i:s');
	$S_Pic= "";
	$S_IsHide=1;
        if($chsh_leve=="授权会员"){
	$S_IsHide=0;
        }
	$S_Hits=0;
	$S_Keywords1=$S_Name;
	$S_PurView=0;
 //删除文章
 if($op=="del"){
	if(!IsNul($S_ID)){ showmessage("出错了，请不要提交非法参数。",$_SERVER['HTTP_REFERER'],3); }
        	$s_id= $db->Getone("select s_id from s_article where S_Author='".$chsh_username."' and s_id=$S_ID");
		if(!$s_id){
		showmessage("出错了，请不要试图删除别人的数据。",$_SERVER['HTTP_REFERER'],3);
		}
		$db->query("delete from s_article where s_id=$S_ID");
		showmessage("恭喜您，文章删除成功。",$_SERVER['HTTP_REFERER'],3);
 }else{
 //填加文章
	if(!IsNul($S_Name)||!IsNul($S_ClassID)||!IsNul($S_Author)||!IsNul($S_Source)||!IsNul($S_Content)){ showmessage("出错了，请把信息填写完整!",$_SERVER['HTTP_REFERER'],0); }
				//入库
		$sql="Insert s_article (S_Name,S_Color,S_Remark,S_ClassID,S_Topic,S_Pic,S_Author,S_Content,S_Reco,S_Source,S_IsHide,S_Hits,S_Keywords,S_AddTime,S_PurView) values ('".$S_Name."','".$S_Color."','".$S_Remark."',".$S_ClassID.",".$S_Topic.",'".$S_Pic."','".$S_Author."','".$S_Content."',".$S_Reco.",'".$S_Source."',0,".$S_Hits.",'".$S_Keywords1."','".$S_AddTime."','".$S_PurView."')";
		if($db->query($sql)){
                                   if($chsh_leve=="授权会员"){
				           showmessage("恭喜您，文章<font color='red'>".$S_Name."</font>发布成功。","space.php?ac=article",0);
                                   }else{
				           showmessage("恭喜您，文章<font color='red'>".$S_Name."</font>发布成功，请等待管理员审核。","space.php?ac=article",0);
                                   }
                                   }else{
				           showmessage("添加文章失败哦!",$_SERVER['HTTP_REFERER'],0);
		}
 }

//添加好友组
}elseif($ac=="zu"){
	global $db;
	if((!$userlogin==true)){showmessage("出错了，请登陆后再操作。","index.php",0);}
	if($op=="del"){
	if(!IsNul($id)){ showmessage("出错了，请不要提交非法参数。",$_SERVER['HTTP_REFERER'],0); }
        	$s_id= $db->Getone("select s_id from s_friendzu where s_user='".$chsh_username."' and s_id=$id");
		if(!$s_id){
		showmessage("出错了，请不要试图删除别人的数据。",$_SERVER['HTTP_REFERER'],3);
		}
		$db->query("delete from s_friendzu where s_id=$id");
		$db->query("delete from s_friend where s_zu=$id and s_namea='".$chsh_username."'");
		showmessage("恭喜您，删除好友组成功。",$_SERVER['HTTP_REFERER'],3);
	}elseif($op=="edit"){
	$s_name=SafeRequest("S_name","post","zr");
	$s_id=SafeRequest("s_id","post");
		$s_ids= $db->Getone("select s_id from s_friendzu where S_name='".$s_name."' and s_user='".$chsh_username."'");
                if($s_ids){showmessage("出错了，该组名已经存在。",$_SERVER['HTTP_REFERER'],0);}
		$db->query("update s_friendzu set S_name='".$s_name."' where S_id=$s_id and s_user='".$chsh_username."'");
		showmessage("恭喜您，修改组名成功。",$_SERVER['HTTP_REFERER'],0);
	}elseif($op=="add"){
	$s_name=SafeRequest("S_name","post","zr");
	if(!IsNul($s_name)){ showmessage("出错了，请填写组名称。",$_SERVER['HTTP_REFERER'],0); }
		$s_ids= $db->Getone("select s_id from s_friendzu where S_name='".$s_name."' and s_user='".$chsh_username."'");
                if($s_ids){showmessage("出错了，该组名已经存在。",$_SERVER['HTTP_REFERER'],0);}
				//入库
				$S_User=$chsh_username;
				$S_Name=$s_name;
				$sqlhy="insert into s_friendzu (S_Name,S_User) values ('".$S_Name."','".$S_User."')";
				if($db->query($sqlhy)){
				showmessage("恭喜您，组填加成功。",$_SERVER['HTTP_REFERER'],0);
				}else{
				showmessage("抱歉，组填加失败。",$_SERVER['HTTP_REFERER'],0);
				}
			}
//删除相片
}elseif($ac=="pic"){
	global $db;
	$ids=SafeRequest("ids","post");
	if((!$userlogin==true)){showmessage("出错了，请登陆后再操作。","index.php",0);}
	if($op=="del"){
	if(!IsNul($id)){ showmessage("出错了，请不要提交非法参数。",$_SERVER['HTTP_REFERER'],0); }
		$sql="select * from s_pic where S_User='".$chsh_username."' and s_id=$id";
		if($row=$db->Getrow($sql)){
                $picurl=explode("upload",$row['S_Url']);
                $picurl="/upload".$picurl[1];
		$fileurl="..".$picurl;
		$fileurl="../".substr($fileurl,strlen(S_SitePath));
		if(file_exists($fileurl)){
		unlink($fileurl);
		}
		$sqlp="delete from s_dt where s_name='".$row['S_Url']."' and s_user='".$chsh_username."'";
		$db->query($sqlp);
		$sql="delete from s_pic where S_ID=".$id."";
		$db->query($sql);
		showmessage("恭喜您，删除图片成功。",$_SERVER['HTTP_REFERER'],3);
		}else{
		showmessage("出错了，请不要试图删除别人的数据。",$_SERVER['HTTP_REFERER'],0);
		}
	}elseif($op=="delall"){
	$idss=RequestBox("S_ID");
	if(!IsNul($idss)){ showmessage("出错了，请选择要删除的数据。",$_SERVER['HTTP_REFERER'],0); }
	$Arr=explode(',',$idss);
		for($i=0;$i<count($Arr);$i++){
		$url=$db->getRow("select S_url from s_pic where S_ID=".$Arr[$i]."");
                $picurl=explode("upload",$url['S_url']);
                $picurl="/upload".$picurl[1];
		$fileurl="..".$picurl;
		$fileurl="../".substr($fileurl,strlen(S_SitePath));
		if(file_exists($fileurl)){
		unlink($fileurl);
		}
		$sqlp="delete from s_dt where s_name='".$url['S_url']."' and s_user='".$chsh_username."'";
		$db->query($sqlp);
		$sql="delete from s_pic where S_ID=".$Arr[$i]."";
		$db->query($sql);	
		}
		showmessage("恭喜您，删除图片成功。",$_SERVER['HTTP_REFERER'],0);
	}
//留言
}elseif($ac=="gbook"){
	global $db;
	if((!$userlogin==true)){showmessage("出错了，请登陆后再操作。","index.php",0);}
	$S_Name=SafeRequest("S_Namea","post","filter");
	$S_Content=SafeRequest("S_Content","post","filter");
	$S_ReContent=SafeRequest("content","get","filter");
	$S_ReContent=iconv("utf-8", "gb2312", "".$S_ReContent."");
	$S_ReTime=date('Y-m-d H:i:s');
	if($op=="del"){
		$sql="select * from s_gbook where S_namea='".$chsh_username."' and s_id=$id";
		if($row=$db->Getrow($sql)){
		$db->query("delete from s_gbook where s_id=$id");
		$db->query("delete from s_xiaoxi where s_namea='".$row['S_Nameb']."' and s_nameb='".$chch_username."'");
		showmessage("恭喜您，进行的操作完成了。",$_SERVER['HTTP_REFERER'],3);
		}else{
		showmessage("出错了，请不要试图删除别人的数据。",$_SERVER['HTTP_REFERER'],3);
		}
	}elseif($op=="hf"){
	$name=SafeRequest("types","get");
		$sql="select * from s_gbook where S_namea='".$chsh_username."' and s_id=".$id."";
		$row=$db->getrow($sql);
		if($row){
		$db->query("update s_gbook set S_ReContent='".$S_ReContent."',S_ReTime ='".$S_ReTime."' where s_id=$id");
				//产生回复消息
				$s_xid=5;
				$s_nameb=$chsh_username;
				$s_namea=$name;
				$s_content="".$chsh_username."回复您留言";
				$s_addtime=date('Y-m-d H:i:s');
				$sqlx="insert into s_xiaoxi (S_Xid,S_Nameb,S_Namea,S_Content,S_Addtime) values (".$s_xid.",'".$s_nameb."','".$s_namea."','".$s_content."','".$s_addtime."')";
				if($db->query($sqlx)){}
		showmessage("恭喜您，回复成功。","javascript:history.go(-1);",0);
		}else{
		showmessage("出错了，请不要回复别人的留言。","javascript:history.go(-1);",0);
		}
	}elseif($op=="add"){
				//入库
				$S_Namea=$S_Name;
				$S_Nameb=$chsh_username;
				$s_content=$S_Content;
				$s_addtime=date('Y-m-d H:i:s');
				$sqlbook="insert into s_gbook (S_Namea,S_Nameb,s_content,s_addtime) values ('".$S_Namea."','".$S_Nameb."','".$s_content."','".$s_addtime."')";
				if($db->query($sqlbook)){
				//产生消息
				$s_xid=4;
				$s_nameb=$chsh_username;
				$s_namea=$S_Name;
				$s_content="".$chsh_username."给您留言";
				$s_addtime=date('Y-m-d H:i:s');
				$sqlx="insert into s_xiaoxi (S_Xid,S_Nameb,S_Namea,S_Content,S_Addtime) values (".$s_xid.",'".$s_nameb."','".$s_namea."','".$s_content."','".$s_addtime."')";
				if($db->query($sqlx)){}
				}else{
				showmessage("抱歉，给 <font color='red'>".$S_Name."</font> 留言失败。",$_SERVER['HTTP_REFERER'],0);
				}
		showmessage("恭喜您，给 <font color='red'>".$S_Name."</font> 留言成功。",$_SERVER['HTTP_REFERER'],0);
	}elseif($op=="add1"){
	$S_Namea=SafeRequest("S_Namea","get","zr");
	$S_Nameb=SafeRequest("S_Nameb","get","zr");
	$S_Content=SafeRequest("content","get","filter");
	$S_Content=iconv("utf-8", "gb2312", "".$S_Content."");
	if($S_Namea=="".$S_Nameb.""){ showmessage("出错了，不能给自己留言。",$_SERVER['HTTP_REFERER'],1); }
				//入库
				$S_Namea=$S_Namea;
				$S_Nameb=$S_Nameb;
				$s_content=$S_Content;
				$s_addtime=date('Y-m-d H:i:s');
				$sqlbook="insert into s_gbook (S_Namea,S_Nameb,s_content,s_addtime) values ('".$S_Namea."','".$S_Nameb."','".$s_content."','".$s_addtime."')";
				if($db->query($sqlbook)){
				//产生消息
				$s_xid=4;
				$s_nameb=$S_Nameb;
				$s_namea=$S_Namea;
				$s_content="".$chsh_username."给您留言";
				$s_addtime=date('Y-m-d H:i:s');
				$sqlx="insert into s_xiaoxi (S_Xid,S_Nameb,S_Namea,S_Content,S_Addtime) values (".$s_xid.",'".$s_nameb."','".$s_namea."','".$s_content."','".$s_addtime."')";
				if($db->query($sqlx)){}
				}else{
				showmessage("抱歉，给 <font color='red'>".$S_Namea."</font> 留言失败。",$_SERVER['HTTP_REFERER'],0);
				}
		showmessage("恭喜您，给 <font color='red'>".$S_Namea."</font> 留言成功。","javascript:history.go(-1);",1);
	}elseif($op=="add2"){
	$s_namea=SafeRequest("s_namea","post");
	$s_nameb=$chsh_username;
	$S_Content=SafeRequest("S_Content","post","filter");
	if(!IsNul($S_Content)){ showmessage("出错了，请写入要说的话。",$_SERVER['HTTP_REFERER'],0); }
	if($s_namea=="".$s_nameb.""){ showmessage("出错了，不能给自己留言。",$_SERVER['HTTP_REFERER'],0); }
				//入库
				$S_Namea=$s_namea;
				$S_Nameb=$s_nameb;
				$s_content=$S_Content;
				$s_addtime=date('Y-m-d H:i:s');
				$sqlg="insert into s_gbook (S_Namea,S_Nameb,s_content,s_addtime) values ('".$S_Namea."','".$S_Nameb."','".$s_content."','".$s_addtime."')";
				if($db->query($sqlg)){
				//产生消息
				$s_xid=4;
				$s_nameb=$s_nameb;
				$s_namea=$s_namea;
				$s_content="".$chsh_username."给您留言";
				$s_addtime=date('Y-m-d H:i:s');
				$sqlx="insert into s_xiaoxi (S_Xid,S_Nameb,S_Namea,S_Content,S_Addtime) values (".$s_xid.",'".$s_nameb."','".$s_namea."','".$s_content."','".$s_addtime."')";
				if($db->query($sqlx)){}
				}else{
				showmessage("抱歉，给 <font color='red'>".$s_namea."</font> 留言失败。",$_SERVER['HTTP_REFERER'],0);
				}
		showmessage("恭喜您，给 <font color='red'>".$s_namea."</font> 留言成功。",$_SERVER['HTTP_REFERER'],0);
	}

//冲值点卡，月卡
}elseif($ac=="pay"){
	if(!$userlogin==true){showmessage("出错了，请登陆后再操作。","index.php",0);}
	if(!IsNul($id)){ showmessage("出错了，请不要提交非法参数。",$_SERVER['HTTP_REFERER'],0); }
	global $db;
	$sqlv="select * from s_users where S_Name='".$chsh_username."'";
	$resultv=$db->query($sqlv);
	if($rowv=$db->fetch_array($resultv)){
	$S_Name=$rowv["S_Name"];
	$S_RMB=$rowv["S_RMB"];
		$sqlc="select * from s_card where S_ID=".$id;
		$resultc=$db->query($sqlc);
		if($rowc=$db->fetch_array($resultc)){
                    if($rowc["S_CardVip"]!=$chsh_username){
			if($rowc["S_RMB"]<$S_RMB){
				showmessage("对不起，你的余额不足，请重新选择卡!",$_SERVER['HTTP_REFERER'],0);
                        }
                    $RMB=$rowc["S_RMB"];
                    }else{
                    $RMB=0;
                    }
				if($rowc["S_CardUsed"]==1){
					showmessage("该充值卡已被使用!",$_SERVER['HTTP_REFERER'],0);
				}else{
					if($rowv["S_UseType"]==$rowc["S_CardGroup"]){
						if($rowc["S_CardGroup"]==0){
							$NewCoin=$rowv["S_Coin"]+$rowc["S_CardWorth"];
							$sqlv="update s_users set S_Coin=".$NewCoin.",S_RMB=S_RMB-$RMB where S_Name='".$S_Name."'";
							$db->query($sqlv);
							$sqlc="update s_card set S_CardState=1,S_CardUsed=1,S_CardVip='".$S_Name."' where S_ID=".$id;
							$db->query($sqlc);
							showmessage("点卡充值成功,为您帐户增加".$rowc["S_CardWorth"]."点,减去人民币".$RMB."元!",$_SERVER['HTTP_REFERER'],0);
						}else{
							$time1=$rowv["S_UseDate"];
							$time2=date('Y-m-d');
							$diff=strtotime($time1)-strtotime($time2);
							if($diff<0){
								$mydate=mktime(0,0,0,date("m")+$rowc["S_CardWorth"],date("d"),date("Y"));
								$NewUseDate= date("Y-m-d H:I:s",$mydate);
								$RMB=$rowc["S_RMB"];
								$sqlv="update s_users set S_UseDate='".$NewUseDate."',S_RMB=S_RMB-$RMB where S_Name='".$S_Name."'";
								$db->query($sqlv);
								$sqlc="update s_card set S_CardState=1,S_CardUsed=1,S_CardVip='".$S_Name."' where  S_ID=".$id;
								$db->query($sqlc);
								showmessage("月卡充值成功,为您帐户增加时间到".$NewUseDate.",减去人民币".$RMB."元!!",$_SERVER['HTTP_REFERER'],0);
							}else{
								$strtimes = explode(" ",$rowv["S_UseDate"]);
								$timearray = explode("-",$strtimes[0]);
								$year = $timearray[0];
								$month = $timearray[1]+$rowc["S_CardWorth"];
								$day = $timearray[2];
								$mydate2=mktime(0,0,0,$month,$day,$year);
								$NewUseDate=date("Y-m-d H:I:s",$mydate2);
								$sqlv="update s_users set S_UseDate='".$NewUseDate."',S_RMB=S_RMB-$RMB where S_Name='".$S_Name."'";
								$db->query($sqlv);
								$sqlc="update s_card set S_CardState=1,S_CardUsed=1,S_CardVip='".$S_Name."' where  S_ID=".$id;
								$db->query($sqlc);
								showmessage("月卡充值成功,为您帐户增加时间到".$NewUseDate.",减去人民币".$RMB."元!!",$_SERVER['HTTP_REFERER'],0);
							}
						}
					}else{
						showmessage("对不起，请购买合适您帐号的充值卡!",$_SERVER['HTTP_REFERER'],0);
					}
				}
		}else{
				showmessage("充值卡号不存在，请重新输入!",$_SERVER['HTTP_REFERER'],0);
		}
	}else{
			showmessage("帐号不存在，请重新输入!",$_SERVER['HTTP_REFERER'],0);

	}
//微薄客
}elseif($ac=="blog"){
	global $db;
	if((!$userlogin==true)){showmessage("出错了，请登陆后再操作。","index.php",0);}
	$S_Content=SafeRequest("S_Content","post","zr");
	$S_ReTime=date('Y-m-d H:i:s');
	if($op=="del"){
		$sql="select * from s_blog where S_User='".$chsh_username."' and s_id=$id";
		if($row=$db->Getrow($sql)){
		$db->query("delete from s_blog where s_id=$id");
		$db->query("delete from s_dt where S_Name='".$row['S_Content']."' and s_user='".$chsh_username."'");
		showmessage("恭喜您，删除成功。",$_SERVER['HTTP_REFERER'],3);
		}else{
		showmessage("出错了，请不要试图删除别人的数据。",$_SERVER['HTTP_REFERER'],0);
		}
	}elseif($op=="pl"){
		$db->query("update s_gbook set S_ReContent='".$S_ReContent."',S_ReTime ='".$S_ReTime."' where s_id=$id");
		showmessage("恭喜您，进行的操作完成了。",$_SERVER['HTTP_REFERER'],0);
	}elseif($op=="add"){
	if(!IsNul($S_Content)){ showmessage("出错了，请填写微薄类容。",$_SERVER['HTTP_REFERER'],0); }
				//入库
				$S_User=$chsh_username;
				$S_content=$S_Content;
				$S_Addtime=date('Y-m-d H:i:s');
				$sqlbook="insert into s_blog (S_User,S_content,S_Addtime) values ('".$S_User."','".$S_Content."','".$S_Addtime."')";
				if($db->query($sqlbook)){
				//产生动态
				$S_Djid=0;
				$S_Xid=4;
				$S_Name=$S_Content;
				$S_Classid=0;
				$S_User=$chsh_username;
				$S_Addtime=date('Y-m-d H:i:s');
				$sqldt="insert into s_dt (S_Name,S_Djid,S_Classid,S_User,S_Xid,S_Addtime) values ('".$S_Name."',".$S_Djid.",".$S_Classid.",'".$S_User."',".$S_Xid.",'".$S_Addtime."')";
				if($db->query($sqldt)){}
				}else{
				showmessage("抱歉，发表微博失败。",$_SERVER['HTTP_REFERER'],0);
				}

		//showmessage("恭喜您，微博发表成功。","qq/weibo/add_weibo.php?content=".$S_Content."",0);
		showmessage("恭喜您，微博发表成功。",$_SERVER['HTTP_REFERER'],0);
	}
}
//推广
function TG(){
	global $db;
	$S_ID = SafeRequest("id","get");
	$IP=getenv('REMOTE_ADDR');
	if(S_TGFun==0){
	exit("<script language=javascript>alert('抱歉，推广功能已经关闭！');location.href = '../index.php';</script>");
	}
	if($S_ID=="" && $S_ID==0){
		echo "<script>window.location='".S_TGURL."'</script>";
	}
	else{
		$sql="select * from s_users where S_ID=".$S_ID;
		$result=$db->query($sql);
		if($row=$db->fetch_array($result)){
			if(isset($_COOKIE["TGIP"])){
			}
			else{
				setcookie("TGIP",$IP,time()+3600);	
			}
			$TGIP=$_COOKIE["TGIP"];
			$IP=getenv('REMOTE_ADDR');
			$TGIPARR=explode(",",$TGIP);
			$tishi="b";
			for($i=0;$i<count($TGIPARR);$i++){
				if($TGIPARR[$i]==$IP){
					$tishi="a";
				}
			}
			if($tishi=="a"){
				echo "<script>window.location='".S_TGURL."'</script>";
			}
			else{
				if(S_TGFun==1){
					setcookie("TGIP",$TGIP.",".$IP,time()+3600);
					$S_Coin=$row["S_Coin"]+S_Points;
					$sqlu="update s_users set S_Coin=".$S_Coin." where S_ID=".$S_ID;
					$db->query($sqlu);
					echo "<script>window.location='".S_TGURL."'</script>";
				}
				else{
					echo "<script>window.location='".S_TGURL."'</script>";
				}
			}
		}
		else{
			echo "<script>window.location='".S_TGURL."'</script>";
		}
	}
}
function formatsize($size) {
	$prec=3;
	$size = round(abs($size));
	$units = array(0=>" B ", 1=>" KB", 2=>" MB", 3=>" GB", 4=>" TB");
	if ($size==0) return str_repeat(" ", $prec)."0$units[0]";
	$unit = min(4, floor(log($size)/log(2)/10));
	$size = $size * pow(2, -10*$unit);
	$digi = $prec - 1 - floor(log($size)/log(10));
	$size = round($size * pow(10, $digi)) * pow(10, -$digi);
	return $size.$units[$unit];
}
?>
</body>
</html>