<%
' +----------------------------------------------------------------------
' | KCMS [ 启点在线网站管理系统 ]
' | Copyright (c) 2018 http://www.kelvinvt.com All rights reserved.
' | Licensed ( http://www.kelvinvt.com )
' | Author: kelvinvt <kelvinvt@qq.com>
' +----------------------------------------------------------------------
	dim UID,U_GID,U_LID,U_OnOff,U_order,sex,username,Password,newPassword,rePassword,Question,Answer,RegTime,TrueName,face,Province,City,District,Address,Post,tel,Mobile,Email,QQ,U_Desc,Adminrand,LastLoginTime,LastLoginIP,LoginCount,sysinfo,points,balance,G_Name,G_discount,G_Mark,Birthday,Age,Recommender
	Function getuser(UID)		
		if isnul(uid) then aspgo iif(iswap,sitepath&"wap/user/"&actmark&"login",sitepath&"user/"&actmark&"login")
		dim rs
		set rs=dbsql("select UID,U_GID,U_LID,U_OnOff,U_order,sex,username,Password,Question,Answer,RegTime,TrueName,face,Province,City,District,Address,Post,tel,Mobile,Email,QQ,U_Desc,Adminrand,LastLoginTime,LastLoginIP,LoginCount,sysinfo,points,balance,G_Name,G_Mark from [dbpre]user,[dbpre]User_Group where U_OnOff=1 and gid=U_gid and UID="&UID)
		if not rs.eof then
		UID=rs(0)
		U_GID=rs(1)
		U_LID=rs(2)
		U_OnOff=rs(3)
		U_order=rs(4)
		sex=isnum(rs(5))
		username=repnul(rs(6))
		Password=rs(7)
		Question=repnul(rs(8))
		Answer=repnul(rs(9))
		RegTime=repnul(rs(10))
		TrueName=repnul(rs(11))
		face=repnul(rs(12))
		if isnul(face) then face="noface.png"
		Province=repnul(rs(13))
		City=repnul(rs(14))
		District=repnul(rs(15))
		Address=repnul(rs(16))
		Post=repnul(rs(17))
		tel=repnul(rs(18))
		Mobile=repnul(rs(19))
		Email=repnul(rs(20))
		QQ=repnul(rs(21))
		U_Desc=repnul(rs(22))
		Adminrand=rs(23)
		LastLoginTime=repnul(rs(24))
		LastLoginIP=repnul(rs(25))
		LoginCount=isnum(rs(26))
		sysinfo=repnul(rs(27))
		points=repnul(rs(28))
		balance=repnul(rs(29))
		G_Name=repnul(rs(30))
		G_Mark=repnul(rs(31))
		end if
	End Function	
		
	Function Run_usering()	
		dim logintype:logintype=getform("type","both") 
		Call zhl.Template_Int()				
		if userMark=0 then goto404 str_usercenter&str_noreg
		dim defaultTemp:defaultTemp= iif(iswap,sitepath&"template/wap/"&zset.WapTemplate&zset.WaphtmlPath&"user.html",sitepath&"template/pc/"&zset.PcTemplate&zset.PchtmlPath&"user.html")		
		dim userTemp:userTemp=  iif(iswap,sitepath&"template/wap/"&zset.WapTemplate&zset.WaphtmlPath&act&".html",sitepath&"template/pc/"&zset.PcTemplate&zset.PchtmlPath&act&".html")		
		if not isfile(userTemp) then			
				if isnul(logintype) then			
					zhl.TempFile   =	defaultTemp
					call zhl.LoadParse()	
				else
					zhl.ZContent="{cms:user}"
				end if	
			select case act				
				case "login"	:	call loginhtml(zhl.ZContent)			
				case "reg"		:	call reghtml(zhl.ZContent)
				case "forget"	:	call forgethtml(zhl.ZContent)		
			end select
			call zhl.ParseGlobal()	'底层基础
		else
			call zhl.LoadParse()
			zhl.ZContent=replacestr(zhl.ZContent,"[login:type]",logintype)
		end if		
		call zhl.LoadlistParse	
		zhl.show()		
   end Function
   
	Function Run_user()	
	 	Call zhl.Template_Int()
		dim defaultTemp:defaultTemp= iif(iswap,sitepath&"template/wap/"&zset.WapTemplate&zset.WaphtmlPath&"user.html",sitepath&"template/pc/"&zset.PcTemplate&zset.PchtmlPath&"user.html")		
		dim userTemp
		if isnul(act) then
			userTemp= iif(iswap=1,sitepath&"template/wap/"&zset.WapTemplate&zset.WaphtmlPath&"userinfo.html",sitepath&"template/pc/"&zset.PcTemplate&zset.PchtmlPath&"userinfo.html")		
		else
			userTemp= iif(iswap=1,sitepath&"template/wap/"&zset.WapTemplate&zset.WaphtmlPath&act&".html",sitepath&"template/pc/"&zset.PcTemplate&zset.PchtmlPath&act&".html")
		end if
		if isfile(userTemp) then 
			zhl.TempFile=userTemp
		else
			zhl.TempFile=defaultTemp
		end if
		call zhl.LoadParse()
		getuser(getsession("uid"))		
		zhl.ZContent = replaceStr(zhl.ZContent,"{cms:sitetitle]",zset.siteTitle)
		zhl.ZContent = replaceStr(zhl.ZContent,"{cms:sitepath}",sitepath)
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:uid]",getsession("uid"))		
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:name]",username)
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:truename]",truename)
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:face]",face)
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:sex]",iif(sex=0,str_nan,str_nv))
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:regTime]",RegTime)
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:province]",Province)
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:city]",City)
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:district]",District)
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:address]",Address)
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:post]",Post)
		if ifstrin(tel,",") then
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:telcode]",split(tel,",")(0))
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:tel]",split(tel,",")(1))
		else
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:telcode]","")
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:tel]",tel)
		end if
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:mobile]",Mobile)
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:qq]",QQ)
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:email]",Email)		
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:desc]",U_Desc)
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:question]",Question)
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:answer]",Answer)
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:LastLoginTime]",LastLoginTime)
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:LastLoginIP]",LastLoginIP)
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:LoginCount]",LoginCount)
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:sysinfo]",sysinfo)
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:points]",points)
        zhl.ZContent = replaceStr(zhl.ZContent,"[user:balance]",balance) 
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:gname]",G_Name)
		zhl.ZContent = replaceStr(zhl.ZContent,"[user:discount]",isnum(G_Mark)/10)
		call zhl.LoadlistParse		  
		zhl.show()
	End Function
	
	Function saveface()
	dim logintype:logintype=getform("type","both") 
		face=getForm("face","post")
		uid=getsession("uid")
		if isnul(uid) then alertgo str_nologin,""&actmark&"login"
		dbsql "update [dbpre]user set face='"&face&"' where UID="&uid	
		setcookie "userface",face
		if logintype="open" then layertrue str_xiugai&str_chenggong else aspgo sitepath&"user"
	End Function

	Function editface	
	if isnul(getsession("uid")) then aspgo sitepath&"user/?act=login&type=open"
	dim path,fileListArray,i,fileAttr,folderListArray,folderAttr,parentPath
	dim logintype:logintype=getform("type","both") 
	path=sitePath&"images/face/"
	if not isfolder(path) then	
		response.end
	end if
	fileListArray= getFileList(path)
	if instr(fileListArray(0),",")>0 then	
		echo "<link rel='stylesheet' type='text/css' href='"&sitepath&"css/bootstrap.min.css'/>"
		echo"<body><form method='post' action='?act=saveface&type="&logintype&"'> <div class='container'><div class='row'>"
		for  i = 0 to ubound(fileListArray)
			dim selectedstr:selectedstr=""
			fileAttr=split(fileListArray(i),",")
			if face=fileAttr(0) then selectedstr="checked"			
			
			echo "<div class='col-sm-2'><label><img src="""&path&fileAttr(0)&"""><br>"&vbcrlf&_
			 "<input type='radio' name='face' value='"&fileAttr(0)&"'  "&selectedstr&">"&str_select&str_face&"</label></div>"&vbcrlf		
		next
		echo " </div><button class='btn btn-primary' type='submit'>"&str_baocun&str_face&"</button> <a href='"&sitepath&"user' class='btn btn-primary'>"&str_back&"</a></form> </div></body>"
	end if	
	End Function
	
	Function showaddress()
	dim rs,sql
	Province=getForm("Province","post")	
	city=getForm("city","post")	
	if not isnul(Province) then
	  sql="select rid,title,entitle,Zipcode,telCode from [dbpre]region where OnOff=1 and depth=2 and pid="&Province&" order by R_order asc,id asc"
	elseif  not isnul(city) then
	  sql="select rid,title,entitle,Zipcode,telCode from [dbpre]region where OnOff=1 and depth=3 and pid="&city&" order by R_order asc,id asc"
	else
	  sql="select rid,title,entitle,Zipcode,telCode from [dbpre]region where OnOff=1 and depth=1 order by R_order asc,id asc"
	end if
	set rs=dbsql(sql)
		echo"<option value=''  ids=''>请选择</option>"
		do while not rs.eof					  				
		 echo"<option value="&rs("title")&"  ids='"&rs("rid")&"' encode='"&rs("entitle")&"' telcode='"&rs("telcode")&"' zipcode='"&rs("zipcode")&"'>"&rs("title")&"</option>"
		rs.movenext
		loop
	closers rs 	
	End Function
	

sub loginhtml(zcontent)
	dim htmlstr,logintype
	logintype=getform("type","both") 
	dim userTemp:userTemp= iif(iswap=1,sitepath &"template/wap/"& zset.WapTemplate&zset.WaphtmlPath&"userlogin.html",sitepath &"template/pc/"&zset.PcTemplate&zset.PchtmlPath&"userlogin.html")		
	if isfile(userTemp) then 
		htmlstr=loadfile(userTemp)			
		htmlstr=replacestr(htmlstr,"[login:type]",logintype)
	else
		if not isnul(logintype) then logintype="&type="&logintype : actmark="?act="
		htmlstr="<script src='"&sitepath&"js/jquery.min.js' type='text/javascript'></script>"&vbcrlf& _	
		"<link href='"&sitepath&"plugins/Validform/Validform.css' rel='stylesheet'/>"&vbcrlf& _	
		"<link href='"&sitepath&"plugins/user/user.css' rel='stylesheet'/>"&vbcrlf& _	
		"<script src='"&sitepath&"plugins/Validform/Validform.min.js'></script>"&vbcrlf& _	
		"<script type='text/javascript'>$(function(){$("".registerform"").Validform({ tiptype:function(msg,o,cssctl){ if(!o.obj.is(""form"")){ var objtip=o.obj.siblings("".Validform_checktip""); cssctl(objtip,o.type); objtip.text(msg); } } });})</script>"&vbcrlf& _	
		"<div class='register'><div class='leftregister'><div class='registerbutton'><h3>"&str_no&str_loginname&"？</h3>"&vbcrlf& _	
		"<a href='"&actmark&"reg"&logintype&"' class='nowreg'>"&str_reg&str_loginname&"</a><h3>"&str_forget&"？</h3><a a href='"&actmark&"forget"&logintype&"' class='nowforget'>"&str_forget&"</a></div></div><div class='rightregister'><h2>"&str_user&str_login&"</h2>"&vbcrlf& _	
		"<form class='registerform' method='post' action='"&actmark&"logining"&logintype&"'>"&vbcrlf& _	
		"<div class='formsub'><ul>"&vbcrlf& _	
		"<li><label><span class='need'>*</span> "&str_loginname&"：</label><input type='text' value='' name='username' placeholder='"&str_loginname&"/"&str_mobile&"' class='inputxt' datatype='*5-18' nullmsg='"&str_isinput&str_loginname&"' errormsg='"&str_loginname&str_fanwei&"5~18' /><div class='Validform_checktip'>"&str_loginname&str_fanwei&"5~18</div></li>"&vbcrlf& _	
		"<li><label><span class='need'>*</span> "&str_password&"：</label><input type='password' value='' name='Password' class='inputxt' datatype='*5-16' nullmsg='"&str_isinput&str_password&"' errormsg='"&str_password&str_fanwei&str_fanwei&"5~16' /><div class='Validform_checktip'>"&str_password&str_fanwei&"5~16</div></li>"&vbcrlf& _	
		"<li><label><span class='need'>*</span> "&str_code&"：</label><input type='text' value='' name='code' id='imgcode' class='inputxt'  ajaxurl='../plugins/sms/sms.asp?act=checkcode' datatype='*4-4' nullmsg='"&str_isinput&str_code&"' errormsg='"&str_code&str_cuowu&"' /><div class='imgcode' style='display:none'><img src='../inc/imgcode.asp' id='SeedImg' align='absmiddle' style='cursor:pointer;' border='0'  onClick=""this.src+='?'+Math.random();""/><script>$(""#imgcode"").focus(function (){$(""#SeedImg"").click();$("".imgcode"").show()});</script></div>"&vbcrlf& _	
		"<div class='Validform_checktip'>"&str_isinput&str_code&"</div></li>"&vbcrlf& _
		"</ul><div class='action'><input type='submit' value='"&str_tijiao&"' /><input type='reset' value='"&str_chongzhi&"' /></div></div></form></div></div>"&vbcrlf
	end if
	zhl.ZContent = replaceStr(ZContent,"{cms:user}",htmlstr)
End sub
	
sub reghtml(zcontent)
	dim htmlstr,logintype,codestr
	logintype=getform("type","both") 
	dim userTemp:userTemp= iif(iswap=1,sitepath &"template/wap/"& zset.WapTemplate&zset.WaphtmlPath&"userreg.html",sitepath &"template/pc/"&zset.PcTemplate&zset.PchtmlPath&"userreg.html")		
	if isfile(userTemp) then 
		htmlstr=loadfile(userTemp)
		htmlstr=replacestr(htmlstr,"[login:type]",logintype)
	else
	if not isnul(logintype) then logintype="&type="&logintype : actmark="?act="
	if ischeckemail=1 then
		codestr="<li><label><span class='need'>*</span> "&str_email&"：</label><input type='text' value='' name='email' id='email' class='inputxt' datatype='e' errormsg='"&str_email&str_nogeshi&"' /><div class='Validform_checktip'>"&str_isinput&str_email&"</div></li>"
	else
		codestr=""
	end if		
	if smsmark=1 and regsendsms=1 then
		codestr=codestr&"<script src='"&sitepath&"plugins/sms/sms.js' type='text/javascript'></script>"&vbcrlf& _	
	"<li><label><span class='need'>*</span> "&str_code&"：</label><input type='text' value='' name='smscode' id='imgcode' class='inputxt' datatype='n4-4'  ajaxurl='../plugins/sms/sms.asp?act=checkcode' nullmsg='"&str_isinput&str_duanxin&str_code&"' errormsg='"&str_code&str_cuowu&"' /><input id='sedcond' value='"&str_get&str_code&"' type='button'><div class='Validform_checktip'>"&str_click&str_get&str_duanxin&str_code&"</div></li>"
	elseif usercode=1 then 
		codestr=codestr&"<li><label><span class='need'>*</span> "&str_code&"：</label><input type='text' value='' name='code' id='imgcode' class='inputxt' ajaxurl='../plugins/sms/sms.asp?act=checkcode' datatype='*4-4' nullmsg='"&str_isinput&str_code&"' errormsg='"&str_code&str_cuowu&"' /><div class='imgcode' style='display:none'><img src='../inc/imgcode.asp' id='SeedImg' align='absmiddle' style='cursor:pointer;' border='0' onClick=""this.src+='?'+Math.random();""/><script>$(""#imgcode"").focus(function (){$(""#SeedImg"").click();$("".imgcode"").show()});</script></div><div class='Validform_checktip'>"&str_isinput&str_code&"</div></li>"		
	end if
	
	htmlstr="<script src='"&sitepath&"js/jquery.min.js' type='text/javascript'></script>"&vbcrlf& _	
	"<link href='"&sitepath&"plugins/Validform/Validform.css' rel='stylesheet'/><link href='"&sitepath&"plugins/user/user.css' rel='stylesheet'/>"&vbcrlf& _	
	"<script src='"&sitepath&"plugins/Validform/Validform.min.js'></script><script type='text/javascript'>$(function(){$("".registerform"").Validform({ tiptype:function(msg,o,cssctl){ if(!o.obj.is(""form"")){ var objtip=o.obj.siblings("".Validform_checktip""); cssctl(objtip,o.type); objtip.text(msg); } } });})</script>"&vbcrlf& _	
	"<div class='register'><div class='leftregister'><div class='registerbutton'><h3>"&str_have&str_loginname&"？</h3><a href='"&sitepath&"user/"&actmark&"login"&logintype&"'' class='nowreg'>立即"&str_login&"</a><h3>"&str_forget&"？</h3><a href='"&sitepath&"user/"&actmark&"forget"&logintype&"'' class='nowforget'>"&str_forget&"</a></div></div>"&vbcrlf& _	
	"<div class='rightregister'><h2>"&str_user&str_reg&"</h2><form class='registerform' method='post' action='"&sitepath&"user/"&actmark&"reging"&logintype&"'><div class='formsub'><ul>"&vbcrlf& _	
	"<li><label><span class='need'>*</span> "&str_loginname&"：</label><input type='text' value='' name='username' class='inputxt' datatype='*5-18' nullmsg='"&str_isinput&str_loginname&"'  ajaxurl='../plugins/sms/sms.asp?act=checkusername'  errormsg='"&str_loginname&str_fanwei&"5~18' /><div class='Validform_checktip'>"&str_loginname&str_fanwei&"5~18</div></li>"&vbcrlf& _	
	"<li><label><span class='need'>*</span> "&str_password&"：</label><input type='password' value='' name='Password' class='inputxt' datatype='*5-16' nullmsg='"&str_isinput&str_password&"' errormsg='"&str_password&str_fanwei&str_fanwei&"5~16' /><div class='Validform_checktip'>"&str_password&str_fanwei&str_fanwei&"5~16</div></li>"&vbcrlf& _	
	"<li><label><span class='need'>*</span> "&str_mobile&"：</label><input type='text' value='' name='mobile' id='phonenum' class='inputxt' datatype='m' nullmsg='"&str_isinput&str_mobile&"' ajaxurl='../plugins/sms/sms.asp?act=checkmobile' errormsg='"&str_mobile&str_nogeshi&"' /><div class='Validform_checktip'>"&str_mobile&str_is&str_login&str_loginname&"</div></li>"&codestr&"</ul>"&vbcrlf& _	
	"<div class='action'><input type='submit' value='"&str_tijiao&"' /><input type='reset' value='"&str_chongzhi&"' /></div></div></form></div></div>"&vbcrlf
	end if
	zhl.ZContent = replaceStr(ZContent,"{cms:user}",htmlstr)
End sub

sub forgethtml(zcontent)
	dim htmlstr	,logintype,codestr,htwostr
	logintype=getform("type","both") 	
	dim userTemp:userTemp= iif(iswap=1,sitepath &"template/wap/"& zset.WapTemplate&zset.WaphtmlPath&"userforget.html",sitepath &"template/pc/"&zset.PcTemplate&zset.PchtmlPath&"userforget.html")		
	if isfile(userTemp) then 
		htmlstr=loadfile(userTemp)
		htmlstr=replacestr(htmlstr,"[login:type]",logintype)
	else
		if not isnul(logintype) then logintype="&type="&logintype : actmark="?act="
		if smsmark=1 and forgetsendsms=1 then
			codestr="<script src='../plugins/sms/sms.js' type='text/javascript'></script>"&vbcrlf& _	
			"<li><label><span class='need'>*</span> "&str_mobile&"：</label><input type='text' value='' name='mobile' id='phonenum' class='inputxt' datatype='m' ajaxurl='../plugins/sms/sms.asp?act=checkmobile&checktype=1' errormsg='"&str_mobile&str_nogeshi&"' /><div class='Validform_checktip'>"&str_mobile&"也可以作为"&str_login&str_loginname&"使用</div></li>"&vbcrlf& _	
			"<li><label><span class='need'>*</span> "&str_code&"：</label><input type='text' value='' name='smscode' id='imgcode' class='inputxt' datatype='n4-4'  ajaxurl='../plugins/sms/sms.asp?act=checkcode' nullmsg='"&str_isinput&str_duanxin&str_code&"' errormsg='"&str_code&str_cuowu&"' /><input id='sedcond' value='"&str_get&str_code&"' type='button'><div class='Validform_checktip'>"&str_click&str_get&str_duanxin&str_code&"</div></li>"&vbcrlf
			htwostr=""&str_duanxin&str_login&""
		elseif usercode=1 then 
			codestr="<li><label><span class='need'>*</span> "&str_wenti&"：</label><input type='text' value='' name='Question' class='inputxt' datatype='*' errormsg='"&str_iskong&"' /><div class='Validform_checktip'>"&str_password&str_wenti&"</div></li>"&vbcrlf& _	
			"<li><label><span class='need'>*</span> "&str_daan&"：</label><input type='text' value='' name='Answer' class='inputxt' datatype='*' errormsg='"&str_iskong&"' /><div class='Validform_checktip'>"&str_password&str_daan&"</div></li>"&vbcrlf& _	
			"<li><label><span class='need'>*</span> "&str_code&"：</label><input type='text' value='' name='code' id='imgcode' class='inputxt' datatype='*4-4' nullmsg='"&str_isinput&str_code&"' errormsg='"&str_code&str_cuowu&"' /><div class='imgcode' style='display:none'><img src='../inc/imgcode.asp' id='SeedImg' align='absmiddle' style='cursor:pointer;' border='0' onClick=""this.src+='?'+Math.random();""/>"&vbcrlf& _	
			"<script>$(""#imgcode"").focus(function (){$(""#SeedImg"").click();$("".imgcode"").show()});</script></div><div class='Validform_checktip'>"&str_isinput&str_code&"</div></li>"&vbcrlf
			htwostr=""&str_wenti&str_login&""
		else
			codestr="<li><label><span class='need'>*</span> "&str_wenti&"：</label><input type='text' value='' name='Question' class='inputxt' datatype='*' errormsg='"&str_iskong&"' /><div class='Validform_checktip'>"&str_password&str_wenti&"</div></li>"&vbcrlf& _	
			"<li><label><span class='need'>*</span> "&str_daan&"：</label><input type='text' value='' name='Answer' class='inputxt' datatype='*' errormsg='"&str_iskong&"' /><div class='Validform_checktip'>"&str_password&str_daan&"</div></li>"&vbcrlf		
			htwostr=""&str_wenti&str_login&""
		end if
			
		htmlstr="<script src='"&sitepath&"js/jquery.min.js' type='text/javascript'></script>"&vbcrlf& _	
		"<link href='"&sitepath&"plugins/Validform/Validform.css' rel='stylesheet'/><link href='"&sitepath&"plugins/user/user.css' rel='stylesheet'/><script src='"&sitepath&"plugins/Validform/Validform.min.js'></script><script type='text/javascript'>$(function(){$("".registerform"").Validform({ tiptype:function(msg,o,cssctl){ if(!o.obj.is(""form"")){ var objtip=o.obj.siblings("".Validform_checktip""); cssctl(objtip,o.type); objtip.text(msg); } } });})</script>"&vbcrlf& _	
		"<div class='register'><div class='leftregister'><div class='registerbutton'><h3>"&str_have&str_loginname&"？</h3><a href='"&actmark&"login"&logintype&"' class='nowreg'>立即"&str_login&"</a><h3>"&str_no&str_loginname&"？</h3><a href='"&actmark&"reg"&logintype&"'>"&str_reg&str_loginname&"</a></div></div>"&vbcrlf& _	
		"<div class='rightregister'><h2>"&htwostr&"</h2><form class='registerform' method='post' action='?act=forgeting&type="&logintype&"'><div class='formsub'><ul>"&vbcrlf& _	
		"<li><label><span class='need'>*</span> "&str_loginname&"：</label><input type='text' value='' name='username' class='inputxt' datatype='*5-18' nullmsg='"&str_isinput&str_loginname&"' ajaxurl='../plugins/sms/sms.asp?act=checkusername&checktype=1' errormsg='"&str_loginname&str_fanwei&"5~18' /><div class='Validform_checktip'>"&str_loginname&str_fanwei&"5~18</div></li>"&codestr&"</ul>"&vbcrlf& _
		"<div class='action'><input type='submit' value='"&str_tijiao&"' /><input type='reset' value='"&str_chongzhi&"' /></div></div></form></div></div>"&vbcrlf			
	end if
	zhl.ZContent = replaceStr(ZContent,"{cms:user}",htmlstr)
End sub

	
	Function loginin(uid)
		dim rs
		Set rs=dbsql("select a.*,b.G_Name,b.G_Mark from [dbpre]User as a,[dbpre]User_Group as b where a.U_GID=b.GID and uid ="& uid &"")
		if not rs.eof then	
		setsession"username",rs("username")	
		setsession"gmark",rs("G_Mark")	
		setsession"uid",rs("uid")
		setsession"gid",rs("U_Gid")		
		setcookie"truename",rs("truename")
		setcookie"useremail",rs("Email")
		setcookie"usermobile",rs("Mobile")
		setcookie"usertel",rs("tel")
		setcookie"userqq",rs("QQ")	
		face=repnul(rs("face"))
		if isnul(face) then face="noface.png"
		setcookie"userface",face
		setcookie"gname",rs("G_Name")	
		end if
	End Function
		
	Function loginout()
		setsession "username",null
		setsession "uid",null
		setsession "gid",null
		setsession "gmark",null
		
		setcookie"truename",""
		setcookie"useremail",""
		setcookie"usermobile",""
		setcookie"usertel",""
		setcookie"userqq",""				
		setcookie"userface",""
		setcookie"gname",""	
		dim logintype :	 logintype	=	enhtml(getform("type","get")) 		
		if logintype="open" then 
			layertrue ""&str_loginout&str_chenggong&""
		else		
			if iswap=1 then aspgo(sitepath&wappath&"user/") else aspgo (sitepath&"user/" )
		end if
	End Function
	
	Function reging
		dim sql,code,smscode,logintype
		logintype	=	enhtml(getform("type","get")) 		
		if smsmark=1 then
			smscode=	enhtml(getForm("smscode","post"))
			if isnul(smscode) then back str_duanxin&str_iskong
			if smscode <> getSession("smscode") then back str_duanxin&str_nogeshi
		elseif usercode=1 then 
			code		=	enhtml(getForm("code","post"))
			if code <> getSession("imgcode") then back str_code&str_cuowu
		end if	
		
		if isOutSubmit then  back str_waibu
		U_GID=5
		U_LID=isnum(getsession("LID"))
		U_OnOff=1
		U_order=9
		username=	enhtml(getForm("username","post"))		:	if  not checkstr(username,"username") then back str_loginname&str_nogeshi
		Password=	getForm("Password", "post")				:	if  not checkstr(Password,"password") then back str_password&str_nogeshi
		Password=	md5(Password,16)
		RegTime=now()
		TrueName	=	enhtml(getForm("TrueName", "post"))	
		mobile		=	enhtml(getForm("mobile", "post"))	:	if ischeckmobile=1 and not checkstr(mobile,"mobile") then back str_mobile&" "&str_nogeshi&""
		Email		=	enhtml(getForm("Email", "post"))	:	if ischeckemail=1 and not checkstr(email,"mobile") then back  str_email&" "&str_nogeshi&""
		if ifnameUsed(username) then alertgo str_loginname&" "&str_isused&"",sitepath&"user/"&actmark&"reg" 
		if ifmobileUsed(mobile) then alertgo str_mobile&" "&str_isused&"",sitepath&"user/"&actmark&"reg"
		sql="insert into [dbpre]user (U_GID,U_LID,U_OnOff,U_order,username,[Password],RegTime,TrueName,Mobile,Email) values("&U_GID&","&U_LID&","&U_OnOff&","&U_order&",'"&username&"','"&Password&"','"&RegTime&"','"&TrueName&"','"&Mobile&"','"&Email&"')"		
		dbconn(sql)
		if err then
			alertgo ""&str_reg&str_cuowu,sitepath&"user"
		else
			if regsendmail=1 then sendmail Receive_email,zset.siteTitle&"网站有新"&str_user&str_reg&",用户名"&username,"网址:"&zset.siteUrl&"</br>项目："&str_user&str_reg&"</br>用户："&username&"手机："&mobile
			UID=dbmaxid("[dbpre]user","uid")
			 loginin(UID)
			 if logintype="open" then layertrue ""&str_reg&str_chenggong&"" else aspgo sitepath&"user"
		end if		
	End Function	
	
	Function logining()
		dim rs,logintype,code
		logintype		=	getform("type","get")
		if usercode=1 then 
			code		=	getForm("code","post")
			if code <> getSession("imgcode") then back str_code&str_cuowu
		end if	
		if act="logining" then
			if session("passtry")>passtry then alertgo ""&str_duocuo&"",sitepath
			username	=	getForm("username","post")
			Password	=	md5(getForm("Password","post"),16)
			if dbcount("[dbpre]User","Password='"&Password&"' and (username = '"& username &"' or Mobile= '"& username &"')")=0 then 		
				back str_loginname&str_password&str_cuowu
				session("passtry")=session("passtry")+1				
			else
				Set rs=dbsql("select uid,U_OnOff from [dbpre]User where (username = '"& username &"' or Mobile= '"& username &"') and Password='"&Password&"'")
				if not rs.eof then
					if rs("U_OnOff")=0 then  alertgo ""&str_jinyong&"",""&actmark&"login"
					loginin(rs("uid"))				
					dbsql "update [dbpre]User set LastLoginTime='"&sqltime&"',LastLoginIP='"&getIp()&"',LoginCount=LoginCount+1 where UID="&rs("uid")&""
					
					if loginsendmail=1 then sendmail Receive_email,zset.siteTitle&"网站有会员"&str_login&",用户名"&username,"网址:"&zset.siteUrl&"</br>项目：会员"&str_login&"</br>用户："&username	
					if logintype="open" then 
						layertrue(""&str_login&str_chenggong&"") 						
					else						
						if iswap=1 then aspgo(sitepath&wappath&"user/") else aspgo (sitepath&"user/" )
					end if
				else
					echop ""&str_jinyong&""
				end if	
				closers rs	
			end if
		end if
	End Function
	
	Function forgeting
		dim sql,code,rs,smscode
		if isOutSubmit then  back str_waibu
		username	=	enhtml(getForm("username", "post"))
		code		=	enhtml(getForm("code","post"))
		smscode		=	enhtml(getForm("smscode","post"))
		if smsmark=1 then			
			if smscode <> getSession("smscode") then back str_duanxin&str_code&str_cuowu
			mobile = enhtml(getForm("mobile", "post"))
			if dbcount("[dbpre]user","username='"&username&"' and mobile='"&mobile&"'")>0 then
				Set rs=dbsql("select uid,U_OnOff from [dbpre]User where mobile='"&mobile&"'")
					if not rs.eof then
						if rs("U_OnOff")=0 then  alertgo str_jinyong,""&actmark&"login"
						loginin(rs("uid"))	
						if forgetsendmail=1 then sendmail Receive_email,zset.siteTitle&"网站有会员正在找回"&str_password&",用户名"&username,"网址:"&zset.siteUrl&"</br>项目：会员找回"&str_password&"</br>用户："&username			
						setsession"smscode",null
						jsgo sitepath&"user/"
					else
						alertgo str_jinyong,sitepath&"user/"&actmark&"forget"
					end if
			else
				back str_loginname&str_and&str_mobile&str_not&str_as
			end if
		else
			if usercode=1 then if code <> getSession("imgcode") then alertgo str_code&str_cuowu,sitepath&"user/"&actmark&"forget"
			Question	=	enhtml(getForm("Question", "post"))
			Answer		=	enhtml(getForm("Answer", "post"))
			if dbcount("[dbpre]user","username='"&username&"' and Question='"&Question&"' and  Answer='"&Answer&"'")>0 then
				Set rs=dbsql("select uid,U_OnOff from [dbpre]User where username='"&username&"' and Question='"&Question&"' and  Answer='"&Answer&"'")
					if not rs.eof then
						if rs("U_OnOff")=0 then  alertgo str_jinyong,""&actmark&"login"
						loginin(rs("uid"))	
						if forgetsendmail=1 then sendmail Receive_email,zset.siteTitle&"网站有会员正在找回"&str_password&",用户名"&username,"网址:"&zset.siteUrl&"</br>项目：会员找回"&str_password&"</br>用户："&username			
						
						jsgo sitepath&"user/"
					else
						alertgo str_jinyong,sitepath&"user/"&actmark&"forget"
					end if
			else
				alertgo str_waibu,sitepath&"user/"&actmark&"forget"
			end if
		end if	
	End Function
		
	Function edituser	
		dim sql
		uid		=		isnum(getForm("UID", "get"))
		if uid<>getsession("uid") then alertgo str_waibu,sitepath&"user/"&actmark&"user" 		
		sex			=	enhtml(getForm("sex", "post"))	
		username	=	enhtml(getForm("username", "post"))	
		RegTime		=	enhtml(getForm("RegTime", "post"))	
		TrueName	=	enhtml(getForm("TrueName", "post"))	
		Province	=	enhtml(getForm("Province", "post"))	
		City		=	enhtml(getForm("City", "post"))	
		District	=	enhtml(getForm("District", "post"))	
		Address		=	enhtml(getForm("Address", "post"))	
		Post		=	enhtml(getForm("Post", "post"))	
		tel			=	enhtml(getForm("tel", "post"))	
		Mobile		=	enhtml(getForm("Mobile", "post"))	
		Email		=	enhtml(getForm("Email", "post"))	
		QQ			=	enhtml(getForm("QQ", "post"))	
		U_Desc		=	enhtml(getForm("U_Desc", "post"))	
		sql= "update [dbpre]user set sex='"&sex&"',TrueName='"&TrueName&"',[Province]='"&Province&"',[City]='"&City&"',[District]='"&District&"',[Address]='"&Address&"',Post='"&Post&"',tel='"&tel&"',Mobile='"&Mobile&"',Email='"&Email&"',QQ='"&QQ&"',U_Desc='"&U_Desc&"' where UID="&UID
		dbconn(sql)
		if iswap=1 then alertgo str_xiugai&str_chenggong,sitepath&wappath&"user/" else alertgo str_xiugai&str_chenggong,sitepath&"user/"
		loginin(uid)
	End Function	
	
	Function editpwd
		dim sql
		uid		=		isnum(getForm("UID", "get"))
		if uid<>getsession("uid") then alertgo str_waibu,sitepath&"user/"&actmark&"user"		
		Password	=	enhtml(getForm("Password", "post"))
		rePassword	=	enhtml(getForm("rePassword", "post"))
		Question	=	enhtml(getForm("Question", "post"))
		Answer		=	enhtml(getForm("Answer", "post"))
		if not isnul(Password) and not isnul(rePassword) then 
			if  not checkstr(Password,"password") then back str_password&str_nogeshi
			if Password=rePassword then newPassword ="[Password]='"&md5(Password,16)&"'," else back str_password&str_and&str_repassword&str_not&str_as
		end if
		dbconn "update [dbpre]user set "&newPassword&"Question='"&Question&"',Answer='"&Answer&"' where UID="&UID
		if iswap=1 then alertgo str_xiugai&str_chenggong,sitepath&wappath&"user/"&actmark&"loginout" else alertgo str_xiugai&str_chenggong,sitepath&"user/"&actmark&"loginout" 	
	End Function
		
	Function gbooking()
	dim code,userid,gname,gtitle,gtel,Gemail,GContent,gnum,sql,backurl
	gnum=isnum(getcookie("gnum"))
	if gbookCode=1 then 
		code    =	enhtml(getForm("code","post"))
		if code <> getSession("imgcode") then back str_code&str_cuowu
	end if	
	userid		=	isnum(getsession("uid"))
	gname		=	enhtml(getForm("gname","post"))		:	if not isnul(isgbookname) 		and isnul(gname)	and ongbookname=1 		then back gbookname&str_nogeshi
	gtitle		=	enhtml(getForm("gtitle","post"))	:	if not isnul(isgbooktitle) 		and isnul(gtitle)	and ongbooktitle=1 		then back gbooktitle&str_nogeshi
	gtel		=	enhtml(getForm("gtel","post"))		:	if not isnul(isgbooktel) 		and isnul(gtel)		and ongbooktel=1 		then back gbooktel&str_nogeshi
	Gemail		=	enhtml(getForm("Gemail","post"))	:	if not isnul(isgbookmail) 		and isnul(Gemail)	and ongbookmail=1 		then back gbookmail&str_nogeshi
	GContent	=	enhtml(getForm("GContent","post"))	:	if not isnul(isgbookcontent)	and isnul(GContent)	and ongbookcontent=1 	then back gbookcontent&str_nogeshi
	backurl		=	enhtml(getForm("backurl","post"))	:	if isnul(backurl) 									then backurl=sitepath
	if userid=0 then 
		if gnum>=isnum(gbookanonymousnum) then alertgo str_nouser&str_tian&str_zuiduo&str_gbook&gbookanonymousnum&str_cishu,sitepath
	else
		if gnum>=isnum(gbookusernum) then alertgo str_user&str_tian&str_zuiduo&gbookusernum&str_gbook&str_cishu,sitepath
	end if
	dim rs,customStr,customval,mailstr
	set rs=dbsqlr1("select custom,customClass from [dbpre]content_custom where customType ='gbook'")	
	Do While not rs.Eof 
		customStr=customStr&","&rs(0)			
		if rs(1)=1 then 
		  customval=customval&","&isnum(getForm(rs(0),"post"))
		  mailstr=mailstr&"</br>"&rs(0)&"："&isnum(getForm(rs(0),"post"))
		elseif rs(1)=3 then 
		  customval=customval&",'"&encode(request.form(rs(0)))& "'"
		  mailstr=mailstr&"</br>"&rs(0)&"："&request.form(rs(0))
		else
		  customval=customval&",'"&getForm(rs(0),"post")&"'"
		  mailstr=mailstr&"</br>"&rs(0)&"："&getForm(rs(0),"post")
		end if	
	rs.MoveNext
	Loop
	closers rs
	sql= "insert into [dbpre]GBook(LID,G_UID,G_title,G_name,G_tel,G_email,G_Content,G_Time,G_Order,G_OnOff,G_IP"&customStr&",R_onoff) values("&zset.Lid&","&userid&",'"&gtitle&"','"&gname&"','"&Gtel&"','"&Gemail&"','"&GContent&"','"&sqltime&"',1,"&gbookonoff&",'"&getip()&"'"&customval&",0)"	
	 dbconn sql
	if gnum=0 then setcookie "gnum",1 else setcookie "gnum",gnum+1
	if gbooksendmail=1 then sendmail Receive_email,zset.siteTitle&"网站有新的留言,姓名"&gname,"网址:"&zset.siteUrl&"</br>项目:留言信息</br>"&gbookname&"："&gname	&"</br>"&gbooktitle&"："&gtitle&"</br>"&gbooktel&"："&gtel&"</br>"&gbookmail&"："&Gemail&"</br>"&gbookcontent&"："&GContent&mailstr
	alertgo str_gbook&str_chenggong,backurl
	End Function		
%>