<?php
include "../include/conn.php";
include "../include/function.php";
include "../include/userset.php";

//'**************************************************************************************************
//' 软件名称: 搜一次 Content Management System
//' 版本编号: V4.0.0版
//' 官方网站: http://www.syccms.com
//' 官方论坛：http://bbs.syccms.com
//' 软件编写: 无痕(QQ:512591)，暮寒，新手℡鼠标
//' 郑重声明:
//'    1、任何个人或组织不得在未经授权的情况下删除、修改、拷贝本软件及其他副本上一切关于版权的信息；
//'    2、搜一次网络有限公司保留此软件的法律追究权利
//'**************************************************************************************************
?><!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=gb2312" />
<link href="images/style.css" rel="stylesheet" type="text/css" />
<title>会员中心</title>
<script language="javascript">
function back(){
	window.history.go(-1);
	};
function del(id){
	var r=confirm('您确定要删除该系统消息吗?');
	if(r==true){
		window.location='?action=del&S_ID='+id;
	};
};
function puterr(){
	var r=confirm('您确定要进行转换吗?');
	if(r==true){
		formjf.submit();
	}
	else{
		return false;
		};
};
function delsq(id){
	var r=confirm('您确定要删除该网址吗?');
	if(r==true){
		window.location='?action=delsq&S_ID='+id;
	};
};
function showlist(page){
	window.location='?action=list2&page='+page
	};
function checkei(it){
		var S_RealName=it.S_RealName.value;
		var S_Tel=it.S_Tel.value;
		var S_QQ=it.S_QQ.value;
		var S_Email=it.S_Email.value;
		it.S_RealName.style.borderColor='#666 #ccc #ccc #666';
		it.S_Tel.style.borderColor='#666 #ccc #ccc #666';
		it.S_QQ.style.borderColor='#666 #ccc #ccc #666';
		it.S_Email.style.borderColor='#666 #ccc #ccc #666';
		if(S_RealName==""){
			document.getElementById("tishi5").innerHTML="请输入真实姓名!";
			it.S_RealName.style.border='1px solid red';
			return false;}
		else if(len(S_RealName)>50){
			it.S_RealName.style.border='1px solid red';
			document.getElementById("tishi5").innerHTML="姓名限制最大50位！";
			return false;}
		else if((S_Tel.length<4)||(S_Tel.length>18)){
			document.getElementById("tishi5").innerHTML="电话限制4-18位!";
			it.S_Tel.style.border='1px solid red';
			return false;}
		else if((S_QQ.length<5)||(S_QQ.length>18)){
			document.getElementById("tishi5").innerHTML="QQ限制5-18位!";
			it.S_QQ.style.border='1px solid red';
			return false;}
		else if(S_Email==""){
			document.getElementById("tishi5").innerHTML="请输入Email!";
			it.S_Email.style.border='1px solid red';
			return false;}
		else if(isEmail(S_Email)==false){
			document.getElementById("tishi5").innerHTML="Email格式错误!";
			it.S_Email.style.border='1px solid red';
			return false;}
		else if(len(S_Email)>50){
			document.getElementById("tishi5").innerHTML="Email限制最大50位!";
			it.S_Email.style.border='1px solid red';
			return false;}
	};
function checkep(it){
		var userid=it.userid.value;
		var oldpwd=it.oldpwd.value;
		var password=it.password.value;
		var password2=it.password2.value;
		it.userid.style.borderColor='#666 #ccc #ccc #666';
		it.oldpwd.style.borderColor='#666 #ccc #ccc #666';
		it.password.style.borderColor='#666 #ccc #ccc #666';
		it.password2.style.borderColor='#666 #ccc #ccc #666';
		if(userid==""){
			it.userid.style.border='1px solid red';
			document.getElementById("tishi4").innerHTML="请输入帐号!";
			return false;}
		else if((len(userid)<4)||(len(userid)>16)){
			it.userid.style.border='1px solid red';
			document.getElementById("tishi4").innerHTML="帐号限制4-16位!";
			return false;}
		else if(oldpwd==""){
			it.oldpwd.style.border='1px solid red';
			document.getElementById("tishi4").innerHTML="请输入原密码!";
			return false;}
		else if((oldpwd.length<6)||(oldpwd.length>18)){
			document.getElementById("tishi4").innerHTML="密码限制6-18位!";
			it.oldpwd.style.border='1px solid red';
			return false;}
		else if(password==""){
			document.getElementById("tishi4").innerHTML="请输入新密码!";
			it.password.style.border='1px solid red';
			return false;}
		else if((password.length<6)||(password.length>18)){
			document.getElementById("tishi4").innerHTML="密码限制6-18位!";
			it.password.style.border='1px solid red';
			return false;}
		else if(password2==""){
			document.getElementById("tishi4").innerHTML="请确认密码!";
			it.password2.style.border='1px solid red';
			return false;}
		else if(password!=password2){
			document.getElementById("tishi4").innerHTML="密码输入不一致!";
			it.password.style.border='1px solid red';
			it.password2.style.border='1px solid red';
			return false;
			}
	};
function checkcz(it){
		var S_Name=it.S_Name.value;
		var S_Name1=it.S_Name1.value;
		var S_CardNum=it.S_CardNum.value;
		var S_CardPWD=it.S_CardPWD.value;
		it.S_Name.style.borderColor='#666 #ccc #ccc #666';
		it.S_Name1.style.borderColor='#666 #ccc #ccc #666';
		it.S_CardNum.style.borderColor='#666 #ccc #ccc #666';
		it.S_CardPWD.style.borderColor='#666 #ccc #ccc #666';
		if(S_Name==""){
			it.S_Name.style.border='1px solid red';
			document.getElementById("tishi").innerHTML="请输入帐号!";
			return false;}
		else if((len(S_Name)<4)||(len(S_Name)>16)){
			it.S_Name.style.border='1px solid red';
			document.getElementById("tishi").innerHTML="帐号限制4-16位!";
			return false;}
		else if(S_Name1==""){
			it.S_Name1.style.border='1px solid red';
			document.getElementById("tishi").innerHTML="请确认帐号!";
			return false;}
		else if(S_Name!=S_Name1){
			it.S_Name.style.border='1px solid red';
			it.S_Name1.style.border='1px solid red';
			document.getElementById("tishi").innerHTML="两次输入帐号不一致!";
			return false;}
		else if(S_CardNum.length!=16){
			it.S_CardNum.style.border='1px solid red';
			document.getElementById("tishi").innerHTML="充值卡号必须是16位数字!";
			return false;}
		else if(S_CardPWD.length!=8){
			it.S_CardPWD.style.border='1px solid red';
			document.getElementById("tishi").innerHTML="充值卡密码必须是8位数字!";
			return false;}
	};
function checksq(it){
		var S_Title=it.S_Title.value;
		var S_Content=it.S_Content.value;
		var S_Info=it.S_Info.value;
		it.S_Title.style.borderColor='#666 #ccc #ccc #666';
		it.S_Content.style.borderColor='#666 #ccc #ccc #666';
		it.S_Info.style.borderColor='#666 #ccc #ccc #666';
		if(S_Title==""){it.S_Title.style.border='1px solid red';return false;}
		else if(len(S_Title)>250){it.S_Title.style.border='1px solid red';return false;}
		else if(S_Content==""){it.S_Content.style.border='1px solid red';return false;}
		else if(S_Info==""){it.S_Info.style.border='1px solid red';return false;}
	};
function checkgb(it){
	var content=it.content.value;
	var codes=it.codes.value;
	it.content.style.borderColor='#666 #ccc #ccc #666';
	it.codes.style.border='1px #eaeaea solid';
	if(content==""){
		it.content.style.border='1px solid red';return false;
		}
	else if(codes==""){
		it.codes.style.border='1px solid red';return false;
		}
	};
function checkzs(it){
	var S_Vip=it.S_Vip.value;
	var S_Coin=it.S_Coin.value;
	it.S_Vip.style.borderColor='#666 #ccc #ccc #666';
	it.S_Coin.style.borderColor='#666 #ccc #ccc #666';
	if(S_Vip==""){
		it.S_Vip.style.border='1px solid red';return false;
		}
	else if((len(S_Vip)<4)||(len(S_Vip)>16)){
		it.S_Vip.style.border='1px solid red';return false;
		}
	else if(S_Coin==""){
		it.S_Coin.style.border='1px solid red';return false;
		}
	else if(S_Coin.length>5){
		it.S_Coin.style.border='1px solid red';return false;
		}
	};
function checklg(it){
	var S_Name=it.S_Name.value;
	var S_PassWord=it.S_PassWord.value;
	var codes=it.codes.value;
	it.S_Name.style.borderColor='#666 #ccc #ccc #666';
	it.S_PassWord.style.borderColor='#666 #ccc #ccc #666';
	it.codes.style.border='1px #eaeaea solid';
	if(S_Name==""){it.S_Name.style.border='1px solid red';return false;}
	else if(S_Name.length>16){it.S_Name.style.border='1px solid red';return false;}
	else if(S_PassWord==""){it.S_PassWord.style.border='1px solid red';return false;}
	else if(S_PassWord.length>18){it.S_PassWord.style.border='1px solid red';return false;}
	else if(codes.length!=4){it.codes.style.border='1px solid red';return false;}
	}
function checkcg(it){
	var days=it.days.value;
	it.days.style.borderColor='#666 #ccc #ccc #666';
	if(days==""){it.days.style.border='1px solid red';return false;}
	}
