<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="qqconfig.asp"-->
<!--#include file="buyconfig.asp"-->
<!--#include file="qqconnect.asp"-->
<%
If app_user = 0 Then writeE "会员系统关闭中"

dim action : action = be("get","action")
dim u_points,u_plays,u_downs,u_fav

Select case action
	case "login" : userhead: login :foot
	case "check" : checkLogin
	case "logout" : logout
	
	case "regcheck":regcheck
	case "reg" : userhead :  reg :  foot
	case "regsave" : regsave
	
	case "findpass" : userhead : findpass : foot
	case "findpasssave" : findpasssave
	
	case "info": chklogin : userhead : info : foot
	case "save": chklogin : save
	case "popedom" : chklogin : userhead : popedom : foot
	
	case "plays": chklogin:  userhead :  plays : foot
	case "playsdel" :  chklogin : playsdel
	
	case "downs": chklogin:  userhead :  downs : foot
	case "downsdel" :  chklogin : downsdel
	
	case "fav" : chklogin: userhead : fav : foot
	case "favdel" : chklogin: favdel
	case "tg" : tg
	case "upgrade": chklogin:  userhead: upgrade : foot
	case "upgradesave": chklogin:  upgradesave
	case "upgradesave2" : chklogin : upgradesave2
	
	case "pay": chklogin:  userhead : pay : foot
	case "pay2": chklogin:  userhead : pay2 : foot
	case "paysave": chklogin: paysave
	case "paysave2": chklogin: paysave2
	case "wel": chklogin: userhead : wel : foot
	case else :  chklogin:  userhead : main : foot
End Select
dispseObj()

Sub chklogin
	dim sql,rs
	dim u_id,loginValidate
	u_id = session("userid")
	if not isN(u_id) then 
		on error resume next
		set rs = objdb.db("SELECT * FROM {pre}user where u_id=" & u_id,"rs1")
		loginValidate = md5(rs("u_random") & rs("u_name") & rs("u_id"),2)
		if err then 
			session("userid") = ""
			session("usergourp")=""
			session("username") = ""
			session("usercheck")=""
	    	writea "<script>top.location.href='index.asp?action=login';</script>"
	    	exit sub
		end if
		if session("usercheck") <> loginValidate then
		   session("usercheck")=""
		   writea "<script>top.location.href='index.asp?action=login';</script>"
		end if
		u_points=rs("u_points")
		u_plays=rs("u_plays")
		u_downs=rs("u_downs")
		u_fav=rs("u_fav")
		objdb.c(rs)
	else
		writea "<script>top.location.href='index.asp?action=login';</script>"
	end if
End Sub

sub checkLogin
	dim u_name,u_password,founderr,randnum,msg,backurl,flag
	dim rs
	u_name = be("post","u_name") : u_name= chkSql(u_name,true)
	u_password = md5(be("post","u_password"),2)
	flag = be("all","flag")  : backurl = request("backurl")
	if isN(flag) then flag = "iframe"
	
	set rs = objdb.db("SELECT u_id,u_qid, u_name, u_qq, u_email,u_regtime,u_status,u_points,u_tj, u_loginnum, u_logintime,u_ip,u_random,u_flag,u_start,u_end,ug_id,u_group,ug_name,ug_type,ug_popedom,ug_popvalue FROM ({pre}user LEFT OUTER JOIN {pre}user_group ON {pre}user.u_group = {pre}user_group.ug_id) where u_name='"&u_name&"' and u_password = '"&u_password&"' and u_status =1" ,"rs3")
	
	if rs.eof and rs.bof then
		objdb.c(rs)
		if flag="iframe" then
			alertUrl "您输入的用户名和密码不正确或者您的账户已经被锁定!","login.asp"
		else
			alertUrl "您输入的用户名和密码不正确或者您的账户已经被锁定!","?action=login&url="&backurl
		end if
		exit sub
	else
		randomize
		randnum = md5(rnd*99999999,2)
		rs("u_logintime") = now()
		rs("u_ip") = getIP()
		rs("u_random") = randnum
		rs("u_loginnum") = rs("u_loginnum") + 1
		if rs("u_flag") = 1 then
			if not CDate(now()) <= CDate(rs("u_end")) then
				rs("u_flag") = 0
				rs("u_start") = ""
				rs("u_end") = ""
			end if
		end if
		rs.update
		
		session("userid") = rs("u_id")
		session("username") = rs("u_name")
		session("usergroup") = rs("u_group")
		session("ugpopvalue") = rs("ug_popvalue")
		session("usercheck") = md5(randnum & rs("u_name") & rs("u_id"),2)
		objdb.C(rs)
		if isN(backurl) then
			if flag="iframe" then
				writea "<script>window.location.href='login.asp';</script>"
			else
				writea "<script>top.location.href='index.asp';</script>"
			end if
		else
			writea "<script>top.location.href='"&backurl &"';</script>"
		end if
	end if
end sub

sub logout
	dim flag : flag = be("all","flag")
	if isN(flag) then flag = "iframe"
	session("userid") = ""
	session("usergroup")=""
	session("username") = ""
	session("usercheck")=""
	session("ugpopvalue")=""
	if flag="iframe" then
		writea "<script>window.location.href='login.asp';</script>"
	else
		writea "<script>top.location.href='index.asp?action=login';</script>"
	end if
end sub

sub regcheck
	on error resume next
	dim str,typea,where,okstr,errstr
	str=be("all","str") : str=chkSql(str,true)
	typea=be("all","typea") : typea=chkSql(typea,true)
	okstr = "{""result"":true}"
	errstr = "{""result"":false}"
	select case typea
		case "u_name": where = "u_name='" & str &"'"
		case "u_email": where = "u_email='" & str &"'"
		case "u_qq": where = "u_qq='" & str &"'"
		case "verifycode": 
			if session("code_userreg") <> str then
				writeE errstr
			else
				writeE okstr
			end if
		case else : where=""
	end select
	
	Dim rs : Set rs = objdb.db("SELECT * FROM {pre}user WHERE " & where ,"rs1")
	if rs.bof and rs.eof then str= okstr else str= errstr
	if err then str=  errstr: err.clear
	objdb.C(rs)
	writeA str
end sub


