<!--#include file="inc/inc_syssite.asp"-->
<!--#include file="inc/md5.asp"-->
<!-- #include file="API/Class_API.asp" -->
<!--#include file="inc/upiconfig.asp"-->
<%
Response.expires = 0
Response.expiresabsolute = now() - 1
Response.addHeader "pragma","no-cache"
Response.addHeader "cache-control","private"
Response.cachecontrol = "no-cache"
Dim username,password,show_login,CookieDate,fromurl,action
action=request("action")
if action<>"showindexlogin" and action<>"showjs" then
	if  oblog.checkuserlogined() then response.Redirect("user_index.asp")
end if

username=oblog.filt_badstr(trim(request("username")))
password=trim(request.form("password"))
CookieDate=trim(request("CookieDate"))
fromurl=trim(request("fromurl"))
if username<>"" or request("chk")="1" then 	
	call sub_chklogin
else
	if action="showindexlogin" then
		call sub_showindexlogin()
	elseif action="showjs" then
		blogurl=oblog.CacheConfig(3)
		call sub_showindexlogin()
	else
		call sub_showlogin()
	end if
end if
sub sub_showlogin()
%>
<!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" />
<title>用户管理登录</title>
<link rel="stylesheet" href="oBlogStyle/group/style.css" type="text/css" />
</head>
<body style="background:#fff;">
<!--=c_main=start=-->
<div id="r_main">
	<!--=c_body=start=-->
	<div class="login_content">
		<div class="login">
			<div class="left">
			 <%If HLIntegration = True Then'----------恒浪整合-----------%>
			<form name="UserLogin" method="post" action="<%=HL_Url&Manage_Url&"User_Chklogin.asp?ComeUrl="&Request("fromurl")%>">
			 <%else%>
			<form name="UserLogin" method="post" action="login.asp?chk=1&fromurl=<%=fromurl%>" >
			<%End if'----------恒浪整合-----------%>
			<p class="username">用户名:<input type="text" name="UserName" /></p>
			<p class="password">密　码:<input type="password" name="Password" /></p>
			<p class="CookieDate"><input name="CookieDate" type="radio" value="0" checked="checked" title="若您不在自己的电脑登录，请不要保存密码" />不保存
			<input type="radio" name="CookieDate" value="1" />一天
			<input type="radio" name="CookieDate" value="2" />一月
			<input type="radio" name="CookieDate" value="3" />一年</p>
			<%if oblog.CacheConfig(29)=1 then%>
			<p class="codestr">验证码:<input name="codestr" type="text" class="put2" size="6" maxlength="4" /><%response.Write(oblog.getcode)%></p>
			<%
			end if
			%>
			<p class="login_btu">
			<input type="hidden" name="fromurl" value="<%=fromurl%>">
			<input name="Submit" type="submit" value="登　录" />
			</p>
			</div>
			</form>
			<div class="right">
				<h5>帮助信息</h5>
				<ul>
				<li>如果你使用原有ID登录不了，请试试<a href="lostpassword.asp">找回密码</a>。</li>
				<li>如果你不是本站会员，请<a href="reg.asp">注册新用户</a>。</li>
				<%if oblog.CacheConfig(29)=1 then%>
				<li>当你看不清左侧验证码时请点验证码图片刷新。</li>
				<%end if
				    if Request.Cookies("hl_user")("username")<>"" and Request.Cookies("hl_user")("password")<>"" and ActiveBlog=True And HLIntegration = True then 			    
		            response.Write"<br><a href='activeblog.asp'><font color='red'>你未激活博客，激活博客请点击</font></a>"
	             end if
				 %>
				</ul>
			</div>
		</div>
		<div class="both"></div>
	</div>
	<!--=c_body=end=-->
	<div class="both"></div>
</div>
</body>
</html>

<%
end sub