function isEmail(str){
 res = /^[0-9a-zA-Z_\-\.]+@[0-9a-zA-Z_\-]+(\.[0-9a-zA-Z_\-]+)*$/;
 var re = new RegExp(res);
 return !(str.match(re) == null);
};
function len(s) {
	var l = 0;
	var a = s.split("");
	for (var i=0;i<a.length;i++) {
	if (a[i].charCodeAt(0)<299) {
		l++;
		}
	else{
   l+=2;
		}
	}
	return l;
}
</script>
</head>
<body>
<?php
$action=SafeRequest("action","get");
switch($action){
	case "editpwd" :
		EditPwd();
		break;
	case "password1" :
		password1();
		break;
	case "showinfo" :
		showinfo();
		break;
	case "editinfo" :
		EditInfo();
		break;
	case "usertg" :
		UserTG();
		break;
	case "usercz" :
		UserCZ();
		break;
	case "cz" :
		CZ();
		break;
	case "watchrec" :
		WatchRec();
		break;
	case "list1" :
		List1();
		break;
	case "list2" :
		List2();
		break;
	case "readmes":
		ReadMes();
		break;
	case "vipinfo":
		VipInfo();
		break;
	case "checklog" :
		CheckLog();
		break;
	case "showlog" :
		ShowLog();
		break;
	case "sqlist" :
		SQList();
		break;
	case "add":
		Add();
		break;
	case "delsq":
		DelSQ();
		break;
	case "addsq":
		AddSQ();
		break;
	case "savesqedit":
		SaveSQEdit();
		break;
	case "saveaddsq":
		SaveAddSQ();
		break;
	case "readsq":
		ReadSQ();
		break;
	case "delcook" :
		DelCook();
		break;
	case "del":
		Del();
		break;
	case "tgerr":
		TGErr();
		break;
	case "changejf":
		ChangeJF();
		break;
	case "savechange":
		SaveChange();
		break;
	case "giftjf":
		GiftJF();
		break;
	case "change":
		Change();
		break;
	default :
		vipinfo();
		break;
}

function Change(){
	CheckCookies();
	global $db;
	$Days=SafeRequest("days","post");
	$Types=SafeRequest("types","post");
	$S_Name=$_COOKIE["S_Name"];
	$sqlv="select * from s_users where S_Name='".$S_Name."'";
	$resultv=$db->query($sqlv);
	$rowv=$db->fetch_array($resultv);
	if($rowv["S_UseType"]==0){
		die("<script>alert('积分会员不能兑换！');window.history.go(-1);</script>");
	}
	else{
		if($Types==0){
			if($Days%S_TGChange!=0){
				die("<script>alert('请输入转换模式的倍数！');window.history.go(-1);</script>");
			}
			else{
				if($rowv["S_Coin"]<$Days){
					die("<script>alert('对不起，您的积分不够兑换！');window.history.go(-1);</script>");
				}
				else{
					if($Days<S_TGChange){
						die("<script>alert('对不起，您的积分不够兑换！');window.history.go(-1);</script>");
					}
					else{
						$time1=$rowv["S_UseDate"];
						$time2=date('Y-m-d');
						$diff=(strtotime($time1)-strtotime($time2))/(60*60*24);
						$NewCoin=$rowv["S_Coin"]-$Days;
						if($diff<0){
							$NewDate=date('Y-m-d H:I:s',mktime(0,0,0,date('m'),date('d')+intval($Days/S_TGChange)-1,date('Y')));
						}
						else{
							$NewDate=date('Y-m-d H:I:s',mktime(0,0,0,date('m',strtotime($time1)),date('d',strtotime($time1))+intval($Days/S_TGChange),date('Y',strtotime($time1))));
						}
						$sqlv="update s_users set S_Coin=".$NewCoin.",S_UseDate='".$NewDate."' where S_Name='".$S_Name."'";
						$db->query($sqlv);
						echo "<script>alert('兑换成功!');window.location='?action=changejf';</script>";
					}
				}
			}
		}
		else{
			$time1=$rowv["S_UseDate"];
			$time2=date('Y-m-d');
			$diff=(strtotime($time1)-strtotime($time2))/(60*60*24);
			if($diff<1){
				die("<script>alert('对不起，您的时间不够兑换！');window.history.go(-1);</script>");
			}
			else{
				if($Days>$diff){
					die("<script>alert('对不起，您的时间不够兑换！');window.history.go(-1);</script>");
				}
				else{
					$NewCoin=$rowv["S_Coin"]+($Days*S_TGChange);
					$NewDate=date('Y-m-d H:I:s',mktime(0,0,0,date('m',strtotime($time1)),date('d',strtotime($time1))-$Days,date('Y',strtotime($time1))));
					$sqlv="update s_users set S_Coin=".$NewCoin.",S_UseDate='".$NewDate."' where S_Name='".$S_Name."'";
					$db->query($sqlv);
					echo "<script>alert('兑换成功!');window.location='?action=changejf';</script>";
				}
			}
		}
	}
}

function SaveChange(){
	CheckCookies();
	global $db;
	$S_Name=$_COOKIE["S_Name"];
	$S_UseType=SafeRequest("S_UseType","post");
	if($S_Name==""){
		die("<script>alert('出错了！');window.history.go(-1);</script>");	
	}
	$sqlv="select * from s_users where S_Name='".$S_Name."'";
	$resultv=$db->query($sqlv);
	if($rowv=$db->fetch_array($resultv)){
		if($S_UseType==$rowv["S_UseType"]){
			die("<script>alert('对不起，您没有选择转换！');window.history.go(-1);</script>");
		}
		else{
			if($rowv["S_ChangeTime"]==date('Y-m-d')){
				die("<script>alert('对不起，您今天已经转换过帐号类型！');window.history.go(-1);</script>");	
			}
			else{
				if($rowv["S_UseType"]==0){//点卡转月卡
					if($rowv["S_Coin"]<S_TGChange){
						die("<script>alert('对不起，您的点数不够转换！');window.history.go(-1);</script>");
					}
					else{
						$NewCoin=$rowv["S_Coin"]%S_TGChange;
						$NewDate=date('Y-m-d H:I:s',mktime(0,0,0,date('m'),date('d')+intval($rowv["S_Coin"]/S_TGChange)-1,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);
						echo("<script>alert('转换成功!已将".intval($rowv["S_Coin"]/S_TGChange)*S_TGChange."积分转换为".intval($rowv["S_Coin"]/S_TGChange)."天,您现在的到期时间为:".$NewDate.",剩余点数为:".$rowv["S_Coin"]%S_TGChange."!');window.location='?action=vipinfo';</script>");
					}
				}
				else{//月卡转点卡
					$time1=$rowv["S_UseDate"];
					$time2=date('Y-m-d');
					$diff=(strtotime($time1)-strtotime($time2))/(60*60*24);
					if($diff<1){
						die("<script>alert('对不起，到期时间必须大于1天才能转换！');window.history.go(-1);</script>");
					}
					else{
						$NewCoin=$rowv["S_Coin"]+($diff*S_TGChange);
						$NewDate=date('Y-m-d');
						$sqlv="update s_users set S_Coin=".$NewCoin.",S_UseDate='".$NewDate."',S_ChangeTime='".date('Y-m-d')."',S_UseType=0 where S_Name='".$S_Name."'";
						$db->query($sqlv);
						echo("<script>alert('转换成功！已将".$diff."天转换为".$diff*S_TGChange."点数,您现在的点数为:".$NewCoin."!');window.location='?action=vipinfo';</script>");
					}
				}
			}
		}
	}
	else{
		die("<script>alert('出错了！');window.history.go(-1);</script>");	
	}
}

function CZ(){
	global $db;
	$S_Name=SafeRequest("S_Name","post");
	$S_Name1=SafeRequest("S_Name1","post");
	$S_CardNum=SafeRequest("S_CardNum","post");
	$S_CardPWD=SafeRequest("S_CardPWD","post");
	if($S_Name!=$S_Name1){
		die("<script>alert('两次帐号输入不一致！');window.history.go(-1);</script>");
	}
	$sqlv="select * from s_users where S_Name='".$S_Name."'";
	$resultv=$db->query($sqlv);
	if($rowv=$db->fetch_array($resultv)){
		$sqlc="select * from s_card where S_CardNum=".$S_CardNum;
		$resultc=$db->query($sqlc);
		if($rowc=$db->fetch_array($resultc)){
			if($rowc["S_CardPWD"]==$S_CardPWD){
				if($rowc["S_CardUsed"]==1){
					die("<script>alert('该充值卡已被使用！');window.history.go(-1);</script>");
				}
				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." 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_CardNum=".$S_CardNum;
							$db->query($sqlc);
							echo("<script>alert('点卡充值成功！');window.location='?action=vipinfo';</script>");
						}
						else{
							$mydate="+1 month";
							$time1=$rowv["S_UseDate"];
							$time2=date('Y-m-d H:I:s');
							$diff=strtotime($time1)-strtotime($time2);
							if($diff<0){
								$NewUseDate=date('Y-m-d H:I:s',strtotime($mydate));
								$sqlv="update s_users set S_UseDate='".$NewUseDate."' 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_CardNum=".$S_CardNum;
								$db->query($sqlc);
								echo("<script>alert('月卡充值成功！');window.location='?action=vipinfo';</script>");
							}
							else{
								$NewUseDate=date('Y-m-d H:I:s',mktime(0,0,0,date('m',strtotime($time1))+1,date('d',strtotime($time1)),date('Y',strtotime($time1))));
								$sqlv="update s_users set S_UseDate='".$NewUseDate."' 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_CardNum=".$S_CardNum;
								$db->query($sqlc);
								echo("<script>alert('月卡充值成功！');window.location='?action=vipinfo';</script>");
							}
						}
					}
					else{
						die("<script>alert('对不起，请购买合适本帐号的充值卡！');window.history.go(-1);</script>");
					}
				}
			}
			else{
				die("<script>alert('卡密错误，请重新输入！');window.history.go(-1);</script>");
			}
		}
		else{
			die("<script>alert('充值卡号不存在，请重新输入！');window.history.go(-1);</script>");
		}
	}
	else{
		die("<script>alert('帐号不存在，请重新输入！');window.history.go(-1);</script>");
	}
}