sub reg
	if app_reg=0 then writeA "系统已经关闭注册" : exit sub
	dim ref,qc,url, result, token, qqid,randnum,rs,rscount,tmpname,nickname,UserInfo
	Dim oauth_token, openid, oauth_vericode, timestamp,i:i=1
	
	ref= be("all","ref")
	if ref="qqlogin" then
    	SET qc = New QqConnet
		Session("State") = qc.MakeRandNum()
		url = qc.GetAuthorization_Code()
		Response.Redirect(url)
		Set qc=Nothing
	elseif ref="qqlogged" then
		SET qc = New QqConnet
			result = qc.CheckLogin()
			
			If result=true Then
				Session("Access_Token") = qc.GetAccess_Token()
				qqid = qc.Getopenid()
				Session("Openid") = qqid
				UserInfo=qc.GetUserInfo()
				nickname = qc.GetUserName(UserInfo)(0): nickname=chkSql(nickname,true) : nickname=replace(nickname,"'","")
				tmpname = nickname
				
				rscount = objdb.db("SELECT count(*) FROM {pre}user where u_qid='" & qqid & "'","exe")(0)
				if rscount = 0 then
					set rs = objdb.db("SELECT * FROM {pre}user where u_name='" & tmpname & "'","rs1")
					do while not rs.eof
						tmpname = nickname & i
						set rs = objdb.db("SELECT * FROM {pre}user where u_name='" & tmpname & "'","rs1")
						i=i+1
					loop
					set rs =nothing
					nickname = tmpname
					objdb.add  "{pre}user",Array("u_name","u_qid", "u_password","u_qq","u_email","u_regtime","u_status","u_points","u_group","u_phone","u_question","u_answer"),Array(nickname,qqid,md5("",2),"","",now(),app_regstate,app_regpoint,app_reggroup,"","","")
				end if
				
				set rs = objdb.db("SELECT u_id,u_qid, u_name, u_qq, u_email,u_regtime,u_status,u_points,u_tj, u_loginnum, u_logintime,u_ip,u_random,u_flag,u_start,u_end,ug_id,u_group,ug_name,ug_type,ug_popedom,ug_popvalue FROM ({pre}user LEFT OUTER JOIN {pre}user_group ON {pre}user.u_group = {pre}user_group.ug_id) where u_qid='"&qqid&"' and u_status =1" ,"rs3")
					if not rs.eof then
						randomize
						randnum = md5(rnd*99999999,2)
						rs("u_logintime") = now()
						rs("u_ip") = getIP()
						rs("u_random") = randnum
						rs("u_loginnum") = rs("u_loginnum") + 1
						if rs("u_flag") = 1 then
							if not CDate(date()) <= CDate(rs("u_end")) then 
								rs("u_flag") = 0
								rs("u_start") = ""
								rs("u_end") = ""
							end if
						end if
						rs.update
						session("userid") = rs("u_id")
						session("username") = rs("u_name")
						session("usergroup") = rs("u_group")
						session("ugpopvalue") = rs("ug_popvalue")
						session("usercheck") = md5(randnum & rs("u_name") & rs("u_id"),2)
					end if
					objdb.c(rs)
				if randnum <>"" then redirect app_installdir
			End If
			SET qc=nothing
	else
		
	end if
%>
<script type="text/javascript">
function remote_check(typea, str){
  var url="?action=regcheck";
  var ret;
  $.ajax({'url':url,'async':false,'dataType':'json','data':{'typea':typea,'str':str},'success':function(data){ret=data;}});
  return ret.result;
}
var validator={
'u_name':[
  [/\S+/, '请输入用户名'],
  [/\S{4,}/, '用户名少于4位'],
  [function(u_name){return remote_check('u_name',u_name);}, '此用户名已被使用']
],
'u_password1':[
  [/^.+$/, '请输入密码'],
  [/^.{6,}$/, '密码少于6位']
],
'u_password2':[
  [/^.+$/, '请输入确认密码'],
  [function(s){return s==$('#item_u_password1 input').val();}, '两次密码输入不一致']
],
'u_email':[
  [/\S+/, '请输入电子邮件'],
  [/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i, '请输入格式正确的电子邮件'],
  [function(u_email){return remote_check('u_email',u_email)}, '此电子邮件已被使用']
],
'u_qq':[
  [/\S+/, '请输入QQ号码'],
  [/^[\d|\.|,]+$/, '请输入格式正确的QQ号码'],
  [function(u_qq){return remote_check('u_qq',u_qq)}, '此QQ号码已被使用']
],
'u_phone':[
  [/\S+/, '请输入电话号码'],
  [/^[\d|\.|,]+$/, '请输入格式正确的电话号码']
],
'verifycode':[
  [/\S+/,'请输入验证码'],
  [function(verifycode){return remote_check('verifycode',verifycode)}, '验证码不正确']
]
};

function validate(item) {
  var str=$("#item_"+item+" input").val();
  var m={
    'RegExp':function(r,s){
      return r.test(s);
    },
    'Function':function(f,s){
      return f(s);
    },
    'String':function(v,s){return v==s;}
  };
  for (var v in validator[item]) {
    var vi=validator[item][v];
    var c=Object.prototype.toString.apply(vi[0]).match(/(\w+)\]$/)[1];
    if (m[c] && !m[c](vi[0],str)) {
      fail(item,vi[1]);
      return false;
    }
  }
  succ(item);
  return true;
}

var result={};
for (var k in validator){
	result[k]=false;
}

function fail(item, msg){
	$("#item_"+item+" .f3 span").html(msg).removeClass('valid').addClass('fail');
	result[item]=false;
	disable();
}
function succ(item) {
	$("#item_"+item+" .f3 span").html('&nbsp;').removeClass('fail').addClass('valid');
	result[item]=true;
	check_all();
}
function check_all() {
	for (var k in result){
	  if (result[k]==false){
	    disable();
	    return true;
	  }
	}
	if (!$('#agree').attr('checked')) {
	  disable();
	  return true;
	}
	enable();
	return true;
}
function enable(){
	$('#submit_enabled').show();
	$('#submit_disabled').hide();
	return true;
}
function disable(){
	$('#submit_enabled').hide();
	$('#submit_disabled').show();
	return false;
}
function check_and_submit() {
	if (!check_all()) {
	return;
	}
	$('form')[0].submit();
}
$(document).ready(function(){
	$('#header').append('<div class="subNavi"><a href="?action=login">登录</a> <a href="../">返回首页</a> </div>');
});
</script>
<div id="outterWrapper">
<div id="container">
	<div id="header">
    	<h1 class="bannerReg">注册我的通行证</h1>
    </div>
    <div id="content">
    	<div id="main">
		<div id="sideMain">
			<div id="regForm">
			<form action="?action=regsave" method="post">
				<ul>
					<li id="item_u_name">
						<div class="f1"><strong>用户名</strong></div>
						<div class="f2"><input type="text" class="text" maxlength="16" name="u_name" /></div>
						<div class="f3"><span></span></div>
						<div class="f4">由4-16位任意字符组成</div>
					</li>
					<li id="item_u_password1">
						<div class="f1"><strong>密　码</strong></div>
						<div class="f2"><input type="password" class="text" maxlength="16" name="u_password1"  /></div>
						<div class="f3"><span></span></div>
						<div class="f4">由6-16位字符组成</div>
					</li>
					<li id="item_u_password2">
						<div class="f1"><strong>确认密码</strong></div>
						<div class="f2"><input type="password" class="text" maxlength="16" name="u_password2" /></div>
						<div class="f3"><span></span></div>
						<div class="f4">由6-16位字符组成</div>
					</li>
					<li id="item_u_email">
						<div class="f1"><strong>电子邮件</strong></div>
						<div class="f2"><input type="text" class="text" maxlength="32" name="u_email" /></div>
						<div class="f3"><span></span></div>
						<div class="f4">请填写有效电子邮件，以获得注册验证信</div>
					</li>
					<li id="item_u_qq">
						<div class="f1"><strong>QQ号码</strong></div>
						<div class="f2"><input type="text" class="text" maxlength="16" name="u_qq" /></div>
						<div class="f3"><span></span></div>
						<div class="f4">请填写有效QQ号码，可以通过QQ号码登录</div>
					</li>
					<li id="item_u_phone">
						<div class="f1"><strong>电话号码</strong></div>
						<div class="f2"><input type="text" class="text" maxlength="16" name="u_phone" /></div>
						<div class="f3"><span></span></div>
						<div class="f4">请填写有效电话号码</div>
					</li>
					<li id="item_u_question">
						<div class="f1"><strong>找回问题</strong></div>
						<div class="f2"><input type="text" class="text" maxlength="255" name="u_question" /></div>
						<div class="f3"><span></span></div>
						<div class="f4">请认真填写问题，以便日后找回密码</div>
					</li>
					<li id="item_u_answer">
						<div class="f1"><strong>找回答案</strong></div>
						<div class="f2"><input type="text" class="text" maxlength="255" name="u_answer" /></div>
						<div class="f3"><span></span></div>
						<div class="f4">请认真填写答案，以便日后找回密码</div>
					</li>
					
					<li class="validCode" id="item_verifycode">
						<div class="f1"><strong>验证码</strong></div>
						<div class="f2"><div>&nbsp;&nbsp;<img src="../inc/code.asp?a=userreg&s='Math.random()" title="看不清楚? 换一张！" style="cursor:hand;" onClick="src='../inc/code.asp?a=userreg&s='+Math.random()"/></div></div>
						<div class="clear"></div>
						<div class="f5">
						  <input type="text" class="text" maxlength="4" name="verifycode" />
						</div>
						<div class="f3"><span></span></div>
						<div class="f4"></div>
					</li>
					<li class="agreement" id="item_agree">
						<div class="f4"><input name="agree" id="agree" type="checkbox" value="1" checked="checked" class="checkbox" /> <span>我已阅读并同意</span></div>
					</li>
				</ul>
				<div class="button">
					<img id="submit_enabled" onclick="check_and_submit();" src="../images/user/btn_reg.gif" title="同意协议并注册" style="cursor:pointer;display:none;"/>
					<img id="submit_disabled" src="../images/user/btn_reg_invalid.gif" title="同意协议并注册"/>
				</div>
			</form>
			</div>
		</div>
