<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Response.Buffer = True 
Response.ExpiresAbsolute = Now() - 1 
Response.Expires = 0 
Response.CacheControl = "no-cache" 
Response.AddHeader "Pragma", "No-Cache"
%>
<!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>恒浪IMS接口配置</title>
<base target="_self"></base>
<style type="text/css">
body{ font-size:12px;}
table{ PADDING: 3px; MARGIN: 0px; BORDER: gray 1px solid; WIDTH: 100%; BORDER-COLLAPSE: collapse; border-spacing: 0px}
td{border-bottom:#98DAF5 1px solid;}
.tableTitle
{
    width:100%;height:25px;background-color:#3872B2; height:25px; color:White; font-weight:bold; text-align:center;
}
.tableTips
{
    width:50%; background:#F7F7F7; border-bottom:#98DAF5 1px solid; line-height:120%; padding-left:5px; 
}
</style>
</head>

<body>
<%
dim objFSO,fdata,objCountFile,ConfigStr
Dim ConfigItem(15),ConfigVar(15)
Dim Num
If Request("Action")="CheckCode" Then 
   CheckIsValid()
Else 
   If Session("HLManageCode")="" Then 
      ShowLogin()
      Response.End()
   End If
End If

Select Case Request("Action")
   Case "Save"
       WriteConfig()
	   ReadConfig()	   
	   ShowFrom()
   Case else
       ReadConfig()
       ShowFrom()
End Select
	
Function CheckInput(str,strType)
	select Case strType
	  Case "bool"
		 if str<>"true" and str<>"false" then
			Response.Write "类型匹配不正确"
			Response.End()
		 End If
	  Case "string"
		 if instr(2,str,"""")<>len(str) and len(str)>100 then
			Response.Write "类型匹配不正确"
			Response.End()
		 End If
	  Case "num"
		 if not IsNumeric(str) then 
			 Response.Write "类型匹配不正确"
			 Response.End()
		 End If
	end Select
End Function

Sub CheckIsValid()
    Dim IsValid
	IsValid=false
    If Request("HLManageCode")<>"" Then
	   ReadConfig()	  
	   If ConfigName("HLManageCode")=""""&Request("HLManageCode")&"""" Then
	      Session("HLManageCode")=ConfigName("HLManageCode")
		  IsValid=true
	   Else
	      Response.Write "<script>alert('输入的管理认证码不正确')</script>"		  
	   End IF	   	  
	Else
	   Response.Write "<script>alert('输入的管理认证码不能为空')</script>"	  
	End IF
    If IsValid=false Then	 
	   ShowLogin()
	   Response.End()
    End If   
End Sub

Sub ShowLogin()
 %>
<form action="HoWaveConfigSetup.asp?Action=CheckCode" method="post">
<table>
  <tr>
      <td>
	      请输入管理认证码：<input type="text" name="HLManageCode"/><input type="submit" value="提交"/>
	  </td>
  </tr>
  
</table>
</form>
<%
End Sub	
Sub WriteConfig()
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")    
	   CheckInput Request("HLIntergration"),"bool"
	   CheckInput Request("HLAdminIntegration"),"bool"
	   CheckInput Request("HLCode"),"string"
	   CheckInput Request("HLVer"),"num"
	   CheckInput Request("HLIsSQL"),"num"
	   CheckInput Request("HL_Url"),"string"
	   CheckInput Request("SecurityKey"),"string"
	   CheckInput Request("AdminSecurityKey"),"string"
	   CheckInput Request("RegPageSet"),"string"
	   CheckInput Request("Domainname"),"string"
	   CheckInput Request("HLSQLUser"),"string"
	   CheckInput Request("HLSQLDb"),"string"
	   CheckInput Request("HLSQLSource"),"string"
	   ConfigStr="<%"&vbcrlf  
	   ConfigStr=ConfigStr&"HLIntegration ="&Request("HLIntergration")&vbcrlf   
	   ConfigStr=ConfigStr&"HLAdminIntegration ="&Request("HLAdminIntegration")&vbcrlf   
	   ConfigStr=ConfigStr&"HLCode ="""&Request("HLCode")&""""&vbcrlf  
	   ConfigStr=ConfigStr&"HLVer ="""&Request("HLVer")&""""&vbcrlf  
	   ConfigStr=ConfigStr&"HLIsSQL ="""&Request("HLIsSQL")&""""&vbcrlf  
	   ConfigStr=ConfigStr&"HL_Url ="""&Request("HL_Url")&""""&vbcrlf  
	   ConfigStr=ConfigStr&"SecurityKey ="""&Request("SecurityKey")&""""&vbcrlf  
	   ConfigStr=ConfigStr&"AdminSecurityKey ="""&Request("AdminSecurityKey")&""""&vbcrlf  
	   ConfigStr=ConfigStr&"RegPageSet ="""&Request("RegPageSet")&""""&vbcrlf  
	   ConfigStr=ConfigStr&"Domainname ="""&Request("Domainname")&""""&vbcrlf 
	   ConfigStr=ConfigStr&"HLSQLUser ="""&Request("HLSQLUser")&""""&vbcrlf 
	   ConfigStr=ConfigStr&"HLSQLPass ="""&Request("HLSQLPass")&""""&vbcrlf 
	   ConfigStr=ConfigStr&"HLSQLDb ="""&Request("HLSQLDb")&""""&vbcrlf 
	   ConfigStr=ConfigStr&"HLSQLSource ="""&Request("HLSQLSource")&""""&vbcrlf 
	   ConfigStr=ConfigStr&"HLManageCode ="""&Request("HLManageCode")&""""&vbcrlf
	   ConfigStr=ConfigStr&"%"&">"&vbcrlf  
	   Set objCountFile=objFSO.CreateTextFile(Server.MapPath("HoWaveConfig.asp"),True) 
	   objCountFile.Write ConfigStr
	   objCountFile.Close
	   Set objCountFile=Nothing
	   Response.Write "<script>alert('修改成功')</script>"	
End Sub
	
Sub ReadConfig()
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")  
    Set objCountFile = objFSO.OpenTextFile(Server.MapPath("HoWaveConfig.asp"),1,True)
    If Not objCountFile.AtEndOfStream Then fdata = objCountFile.ReadAll
    Dim ConfigDataArray,dataLen
    ConfigDataArray=split(fdata,vbcrlf)
    datalen=UBound(ConfigDataArray)
    for i=1 to datalen-2
	  ArrConfig = split(ConfigDataArray(i),"=")
	  ConfigVar(i)=Trim(ArrConfig(0))
	  ConfigItem(i)=Trim(ArrConfig(1))
    next
    Set objFSO = Nothing
	Num = datalen-2
End Sub	
	
	
Function ConfigName(Str)
	For i=0 to Num
		If Lcase(ConfigVar(i)) = Lcase(Str) Then
			ConfigName = ConfigItem(i)
		End If
	Next 
End Function

Sub ShowFrom()
%> 
<form action="HoWaveConfigSetup.asp?Action=Save" method="post">
   <table>
       <tr><td colspan="2" class="tableTitle">恒浪整合接口配置文件设置-----适用于ASP系统</td></tr>
      <tr>
	      <td class="tableTips"><b>开启前台整合</b><br />
		     若你需要整合你的网站的前台请选择是，若想还原整合，请选择否
		  </td>                                                                       
		  <td><input type="radio" name="HLIntergration" value="true" <%if ConfigName("HLIntegration")="true" then%>checked="checked"<%end if%>/>是<input type="radio" name="HLIntergration" <%if ConfigName("HLIntegration")="false" then%>checked="checked"<%end if%> value=false />否          </td>
	  </tr>	
	  <tr>
	      <td class="tableTips"><b>开启后台整合</b><br />
		     若你不需要整合网站的管理后台或者要关闭整合后台，请选择否。</td>
		  <td><input type="radio" name="HLAdminIntegration" value="true"  <%if ConfigName("HLAdminIntegration")="true" then%>checked="checked"<%end if%>/>是<input type="radio" name="HLAdminIntegration" value="false" <%if ConfigName("HLAdminIntegration")="false" then%>checked="checked"<%end if%>/>否          </td>
	  </tr> 	  
	  <tr>
	      <td class="tableTips"><b>系统编码</b><br />
		  查看你所使用的系统的编码，若不清楚，可以打开浏览器-->查看--->编码		  
		  </td>
		  <td>
		  <select name="HLCode">
		    <option value="gb2312" <%if ConfigName("HLCode")="""gb2312""" then%>selected="selected"<%end if%>>GB2312</option>
		    <option value="utf-8" <%if ConfigName("HLCode")="""utf-8""" then%>selected="selected"<%end if%>>Utf-8</option>		    
		  </select>		  
	     </td>
	  </tr>
	  <tr>
	      <td class="tableTips"><b>恒浪整合系统版本</b><br />
		    恒浪已经发布的系统版本有HoWaveIMSV4.X,HoWaveIMSV5.X 这两种系列
		  </td>
		  <td>
		  <select name="HLVer">
		    <option value="0"  <%if ConfigName("HLVer")="""0""" then%>selected="selected"<%end if%>>HoWaveIMSV4.X</option>
		    <option value="1"  <%if ConfigName("HLVer")="""1""" then%>selected="selected"<%end if%>>HoWaveIMSV5.X</option>		    
		  </select>
	     </td>
	  </tr>
	   <tr>
		  <td class="tableTips"><b>注册页面</b><br />
			为空则默认在本系统注册，不为空则在本系统的注册一律跳到你所填写的注册页面地址进行注册
		  </td>
		  <td><input type="text" name="RegPageSet" value=<%=ConfigName("RegPageSet")%>/></td>
	  </tr>
	  <tr>
	      <td class="tableTips"><b>恒浪数据库版本</b><br />	
		    若你的数据库版本是SQL版本，则以下的整合配置将会直接读取恒浪数据库的设置.	     
		  </td>
		  <td><input type="radio" name="HLIsSQL" value="0" onclick="ShowSQL('0')"  <%if ConfigName("HLIsSQL")="""0""" then%>checked="checked"<%end if%> />Access<input type="radio" name="HLIsSQL" value="1" <%if ConfigName("HLIsSQL")="""1""" then%>checked="checked"<%end if%> onclick="ShowSQL('1')"/>SQL
		   
		  </td>
	  </tr>
	 
	  <tr id="SQLSet">
	     <td class="tableTips">恒浪SQL数据库配置</td>
		 <td>		  
		    SQL数据库帐号<input type="text" name="HLSQLUser" value=<%=ConfigName("HLSQLUser")%>/><br/>
			SQL数据库密码<input type="text" name="HLSQLPass" value=<%=ConfigName("HLSQLPass")%>/><br/>
			SQL数据库名称<input type="text" name="HLSQLDb" value=<%=ConfigName("HLSQLDb")%>/><br/>
			SQL数据库地址<input type="text" name="HLSQLSource" value=<%=ConfigName("HLSQLSource")%>/><br/>		 
		 </td>
	  </tr>	 	
	  <tr id="AccessSet">
	     <td colspan="2">
			<table style="border:0" >
			  <tr>
				  <td class="tableTips"><b>恒浪主站URL</b><br />
					恒浪整合系统所在的网站URL，(若恒浪放在二级目录，则需要加上二级目录)以"/"结尾,后面无须加"manage"或"passport"
				  </td>
				<td><input type="text" name="HL_Url" value=<%=ConfigName("HL_Url")%> /></td>
			  </tr>
			  <tr>
				  <td class="tableTips"><b>前台密钥</b><br />
					 整合网站的前台密钥，这个密钥必须跟恒浪整合管理系统后台设置的网站前台密钥相同！
				  </td>
				  <td><input type="text" name="SecurityKey" value=<%=ConfigName("SecurityKey")%>/></td>
			  </tr>
			  <tr>
				  <td class="tableTips"><b>后台密钥</b><br />
					 整合网站的后台密钥，这个密钥必须跟恒浪整合管理系统后台设置的网站后台密钥相同！
				  </td>
				  <td><input type="text" name="AdminSecurityKey" value=<%=ConfigName("AdminSecurityKey")%> /></td>
			  </tr>			
			   <tr>
				  <td class="tableTips"><b>根域名</b><br />
					若你的网站是作为一个二级域名来整合的，请填写网站的根域名。<br />
					如http://www.howave.net/则填写根域名为howave.net<br />
					如http://www.sina.com.cn/则填写根域名为sina.com.cn<br />
				  </td>
				  <td><input type="text" name="Domainname" value=<%=ConfigName("Domainname")%>/></td>
			  </tr>
			</table>
		  </td>
	  <tr>	  	
	  <tr>
	      <td class="tableTips"><b>管理认证码</b><br />
		   用于设置整合接口身份认证，请更改默认值，易免被他人盗用！
		  </td>
		  <td><input type="text" name="HLManageCode" value=<%=ConfigName("HLManageCode")%>/></td>
	  </tr>	 
	   <tr>
	      <td  colspan="2" style="text-align:center;"><input type="submit" value="确定" />&nbsp;&nbsp;<input type="reset" value="取消"/><br /><br />
		  注意：请确保该HoWaveConfig.asp文件具有可写权限，否则将会出错！
		  </td>		  
	  </tr>
	</table>
	<div class="tableTitle" style=" line-height:150%">欢迎使用,版本号:1.1　 2005-2008 Powered by <a href="http://www.howave.net">HoWave</a> Inc. </div>  
</form>
<%End Sub%>

<script type="text/javascript">
ShowSQL(<%=ConfigItem(5)%>);
function ShowSQL(dbtype)
{
  var Sqlobj=document.getElementById("SQLSet");
  var Acobj=document.getElementById("AccessSet");
  if(dbtype=="0")
  { Sqlobj.style.display="none";
    Acobj.style.display="";
  }
  else
  {
     Sqlobj.style.display="block";
	 Acobj.style.display="none";
   }
}
</script>
</body>
</html>