function CheckLog(){
	global $db;
	$S_Name=SafeRequest("S_Name","post");
	$S_PassWord=SafeRequest("S_PassWord","post");
	$Code=SafeRequest("codes","post");
	if(($S_Name=="")||($S_PassWord=="")){
		echo "<script>alert('请输入帐号密码！');window.history.go(-1);</script>";
	}
	else{
		if($_COOKIE["captcha"]!=$Code){
			echo "<script>alert('验证码错误，请重新输入！');window.history.go(-1);</script>";
		}
		else{
			$S_PassWord=Md5($S_PassWord);
			$sql="select * from s_users where S_Name='".$S_Name."'";
			$result=$db->query($sql);
			if($row=$db->fetch_array($result)){
				if($row["S_PassWord"]==$S_PassWord){
					setcookie("S_Name",$S_Name,time()+3600);
					setcookie("S_PWD",$S_PassWord,time()+3600);
					if($row["S_Group"]==1){
						setcookie("S_LogName",$S_Name,time()+3600);
					}
					$S_LogIP=$row["S_LogIP"];
					if($S_LogIP==""){
					}
					else{
						setcookie("S_LogIP",$S_LogIP,time()+3600);
					}
					$S_LogNum=$row["S_LogNum"]+1;
					$S_LogTime=date("Y-m-d");
					$S_LogIP = getenv('REMOTE_ADDR');
					$update="update s_users set S_LogNum='".$S_LogNum."',S_LogTime='".$S_LogTime."',S_LogIP='".$S_LogIP."' where S_Name='".$S_Name."'";
					$db->query($update);
					echo "<script>window.location='?action=vipinfo'</script>";
				}
				else{
					echo "<script>alert('密码错误，请重新输入！');window.history.go(-1);</script>";
				}
			}
			else{
				echo "<script>alert('帐号不存在，请重新输入！');window.history.go(-1);</script>";
			}
		}
	}
}

function CheckCookies(){
	if(empty($_COOKIE["S_Name"])||empty($_COOKIE["S_PWD"])){
		echo "<script>window.location='?action=showlog'</script>";
	}
	else{
		global $db;
		$sql="select * from s_users where S_Name='".$_COOKIE["S_Name"]."'";
		$result=$db->query($sql);
		if($row=$db->fetch_array($result)){
			if($row["S_PassWord"]!=$_COOKIE["S_PWD"]){
				echo "<script>window.location='?action=showlog'</script>";
			}
			else{
				if($row["S_Group"]==1){
					if($row["S_Name"]!=$_COOKIE["S_LogName"]){
							echo "<script>alert('网吧用户需要先登陆才能进入管理！');window.location='?action=showlog';</script>";
					}
				}
			}
		}
		else{
			echo "<script>window.location='?action=showlog'</script>";
		}
	}
}


function GiftJF(){
	CheckCookies();
	$S_Vip=SafeRequest("S_Vip","post");
	$S_Coin=SafeRequest("S_Coin","post");
	if($_COOKIE["S_Name"]==$S_Vip){
		die("<script>alert('对不起，点数不能赠送给自己！');window.history.go(-1);</script>");	
	}
	global $db;
	$sqlz="select * from s_users where S_Name='".$_COOKIE["S_Name"]."'";
	$resultz=$db->query($sqlz);
	$rowz=$db->fetch_array($resultz);
	$sqls="select * from s_users where S_Name='".$S_Vip."'";
	$results=$db->query($sqls);
	if($rows=$db->fetch_array($results)){
		if($rowz["S_Coin"]<$S_Coin){
			echo "<script>alert('对不起，您的点数不够赠送！');window.history.go(-1);</script>";
		}
		else{
			$S_Coinz=$rowz["S_Coin"]-$S_Coin;
			$S_Coins=$rows["S_Coin"]+$S_Coin;
			$sqlz1="update s_users set S_Coin=".$S_Coinz." where S_Name='".$_COOKIE["S_Name"]."'";
			$db->query($sqlz1);
			$sqls1="update s_users set S_Coin=".$S_Coins." where S_Name='".$S_Vip."'";
			$db->query($sqls1);
			die("<script>alert('点数赠送成功,您的剩余点数位:".$S_Coinz."!');window.location='?action=usertg';</script>");
		}
	}
	else{
		echo "<script>alert('对不起，输入的会员帐号不存在！');window.history.go(-1);</script>";
	}
}





function DelCook(){
	setcookie("S_Name","",time()-3600);
	setcookie("S_PWD","",time()-3600);
	setcookie("S_LogName","",time()-3600);
	echo "<script>window.location='userlog.php';</script>";
}


function EditInfo(){
	global $db;
	$S_Name=SafeRequest("S_Name","post");
	$S_QQ=SafeRequest("S_QQ","post");
	$S_RealName=SafeRequest("S_RealName","post");
	$S_Tel=SafeRequest("S_Tel","post");
	$S_Email=SafeRequest("S_Email","post");
	if($S_Name==""){
		die("<script>alert('非法侵入！');window.location='userlog.php';</script>");
	}
	else{
		$sql="update s_users set S_QQ='".$S_QQ."',S_RealName='".$S_RealName."',S_Tel='".$S_Tel."',S_Email='".$S_Email."' where S_Name='".$S_Name."'";
		$db->query($sql);
		echo("<script>alert('修改成功！');window.location='?action=vipinfo';</script>");
	}
}

function EditPwd(){
	global $db;
	$S_Name=SafeRequest("userid","post");
	$S_OldPwd=$_POST["oldpwd"];
	$S_NewPwd=$_POST["password2"];
	$S_NewPwd1=$_POST["password"];
	if($S_NewPwd!=$S_NewPwd1){
		die("<script>alert('两次密码输入不一致！');window.history.go(-1);</script>");
	}
	$S_OldPwd=Md5($S_OldPwd);
	$S_NewPwd=Md5($S_NewPwd);
	$sql="select * from s_users where S_Name='".$S_Name."'";
	$result=$db->query($sql);
	if($row=$db->fetch_array($result)){
		if($row["S_PassWord"]!=$S_OldPwd){
			die("<script>alert('原密码错误，请重新输入！');window.history.go(-1);</script>");
		}
		else{
			setcookie("S_PWD",$S_NewPwd,time()+3600);
			$sql1="update s_users set S_PassWord='".$S_NewPwd."' where S_Name='".$S_Name."'";
			$db->query($sql1);
			echo "<script>alert('密码修改成功！');window.location='?action=vipinfo';</script>";
		}
	}
	else{
		die("<script>alert('帐号不存在，请重新输入！');window.history.go(-1);</script>");
	}
}

function Del(){
	global $db;
	$S_ID=SafeRequest("S_ID","get");
	$sql="select * from s_stationmes where S_ID=".$S_ID;
	$result=$db->query($sql);
	$row=$db->fetch_array($result);
	$S_Name=$row["S_Name"];
	$S_Name=str_replace($_COOKIE["S_Name"],"",$S_Name);
	if($S_Name==""){
		$sql1="delete from s_stationmes where S_ID=".$S_ID;
		$db->query($sql1);
	}
	else{
		$sql1="update s_stationmes set S_Name='".$S_Name."' where S_ID=".$S_ID;
		$db->query($sql1);
	}
	echo("<script>alert('删除成功！');window.location='?action=list1';</script>");
}

function add(){
		global $db;
		$S_Content=SafeRequest("content","post","filter");
		$S_Name=$_COOKIE["S_Name"];
		$S_Code=SafeRequest("codes","post","filter");
		$S_IP=$_SERVER['SERVER_ADDR'];
		$S_VID=SafeRequest("id","post","filter");
		$S_IP=str_encode($S_IP);
		if(!IsNum($S_VID)){$S_VID=="0";}
		$S_Name=filter(mb_convert_encoding($S_Name,"GBK","UTF-8"));
		$S_Content=filter(mb_convert_encoding($S_Content,"GBK","UTF-8"));
		$S_AddTime=date('Y-m-d');
		if(S_MStar=="0"){
			die("close");
			}
		if($_COOKIE["captcha"]!=$S_Code){
			die("<script>alert('对不起，验证码错误！');window.history.go(-1);</script>");//验证码错误
			}
		if(strlen($S_Content)>S_Message){
			die("<script>alert('对不起，内容长度超过最大值！');window.history.go(-1);</script>");//内容过长
			}
//		if(DateDiff($_SESSION['gbooktime'],date("Y-m-d H:i:s"))<16){
//			die("timeerror");
//			}	
		$sql="Insert s_gbook (S_Name,S_Content,S_IP,S_VID,S_AddTime,S_IsVip) values ('".$S_Name."','".$S_Content."','".$S_IP."','".$S_VID."','".$S_AddTime."',1)";
		if($db->query($sql)){
				echo("<script>alert('留言成功！');window.location='?action=list2';</script>");
			}
}


function SaveAddSQ(){
	CheckCookies();
	global $db;
	$S_Title=SafeRequest("S_Title","post");
	$S_Content=SafeRequest("S_Content","post");
	$S_Info=SafeRequest("S_Info","post");
	$sql="insert into s_bookmarks (S_Title,S_Content,S_Info,S_Vip) values ('".$S_Title."','".$S_Content."','".$S_Info."','".$_COOKIE["S_Name"]."')";
	//die($sql);
	$db->query($sql);
	echo("<script>alert('添加成功！');window.location='?action=sqlist';</script>");
}