<script type="text/javascript">
$('#regForm input')
.blur(function(){validate(this.name);})
.change(check_all);
</script>
<div id="sideSub">
		<div class="subNotice02">
		<p>注册通行证可享会员服务</p>
		<p>收费影片</p>
		<p>会员影片</p>
		<p>特殊影片</p>
		<p>让您看片、交友、互动，一个都不少。</p>
		</div>
		<div class="toReg">
			<a href="?action=reg" title="还没有通行证？立即注册 &raquo;"><img src="../images/user/toreg.png" width="210" height="21" alt="还没有通行证？立即注册 &raquo;" /></a>
		</div>
	</div>            <div class="clear"></div>
        </div>
    </div>
    <div class="footer">
		<div class="link_bk">&copy; 2008-2013 <a href="http://www.maccms.com/" target="_blank">MACCMS</a> Inc. Powered by 苹果电影程序</div>
	</div>
</div>
</div>
<%
end sub

sub regsave
	dim verifycode,u_name,u_password1,u_password2,u_qq,u_email,u_phone,u_question,u_answer
	if app_reg=0 then writeA "系统已经关闭注册" : exit sub
	verifycode = be("post","verifycode")
	if verifycode ="" then alert "请返回输入确认码。返回后请刷新登陆页面后重新输入正确的信息。" : exit sub
	if trim(verifycode) <> trim(session("code_userreg")) then alert "确认码错误，请重新输入。返回后请刷新登陆页面后重新输入正确的信息。" : exit sub
	u_name = be("post","u_name") : u_name=chkSql(u_name,true)
	u_password1 = be("post","u_password1") : u_password1=chkSql(u_password1,true)
	u_password2 = be("post","u_password2") : u_password2=chkSql(u_password2,true)
	u_qq = be("post","u_qq") : u_qq=chkSql(u_qq,true)
	u_email = be("post","u_email") : u_email=chkSql(u_email,true)
	u_phone = be("post","u_phone") : u_phone=chkSql(u_phone,true)
	u_question = be("post","u_question") : u_question=chkSql(u_question,true)
	u_answer = be("post","u_answer") : u_answer=chkSql(u_answer,true)
	
	if u_password1 <> u_password2 then alert "两次密码不同" : exit sub
	if len(u_name) >32 then u_name= left(u_name,32)
	if len(u_password1) >32 then u_password1=left(u_password1,32)
	if len(u_email) > 32 then u_email=left(u_email,32)
	if len(u_qq) > 16 then u_qq=left(u_qq,16)
	if len(u_phone) >16 then u_phone=left(u_phone,16)
	if len(u_question) >255 then u_question=left(u_question,255)
	if len(u_answer) >255 then u_answer=left(u_answer,255)
	if not isNum(u_qq) then alert "QQ号码格式不正确" : exit sub
	if not isNum(u_phone) then alert "电话号码格式不正确" : exit sub
	
	u_password1 = md5(u_password1,2)
	u_name = htmlFilter(u_name)
	
	dim rs
	set rs= objdb.db("SELECT * FROM {pre}user WHERE u_name='"&u_name&"'","rs1")
	
	if rs.eof and rs.bof then
		 objdb.add  "{pre}user",Array("u_name", "u_password","u_qq","u_email","u_regtime","u_status","u_points","u_group","u_phone","u_question","u_answer"),Array(u_name,u_password1,u_qq,u_email,now(),app_regstate,app_regpoint,app_reggroup,u_phone,u_question,u_answer)
		alertUrl "注册成功,正在转向登录页面","index.asp?action=login" : exit sub
	else
		alert "注册失败,该用户名已经被使用" : exit sub
	end if
	objdb.c(rs)
end sub

sub findpass
%>
<div id="outterWrapper">
<div id="container">
<div id="header">
    	<h1 class="bannerFindPass">找回密码</h1>
</div>
    <div id="content">
    	<div id="main">
            <div id="sideMain">
<div id="pass">
<form method="post" action="?action=findpasssave">
<p class="notice">填写信息并提交后，将自动重设密码</p>
<p class="findPass"><span class="f1">用户名</span><span class="f2">
<input type="text" class="text" name="u_name" maxlength="32" /></span></p>
<p class="findPass"><span class="f1">找回问题</span><span class="f2">
<input type="text" class="text" name="u_question" maxlength="255" /></span></p>
<p class="findPass"><span class="f1">找回答案</span><span class="f2">
<input type="text" class="text" name="u_answer" maxlength="255" /></span></p>
<p class="findPass"><span class="f1">新密码</span><span class="f2">
<input type="text" class="text" name="u_password" maxlength="32" /></span></p>
<p class="button"><input type="submit" value="提交" class="button" /></p>
</form>
</div>
<div id="solution">
<p>如果需要帮助可发送邮件至 <a href="mailto:<%=app_email%>"><%=app_email%></a></p>
<p>您也可以加QQ:<%=app_qq%>为好友与我联系</p>
</div>
</div>
<div id="sideSub">
		<div class="subNotice02">
		<p>注册通行证可享会员服务</p>
		<p>收费影片</p>
		<p>会员影片</p>
		<p>特殊影片</p>
		<p>让您看片、交友、互动，一个都不少。</p>
		</div>
		<div class="toReg">
			<a href="?action=reg" title="还没有通行证？立即注册 &raquo;"><img src="../images/user/toreg.png" width="210" height="21" alt="还没有通行证？立即注册 &raquo;" /></a>
		</div>
            <div class="clear"></div>
        </div>
    </div>
   <div class="footer">
	<div class="link_bk">&copy; 2008-2013 <a href="http://www.maccms.com/" target="_blank">MACCMS</a> Inc. Powered by 苹果电影程序</div>
	</div>
</div>
</div>
<%
end sub