sub sub_chklogin()
	dim ajax,rearr,gohref
	'set ajax=new AjaxXml
	if oblog.chkiplock() then
		oblog.adderrstr("对不起！你的IP已被锁定，不允许登录！")
	end if
	if oblog.CacheConfig(29)=1 then
		if not oblog.codepass then oblog.adderrstr("验证码错误！")
	end if
	if UserName="" then oblog.adderrstr("登录用户名不能为空！")
	if Password="" then oblog.adderrstr("登录密码不能为空！")
	if oblog.errstr<>"" then 
		rearr=split(replace(oblog.errstr,"_","\n")&"$$1","$$")
		response.Write "<script language=JavaScript>alert(""" & rearr(0) & """);history.go(-1)</script>"
		response.End()
		'ajax.re(rearr)
		'response.end
	end if
	if CookieDate="" then CookieDate=0	else CookieDate=Clng(CookieDate)
'	password=md5(password)
	if Is_ot_User=1 then
		call ot_chklogin()
	Else 
		oblog.ob_chklogin UserName,MD5(password),CookieDate

		If API_Enable Then 
				Dim blogAPI
				Set blogAPI = New DPO_API_OBLOG
				blogAPI.LoadXmlFile True
				blogAPI.UserName=username
				blogAPI.PassWord=password
				blogAPI.CookieDate=CookieDate
				blogAPI.userip=oblog.userip
				Call blogAPI.ProcessMultiPing("login")
				Set blogAPI=Nothing
				Dim strUrl,i,turl
				For i=0 To UBound(aUrls)
					strUrl=Lcase(aUrls(i))
					If Left(strUrl,7)="http://" Then																
						turl=strUrl&"?syskey="&MD5(UserName&oblog_Key)&"&username="&UserName&"&password="&MD5(PassWord)&"&savecookie="&CookieDate & "@@@"& turl
					End If
				Next
				session("turl")=turl
				Dim trearr
				trearr="$$"&MD5(username & oblog_Key )&"$$"&username&"$$"&MD5(password)
		End If
	End If
	if oblog.errstr<>"" then 
		rearr=split(replace(oblog.errstr,"_","\n")&"$$1","$$")
		response.Write "<script language=JavaScript>alert(""" & rearr(0) & """);history.go(-1)</script>"
		response.End()
		'ajax.re(rearr)
		'response.end
	end if
	if fromurl<>"" then
		gohref=replace(fromurl,"&","$")
		rearr=split("登录成功!$$2$$"&gohref & trearr,"$$")
	else
		if action="showindexlogin" then
			gohref=oblog.comeurl
		else
			gohref="user_index.asp"
		end if
	end if
	rearr=split("登录成功!$$2$$"&gohref & trearr,"$$")
	if rearr(1)=2 Then
		If InStr (rearr(2),"user_index.asp")>0 Then 
			response.Redirect(rearr(2))
		Else 
			response.Redirect(Replace(rearr(2),"$","&"))
		End if
	else
		response.Write "<script language=JavaScript>alert(""" & rearr(0) & """);history.go(-1)</script>"
	end if
	'ajax.re(rearr)
	'response.End
end Sub

sub ot_chklogin()
	dim sql,rs,rsreg
	Dim ajax,rearr
	set ajax=new AjaxXml
	if not IsObject(ot_conn) then link_database
	sql="select * from "&ot_usertable&" where "&ot_username&"='"& username & "' and "&ot_password&" ='" & md5(password) &"'"
	set rs=ot_conn.execute(sql)
	if rs.bof and rs.eof then
		set rs=nothing
		if isobject(ot_conn) then ot_conn.close:set ot_conn=nothing
		oblog.adderrstr("用户名或密码错误，请重新输入！！")
		exit sub
	else
		set rsreg=server.CreateObject("adodb.recordset")
		rsreg.open "select * from [oblog_user] where username='"& username &"'",conn,1,3
		if rsreg.eof then
			dim reguserlevel
			If oblog.CacheConfig(18) = 1 Then reguserlevel = 6 Else reguserlevel = 7
			set rsreg=server.CreateObject("adodb.recordset")
			rsreg.open "select top 1 * from [oblog_user]",conn,1,3
			rsreg.addnew
			rsreg("username")=username
			rsreg("password")=MD5(password)
			rsreg("user_dir")=oblog.setup(8,0)
			rsreg("user_level")=reguserlevel
			rsreg("lockuser")=0
			rsreg("en_blogteam")=1
			rsreg("adddate")=ServerDate(Now())
			rsreg("regip")=oblog.userip
			rsreg("lastloginip")=oblog.userip
			rsreg("lastlogintime")=ServerDate(now())
			rsreg("user_group") = oblog.defaultGroup
			rsreg("scores") = oblog.cacheScores(1)
			rsreg("newbie") = 1
			if oblog.CacheConfig(40)=1 then rsreg("comment_isasc")=1
			If oblog.chkdomain(UserName)=False Then
				rsreg("Nickname")=UserName
			End If
			rsreg.update
			oblog.execute("update oblog_user set user_folder=userid where username='"&username&"'")
			oblog.execute("update oblog_setup set user_count=user_count+1")
			rsreg.close
			set rsreg=nothing
			oblog.SaveCookie username,md5(password),0," "
			oblog.CreateUserDir username,1
			set rs=Nothing
			'rearr=split("您是第一次激活blog系统，请完善blog资料!$$2$$user_index.asp","$$")
			oblog.showok "您是第一次激活blog系统，请完善blog资料!","user_index.asp"
			'ajax.re(rearr)
			response.End
		Else
			If rsreg("password")<>MD5(password) Then rsreg("password")=MD5(password)
			rsreg("LastLoginIP")=oblog.userip
			rsreg("LastLoginTime")=ServerDate(Now())
			rsreg("LoginTimes")=rsreg("LoginTimes")+1
			rsreg.update			
		end if
		rsreg.close
		set rsreg=nothing
		set rs=nothing
		if isobject(ot_conn) then ot_conn.close:set ot_conn=nothing
		oblog.SaveCookie username,md5(password),CookieDate,""
	end if
end sub


sub sub_showindexlogin()
	dim show_userlogin
	if oblog.CheckUserLogined()=False then
		if request("n")="1" then '横向
		   if HLIntegration = True Then'---------恒浪整合-------------
			  show_userlogin="<form action='"&HL_Url&Manage_Url&"User_Chklogin.asp' method='post' name='UserLogin'><table align='center' width='100%' border='0' cellspacing='0' cellpadding='0' style=""font-size:12px""><tr><td height='25'>"			 
			  if Request.Cookies("hl_user")("username")<>"" and Request.Cookies("hl_user")("password")<>"" and ActiveBlog=True then
			   show_userlogin=show_userlogin & "<a href='activeblog.asp'>你未激活博客，激活博客请点击</a>&nbsp;&nbsp;"	
	          end if
			  show_userlogin=show_userlogin&"用户名：<input name='UserName' type='text' id='UserName' size='12' maxlength='20' onkeydown='keydown()'>"
			else
			show_userlogin="<form action='"&blogurl&"login.asp?action=showindexlogin&chk=1' method='post' name='UserLogin'><table align='center' width='100%' border='0' cellspacing='0' cellpadding='0' style=""font-size:12px""><tr>"
			show_userlogin=show_userlogin & "<td height='25'>用户名：<input name='UserName' type='text' id='UserName' size='12' maxlength='20' >"
			end if'---------恒浪整合结束 -------------
			show_userlogin=show_userlogin & "　密码：<input name='Password' type='password' id='Password' size='12' maxlength='20'  />"
			if oblog.CacheConfig(29)=1 then
				show_userlogin=show_userlogin&"　验证码：<input name=""codestr"" type=""text"" size=""4"" maxlength=""4"" />"&oblog.getcode&""
			end if
			show_userlogin=show_userlogin & "　<input type=""checkbox"" name=""CookieDate"" value=""3"">记住密码"			
			show_userlogin=show_userlogin & "　<input name='fromurl' type='hidden'><input name='Login' type='submit' id='submit' value='登录' > "
			show_userlogin=show_userlogin & "<a href='"&blogurl&"reg.asp'>用户注册</a>&nbsp;<a href='"&blogurl&"lostpassword.asp'>忘记密码</a></td>"
			show_userlogin=show_userlogin & "</tr></table></form>"
		else
		    if HLIntegration = True Then'---------恒浪整合--------------			
			show_userlogin="<form action='"&HL_Url&Manage_Url&"User_Chklogin.asp' method='post' name='UserLogin'>"
			if Request.Cookies("hl_user")("username")<>"" and Request.Cookies("hl_user")("password")<>"" and ActiveBlog=True And HLIntegration = True then 			    
		    show_userlogin=show_userlogin&"<a href='activeblog.asp'><font color='red'>你未激活博客，激活博客请点击</font></a>"
	        end if
			else
			show_userlogin="<form action='"&blogurl&"login.asp?action=showindexlogin&chk=1' method='post' name='UserLogin'>"
			end if'------------------------------恒浪整合结束--------------			
			show_userlogin=show_userlogin&"<table align='center' width='100%' border='0' cellspacing='0' cellpadding='0' style=""font-size:12px"">"
			show_userlogin=show_userlogin & "<tr><td height='25' class=login>用户名：<input name='UserName' type='text' id='UserName' size='12' maxlength='20' ></td></tr>"
			show_userlogin=show_userlogin & "<tr><td height='25' class=login >密　码：<input name='Password' type='password' id='Password' size='12' maxlength='20' /></td></tr>"
			if oblog.CacheConfig(29)=1 then
				show_userlogin=show_userlogin&"<tr><td height='25' >验证码：<input name=""codestr"" type=""text"" size=""4"" maxlength=""4"" />"&oblog.getcode&"</td></tr>"
			end if
			show_userlogin=show_userlogin & "<tr><td height='25'>　　　　<input type=""checkbox"" name=""CookieDate"" value=""3"">记住密码</td></tr>"
			
			show_userlogin=show_userlogin & "<tr><td height='25'><input name='fromurl' type='hidden'><input name='Login' type='submit' id='Login' value='登录' > "
			show_userlogin=show_userlogin & "<a href='"&blogurl&"reg.asp'>用户注册</a>&nbsp;<a href='"&blogurl&"lostpassword.asp'>忘记密码</a><br></td>"
			show_userlogin=show_userlogin & "</tr></table></form>"
		end if
	Else
		if request("n")="1" then '横向
			show_userlogin="欢迎您," & oblog.l_uname & "&nbsp;&nbsp;"
			show_userlogin= show_userlogin&"您的身份："
			show_userlogin= show_userlogin& oblog.l_Group(1,0)
			show_userlogin= show_userlogin& "&nbsp;&nbsp;<a href="&blogurl&"go.asp?user="&oblog.l_uname&" target='_blank'>我的首页</a>"
			show_userlogin= show_userlogin& "&nbsp;&nbsp;<a href='"&blogurl&"user_index.asp' target='_blank'>管理中心</a>&nbsp;&nbsp;"
			show_userlogin= show_userlogin& "<a href='"&blogurl&"user_index.asp?url=user_post.asp' target='_blank'>发表日志</a>&nbsp;&nbsp;"
			show_userlogin= show_userlogin& "<a href='"&blogurl&"user_index.asp?t=logout&re=1'>注销登录</a><br />"
		else
			show_userlogin="--欢迎您," & oblog.l_uname & "--<br />"
			show_userlogin= show_userlogin&"您的身份："
			show_userlogin= show_userlogin& oblog.l_Group(1,0)
			'show_userlogin= show_userlogin& "<br><b>用户控制面板：</b><br>" & vbcrlf
			show_userlogin= show_userlogin& "<br /><a href="&blogurl&"go.asp?user="&oblog.l_uname&" target='_blank'>我的首页</a>"
			show_userlogin= show_userlogin& "&nbsp;&nbsp;<a href='"&blogurl&"user_index.asp' target='_blank'>管理中心</a><br />"
			show_userlogin= show_userlogin& "<a href='"&blogurl&"user_index.asp?url=user_post.asp' target='_blank'>发表日志</a>&nbsp;&nbsp;"
			show_userlogin= show_userlogin& "<a href='"&blogurl&"user_index.asp?t=logout&re=1'>注销登录</a><br />"
		end If
		If API_Enable Then 
			If session("turl")<>"" Then
				Dim arrturl,i,turl
				turl=Replace(session("turl"),"$","&")
				arrturl=Split(turl,"@@@")
				For i=0 To UBound(arrturl)
					If arrturl(i)="" Then Exit For
					show_userlogin= show_userlogin& "<script language=JAVASCRIPT src="""&arrturl(i)&"""></script>" & vbcrlf
				Next 
				Response.Flush
				session("turl")=""
			End if
		End if
	end if
	Response.Write oblog.htm2js_div(show_userlogin,"ob_login")
end sub 
%>