function SaveSQEdit(){
	CheckCookies();
	global $db;
	$S_ID=SafeRequest("S_ID","get");
	$S_Title=SafeRequest("S_Title","post");
	$S_Content=SafeRequest("S_Content","post");
	$S_Info=SafeRequest("S_Info","post");
	$sql="update s_bookmarks set S_Title='".$S_Title."',S_Content='".$S_Content."',S_Info='".$S_Info."' where S_ID=".$S_ID;
	$db->query($sql);
	echo("<script>alert('修改成功！');window.location='?action=sqlist';</script>");
}

function DelSQ(){
	CheckCookies();
	global $db;
	$S_ID=SafeRequest("S_ID","get");
	$sql="delete from s_bookmarks where S_ID=".$S_ID;
	$db->query($sql);
	echo "<script>window.location='?action=sqlist';</script>";
}



function filter($str){
	$KeyArr=explode(',',Syc_GSQL);
	for($i=0;$i<count($KeyArr);$i++){
		$str=ReplaceStr($str,$KeyArr[$i],"***");
		}
		return $str;
}

function getpagerow2($mysql,$pagesize){
	global $db;
	$url=$_SERVER["QUERY_STRING"];
	if(stristr($url,'&pages')){
		$url=preg_replace('/&pages=([\S]+?)$/','',$url);
	}
	if(stristr($url,'pages')){
		$url=preg_replace('/pages=([\S]+?)$/','',$url);
	}
	if(IsNul($url)){$url.="&";}

	$pages=SafeRequest("pages","post");
	$pagesok=$pagesize;//每页显示记录数
    if (!isset($pages)||$pages==""||!is_numeric($pages)||$pages<=0){
    $pages=1;
	}
  	$sqlstr=$mysql;
  	$res=$db -> query($sqlstr);
 	$nums= $db -> num_rows($res);
	if($nums==0){
		$pagejs=1;
		}
	else{
		$pagejs=ceil($nums/$pagesok);//总页数
		}	
 	$str="总<font color=red>".$nums."</font>条记录&nbsp;";
    
  
    if($pages>$pagejs){
     $pages=$pagejs;
    }
  
    $sql=$sqlstr." LIMIT ".$pagesok*($pages-1).",".$pagesok;
	$str.="当前<font color=red>".$pages."/</font>".$pagejs."页&nbsp;";                                                              ;
	$result = $db -> query($sql);
 
 
 	//$str.= "页数".$pagejs."&nbsp;";
 


	$str.= "<a href='#' onclick='showlist(1)'>第一页</a>";
	if($pagejs<=10){
  		for($i=1;$i<=$pagejs;$i++){
   			$str.="<a href='#' onclick='showlist(".$i.")'>".$i."</a>&nbsp;";
 	 	}
	}
	else{
 		if($pages>=12){
 			for($i=$pages-5;$i<=$pages+6;$i++){
   				if($i<=$pagejs){
   					$str.="<a href='#' onclick='showlist(".$i.")'>".$i."</a>&nbsp;";
    			}
  			}
  			if($i<=$pagejs){ 
    			$str.="....";
	    		$str.="<a href='#' onclick='showlist(".$pagejs.")'>".$pagejs."</a>&nbsp;";
   			}
   		}
  		else{
  			for($i=1;$i<=12;$i++){
    			$str.="<a href='#' onclick='showlist(".$i.")'>".$i."</a>&nbsp;";
 		} 
 				if($i<=$pagejs){ 
      				$str.="....";
	  				$str.="<a href='#' onclick='showlist(".$pagejs.")'>".$pagejs."</a>&nbsp;";
    			}
 		 }
	}

	$str.="<a href='#' onclick='showlist(".($pages+1).")'>下一页</a>&nbsp;";
	$str.="<a  href='#' onclick='showlist(".$pagejs.")'>最后页</a>&nbsp;";
	$str.="转<input type=text size=4 name='gopage' style='margin-top:4px;' value='".$pages."'/>&nbsp;<a style='cursor:pointer;' onclick='showlist(gopage.value)'>GO>></a>&nbsp;";
	//echo $str;
	//echo $result;
	 while ($row = $db -> fetch_array($result) ){
  		//echo $row['S_ID']."&nbsp;";
	 }
	 $arr=array($str,$result,$sql);
	 return $arr;
}

?>


<?php
function VipInfo(){
	CheckCookies();
	global $db;
	$S_Name=$_COOKIE["S_Name"];
	$sql="select * from s_users where S_Name='".$S_Name."'";
	$result=$db->query($sql);
	$row=$db->fetch_array($result);
	$S_UseType=$row["S_UseType"];
?>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><table width="27%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="5%"><img src="images/inleft.jpg"/></td>
              <td width="91%" align="center" bgcolor="#20A9F9" class="starsize">用户资料信息</td>
              <td width="4%"><img src="images/inright.jpg"/></td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td align="center" valign="top" style="border:2px #21A8F6 solid;"><table width="100%" border="0" cellspacing="10" cellpadding="0">
          
          <tr>
            <td height="10" background="images/inrepeat.jpg"></td>
          </tr>
          <tr>
            <td height="380" valign="middle" bgcolor="#EAF5FF"><table width="80%" height="300" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
              <tr>
                <td width="30%" height="32" align="center" class="td_border">用户帐号：</td>
                <td width="70%" colspan="2" align="left" class="td_border"><?php echo $S_Name?></td>
              </tr>
              <tr>
                <td width="30%" height="32" align="center" class="td_border">消费模式：</td>
                <td colspan="2" align="left" class="td_border"><?php if($S_UseType==0){echo "耗点";}else{echo "包月";}?></td>
              </tr>
              <tr>
                <td width="30%" height="32" align="center" class="td_border">会员类型：</td>
                <td colspan="2" align="left" class="td_border"><?php if($row["S_Group"]==0){echo "个人会员";}else{echo "网吧会员";}?></td>
              </tr>
              <tr>
                <td height="32" align="center" class="td_border"><?php if($S_UseType==0){echo "剩余点数：";}else{echo "到期时间：";}?></td>
                <td colspan="2" align="left" class="td_border"><?php if($S_UseType==0){echo $row["S_Coin"];}else{echo $row["S_UseDate"];}?></td>
              </tr>
              <tr>
                <td height="32" align="center" class="td_border"><?php if($row["S_Group"]==0){echo "最后登录：";}else{echo "网吧IP组：";}?></td>
                <td colspan="2" align="left" class="td_border"><?php if($row["S_Group"]==0){echo $row["S_LogIP"];}else{echo $row["S_StartIP"]."-".$row["S_LastIP"];}?></td>
              </tr>
              <tr>
                <td height="32" align="center" class="td_border">注册时间：</td>
                <td colspan="2" align="left" class="td_border"><?php echo $row["S_CreateTime"]?></td>
              </tr>
              <tr>
                <td height="32" align="center" class="td_border">真实姓名：</td>
                <td colspan="2" align="left" class="td_border"><?php echo $row["S_RealName"]?></td>
              </tr>
              <tr>
                <td height="32" align="center" class="td_border">电子邮箱：</td>
                <td colspan="2" align="left" class="td_border"><?php echo $row["S_Email"]?></td>
              </tr>
              <tr>
                <td height="32" align="center" class="td_border">联系Q Q：</td>
                <td colspan="2" align="left" class="td_border"><?php echo $row["S_QQ"]?></td>
              </tr>
              <tr>
                <td height="32" align="center" class="td_border">联系电话：</td>
                <td colspan="2" align="left" class="td_border"><?php echo $row["S_Tel"]?></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td height="10" background="images/inrepeat.jpg"></td>
          </tr>
        </table></td>
      </tr>
    </table>
<?php
}

function showinfo(){
	CheckCookies();
	global $db;
	$S_Name=$_COOKIE["S_Name"];
	$sql="select * from s_users where S_Name='".$S_Name."'";
	$result=$db->query($sql);
	$row=$db->fetch_array($result);
?>    
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td><table width="27%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="5%"><img src="images/inleft.jpg"/></td>
                <td width="91%" align="center" bgcolor="#20A9F9" class="starsize">用户资料修改</td>
                <td width="4%"><img src="images/inright.jpg"/></td>
              </tr>
          </table></td>
        </tr>
        <tr>
          <td align="center" valign="top" style="border:2px #21A8F6 solid;"><table width="100%" border="0" cellspacing="10" cellpadding="0">
              <tr>
                <td height="10" background="images/inrepeat.jpg"></td>
              </tr>
              <tr>
                <td height="380" bgcolor="#EAF5FF"><table width="80%" height="300" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
                    <form name="form" id="Reg" action="?action=editinfo" method="post" onSubmit="return checkei(this);">
                      <tr>
                        <td width="30%" height="35" align="center" class="td_border">会员帐号：</td>
                        <td width="70%" align="left" class="td_border"><input name="S_Name" type="text" id="S_Name" value="<?php echo $_COOKIE["S_Name"]?>" size="30" readonly="readOnly"/>
                        <font color="#FF0000"> ＊ </font></td>
                      </tr>
                      <tr>
                        <td height="35" align="center" class="td_border">真实姓名：</td>
                        <td align="left" class="td_border"><input name="S_RealName" type="text" size="30" value="<?php echo $row["S_RealName"]?>"/>
                        <font color="#FF0000"> ＊ </font></td>
                      </tr>
                      <tr>
                        <td height="35" align="center" class="td_border">联系电话：</td>
                        <td align="left" class="td_border"><input name="S_Tel" type="text" size="30" value="<?php echo $row["S_Tel"]?>" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"/>
                        <font color="#FF0000"> ＊ </font></td>
                      </tr>
                      <tr>
                        <td height="35" align="center" class="td_border">联系Q Q：</td>
                        <td align="left" class="td_border"><input name="S_QQ" type="text" size="30"  value="<?php echo $row["S_QQ"]?>" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"/>
                        <font color="#FF0000"> ＊ </font></td>
                      </tr>
                      <tr>
                        <td height="35" align="center" class="td_border">电子邮箱：</td>
                        <td align="left" class="td_border"><input name="S_Email" type="text" size="30" value="<?php echo $row["S_Email"]?>"/>
                        <font color="#FF0000"> ＊ </font></td>
                      </tr>
                      <tr>
                        <td height="32" align="center" class="td_border">&nbsp;</td>
                        <td align="left" class="td_border"><input name="submit" type="submit" class="subput" value="确定修改" />
                        <b><label id="tishi5" style="color:#F00"></label></b>
                        </td>
                      </tr>
                    </form>
                </table></td>
              </tr>
              <tr>
                <td height="10" background="images/inrepeat.jpg"></td>
              </tr>
          </table></td>
        </tr>
      </table>
<?php
}