sub findpasssave
	dim u_name,u_email,u_password,u_question,u_answer,rs
	u_name = be("post","u_name") : u_name=chkSql(u_name,true)
	u_password = be("post","u_password") : u_password=chkSql(u_password,true)
	u_email = be("post","u_email") : u_email=chkSql(u_email,true)
	u_question = be("post","u_question") : u_question=chkSql(u_question,true)
	u_answer = be("post","u_answer") : u_answer=chkSql(u_answer,true)
	
	if len(u_name) >32 then u_name= left(u_name,32)
	if len(u_password) >32 then u_password=left(u_password,32)
	if len(u_question) >255 then u_question=left(u_question,255)
	if len(u_answer) >255 then u_answer=left(u_answer,255)
	u_password = md5(u_password,2)
	
	if isN(u_question) or isN(u_answer) or isN(u_password) or isN(u_name) then
		alert  "表单信息不完整,请重填!"
	else
		set rs= objdb.db("SELECT * FROM {pre}user WHERE u_name='"&u_name&"'","rs1")
		if rs.eof and rs.bof then
			alert "重置密码失败" : exit sub
		else
			if (u_question <> rs("u_question")) or (u_answer <> rs("u_answer")) then alert "重置密码失败" : exit sub
			objdb.update  "{pre}user",Array("u_password"),Array(u_password),"u_id = "& rs("u_id")
			alertUrl "重置密码成功,正在转向登录页面","index.asp?action=login" : exit sub
		end if
		objdb.c(rs)
	end if
end sub

sub tg
	dim userid,Ip,Ly,sql,rsUV,rs
	userid = be("get","uid") : userid=chkSql(userid,true)
	on error resume next
	
	if isN(application("LyLastDelDate")) then application("LyLastDelDate") = Date()
	if isNum(userid) and app_popularizestate=1 then
		Ip = getIP()
		Ly=  getReferer()
		Set rs = objdb.db("select * from {pre}user where u_id=" & userid &"","rs1") 
		if not rs.eof then
			sql="Select * From {pre}user_visit where uv_uid = " &userid&" and uv_ip ='"&IP&"' and year(uv_time)="&Year(date)&" and month(uv_time)="&month(date)&" and day(uv_time)="&day(date)
			set rsUV = objdb.db(sql,"rs1")
			if rsUV.eof or rsUV.bof then
				objdb.add "{pre}user_visit",Array("uv_uid","uv_ip","uv_ly","uv_time" ), array(userid,Ip,Ly,now() )
				objdb.db "update {pre}user set u_tj=u_tj+1,u_points=u_points+" & app_popularize & " where u_id="& userid,"exe"
				If DateDiff("d",application("LyLastDelDate"),Date())<>0 Then
					 Sql="delete from {pre}user_visit where year(uv_time)<="&Year(date)&" and month(uv_time)<="&month(date)&" and day(uv_time)<"&day(date)
					 objdb.db Sql,"exe"
					 application("LyLastDelDate") = Date()
				End If
			end if
		end if
		objdb.c(rs)
	end if
	on error goto 0
	response.redirect "../"
end sub

sub save
	dim oldpass,password1,password2,u_qq,u_email,rs
	oldpass = be("post","u_oldpass") : oldpass=chkSql(oldpass,true)
	password1 = be("post","u_password1") : password1=chkSql(password1,true)
	password2 = be("post","u_password2") : password2=chkSql(password2,true)
	u_qq= be("post","u_qq") : u_qq=chkSql(u_qq,true)
	u_email = be("post","u_email") : u_email=chkSql(u_email,true)
	
	
	if len(u_email)>32 then u_email = left(u_email,32)
	if len(u_qq)>16 then u_qq = left(u_qq,16)
	if len(password1)>32 then password1 = left(password1,32)
	
	set rs = objdb.db("select * from {pre}user where u_id=" & session("userid"),"rs1")
	if rs.eof and rs.bof then
		alert "非法访问" : exit sub
	else
		if rs("u_password") <> md5(oldpass,2) then
			alert "旧密码不正确" : exit sub
		end if
	end if
	objdb.c(rs)
	if password1 <> "" then
		if password1<>password2 then alert "两次密码不同" : exit sub
		password1 = md5(password1,2)
		objdb.update "{pre}user",Array("u_qq","u_email","u_password") ,Array(u_qq,u_email,password1) ,"u_id = "& session("userid")
	else 
		objdb.update "{pre}user",Array("u_qq","u_email") ,Array(u_qq,u_email) ,"u_id = "& session("userid")
	end if
	alertUrl "修改成功！","?action=wel"
end sub

sub upgradesave
	dim upgradearr,NewU_Group
	NewU_Group = be("post","u_group") : NewU_Group=chkSql(NewU_Group,true)
	upgradearr = split(NewU_Group,"_")
	if cint(session("ugpopvalue")) > cint(upgradearr(2)) then alert "您现在的会员组比目标会员组权限高，不需要升级!" :exit sub
	if session("usergroup") = cint(upgradearr(0))  then alert "您已经是该会员组成员无需升级!" :exit sub
	if u_points < cint(upgradearr(1)) then alert "您的积分不够，无法升级到该会员组!" :exit sub
	objdb.db "UPDATE {pre}user set u_points=u_points-"&upgradearr(1) & ",u_group="&upgradearr(0) & "  WHERE u_id ="& session("userid"),"exe"
	alertUrl "升级成功,请重新登陆！","?action=wel"
end sub

sub upgradesave2
	dim baoshi,dn
	baoshi = be("post","baoshi")
	if not isNum(baoshi) then baoshi=0 else baoshi = clng(baoshi)
	select case baoshi
		case 1 : baoshi = app_weekpoint : dn=7
		case 2 : baoshi = app_monthpoint : dn=30
		case 3  : baoshi = app_yearpoint : dn=365
		case else : alertUrl "非法请求，请重试！",""
	end select
	if u_points < baoshi then alert "您的积分不够，无法包时长!" :exit sub
	objdb.db "UPDATE {pre}user set u_points=u_points-"&baoshi & ",u_start='"&now&"',u_end='"&now+dn&"',u_flag=1  WHERE u_id ="& session("userid"),"exe"
	alertUrl "包时长成功,请重新登陆！","?action=wel"
end sub

sub playsdel
	objdb.update  "{pre}user" ,Array("u_plays"), Array("") ,"u_id="& session("userid")
	alerturl "清空收费播放记录成功!","?action=plays"
end sub

sub downsdel
	objdb.update  "{pre}user" ,Array("u_downs"), Array("") ,"u_id="& session("userid")
	alerturl "清空收费下载记录成功!","?action=downs"
end sub

sub favdel
	dim d_id,arr,i
	d_id = be("all","d_id") : d_id=chkSql(d_id,true)
	if not isN(d_id) then
		arr = split(d_id,",")
		for i=0 to ubound(arr)
			if instr(u_fav,","& trim(arr(i)) &",") > 0 then
				u_fav = replace(u_fav, trim(arr(i)),"")
				u_fav = replace(u_fav,",,",",")
			end if
		next
		objdb.update  "{pre}user" ,Array("u_fav"), Array(u_fav) ,"u_id="& session("userid")
	end if
	alerturl "删除完毕!","?action=fav"
end sub

sub userhead
%>
<!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=utf-8" />
    <title>用户中心 - <%=app_sitename%></title>
    <meta http-equiv="X-UA-Compatible" content="IE=7">
    <link rel="stylesheet" type="text/css" href="../images/user.css" />
    <link rel="stylesheet" type="text/css" href="../images/icon.css" />
    <script type="text/javascript" src="../js/jquery.js"></script>
    <script type="text/javascript" src="../js/jquery.validate.js"></script>
    <script type="text/javascript" src="../js/function.js"></script>
</head>
<body>
<%
end sub

sub foot
%>
</body>
</html>
<%
end sub

