<%
'Version=HowaveV5.0_1.0.0.1
Dim SecurityKey,HL_Url,oBlog_Url,AdminSecurityKey,Manage_Url,RegPageSet,Domainname,GoUrl
Dim RegFileName,LoginFileName,LogoutFileName,ChangePasswordFileName,LostPasswordFileName
Const RefreshTime = 1                         
Const HLIntegration = True      'True前台整合设置,Flase为还原前台整合设置
Const HLAdminIntegration = True 'True为后台整合设置，Flase为还原后台整合设置                               
Const ActiveBlog=True           'True为需要激活博客，若不需要激活博客ActiveBlog=False
Const Ver="1"                    '若为恒浪V5.0则填 1 ，若为恒浪V4.0则填 0 
Const IsSQL="false"             '若恒浪V5.0为 SQL数据库  则设为"true",
'若为 Access 数据库或者V4.05SP1则设为"false"并手动填写SecurityKey,HL_Url,RegPageSet，AdminSecurityKey这四个参数

GoUrl=Request.ServerVariables("HTTP_REFERER")                 

If IsSQL="true" then
   SetSecurityKey()
Else
   SecurityKey="testtesttesttestlong"   '前台密钥
   HL_Url="http://localhost/"           '恒浪主站URL
   AdminSecurityKey="kjsdaf89Wfdf78Vsd"  '后台密钥
   RegPageSet=""                        '若RegPageSet为空则表示默认为本系统注册，若想固定某一个页面进行注册请填写该注册页面的URL
   Domainname=""                        '若在恒浪后台开启了二级域名则需要填写相同的域名
end if


IF Ver="1" Then
   Manage_Url="Passport/"           '整合系统为V5.0的情况"
   RegFileName="UserReg.aspx"
   LoginFileName="Login.aspx"
   LogoutFileName="Logout.aspx"
   ChangePasswordFileName="PasswordManager.aspx"
   LostPasswordFileName="forget_password"
Else 
   if Ver="0" Then
      Manage_Url="manage/"           '整合系统为V4.05SP1的情况"
      RegFileName="User_RegPost.asp"
      LoginFileName="User_ChkLogin.asp"
      LogoutFileName="User_Logout.asp"
      ChangePasswordFileName="User_ModifyPWD.asp"
      LostPasswordFileName="User_GetPassword.asp"
   End If	 
End If 
'连接恒浪数据库获取资料
Function SetSecurityKey()
    Dim HLInfor_ConnStr,HLInfor_SqlUsername,HLInfor_SqlPassword,HLInfor_SqlDatabaseName,HLInfor_SqlHostIP,HLInfor_Conn,HLInfor_Res
	
	HLInfor_SqlUsername      = "sa"             '恒浪V5.0数据库登录帐号
	HLInfor_SqlPassword      = "123456"         '恒浪V5.0数据库登录密码
	HLInfor_SqlDatabaseName  = "testhowave5.0"  '恒浪V5.0数据库名
	HLInfor_SqlHostIP        = "(local)"        '恒浪V5.0数据库服务器
	
    HLInfor_ConnStr = "Provider = Sqloledb; User ID = " & HLInfor_SqlUsername & "; Password = " & HLInfor_SqlPassword & "; Initial Catalog = " & HLInfor_SqlDatabaseName & "; Data Source = " & HLInfor_SqlHostIP & ";"

    Set HLInfor_Conn = Server.CreateObject("ADODB.Connection")
    HLInfor_Conn.open HLInfor_ConnStr
	Set HLInfor_Res=HLInfor_Conn.Execute("Select SiteUrl,SecurityKey,AdminSecurityKey,RegPageSet,DomainName From HL_Setup")
	HL_Url=HLInfor_Res("SiteUrl")
	SecurityKey = HLInfor_Res("SecurityKey")
	AdminSecurityKey = HLInfor_Res("AdminSecurityKey")
	RegPageSet=HLInfor_Res("RegPageSet")
	Domainname=HLInfor_Res("DomainName")
	Set HLInfor_Res = Nothing
	Set HLInfor_Conn = Nothing
End Function

'检测注册入口
Function Howave_CheckIsReg()
Dim HowaveRegSeturl
IF HLIntegration=True Then
   HowaveRegSeturl="http://"&request.ServerVariables("Server_NAME")&request.ServerVariables("SCRIPT_NAME") 
   IF(len(trim(request.ServerVariables("QUERY_STRING")))>0) then 
      HowaveRegSeturl=HowaveRegSeturl& "?" & request.ServerVariables("QUERY_STRING") 
   End if
   IF RegPageSet<>"" And Lcase(RegPageSet)<>Lcase(HowaveRegSeturl) Then     
      Response.Redirect RegPageSet&"?ComeUrl="&GoUrl
      Response.End()
   End IF