function List1(){
	CheckCookies();
	global $db;
	$sql="select * from s_stationmes";
	$Arr=getpagerow($sql,20);//sql,每页显示条数
	$result=$db->query($Arr[2]);
?>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td><table width="27%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="5%"><img src="images/inleft.jpg"/></td>
                <td width="91%" align="center" bgcolor="#20A9F9" class="starsize">系统消息列表</td>
                <td width="4%"><img src="images/inright.jpg"/></td>
              </tr>
          </table></td>
        </tr>
        <tr>
          <td align="center" valign="top" style="border:2px #21A8F6 solid;"><table width="100%" border="0" cellspacing="10" cellpadding="0">
              
              <tr>
                <td height="380" valign="top" bgcolor="#EAF5FF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="51%" align="left" class="td_title">&nbsp;消息标题</td>
                    <td width="36%" align="left" class="td_title">&nbsp;发布日期</td>
                    <td width="13%" align="center" class="td_title">操 作</td>
                  </tr>
                  <?php
				  $numdate=0;
                  if($result){
					  while($row = $db ->fetch_array($result)){
						  $S_NameArr=explode(",",$row["S_Name"]);
						  $tishi="b";
						  for($i=0;$i<count($S_NameArr);$i++){
					  		if($S_NameArr[$i]==$_COOKIE["S_Name"]){
								$tishi="a";
							}
						  }
				  if($tishi=="a"){
					  $numdate=$numdate+1;
				  ?>
                  <tr>
                    <td width="51%" height="30" align="left" class="td_border">&nbsp;<a href="?action=readmes&S_ID=<?php echo $row["S_ID"]?>"><?php echo $row["S_Title"]?></a></td>
                    <td width="36%" align="left" class="td_border">&nbsp;<?php echo $row["S_CreateTime"]?></td>
                    <td width="13%" align="center" class="td_border"><a href="?action=readmes&S_ID=<?php echo $row["S_ID"]?>">查看</a>&nbsp; &nbsp;<a style="cursor:pointer;" onClick="del(<?php echo $row["S_ID"]?>)">删除</a></td>
                  </tr>
				  <?php
				  }
					  }
				  }
				  if($numdate==0){
					  echo("<tr><td colspan='3' align='center' class='td_border'><b>暂无系统消息！</b></td></tr>");
				  }
				  ?>
                </table>
                </td>
              </tr>
          </table></td>
        </tr>
      </table>
<?php
}

function PassWord1(){
?>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td><table width="27%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="5%"><img src="images/inleft.jpg"/></td>
                <td width="91%" align="center" bgcolor="#20A9F9" class="starsize">用户密码修改</td>
                <td width="4%"><img src="images/inright.jpg"/></td>
              </tr>
          </table></td>
        </tr>
        <tr>
          <td align="center" valign="top" style="border:2px #21A8F6 solid;"><table width="100%" border="0" cellspacing="10" cellpadding="0">
              <tr>
                <td height="10" background="images/inrepeat.jpg"></td>
              </tr>
              <tr>
                <td height="380" bgcolor="#EAF5FF"><table width="80%" height="300" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
                    <form name="form" id="Reg" action="?action=editpwd" method="post" onsubmit="return checkep(this);">
                      <tr>
                        <td width="30%" height="35" align="center" class="td_border">会员帐号：</td>
                        <td width="70%" align="left" class="td_border"><input name="userid" id="userid" value="<?php echo $_COOKIE["S_Name"]?>" size="30"/>
                        <font color="#FF0000"> ＊ </font></td>
                      </tr>
                      <tr>
                        <td height="35" align="center" class="td_border">原始密码：</td>
                        <td align="left" class="td_border"><input name="oldpwd" id="oldpwd" value="" size="30"/>
                        <font color="#FF0000"> ＊ </font></td>
                      </tr>
                      <tr>
                        <td height="35" align="center" class="td_border">用户密码：</td>
                        <td align="left" class="td_border"><input name="password" id="password" type="password" value="" size="30"/>
                        <font color="#FF0000"> ＊ </font></td>
                      </tr>
                      <tr>
                        <td height="35" align="center" class="td_border">确认密码：</td>
                        <td align="left" class="td_border"><input id="password2" type="password" size="30" value="" name="password2"/>
                        <font color="#FF0000"> ＊ </font></td>
                      </tr>
                      <tr>
                        <td height="32" align="center" class="td_border">&nbsp;</td>
                        <td align="left" class="td_border"><input name="submit" type="submit" class="subput" value="确认修改" />
                        <b><label id="tishi4" style="color:#F00"></label></b>
                        </td>
                      </tr>
                    </form>
                </table></td>
              </tr>
              <tr>
                <td height="10" background="images/inrepeat.jpg"></td>
              </tr>
          </table></td>
        </tr>
      </table>
<?php
}

function ReadMes(){
	CheckCookies();
	global $db;
	$S_ID=SafeRequest("S_ID","get");
	$sql="select * from s_stationmes where S_ID=".$S_ID;
	$result=$db->query($sql);
	$row=$db->fetch_array($result);
?>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td><table width="27%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="5%"><img src="images/inleft.jpg"/></td>
                <td width="91%" align="center" bgcolor="#20A9F9" class="starsize">会员系统消息</td>
                <td width="4%"><img src="images/inright.jpg"/></td>
              </tr>
          </table></td>
        </tr>
        <tr>
          <td align="center" valign="top" style="border:2px #21A8F6 solid"><table width="100%" border="0" cellspacing="10" cellpadding="0">
              <tr>
                <td height="10" background="images/inrepeat.jpg"></td>
              </tr>
              <tr>
                <td height="350px" bgcolor="#EAF5FF"><table width="80%" height="300" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
                      <tr>
                        <td width="19%" height="23" align="center" class="td_border">消息标题：</td>
                        <td width="81%" align="left" class="td_border"><font color="#FF0000"><?php echo $row["S_Title"]?></font> </td>
                      </tr>
                      <tr>
                        <td width="19%" height="30" align="center" valign="top" class="td_border"><br />消息内容：</td>
                        <td align="left" valign="top" class="td_border"><br />
                        <?php echo $row["S_Content"]?></td>
                      </tr>
                      <tr>
                        <td width="19%" height="35" align="center" class="td_border">&nbsp;</td>
                        <td align="left" valign="top" class="td_border">
                        <input type="button" class="subput" id="bt1" value="删除消息" onClick="del(<?php echo $row["S_ID"]?>)"/>
        				<input type="button" class="subput" value="返回列表" id="bt2" onClick="back()"/>
        				<br/>&nbsp;                        </td>
                      </tr>
                    
                </table></td>
              </tr>
              <tr>
                <td height="10" background="images/inrepeat.jpg"></td>
              </tr>
          </table></td>
        </tr>
      </table>
<?php
}