sub main
%>
<script type="text/javascript">
$(document).ready(function(){
	$(".left_menu_btop li").hover(
		function()
		{
			$(this).css("background-color","#E9FBFE");
			},
			function()
			{
			$(this).css("background-color","");
			}
		);
	$(".left_menu_bg").click(function(){
		var tb=$(this).next();
		var tb_display=tb.css("display");
		if (tb_display=="block")
		{
		tb.css("display","none");
		$(this).find("img").attr("src","../images/user/06.gif");
		}
		else
		{
		tb.css("display","block");
		$(this).find("img").attr("src","../images/user/07.gif");
		}
	});
});
</script>
<div class="nav_outer">
<div class="nav idTabs" id="tabshow">
	<div class="clear"></div>
</div>
	<div class="nav_bottom_left"></div>
	<div class="nav_bottom_center">
	  <div id="tab1" style="padding-left:8px;">
		<span style="color:#FFFFFF">欢迎您登录会员中心</span>
	  </div>
    </div>
	<div class="nav_bottom_right"></div>
	<div class="clear"></div>
</div>
<table width="960" border="0" align="center" cellpadding="0" cellspacing="0" style="margin-top:6px;" >
  <tr>
    <td width="173" height="500" valign="top" class="link_bk">
	<div class="left_menu_box">
		<div class="left_menu_bg">
			<div class="left_menu_tit">数据管理</div>
			<div class="left_menu_img"><img src="../images/user/07.gif"  border="0" /></div>
			<div class="clear"></div>
		</div>
		<div class="left_menu_btop" style="height:450px;">
		<ul>
				<li><a target="ifu" href="?action=wel">会员信息</a></li>
				<li><a target="ifu" href="?action=info">修改信息</a></li>
				<li><a target="ifu" href="?action=popedom">我的权限</a></li>
				<li><a target="ifu" href="?action=plays">收费点播记录</a></li>
				<li><a target="ifu" href="?action=downs">收费下载记录</a></li>
				<li><a target="ifu" href="?action=fav">我的收藏</a></li>
				<li><a target="ifu" href="?action=upgrade">升级会员</a></li>
				<li><a target="ifu" href="?action=pay">充值卡充值</a></li>
				<li><a target="_blank" href="?action=pay2">在线充值</a></li>
				<li><a target="ifu" href="?action=logout&flag=main">退出</a></li>
				</ul>
		</div>
	</div>
	
	</td>
    <td valign="top" height="500">
       <iframe id="ifu" name="ifu" scrolling="auto" frameborder="0"  src="?action=wel" style="width:100%;height:100%;"></iframe>
    </td>
  </tr>
</table>
<div class="footer">
<div class="link_bk">&copy; 2008-2013 <a href="http://www.maccms.com/" target="_blank">MACCMS</a> Inc. Powered by 苹果电影程序</div>
</div>
<%
end sub

sub login
%>
<script type="text/javascript">
$(document).ready(function(){	
	$("body").bind('keyup',function(event) {
		if(event.keyCode==13){
			$('#btnLogin').click();
		}
	}); 
	$('#btnLogin').click(function() {
		var u_name = $('#u_name').val();
		var u_password = $('#u_password').val();
		if (u_name == '') {
			alert('请输入用户！');
			$("#u_name").focus();
			return false;
		}
		if (u_password  == '') {
			alert('请输入密码！');
			$("#u_password").focus();
			return false;
		}
		$("#form1").submit();
	});
	$('#header').append('<div class="subNavi"><a href="?action=reg">注册</a> <a href="../">返回首页</a> </div>');
});
</script>
<div id="outterWrapper">
<div id="container">
<div id="header">
	<h1 class="bannerLogin">登录通行证</h1>
</div>
<div id="content">
	<div id="main">
		<div id="sideMain">
			<div id="loginFrame">
			<form id="form1" method="post" action="?action=check">
			<input id="flag" name="flag" type="hidden" value="center">
			<ul>
			<li>
			<div class="f1">用户名</div>
			<div class="f2"><input type="text" class="text" maxlength="16" name="u_name" id="u_name" /></div>
			</li>
			<li>
			<div class="f1">密　码</div>
			<div class="f2"><input type="password" class="text" maxlength="16" name="u_password" id="u_password" /></div>
			</li>
			<li class="remember">
			<div class="f2"><span class=""><label><input name="remember" type="checkbox" value="1" class="checkbox" /> 记住我</label></span> <a href="?action=findpass">找回密码</a> </div>
			</li>
			    </ul>
			    <div class="login"><input type="image" id="btnLogin" src="../images/user/btn_login.gif" width="88" height="39" /></div>
			</form>
    		</div>
	</div>
	<div id="sideSub">
		<div class="subNotice02">
		<p>注册通行证可享会员服务</p>
		<p>收费影片</p>
		<p>会员影片</p>
		<p>特殊影片</p>
		<p>让您看片、交友、互动，一个都不少。</p>
		</div>
		<div class="toReg">
			<a href="?action=reg" title="还没有通行证？立即注册 &raquo;"><img src="../images/user/toreg.png" width="210" height="21" alt="还没有通行证？立即注册 &raquo;" /></a>
		</div>
	</div>
	<div class="clear"></div>
	</div>
	</div>
	<div id="footer">
	<div class="link_bk">&copy; 2008-2013 <a href="http://www.maccms.com/" target="_blank">MACCMS</a> Inc. Powered by 苹果电影程序</div>
	</div>
</div>
</div>
<%
end sub

sub wel
	dim rs
	set rs = objdb.db("SELECT u_id, u_name, u_qq, u_email,u_regtime,u_status,u_points,u_tj, u_loginnum, u_logintime,u_ip,u_random,u_flag,u_start,u_end,ug_id,u_group,ug_name,ug_type,ug_popedom,ug_popvalue FROM ({pre}user LEFT OUTER JOIN {pre}user_group ON {pre}user.u_group = {pre}user_group.ug_id) where u_id="&session("userid")&"" ,"rs1")
%>
<script type="text/javascript" src="../js/function.js"></script>
<script>
$(document).ready(function(){
});
</script>
<div class="user_right_box">
		<div class="user_right_top_tit_bg">
		  <h1>个人资料</h1>
		</div>
		<form id="form1" name="form1" method="post" action="" >
			<table width="100%" border="0" cellpadding="4" cellspacing="0" style="margin-top:20px; margin-bottom:20px;" >
			<tr>
		        <td width="150" height="30" align="right">用户名：</td>
		        <td> <%=rs("u_name")%> </td>
		    </tr>
		    <tr>
		        <td width="150" height="30" align="right">所属会员组：</td>
		        <td> <%=rs("ug_name")%> </td>
		    </tr>
		    <tr>
		        <td width="150" height="30" align="right">计费类型：</td>
		        <td> <%=getUserFlag(rs("u_flag"))%> </td>
		    </tr>
		    <tr>
		        <td width="150" height="30" align="right">限制时长：</td>
		        <td> 从 <%=rs("u_start")%> 到 <%=rs("u_end")%> </td>
		    </tr>
		    <tr>
		        <td width="150" height="30" align="right">QQ号码：</td>
		        <td> <%=rs("u_qq")%> </td>
		    </tr>
		    <tr>
		        <td width="150" height="30" align="right">Email地址：</td>
		        <td> <%=rs("u_email")%> </td>
		    </tr>
		    <tr>
		        <td width="150" height="30" align="right">注册时间：</td>
		        <td> <%=rs("u_regtime")%> </td>
		    </tr>
		    <tr>
		        <td width="150" height="30" align="right">上次登录IP：</td>
		        <td> <%=rs("u_ip")%> </td>
		    </tr>
		    <tr>
		        <td width="150" height="30" align="right">上次登录时间：</td>
		        <td> <%=rs("u_logintime")%> </td>
		    </tr>
		    <tr>
		        <td width="150" height="30" align="right">账户积分：</td>
		        <td> <%=rs("u_points")%> </td>
		    </tr>
		    <tr>
		        <td width="150" height="30" align="right">登录次数：</td>
		        <td> <%=rs("u_loginnum")%> </td>
		    </tr>
		    <tr>
		        <td width="150" height="30" align="right">推广次数：</td>
		        <td> <%=rs("u_tj")%> </td>
		    </tr>
		    <tr>
		        <td width="150" height="30" align="right">推广链接：</td>
		        <td> <input id="page_url" name="page_url"  value="http://<%=app_siteurl%>/user/?action=tg&uid=<%=session("userid")%>" size="60" style="border: 1 solid #000000">&nbsp;
        <input type="button" name="Button" class="button1" value="复制推广连接" onClick="copyData(document.getElementById('page_url').value);"> </td>
		    </tr>
		    </table>
		</form>
