<%
dim show_username
dim rs,rsskin,sqluser
dim show,show_logtmp
dim user_siterefu_num,user_showlog_num,user_showcomment_num,user_showmessage_num
dim user_shownewlog_num,user_shownewcomment_num,user_shownewmessage_num
dim user_blogname,user_adddate,user_commentcount,user_messagecount,user_logcount
dim userlinks,userplacard,nickname,vipsee 'vip用户查看权限
show_username=ReplaceBadChar(trim(request.QueryString("name")))
sqluser="select userskinmain,userskinshowlog,defaultskin"
sqluser=sqluser&",user_siterefu_num,user_showlog_num,user_showcomment_num,user_showmessage_num"
sqluser=sqluser&",user_shownewlog_num,user_shownewcomment_num,user_shownewmessage_num,blogname"
sqluser=sqluser&",adddate,commentcount,messagecount,logcount,lockuser,blog_password,userlinks,userplacard"
sqluser=sqluser&",nickname"
sqluser=sqluser&" from [user] where username='"&show_username&"'"
set rs=conn.execute(sqluser)
if rs.eof or rs.bof then
	response.Write("无此用户，请检查连接是否正确")
	response.End()
end if
if rs(2)<>0 then
	show=rs(0)
	show_logtmp=rs(1)
else
	set rsskin=conn.execute("select skinmain,skinshowlog from userskin where isdefault='true'")
	show=rsskin(0)
	show_logtmp=rsskin(1)
	set rsskin=nothing	
end if
user_siterefu_num=rs(3)+1 '页面刷新数
user_showlog_num=rs(4) 
user_showcomment_num=rs(5)
user_showmessage_num=rs(6)
user_shownewlog_num=rs(7)
user_shownewcomment_num=rs(8)
user_shownewmessage_num=rs(9)
user_blogname=rs(10)
user_adddate=FormatDateTime(rs(11),1)
user_commentcount=rs(12)
user_messagecount=rs(13)
user_logcount=rs(14)
userlinks=rs(17)
userplacard=rs(18)
nickname=rs(19)
if rs(15)="true" then
	Response.Write "该用户已经被系统屏蔽！"
	response.End()
end if
if Request.Cookies(cookiesname)("userlevel")=8 and vip_prosee="true" then
	vipsee=true
else
	vipsee=false
end if
if not isnull(rs(16)) and Request.Cookies(cookiesname)("blog_password")<>rs(16) and Request.Cookies(cookiesname)("UserLevel")<>9 and vipsee=false then
	set rs=nothing
	call closeconn()
	response.Redirect "user_chkblogpassword.asp?name="&show_username
end if
conn.execute("update [user] set user_siterefu_num="&user_siterefu_num&" where username='"&show_username&"'")
response.Write "<link rel='alternate' href='rss2.asp?name="&show_username&"' type='application/rss+xml' title='RSS' >"

sub SaveCookie()
	Response.Cookies(cookiesname)("UserName")=username
	Response.Cookies(cookiesname)("Password") = PassWord
	if ot_user then
		Response.Cookies(cookiesname)("UserLevel")=rsreg("UserLevel")
	else	
		Response.Cookies(cookiesname)("UserLevel")=rs("UserLevel")
	end if
	Response.Cookies(cookiesname)("CookieDate") = CookieDate
	select case CookieDate
		case 0
			'not save
		case 1
		   	Response.Cookies(cookiesname).Expires=Date+1
		case 2
			Response.Cookies(cookiesname).Expires=Date+31
		case 3
			Response.Cookies(cookiesname).Expires=Date+365
	end select
end sub

sub ob_chklogin()
	password=md5(password)
	set rs=server.createobject("adodb.recordset")
	sql="select * from [user] where username='"& username & "' and UserPassword ='" & password &"'"
	rs.open sql,Conn,1,3
	if rs.bof and rs.eof then
		Response.Write"<script language=JavaScript>"
		Response.Write"alert(""对不起！用户名或密码错误！"");"
		Response.Write"window.history.go(-1);"
		Response.Write"</script>"
	else
		if rs("lockuser")="true" then
			Response.Write"<script language=JavaScript>"
			Response.Write"alert(""对不起！你的ID已被锁定，不能登陆！"");"
			Response.Write"window.history.go(-1);"
			Response.Write"</script>"
		else
			rs("LastLoginIP")=Request.ServerVariables("REMOTE_ADDR")
			rs("LastLoginTime")=blognow()
			rs("LoginTimes")=rs("LoginTimes")+1
			rs.update
			call SaveCookie()
		end if
	end if
	rs.close
end sub

sub ot_chklogin()
	password=md5(password)
	sql="select * from "&ot_usertable&" where "&ot_username&"='"& username & "' and "&ot_password&" ='" & password &"'"
	'response.Write(sql)
	set rs=ot_conn.execute(sql)
	if rs.bof and rs.eof then
		Response.Write"<script language=JavaScript>"
		Response.Write"alert(""对不起！用户名或密码错误！"");"
		Response.Write"window.history.go(-1);"
		Response.Write"</script>"
		exit sub
	else
		set rsreg=server.CreateObject("adodb.recordset")
		rsreg.open "select * from [user] where username='"& username &"'",conn,1,3
		if rsreg.eof then
			dim reguserlevel
			set rs=conn.execute("select reguserlevel,admincheckreg from bloginfo")
			reguserlevel=rs("reguserlevel")
			if rs("admincheckreg")="true" then
				reguserlevel=6
			end if
			rsreg.addnew
			rsreg("username")=username
			rsreg("userlevel")=reguserlevel
			rsreg("lockuser")="false"
			rsreg("userisbest")="false"
			rsreg("en_blogteam")="true"
			rsreg("adddate")=now()
			rsreg.update
			conn.execute("update bloginfo set usercount=usercount+1")
			rsreg.close
			set rsreg=nothing
			call PutApplicationValue()
		else
			rsreg("LastLoginIP")=Request.ServerVariables("REMOTE_ADDR")
			rsreg("LastLoginTime")=blognow()
			rsreg("LoginTimes")=rsreg("LoginTimes")+1
			rsreg.update
			call SaveCookie()
		end if	
	end if
end sub
%>