function UserTG(){
	CheckCookies();
	if(S_TGFun==0){
		die("<script>window.location='?action=tgerr'</script>");
	}
	global $db;
	$S_Name=$_COOKIE["S_Name"];
	$sql="select * from s_users where S_Name='".$S_Name."'";
	$result=$db->query($sql);
	$row=$db->fetch_array($result);
	$S_ID=$row["S_ID"];
?>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td><table width="27%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="5%"><img src="images/inleft.jpg"/></td>
                <td width="91%" align="center" bgcolor="#20A9F9" class="starsize">会员赚取点数</td>
                <td width="4%"><img src="images/inright.jpg"/></td>
              </tr>
          </table></td>
        </tr>
        <tr>
          <td align="center" valign="middle" style="border:2px #21A8F6 solid;">
          <table width="100%" border="0" cellspacing="10" cellpadding="0">
              <tr>
                <td height="10" background="images/inrepeat.jpg"></td>
              </tr>
              <tr>
                <td height="380" bgcolor="#EAF5FF" align="center"><table width="100%" height="300" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
                  <tr>
                    <td colspan="2" align="left" class="td_title">&nbsp; 推广地址</td>
                  </tr>
                  <tr>
                    <td width="16%" height="35" class="td_border">&nbsp;您的帐号：</td>
                    <td width="84%" align="left" class="td_border"><label><?php echo $_COOKIE["S_Name"]?></label>                    </td>
                  </tr>
                  <tr>
                    <td height="35" colspan="2" align="left" class="td_border"><input name="text" type="text" id="url" onclick="jscript:copyUrl()" value="<?php echo S_SiteDomain.S_SitePath?>users/userfin.php?action=tg&id=<?php echo $S_ID?>"  size="60" readonly="readonly"/>                    </td>
                  </tr>
                  <tr>
                    <td height="35" colspan="2" align="left" class="td_border"><font color="red">&nbsp;&nbsp;&nbsp;通过QQ，EMAIL，WEB，BBS等方式发送此网址，当有人通过此连接访问本站时，系统会自动为您增加点数数量，本系统使用了IP筛选，所以作弊是没有用的，甚至会物及必反，每推荐一个系统将自动为您加入<?php echo S_Points?>个点数！</font>                    <br />
                    <br /></td>
                  </tr>
                  <tr>
                    <td height="30" colspan="2" align="left" class="td_title">&nbsp; 点数赠送</td>
                  </tr>
                  <tr>
                    <td height="30" class="td_border">&nbsp;剩余点数：</td>
                    <td height="30" class="td_border" align="left">&nbsp;<?php echo $row["S_Coin"]?>点数</td>
                  </tr>
                  <tr>
                    <td height="35"  colspan="2" class="td_border">
                    <form action="?action=giftjf" method="post" onsubmit="return checkzs(this);">
                    <table width="100%" border="0" cellpadding="0" cellspacing="0">
                    	<tr>
                        	<td valign="middle" class="td_border">&nbsp;赠送对象：</td>
                            <td valign="middle" class="td_border"><input type="text" name="S_Vip" id="S_Vip" size="15"/></td>
                            <td valign="middle" class="td_border">&nbsp;赠送点数：</td>
                            <td valign="middle" class="td_border"><input name="S_Coin" type="text" id="S_Coin" onKeyUp="this.value=this.value.replace(/[^\d]/g,'')" size="15" maxlength="5" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"/></td>
                            <td valign="middle" class="td_border">&nbsp;<input type="submit"value="确 认"class="subput"/></td>
                        </tr>
                    </table>
                    </form>                    </td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td height="10" background="images/inrepeat.jpg"></td>
              </tr>
          </table></td>
        </tr>
      </table>
				<SCRIPT language=JScript type=text/jscript>
						var obj=document.getElementById("url");
						function copyUrl(){
							if (obj) { 								
							obj.select();
							js=obj.createTextRange();
							js.execCommand("Copy");
							alert("地址已经复制，您可以将它粘贴到任何位置了，如QQ、BBS、聊天室等。");
							}
						}
				</SCRIPT>
<?php
}

function TGErr(){
?>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td><table width="27%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="5%"><img src="images/inleft.jpg"/></td>
                <td width="91%" align="center" bgcolor="#20A9F9" class="starsize">会员点数推广</td>
                <td width="4%"><img src="images/inright.jpg"/></td>
              </tr>
          </table></td>
        </tr>
        <tr>
          <td align="center" valign="top" style="border:2px #21A8F6 solid;"><table width="100%" border="0" cellspacing="10" cellpadding="0">
              <tr>
                <td height="10" background="images/inrepeat.jpg"></td>
              </tr>
              <tr>
                <td height="380" bgcolor="#EAF5FF"><table width="80%" height="300" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
                  <tr>
                    <td align="center"><div style="color:#FF0000; font-family:'宋体'; font-size:15px;"><strong>非常抱歉！网站已暂时关闭会员推广！</strong></div></td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td height="10" background="images/inrepeat.jpg"></td>
              </tr>
          </table></td>
        </tr>
      </table>

<?php
}

function List2(){
	CheckCookies();
?>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td><table width="27%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="5%"><img src="images/inleft.jpg"/></td>
                <td width="91%" align="center" bgcolor="#20A9F9" class="starsize">会员留言记录</td>
                <td width="4%"><img src="images/inright.jpg"/></td>
              </tr>
          </table></td>
        </tr>
        <tr>
          <td align="center" valign="top" style="border:2px #21A8F6 solid;"><table width="100%" border="0" cellspacing="10" cellpadding="0">
              <tr>
                <td height="10" background="images/inrepeat.jpg"></td>
              </tr>
              <tr>
                <td height="380" bgcolor="#EAF5FF"><table width="80%" height="300" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
                      <tr>
                        <td height="35" align="center">
<?php
		global $db;
	if(S_MStar=="0"){
		die("close");//留言关闭
	}
	$sql="select * from s_gbook where S_IsVip=1 and S_Name='".$_COOKIE["S_Name"]."' order by S_ID desc";
		$Arr=getpagerow2($sql,S_MCount);//sql,每页显示条数
		$result=$db->query($Arr[2]);
		$recount=$db->num_rows($result);
		//$result=$db->query($sql);
		if($recount=="0"){
			echo "<div style='width:100%; border:1px solid #B5D6E6; margin-top:10px; height:30px; font-size:12px; line-height:30px;'>&nbsp;Sorry!暂无留言,请留言吧！！</div>";
			}
		else{
		if($result){
			while ($row = $db ->fetch_array($result)){
				if($row['S_Reply']=="1"){
?>
<div style="width:100%; border:1px solid #B5D6E6;margin-top:10px;"><div style="width:100%; height:30px; line-height:30px; font-size:12px; background:#EEF7FE">
	<div style="width:70%; float:left;color:#185691; text-align:left;">&nbsp;<strong><?php echo $row['S_Name']?></strong>&nbsp;&nbsp;IP：<?php echo $row['S_IP']?></div>
    <div style="width:28%; float:left;text-align:right; font-size:12px;">发表于:<font color=""red""><em><?php echo $row['S_AddTime']?></em></font></div>
    </div>
    <div style="width:95%; margin:0 auto; height:50px;font-size:12px; line-height:25px; text-align:left;">&nbsp;&nbsp;<?php echo $row['S_Content']?></div>
    <div style="width:95%; margin:0 auto; height:20px;font-size:12px; line-height:20px; color:red; text-align:left">&nbsp;&nbsp;站长回复：时间(<?php echo $row['S_ReTime']?>)</div>
    <div style="width:95%; margin:0 auto; color:red; height:30px;font-size:12px; line-height:20px; text-align:left">&nbsp;&nbsp;<?php echo $row['S_ReContent']?></div></div>
<?php					
					}
				else{
?>				
		<div style="width:100%; border:1px solid #B5D6E6;margin-top:10px;">
        	<div style="width:100%; height:30px; line-height:30px; font-size:12px; background:#EEF7FE">
            	<div style="width:70%; float:left;color:#185691; text-align:left;">&nbsp;<strong><?php echo $row['S_Name']?></strong>&nbsp;IP:<?php echo $row['S_IP']?></div>
                <div style="width:28%; float:left;text-align:right; font-size:12px;">发表于：<font color=red><em><?php echo $row['S_AddTime']?></em></font></div>
             </div>
            <div style="width:95%; margin:0 auto; height:80px;font-size:12px; line-height:25px; text-align:left;">&nbsp;&nbsp;<?php echo $row['S_Content']?></div>
      </div>		
<?php
				}
			}
?>
            <div style="font-size:12px; float:right"><?php echo $Arr[0];?>&nbsp;</div>
<?php			
		}
	}	
$GbookContent="<form name='form11' id='form11' action='?action=add' method='post' onsubmit='return checkgb(this);'>";
$GbookContent=$GbookContent."<div style='margin-top:0px; height:110px; width:590px; '><div style='float:left; height:80px; width:98%; margin-left:2px; '><textarea name='content' id='content' style='width:100%' rows='7'  ></textarea></div></div>";
$GbookContent=$GbookContent."<div style='margin-top:5px;' align='left'>&nbsp;验证码：<input type='text' size='4' id='codes' name='codes' style='background:#fffff9;border:1px #eaeaea solid;'>&nbsp;<img src='../include/code.php' id='imgcode' >&nbsp;<input type='submit' value='我要留言' id='add' style='padding:1px;font-size:1.0em'  class='subput'></div><div style='width:520px; height:30px; line-height:30px; margin-top:5px;'></div>";
$GbookContent=$GbookContent."</form></div></div></div>";
	echo($GbookContent);
	?>
                        </td>
                      </tr>
                </table></td>
              </tr>
              <tr>
                <td height="10" background="images/inrepeat.jpg"></td>
              </tr>
          </table></td>
        </tr>
      </table><br />
	<?php
}