</div>
<%
	objdb.c(rs)
end sub

sub info
	dim rs
	set rs = objdb.db("SELECT u_id, u_name, u_qq, u_email,u_regtime,u_status,u_points,u_tj, u_loginnum, u_logintime,u_ip,u_random,u_flag,u_start,u_end,ug_id,u_group,ug_name,ug_type,ug_popedom,ug_popvalue FROM ({pre}user LEFT OUTER JOIN {pre}user_group ON {pre}user.u_group = {pre}user_group.ug_id) where u_id="&session("userid")&"" ,"rs1")
%>
<div class="user_right_box">
		<div class="user_right_top_tit_bg">
		  <h1>个人资料</h1>
		</div>
		<form id="form1" name="form1" method="post" action="?action=save" >
		<table width="100%" border="0" cellpadding="4" cellspacing="0" style="margin-top:20px; margin-bottom:20px;" >
			<tr>
			<td width="150" height="30" align="right">用户名：</td>
			<td><%=rs("u_name")%>
			</td>
			</tr>
			<tr>
			<td width="150" height="30" align="right">旧密码：</td>
			<td><input id="u_oldpass" size=20 value="" name="u_oldpass">
			</td>
			</tr>
			<tr>
			<td width="150" height="30" align="right">用户密码：</td>
			<td><input id="u_password1" size=20 value="" name="u_password1"> &nbsp;不修改请留空
			</td>
			</tr>
			<tr>
			<td width="150" height="30" align="right">确认密码：</td>
			<td><input id="u_password2" size=20 value="" name="u_password2" >
			</td>
			</tr>
			<tr>
			<td width="150" height="30" align="right">QQ号码：</td>
			<td>
			<input id="u_qq" size="20" value="<%=rs("u_qq")%>" name="u_qq" >
			</td>
			</tr>
			<tr>
			<td width="150" height="30" align="right">邮件地址：</td>
			<td><input id="u_email" size="20" value="<%=rs("u_email")%>" name="u_email" >
			</td>
			</tr>
		    <tr align="center">
		      <td colspan="2"><input class="input" type="submit" value="保存" id="btnSave"> <input class="input" type="button" value="返回" id="btnCancel"> </td>
		    </tr>
		</table>
		</form>
</div>
<%
objdb.c(rs)
end sub

sub popedom
%>
<div class="user_right_box">
		<div class="user_right_top_tit_bg">
		  <h1>我的权限</h1>
		</div>
<table width="100%" border="0" cellpadding="4" cellspacing="0" style="margin-top:20px; margin-bottom:20px;" >
<%
	dim rsp,i,sql
	i=0
	set rsp = objdb.db( "select t_id,t_name from {pre}vod_type" ,"rs1")
	do while not rsp.eof
		response.write  "<tr><td width=""150"" height=""30"" align=""right""> "& rsp("t_name") & "</td>"
		response.write "<td width=""400"">"
		response.write "浏览分类页 <img src='../images/icons/"
		if getUserPopedom( rsp("t_id"),"list") then response.write "ok.png" else response.write "cancel.png"
		response.write "' width=16 height=16 border=0 />      " 
		      	  
		response.write "浏览内容页 <img src='../images/icons/"
		if getUserPopedom( rsp("t_id"),"vod") then response.write "ok.png" else response.write "cancel.png"
		response.write "' width=16 height=16 border=0 />      " 
		      	  
		response.write "浏览播放页 <img src='../images/icons/"
		if getUserPopedom(rsp("t_id"),"play")  then response.write "ok.png" else response.write "cancel.png"
		response.write "' width=16 height=16 border=0 />      " 
		
		response.write "浏览下载页 <img src='../images/icons/"
		if getUserPopedom(rsp("t_id"),"down")  then response.write "ok.png" else response.write "cancel.png"
		response.write "' width=16 height=16 border=0 />      " 
		
		response.Write("</td></tr>")
		rsp.movenext
		i = i + 1
		loop
	objdb.c(rsp)
%>
</table>
</div>
<%
end sub

sub plays
%>
<script>
$(document).ready(function(){
	$("#btnDel").click(function(){
		if(confirm('确定要清空吗')){
			$("#form1").attr("action","index.asp?action=playsdel");
			$("#form1").submit();
		}
		else{return false}
	});
});
</script>
<div class="user_right_box">
	<div class="user_right_top_tit_bg">
	<h1>我的播放记录</h1>
	</div>
<form id="form1" name="form1" method="post">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="link_lan" id="list"  align="center">
<tr>
<td width="5%" height="26" class="us_list_title">&nbsp;</td>
<td class="us_list_title" >影片名称</td>
<td width="15%" class="us_list_title">影片分类</td>
<td width="15%" class="us_list_title">影片地址</td>
<td width="15%" class="us_list_title">消费积分</td>
</tr>
	<%
	if isN(u_plays) then
	%>
	<tr><td align="center" colspan="5">没有任何播放记录!</td></tr>
	<%
	else
		u_plays= "0"&u_plays
		If Right(u_plays, 1) = "," Then u_plays = Mid(u_plays, 1, Len(u_plays) - 1)
		Dim pagenum : pagenum = be("all","page")
		dim rs,rsr,typestr,rc,sql,i,t_name,t_enname,typearr,playarr,arr1
		
		if not isNum(pagenum) then pagenum = 1 else pagenum = cint(pagenum)
		if pagenum < 1 then pagenum = 1
		rc=false
		playarr = split(u_plays,",") : u_plays=""
		for i=0 to ubound(playarr)
			arr1 = split(playarr(i),"-")
			if ubound(arr1)=2 then
				if rc then u_plays = u_plays & ","
				u_plays = u_plays & arr1(0)
				rc=true
			end if
		next
		sql = "SELECT d_id,d_name,d_enname,d_type,d_stint,d_addtime FROM {pre}vod  where d_id in ("&u_plays&") order by d_addtime desc"
		Set rs = objdb.db(sql,"rs1")
		
		if not rs.eof then
			rs.PageSize = 30
		    rs.AbsolutePage = pagenum
		  	for i = 1 to rs.PageSize
		  		if rs.eof then exit for
		  		t_name= "未知"
				t_enname=""
		  		typearr = getValueByArray(cachevodtype, rs("d_type"))
	    		if isarray(typearr) then
	    			t_name= typearr(1)
					t_enname=typearr(2)
	    		end if
		  		%>
		  		<tr>
				<td> </td>
				<td><%=rs("d_name")%></td>
				<td><%=t_name%></td>
				<td><a target="_blank" href="<%=objTemplate.getVodLink(rs("d_id"),rs("d_name"),rs("d_enname"),rs("d_addtime"),rs("d_type"),t_name,t_enname)%>">浏览</a></td>
				<td><%=rs("d_stint")%></td>
				</tr>
		  		<%
				rs.movenext
		  	next
		  else
		  %>
		  <tr><td align="center" colspan="5">没有任何播放记录!</td></tr>
		  <%
	  	end if
	  	objdb.c(rs)
	end if
	%>
	<tr>
	<td colspan="5">
    <input type="button" id="btnDel" value="清空记录" class="input">
	</td>
	</tr>
	</table>
	</form>
	</div>