End IF  
End Function 

'注册
function Howave_Reg(UserName,UserPassword,Email,UserQuestion,UserAnswer,Sex)
if HLIntegration=True Then
	Dim Sign,RegUserName,RegQuestion,RegPassword
	RegUserName=Lcase(Server.URLEncode(UserName))
	RegQuestion=Lcase(Server.URLEncode(UserQuestion))
	RegPassword=Md5(UserPassword,32)
	Sign=MD5(RegUserName&RegPassword&SecurityKey,32)
	
	Response.Write "<form action='"& HL_Url &Manage_Url&RegFileName&"' method='post' name=HowaveRegForm id=HowaveRegForm >"& vbCrLf
	Response.Write "    <input name='UserName' type='hidden' id='UserName' value="&RegUserName&">"& vbCrLf
	Response.Write "    <input name='Password' type='hidden' value="&RegPassword&">"& vbCrLf
	Response.Write "    <input name='Email' type='hidden' value="&Email&">"& vbCrLf
	Response.Write "    <input name='Question' type='hidden' value="&RegQuestion&">"& vbCrLf
	Response.Write "    <input name='Answer' type='hidden' value="&Md5(UserAnswer,32)&">"& vbCrLf
	Response.Write "    <input name='Sex' type='hidden' value="&Sex&">"& vbCrLf
	Response.Write "    <input name='Sign' type='hidden' value="&Sign&">"& vbCrLf
	Response.Write "    <input name='Code' type='hidden' value='gb2312'>"& vbCrLf
	Response.Write "    <input name='ComeUrl' type='hidden' id='ComeUrl' value="&GoUrl&">"& vbCrLf
	Response.Write "</form>"& vbCrLf
	Response.Write "<script language='JavaScript' type='text/javascript'>" & vbCrLf
	Response.Write "	HowaveRegForm.submit();" & vbCrLf
	Response.Write "</script>" & vbCrLf
	
End If
End Function

'登录
Function Howave_Login(UserName,UserPassword,CookieTime,ComeUrl)
Dim HLUserName
HLUserName=Lcase(Server.URLEncode(UserName))
if HLIntegration=True Then
	Response.Write"<body onload='document.HowaveLoginform.submit();'>"& vbCrLf
	Response.Write "<form name='HowaveLoginform' id='HowaveLoginform' action='"&HL_Url&Manage_Url&LoginFileName&"' method='post'>" & vbCrLf
	Response.Write "	<input type='hidden' name='UserName' value='"&HLUserName&"'>" & vbCrLf
	Response.Write "	<input type='hidden' name='UserPassword' value='"&UserPassword&"'>" & vbCrLf
	Response.Write "	<input type='hidden' name='CookieDate' value='"&CookieTime&"'>" & vbCrLf
	Response.Write "	<input type='hidden' name='ComeUrl' value='"&ComeUrl&"'>" & vbCrLf
	Response.Write "	<input name='Code' type='hidden' value='gb2312'>" & vbCrLf
	Response.Write "</form>" & vbCrLf
    Response.Write "</body>"
    Response.End()
End If
End Function

'注销
Function Howave_Logout()
IF HLIntegration = True Then 
    Response.Redirect (HL_Url&Manage_Url&LogoutFileName&"?ComeUrl="&GoUrl)
End If
End Function

'找回密码
Function Howave_LostPassword()
IF HLIntegration = True Then 
    Response.Redirect(HL_URl&Manage_Url&LostPasswordFileName&"?ComeUrl="&GoUrl)
End If
End Function

'修改密码
Function Howave_ChangePassword()
IF HLIntegration = True Then 
    Response.Redirect(HL_URl&Manage_Url&ChangePasswordFileName&"?ComeUrl="&GoUrl)
End If
End Function

'修改密码URL
Dim HowaveChangePasswordUrl
HowaveChangePasswordUrl=HL_Url&Manage_Url&ChangePasswordFileName&"?ComeUrl="&GoUrl


'===================================================
' HoWaveV5.0
'				Powered by HoWave.Net
'===================================================
' Mail: websky888@126.com 
' Q  Q: 18469685, 615939753    Tel:020-88386767
' Web : http://www.HoWave.net, http://www.jsp163.com
' Bbs : http://bbs.HoWave.net, http://bbs.jsp163.com
' Copyright (C) 2005 HoWave.net All Rights Reserved.
'===================================================
%>