function WatchRec(){
	CheckCookies();
	global $db;
	$S_Name=$_COOKIE["S_Name"];
	$sql="select * from s_users where S_Name='".$S_Name."'";
	$result=$db->query($sql);
	$row=$db->fetch_array($result);
	$S_WatchRec=$row["S_WatchRec"];
?>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td><table width="27%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="5%"><img src="images/inleft.jpg"/></td>
                <td width="91%" align="center" bgcolor="#20A9F9" class="starsize">用户观看记录</td>
                <td width="4%"><img src="images/inright.jpg"/></td>
              </tr>
          </table></td>
        </tr>
        <tr>
          <td align="center" valign="top" style="border:2px #21A8F6 solid;"><table width="100%" border="0" cellspacing="10" cellpadding="0">
              
              <tr>
                <td height="380" valign="top" bgcolor="#EAF5FF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="23%" align="left" class="td_title">&nbsp;内容名称</td>
                    <td width="8%" align="center" class="td_title">&nbsp;类别</td>
                    <td width="69%" align="left" class="td_title">&nbsp;链接地址</td>
                  </tr>
    <?php
	if($S_WatchRec==""){
	?>
    			<tr>
                    <td height="30" colspan="3" align="center" class="td_border">
                    <b><font color="#000000">暂时没有记录!</font></b>                    </td>
                </tr>
    <?php
    }
	else{
		$S_WatchRecArr = explode(",",$S_WatchRec);
		$pagecounts=count($S_WatchRecArr)/12;
		
		if((count($S_WatchRecArr)%12)>0){
			$pagecounts=$pagecounts+1;
		}
		$page=SafeRequest("page","get");
		
		if($page==""){
			$page=1;
		}
		else{
			if($page<1){
				$page=1;
			}
		}
		if($page>$pagecounts){
			$page=$pagecounts;
		}
		
		if(count($S_WatchRecArr)==0){
			$page=1;
			$pagecounts=1;
		}
		for($i=($page-1)*12;$i<$page*12;$i++){
			if($i<count($S_WatchRecArr)){
				if($i>count($S_WatchRecArr)){
					$i=count($S_WatchRecArr);
				}
				if($S_WatchRecArr[$i]==""){
				
				}
				else{
					if($i>count($S_WatchRecArr)){
						$i=count($S_WatchRecArr);
					}
				if(substr($S_WatchRecArr[$i],0,1)=="a"){
					$sqlv="select * from s_article where S_ID=".substr($S_WatchRecArr[$i],1,10);
					$classname="文章";
				}
				else{
					$sqlv="select * from s_video where S_ID=".substr($S_WatchRecArr[$i],1,10);
					$classname="视频";
				}
				
				$resultv=$db->query($sqlv);
				if($rowv=$db->fetch_array($resultv)){
					if(substr($S_WatchRecArr[$i],0,1)=="a"){
						$url=LinkUrl("s_article",$rowv['S_ClassID'],0,$rowv['S_ID']);
					}
					else{
						$url=LinkUrl("s_video",$rowv['S_ClassID'],1,$rowv['S_ID']);
					}
	?>
                  <tr>
                    <td width="23%" height="30" align="left" class="td_border">&nbsp;<?php echo $rowv["S_Name"]?></td>
                    <td width="8%" height="30" align="center" class="td_border">&nbsp;<?php echo $classname?></td>
                    <td width="69%" align="left" class="td_border">&nbsp;<a href="<?php echo  $url?>" target="_blank"><?php echo S_SiteDomain.$url?></a></td>
                  </tr>
        <?php
				}
				}
			}
		}
		?>
                  <tr>
                    <td height="35" colspan="3" align="right"  class="td_border">
            当前<?php echo intval($page)?>/<?php echo intval($pagecounts)?>页 每页12条记录
        	<a href="?action=watchrec&page=1">首页</a>
            <a href="?action=watchrec&page=<?php echo $page-1?>">上页</a>
            <a href="?action=watchrec&page=<?php echo $page+1?>">下页</a>
            <a href="?action=watchrec&page=<?php echo $pagecounts?>">尾页</a>
            共<?php echo count($S_WatchRecArr)?>条记录</td>   
                 </tr>
<?php
	}
	
	?>
                </table></td>
              </tr>
          </table></td>
        </tr>
      </table>
	<?php
}

function SQList(){
	CheckCookies();
?>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td><table width="27%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="5%"><img src="images/inleft.jpg"/></td>
                <td width="91%" align="center" bgcolor="#20A9F9" class="starsize">用户网址列表</td>
                <td width="4%"><img src="images/inright.jpg"/></td>
              </tr>
          </table></td>
        </tr>
        <tr>
          <td align="center" valign="top" style="border:2px #21A8F6 solid;"><table width="100%" border="0" cellspacing="10" cellpadding="0">
              
              <tr>
                <td height="380" valign="top" bgcolor="#EAF5FF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="22%" align="left" class="td_title">&nbsp;网址名称</td>
                    <td width="58%" align="left" class="td_title">&nbsp;网站地址</td>
                    <td width="20%" align="center" class="td_title">操 作</td>
                  </tr>
    <?php
		global $db;
		$sql="select * from s_bookmarks";
		$Arr=getpagerow($sql,20);//sql,每页显示条数
		$result=$db->query($Arr[2]);
		$numdate=0;
		if($result){
			while ($row = $db ->fetch_array($result)){
				$numdate=$numdate+1;
	?>
                  <tr>
                    <td width="22%" height="30" align="left" class="td_border">&nbsp;<?php echo $row["S_Title"]?></td>
                    <td width="58%" align="left" class="td_border">&nbsp;
                    <?php if(substr($row["S_Content"],0,7)=="http://"){?>
                    <a href="<?php echo $row["S_Content"]?>" target="_blank"><?php echo $row["S_Content"]?></a>
                    <?php }else{?>
                    <?php echo $row["S_Content"];}?>
                    </td>
                    <td width="20%" align="center" class="td_border"><a href="?action=readsq&S_ID=<?php echo $row["S_ID"]?>">编 辑</a> &nbsp;
        <a style="cursor:pointer;" onClick="delsq(<?php echo $row["S_ID"]?>)">删 除</a></td>
                  </tr>
	<?php
			}
		}
		if($numdate==0){
			echo("<tr><td colspan='3' align='center' class='td_border'><b>暂无网址收藏！</b></td></tr>");	
		}
	?>
                  <tr>
                    <td height="30" align="left" class="td_border">&nbsp;<input type="button" class="subput" value="添加网址" onClick=location.href='?action=addsq'></td>
                    <td height="35" colspan="2" align="right" class="td_border">
					<?php echo $Arr[0];?>
                    </td>
                  </tr>
                </table></td>
              </tr>
          </table></td>
        </tr>
      </table>

<?php
}

function AddSQ(){
	CheckCookies();
?>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td><table width="27%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="5%"><img src="images/inleft.jpg"/></td>
                <td width="91%" align="center" bgcolor="#20A9F9" class="starsize">添加网址</td>
                <td width="4%"><img src="images/inright.jpg"/></td>
              </tr>
          </table></td>
        </tr>
        <tr>
          <td align="center" valign="top" style="border:2px #21A8F6 solid;"><table width="100%" border="0" cellspacing="10" cellpadding="0">
              <tr>
                <td height="10" background="images/inrepeat.jpg"></td>
              </tr>
              <tr>
                <td height="380" bgcolor="#EAF5FF"><table width="80%" height="300" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
                    <form action="?action=saveaddsq" method="post" onsubmit="return checksq(this);">
                      <tr>
                        <td width="30%" height="35" align="center" class="td_border">网址标题：</td>
                        <td width="70%" align="left" class="td_border"><input type="text" name="S_Title" id="S_Title" size="30"/>
                        <font color="#FF0000"> ＊ </font></td>
                      </tr>
                      <tr>
                        <td height="35" align="center" class="td_border">网站地址：</td>
                        <td align="left" class="td_border"><input type="text" name="S_Content" id="S_Content" size="30"/>
                        <font color="#FF0000"> ＊ </font></td>
                      </tr>
                      <tr>
                        <td height="35" align="center" class="td_border">网址说明：</td>
                        <td align="left" class="td_border"><textarea  name="S_Info" id="S_Info" cols="40" rows="3"></textarea>
                        <font color="#FF0000"> ＊ </font></td>
                      </tr>
                      <tr>
                        <td height="32" align="center" class="td_border">&nbsp;</td>
                        <td align="left" class="td_border"><input name="submit" type="submit" class="subput" value="确认添加" /></td>
                      </tr>
                    </form>
                </table></td>
              </tr>
              <tr>
                <td height="10" background="images/inrepeat.jpg"></td>
              </tr>
          </table></td>
        </tr>
      </table>
<?php
}

function ReadSQ(){
	CheckCookies();
	$S_ID=SafeRequest("S_ID","get");
	global $db;
	$sql="select * from s_bookmarks where S_ID=".$S_ID;
	$result=$db->query($sql);
	$row=$db->fetch_array($result);
?>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td><table width="27%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="5%"><img src="images/inleft.jpg"/></td>
                <td width="91%" align="center" bgcolor="#20A9F9" class="starsize">编辑网址</td>
                <td width="4%"><img src="images/inright.jpg"/></td>
              </tr>
          </table></td>
        </tr>
        <tr>
          <td align="center" valign="top" style="border:2px #21A8F6 solid;"><table width="100%" border="0" cellspacing="10" cellpadding="0">
              <tr>
                <td height="10" background="images/inrepeat.jpg"></td>
              </tr>
              <tr>
                <td height="380" bgcolor="#EAF5FF"><table width="80%" height="300" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
                <form action="?action=savesqedit&S_ID=<?php echo $S_ID?>" method="post" onsubmit="return checksq(this);">
                      <tr>
                        <td width="30%" height="35" align="center" class="td_title">网址标题：</td>
                        <td width="70%" align="left" class="td_title">
                        <input type="text" name="S_Title" size="30" value="<?php echo $row["S_Title"]?>"/>
                        <font color="#FF0000"> ＊ </font>
                        </td>
                      </tr>
                      <tr>
                        <td height="35" align="center" class="td_title">网站地址：</td>
                        <td align="left" class="td_title">
                        <input type="text" name="S_Content" size="30" value="<?php echo $row["S_Content"]?>"/>
                            <font color="#FF0000"> ＊ </font>
                        </td>
                      </tr>
                      <tr>
                        <td align="center" class="td_title">网址说明：</td>
                        <td align="left" class="td_title">
                        <textarea cols="40" rows="3" name="S_Info"><?php echo $row["S_Info"]?></textarea>
                        </td>
                      </tr>
                      <tr>
                        <td height="32" align="center" class="td_title">&nbsp;</td>
                        <td align="left" class="td_title">
                        <input type="submit" class="subput" value="确定编辑"/>
                        <input type="button" class="subput" value="返回列表" onClick="back()"/>
                        </td>
                      </tr>
                  </form>
                </table>
                </td>
              </tr>
              <tr>
                <td height="10" background="images/inrepeat.jpg"></td>
              </tr>
          </table></td>
        </tr>
      </table>
<?php
}