<%
end sub

sub downs
%>
<script>
$(document).ready(function(){
	$("#btnDel").click(function(){
		if(confirm('确定要清空记录吗')){
			$("#form1").attr("action","index.asp?action=downsdel");
			$("#form1").submit();
		}
		else{return false}
	});
});
</script>
<div class="user_right_box">
	<div class="user_right_top_tit_bg">
	<h1>我的播放记录</h1>
	</div>
<form id="form1" name="form1" method="post">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="link_lan" id="list"  align="center">
<tr>
<td width="5%" height="26" class="us_list_title">&nbsp;</td>
<td class="us_list_title" >影片名称</td>
<td width="15%" class="us_list_title">影片分类</td>
<td width="15%" class="us_list_title">影片地址</td>
<td width="15%" class="us_list_title">消费积分</td>
</tr>
	<%
	if isN(u_downs) then
	%>
	<tr><td align="center" colspan="5">没有任何下载记录!</td></tr>
	<%
	else
		u_downs= "0"&u_downs
		If Right(u_downs, 1) = "," Then u_downs = Mid(u_downs, 1, Len(u_downs) - 1)
		Dim pagenum : pagenum = be("all","page")
		dim rs,rsr,typestr,rc,sql,i,t_name,t_enname,typearr,playarr,arr1
		
		if not isNum(pagenum) then pagenum = 1 else pagenum = cint(pagenum)
		if pagenum < 1 then pagenum = 1
		rc=false
		playarr = split(u_downs,",") : u_downs=""
		for i=0 to ubound(playarr)
			arr1 = split(playarr(i),"-")
			if ubound(arr1)=2 then
				if rc then u_downs = u_downs & ","
				u_downs = u_downs & arr1(0)
				rc=true
			end if
		next
		sql = "SELECT d_id,d_name,d_enname,d_type,d_stintdown,d_addtime FROM {pre}vod  where d_id in ("&u_downs&") order by d_addtime desc"
		Set rs = objdb.db(sql,"rs1")
		
		if not rs.eof then
			rs.PageSize = 30
		    rs.AbsolutePage = pagenum
		  	for i = 1 to rs.PageSize
		  		if rs.eof then exit for
		  		t_name= "未知"
				t_enname=""
		  		typearr = getValueByArray(cachevodtype, rs("d_type"))
	    		if isarray(typearr) then
	    			t_name= typearr(1)
					t_enname=typearr(2)
	    		end if
		  		%>
		  		<tr>
				<td> </td>
				<td><%=rs("d_name")%></td>
				<td><%=t_name%></td>
				<td><a target="_blank" href="<%=objTemplate.getVodLink(rs("d_id"),rs("d_name"),rs("d_enname"),rs("d_addtime"),rs("d_type"),t_name,t_enname)%>">浏览</a></td>
				<td><%=rs("d_stintdown")%></td>
				</tr>
		  		<%
				rs.movenext
		  	next
		  else
		  %>
		  <tr><td align="center" colspan="5">没有任何下载记录!</td></tr>
		  <%
	  	end if
	  	objdb.c(rs)
	end if
	%>
	<tr>
	<td colspan="5"> 
    <input type="button" id="btnDel" value="清空记录" class="input">
	</td>
	</tr>
	</table>
	</form>
	</div>
<%
end sub

sub fav
%>
<script>
$(document).ready(function(){
	$("#btnDel").click(function(){
		if(confirm('确定要删除吗')){
		$("#form1").attr("action","index.asp?action=favdel");
		$("#form1").submit();
		}
		else{return false}
	});
});
</script>
<div class="user_right_box">
	<div class="user_right_top_tit_bg">
	<h1>我的收藏记录</h1>
	</div>
	<form id="form1" name="form1" method="post">
	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="link_lan" id="list"  align="center">
	<tr>
	<td width="5%" height="26" class="us_list_title">&nbsp;</td>
	<td class="us_list_title" >影片名称</td>
	<td width="15%" class="us_list_title">影片分类</td>
	<td width="15%" class="us_list_title">影片地址</td>
	<td width="15%" class="us_list_title">消费积分</td>
	</tr>
	<%
	if isN(u_fav) then
	%>
	<tr><td align="center" colspan="5">没有任何收藏记录!</td></tr>
	<%
	else
		u_fav= "0"&u_fav
		If Right(u_fav, 1) = "," Then u_fav = Mid(u_fav, 1, Len(u_fav) - 1)
		Dim pagenum : pagenum = be("all","page")
		if not isNum(pagenum) then pagenum = 1 else pagenum = cint(pagenum)
		if pagenum < 1 then pagenum = 1
		
		dim rs,rsr,typestr,rc,sql,i,t_name,t_enname
		
		sql = "SELECT d_id,d_name,d_enname,d_type,d_stint,d_addtime FROM {pre}vod  where d_id in ("&u_fav&") order by d_addtime desc"
		Set rs = objdb.db(sql,"rs1")
		if not rs.eof then
			rs.PageSize = 30
		    rs.AbsolutePage = pagenum
		  	for i = 1 to rs.PageSize
		  		if rs.eof then exit for
		  		t_name= "未知"
				t_enname=""
		  		typearr = getValueByArray(cachevodtype, rs("d_type"))
	    		if isarray(typearr) then
	    			t_name= typearr(1)
					t_enname=typearr(2)
	    		end if
		  		%>
		  		<tr>
				<td><input name="d_id" type="checkbox" id="d_id" value="<%=rs("d_id")%>"></td>
				<td><%=rs("d_name")%></td>
				<td><%=t_name%></td>
				<td><a target="_blank" href="<%=objTemplate.getVodLink(rs("d_id"),rs("d_name"),rs("d_enname"),rs("d_addtime"),rs("d_type"),t_name,t_enname)%>">浏览</a></td>
				<td><%=rs("d_stint")%></td>
				</tr>
		  		<%
				rs.movenext
		  	next
		  else
		  %>
		  <tr><td align="center" colspan="5">没有任何收藏记录!</td></tr>
		  <%
		  end if
	  	objdb.c(rs)
	end if
	
	%>
	<tr>
	<td colspan="5">
	全选<input name="chkall" type="checkbox" id="chkall" value="1" onClick="checkAll(this.checked,'d_id');"/>&nbsp;
    <input type="button" id="btnDel" value="批量删除" class="input">
	</td>
	</tr>
	</table>
	</form>
	<%
end sub

sub upgrade
	dim rs
	set rs = objdb.db("SELECT u_id, u_name, u_qq, u_email,u_regtime,u_status,u_points,u_tj, u_loginnum, u_logintime,u_ip,u_random,u_flag,u_start,u_end,ug_id,u_group,ug_name,ug_type,ug_popedom,ug_popvalue FROM ({pre}user LEFT OUTER JOIN {pre}user_group ON {pre}user.u_group = {pre}user_group.ug_id) where u_id="&session("userid")&"" ,"rs1")
%>
<div class="user_right_box">
	<div class="user_right_top_tit_bg"><h1>升级会员组</h1></div>
	<form action="?action=upgradesave" method="post" name="form3" id="form3">
	<table width="100%" border="0" cellpadding="4" cellspacing="0" style="margin-top:20px; margin-bottom:20px;" >
		<tr>
		<td width="150" height="30" align="right">当前会员组：</td>
		<td> <%=rs("ug_name")%>
		</td>
		</tr>
		<tr>
		<td width="150" height="30" align="right">目标会员组：</td>
		<td><select id="u_group" name="u_group">
			<option value="">全部会员组</option>
            <%
            dim rsug
			set rsug = objdb.DB("select ug_id,ug_name,ug_upgrade,ug_popvalue FROM {pre}user_group","rs1")
			do while not rsug.eof
				response.write   "<option value='"&rsug("ug_id")&"_"&rsug("ug_upgrade")&"_"&rsug("ug_popvalue")&"'>&nbsp;|—"&rsug("ug_name")&"("&rsug("ug_upgrade")&"积分)</option>"
				rsug.movenext
			loop
			objdb.c(rsug)
            %>
            </select>
		</td>
		</tr>
	    <tr align="center">
	      <td colspan="2"><input class="input" type="submit" value="升级" id="btnSave"> <input class="input" type="button" value="返回" id="btnCancel1"> </td>
	    </tr>
	</table>
	</form>
	<div class="user_right_top_tit_bg"><h1>包时长</h1></div>
	<form action="?action=upgradesave2" method="post" name="form3" id="form3">
	<table width="100%" border="0" cellpadding="4" cellspacing="0" style="margin-top:20px; margin-bottom:20px;" >
		<tr>
		<td width="150" height="30" align="right">
			当前计费类型：<%=getUserFlag(rs("u_flag"))%> 
		</td>
		<td>
		<%
			if rs("u_flag")=1 then
				writeA "&nbsp;&nbsp;时间从：&nbsp;&nbsp;从" & rs("u_start") & "到" & rs("u_end")
			end if
		%>
		</td>
		</tr>
		<tr>
		<td width="150" height="30" align="right">所需时长：</td>
		<td><select id="baoshi" name="baoshi">
			<option value="1">包周会员</option>
            <option value="2">包月会员</option>
            <option value="3">包年会员</option>
            </select>
		</td>
		</tr>
	    <tr align="center">
	      <td colspan="2"><input class="input" type="submit" value="升级" id="btnSave"> <input class="input" type="button" value="返回" id="btnCancel1"> </td>
	    </tr>
	</table>
	</form>
</div>
<%
objdb.c(rs)
end sub

sub pay
%>
<div class="user_right_box">
		<div class="user_right_top_tit_bg">
		  <h1>在线充值</h1>
		</div>
	<form action="?action=paysave" method="post" name="form4" id="form4">
	<table width="100%" border="0" cellpadding="4" cellspacing="0" style="margin-top:20px; margin-bottom:20px;" >
		<tr>
		<td width="150" height="30" align="right">充值卡号码：</td>
		<td><input id="cardnum" size="20" value="" name="cardnum" ></td>
		</tr>
		<tr>
		<td width="150" height="30" align="right">充值卡密码：</td>
		<td><input id="cardpwd" size="20" value="" name="cardpwd" ></td>
		</tr>
	    <tr align="center">
	      <td colspan="2"><input class="input" type="submit" value="确认" id="btnSave"> <input class="input" type="button" value="返回" id="btnCancel2"> </td>
	    </tr>
	</table>
	</form>
</div>
<%
end sub

sub paysave
	dim cardnum : cardnum = be("post","cardnum") : cardnum=chkSql(cardnum,true)
	dim cardpwd : cardpwd = be("post","cardpwd") : cardpwd=chkSql(cardpwd,true)
	if isN(cardnum) then alert "卡号不能为空！" : exit sub
	if isN(cardpwd) then alert "卡号密码不能为空" : exit sub
	dim c_id,c_point,rs
	dim sql : sql = "SELECT * FROM {pre}user_card WHERE c_number='"&cardnum&"'and c_pass='"&cardpwd&"'"
    set rs = objdb.db(sql,"rs1")
	If Rs.BOF And Rs.EOF Then 
		alert "该充值卡不存在或者卡号密码错了" : exit sub
	Else
		If Rs("c_used")=1 Then
		   alert "此卡已经充值，请不要重复使用此卡" : exit sub
		End If
		'If DateDiff("D", CDate(Rs("c_endtime")), Now()) > 0 Then
	'		alert "对不起！您的充值卡已到期，不能充值；如果你要购买充值卡请联系管理员": exit sub
	'	End If
		c_id = Rs("c_id")
		c_point = Rs("c_point")
	End If
	objdb.c(rs)
	
	sql = "SELECT * FROM {pre}user WHERE u_id=" & session("userid") & ""
	set rs = objdb.db(sql,"rs1")
	If Rs.BOF And Rs.EOF Then
		alert "获取会员信息出错,充值失败" : exit sub
	Else
		objdb.db "update {pre}user set u_points=u_points+"&c_point&" where u_id = "& session("userid") ,"exe"
	End If
	objdb.c(rs)
	objdb.db "update {pre}user_card set c_used=1,c_user="&session("userid")&",c_sale=1,c_usetime='"&now()&"' where c_id = "& c_id,"exe"
	alert "充值成功"
end sub


sub pay2
	dim url,OrdId
	url = "http://" & getBody(geturl(),"http://","user/") & "/user/"
	OrdId = getDate("yyyymmddhhiiss",now)
%>
<script language="javascript">
$(document).ready(function(){
	$("#form5").validate({
		rules:{
			OrdAmt:{
				required:true,
				number:true,
				min:<%=app_buymin%>
			}
		}
	});
});
</script>
<div class="user_right_box" style="width:500px;margin:80px auto;">
	<div class="user_right_top_tit_bg"><h1>在线充值</h1></div>
	<form action="http://pay.yinshengvip.com/pay/" method="post" name="form5" id="form5">
	<table width="100%" border="0" cellpadding="4" cellspacing="0" style="margin-top:20px; margin-bottom:20px;" >
		<tr>
		<td width="150" height="30" align="right">充值金额：</td>
		<td><input type="text" name="OrdAmt" value="<%=app_buymin%>" size="22" maxlength="12"></td>
		</tr>
		<tr>
		<td width="150" height="30" align="right">提示信息：</td>
		<td> 最小充值金额为<%=app_buymin%>元，1元可以兑换<%=app_buyexc%>个积分
		</td>
		</tr>
	    <tr align="center">
	      <td colspan="2"><input class="input" type="submit" value="确认" id="btnSave">  </td>
	    </tr>
	</table>
		
		<input type="hidden" name="merchant_idcode" value="ksyitnnoudo6oght" size="40" maxlength="40">
		<input type="hidden" name="OrdId" value="<%=OrdId%>" size="22" maxlength="20">
		<input type="hidden" name="Pid" value="10000" size="6" maxlength="10">
		<input type="hidden" name="RetUrl" value="<%=url%>buy_return_url.asp" size="60" maxlength="60">
		<input type="hidden" name="BgRetUrl" value="<%=url%>buy_notify_url.asp" size="60" maxlength="260">
		<input type="hidden" name="MerPriv" value="" size="60" maxlength="60">
		<input type="hidden" name="UsrMp" value="" size="15" maxlength="11">
		<input type="hidden" name="partnerID" value="<%=app_buyid%>" size="40" maxlength="40">
		<input type="hidden" name="keyID" value="<%=app_buykey%>" size="40" maxlength="40">
		
	</form>
</div>
<%
end sub

sub paysave2

end sub
%>