function UserCZ(){
?> 
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td><table width="27%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="5%"><img src="images/inleft.jpg"/></td>
                <td width="91%" align="center" bgcolor="#20A9F9" class="starsize">在线充值</td>
                <td width="4%"><img src="images/inright.jpg"/></td>
              </tr>
          </table></td>
        </tr>
        <tr>
          <td align="center" valign="top" style="border:2px #21A8F6 solid;"><table width="100%" border="0" cellspacing="10" cellpadding="0">
              <tr>
                <td height="10" background="images/inrepeat.jpg"></td>
              </tr>
              <tr>
                <td height="380" bgcolor="#EAF5FF"><table width="80%" height="300" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
                    <form action="?action=cz" method="post" onsubmit="return checkcz(this);">
                      <tr>
                        <td width="30%" height="35" align="center" class="td_border">会员帐号：</td>
                        <td width="70%" align="left" class="td_border"><input name="S_Name" type="text" id="S_Name" value="<?php echo $_COOKIE["S_Name"]?>" size="30" />
                        <font color="#FF0000"> ＊ </font>
                            <label id="tishi1"></label>
                        </td>
                      </tr>
                      <tr>
                        <td height="35" align="center" class="td_border">确认帐号：</td>
                        <td align="left" class="td_border"><input name="S_Name1" type="text" id="S_Name1" size="30"/>
                        <font color="#FF0000"> ＊ </font></td>
                      </tr>
                      <tr>
                        <td height="35" align="center" class="td_border">充值卡号：</td>
                        <td align="left" class="td_border"><input name="S_CardNum" type="text" id="S_CardNum" onKeyUp="this.value=this.value.replace(/[^\d]/g,'')" size="30" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"/>
                        <font color="#FF0000"> ＊ </font>
                            <label id="tishi2"></label>
                        </td>
                      </tr>
                      <tr>
                        <td height="35" align="center" class="td_border">充值密码：</td>
                        <td align="left" class="td_border"><input name="S_CardPWD" type="text" id="S_CardPWD" onKeyUp="this.value=this.value.replace(/[^\d]/g,'')" size="30" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"/>
                        <font color="#FF0000"> ＊ </font>
                            <label id="tishi3"></label>
                        </td>
                      </tr>
                      <tr>
                        <td height="32" align="center" class="td_border">&nbsp;</td>
                        <td align="left" class="td_border">
                        <input name="submit" type="submit" class="subput" value="确定充值" />
                        <label id="tishi" style="color:#F00"></label>
                        </td>
                      </tr>
                    </form>
                </table></td>
              </tr>
              <tr>
                <td height="10" background="images/inrepeat.jpg"></td>
              </tr>
          </table></td>
        </tr>
      </table>
<?php
}

function ShowLog(){
?>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td><table width="27%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="5%"><img src="images/inleft.jpg"/></td>
                <td width="91%" align="center" bgcolor="#20A9F9" class="starsize">会员登录</td>
                <td width="4%"><img src="images/inright.jpg"/></td>
              </tr>
          </table></td>
        </tr>
        <tr>
          <td align="center" valign="top" style="border:2px #21A8F6 solid;">
          <table width="100%" border="0" cellspacing="10" cellpadding="0">
          	  <tr>
                <td>
                	<table align="left">
                    	<tr>
                        	<td>
                	<img src="images/center.jpg" />
                    		</td>
                            <td valign="middle">
                    <b><font color="#720F39" style="font-size:16px;">&nbsp;会员登录&nbsp;</font></b>
                    		</td>
                        </tr>
                    </table>
                </td>
              </tr>
              <tr>
                <td height="10" background="images/inrepeat.jpg"></td>
              </tr>
              <tr>
                <td bgcolor="#EAF5FF" align="center" valign="middle" height="250">

              <table height="172" cellpadding="0" cellspacing="0" style="background-color:#FFF; ">
              <form method="post" action="?action=checklog" name="form1" onSubmit="return checklg(this);">
                  <tr>
                    <td width="79" height="37">&nbsp;&nbsp;&nbsp;用户名:</td>
                    <td width="199" align="left">
                    <input type="text" name="S_Name" id="S_Name" style="border-color:#666 #ccc #ccc #666"/></td>
                  </tr>
                  <tr>
                    <td height="37">&nbsp;&nbsp;&nbsp;密　码:</td>
                    <td align="left">
                    <input type="password" name="S_PassWord" id="S_PassWord" style="border-color:#666 #ccc #ccc #666"/>
                    </td>
                  </tr>
                  <tr>
                	<td height="37">&nbsp;&nbsp;&nbsp;验证码:</td>
                    <td align="left"><input type="text" size="5" id="codes"name="codes" style="background:#fffff9;border:1px #eaeaea solid;">
                    &nbsp;<img src="../include/code.php" id="imgcode"></td>
                </tr>
                  <tr>
                  <td colspan="2" align="center">
                    <input type="image" src="images/user.gif" style=" border:0px">
                  <a href="userreg.php"><img src="images/reg.gif" width="52" height="21" style="border:0px;"></a>
                  <a href="userfin.php"><img src="images/wm.gif" width="52" height="21" style="border:0px;"></a>
                  </td>
                  </tr>
                </form>
              </table>
                
                </td>
              </tr>
              <tr>
                <td height="10" background="images/inrepeat.jpg"></td>
              </tr>
          </table></td>
        </tr>
      </table>

<?php
}

function ChangeJF(){
	CheckCookies();
	$S_Name=$_COOKIE["S_Name"];
	global $db;
	$sql="select * from s_users where S_Name='".$S_Name."'";
	$result=$db->query($sql);
	$row=$db->fetch_array($result);
?>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td><table width="27%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="5%"><img src="images/inleft.jpg"/></td>
                <td width="91%" align="center" bgcolor="#20A9F9" class="starsize">点数转换</td>
                <td width="4%"><img src="images/inright.jpg"/></td>
              </tr>
          </table></td>
        </tr>
        <tr>
          <td align="center" valign="top" style="border:2px #21A8F6 solid;"><table width="100%" border="0" cellspacing="10" cellpadding="0">
              <tr>
                <td height="10" background="images/inrepeat.jpg"></td>
              </tr>
              <tr>
                <td height="380" bgcolor="#EAF5FF"><table width="80%" height="229" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
                    <form method="post" action="?action=savechange" name="formjf" id="formjf">
                      <tr>
                        <td width="30%" height="35" align="center" class="td_border">用户帐号：</td>
                        <td width="70%" align="left" class="td_border">
                        <?php echo $_COOKIE["S_Name"]?>                        </td>
                      </tr>
                      <tr>
                        <td height="35" align="center" class="td_border">
                        <?php
						if($row["S_UseType"]==0){
                        	echo "剩余积分：";
                        }
						else{
                        	echo "剩余财富：";
                        }
						?>
                        </td>
                        <td align="left" class="td_border">
                        <?php
						if($row["S_UseType"]==0){
							echo($row["S_Coin"]."积分");
						}
						else{
							echo($row["S_Coin"]."点积分,".$row["S_UseDate"]."到期");
						}
						?>
                        </td>
                      </tr>
                      <tr>
                        <td height="35" align="center" class="td_border">转换类型：</td>
                        <td align="left" class="td_border">
                        <input type="radio" name="S_UseType" value="0"<?php if($row["S_UseType"]==0){ echo "checked";}?> class="checkbox"/>
                        扣点会员
                        <input type="radio" name="S_UseType" value="1"<?php if($row["S_UseType"]==1){ echo "checked";}?> class="checkbox"/>
                        包月会员                        </td>
                      </tr>
                      <tr>
                        <td height="82" colspan="2" align="left" valign="top" class="td_border">
                        <font color="#FF0000"><br />
                       &nbsp;&nbsp;&nbsp;转换模式点数说明：<br />
                       &nbsp;&nbsp;&nbsp;当前点数：一天可以转换为<?php echo S_TGChange?>点数，<?php echo S_TGChange?>点数可以转换为一天。<br />
                       &nbsp;&nbsp;&nbsp;每个会员一天只能转换一次，请慎重操作！<br />
                       &nbsp;&nbsp;&nbsp;月卡用户当天不记入转换，点卡用户当天记入转换!</font>                        
                       </td>
                      </tr>
                      <tr>
                        <td class="td_border" align="center" colspan="2">
                        <input type="button" value="确定转换" class="subput" onclick="puterr()"/>
                        </td>
                      </tr>
                    </form>
                </table>
                <table width="80%" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
                	<form action="?action=change" method="post"  onsubmit="return checkcg(this);">
                	<tr>
                    	<td class="td_border" height="35" width="30%">
                        &nbsp;财富兑换：
                        </td>
                        <td class="td_border" height="35" align="left" width="70%">
                        <input type="radio" name="types" id="types1" value="0" class="checkbox" checked="checked"/>使用积分兑换时间
                        <input type="radio" name="types" id="types2" value="1" class="checkbox"/>使用时间兑换积分
                        </td>
                	</tr>
                    <tr>
                        <td class="td_border" height="35">
                        &nbsp;使用天数/积分：
                        </td>
                        <td class="td_border" height="35" align="left">
                        <input type="text" name="days" id="days" onKeyUp="this.value=this.value.replace(/[^\d]/g,'')" size="15" maxlength="5" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"/>
                        <span style="color:#F00">填写您要使用的财富数额</span>
                        </td>
                    </tr>
                    <tr>
                    	<td colspan="2" align="center" height="35" class="td_border" >
                        <input type="submit" value="确认兑换" class="subput"/>
                        </td>
                    </tr>
                    </form>
                </table>
                </td>
              </tr>
              <tr>
                <td height="10" background="images/inrepeat.jpg"></td>
              </tr>
          </table></td>
        </tr>
      </table>
<?php
}
?>
</body>
</html>