<!--#includ file="../inc/config_conn_root.asp"-->
<%
'connclose
function geterror(info,location)
response.write "<script >alert("""&info&""");window.location="""&location&"""</script>"
response.end
end function

action=request("action")
select case action
case "regdll"
	dll=request("name")
	if dll<>"" then
		on error resume next
		Set oShell = CreateObject ("WScript.Shell")
		reg=oShell.Run("regsvr32 /s "&server.MapPath("../../DLL")&"\"&dll, 0, true)
		if err.number<>0 then
			set oShell =nothing
			geterror "组件"&dll&"注册失败，错误信息：<br>"&err.description,"?open=2"
		end if
		set oShell =nothing
		
		dim d
		if dll="FB_EM_SQL_Site.dll" then set d=server.CreateObject("FB_EM_SQL_Site.sitecheck")
		if dll="FB_EM_SQL_Cache.dll" then set d=Server.CreateObject("FB_EM_SQL_Cache.CacheHandle")
		session(dll)="ok"
		if err.number<>0 then
			set d =nothing
			geterror "组件"&dll&"注册完成，您需要重新启动IIS服务器！","?open=2"
		else
			set d =nothing
			geterror "组件"&dll&"注册完成，您需要重新启动IIS服务器！","?open=2"
		end if
	end if
case "dbconfig"
	dbserver=request.form("dbserver")
	dbname=request.form("dbname")
	dbuser=request.form("dbuser")
	dbpassword=request.form("dbpassword")
	
	if dbserver="" or dbname="" or dbuser="" or dbpassword="" then geterror "数据库配置的所有选项都必须填写！","?open=1"
	
	dim fs
	dim content
	
	Set fs=Server.CreateObject("Scripting.FileSystemObject")
	Set TS = fs.OpenTextFile(Server.MapPath("template_config_conn_root.asp")) 
	content=ts.readall
	set ts=nothing
	
	Set TS = fs.CreateTextFile(Server.MapPath("../inc/config_conn_root.asp"), True) 
	content=replace(content,"$dbserver$",dbserver)
	content=replace(content,"$dbname$",dbname)
	content=replace(content,"$dbuser$",dbuser)
	content=replace(content,"$dbpassword$",dbpassword)
	TS.write content
	Set TS = Nothing
	on error resume next

	Set conn = Server.CreateObject("ADODB.Connection")
	connstr="driver={SQl Server};server=("&dbserver&");uid="&dbuser&";pwd="&dbpassword&";database="&dbname&" "
	conn.Open connstr

	if err.number<>0 then 
		set conn=nothing		
		geterror "数据库连接不可用！错误信息：\n"&err.description,"?open=1"
	else
		session("sqlconn")="ok"
		Application.Lock()
		Application("FB_EM_1_SQL_connstr")=connstr
		Application.UnLock()
		conn.close
		set conn=nothing
		geterror "数据库连接建立成功！","?open=2"
	end if
	
case "delete"
	response.Redirect "../delete.asp"

end select

%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>eMart 网店系统 V1.0 SqlServer版安装</title>
<link rel="stylesheet" href="../inc/css/admin_style.css" type="text/css">
</head>
<body topmargin="0" marginwidth="0" marginheight="0" leftmargin="0" rightmargin="0" bottommargin="0">
<%
dim menu(3)
dim menu_o(3)
menu(0)="数据库安装"
menu(1)="数据库配置"
menu(2)="系统组件安装"
menu(3)="删除安装文件"
'menu(4)="其他设置"
menu_open=request("open")
if menu_open="" then menu_open=0
%>
<style>
table{
font-family:"Courier New", Courier, mono

}

</style>
<SCRIPT language=javascript>
	function opencat(cat)
	{
 	 	if(cat.style.display=="none"){
     	cat.style.display="";
  		} else {
     	cat.style.display="none"; 
  		}
	}
	
</SCRIPT>

<table cellpadding="0" cellspacing="0" width="100%" height="100%">
	<!-- MSTableType="nolayout" -->
	<tr>
		<td height="48" bgcolor="#014E82" style="padding: 5px" colspan="3" ><font color=#ffffff>　·eMart 网店系统 V1.0 SqlServer版安装</font></td>
	</tr>
	<tr>
		<td height="6" bgcolor="#5E8FB0" colspan="3"></td>
	</tr>
	<tr>
		<td width="160" bgcolor="#A3BFD2" rowspan="2">
		<table cellpadding="0" cellspacing="0" width="100%" height="100%">
			<!-- MSTableType="nolayout" -->
			<tr>
				<td height="60" width="100%" colspan="2">　</td>
			</tr>
			<%for i=0 to ubound(menu)%>
			<tr>
				<td height="33" width="6%">　</td>
				<td height="33" width="94%" background="Images/menu_yes.gif" style="padding-left: 30px">
				<a href='index.asp?open=<%=i%>'>
				<%=menu(i)%>
				</a>
				</td>
			</tr>
			<tr>
				<td height="5" width="100%" colspan="2"></td>
			</tr>
			<%
			if menu_open-i=0 then menu_o(i)="" else menu_o(i)="none"
			next
			%>
			<tr>
				<td  width="100%" colspan="2">　</td>
			</tr>
		</table>
		</td>
		
		<td valign=top>
			<table cellspacing="0" cellpadding="0" >
			<tr bgcolor="#A3BFD2" bgcolor="#A3BFD2" >
				<td >
				<div id=menu align="center" style='width:212px;height:28px; padding-top:12px;background-image=url(Images/chanle.gif)'> 
				+ <%=menu(menu_open)%> +</nobr>
				</div>
				</td>
				<td width="800"  bgcolor="#A3BFD2">　</td>
		    </tr>
		    <tr>
				<td height="518" bgcolor="#FFFFFF" colspan="2">
				<table cellpadding="0" cellspacing="0" width="100%" height="100%">
					<!-- MSTableType="nolayout" -->
					<tr>
						<td height="100%" width="100%" valign= top>
						<div id=m_0 style='display:<%=menu_o(0)%>'>
<!--#include file="install_db.asp" -->
						</div>
						
						<div id=m_1 style='display:<%=menu_o(1)%>' >
<!--#include file="install_db_config.asp" -->
						</div>
						
						<div id=m_2 style='display:<%=menu_o(2)%>' >
<!--#include file="install_dll.asp" -->
						</div>
						
						<div id=m_3 style='display:<%=menu_o(3)%>' >
<!--#include file="install_done.asp" -->
						</div>


						</td>
					</tr>
				</table>
				</td>
		    </tr>
	  </table>      </td>
	</tr>
</table>
<SCRIPT language=javascript>

	function menushow(m,i){
		document.getElementById("menu").innerHTML=m;
		for(var ii=0 ;ii< 3;ii++)
			if (ii==i)
				document.getElementById("m_"+ii).style.display="";
			else
				document.getElementById("m_"+ii).style.display="none";
	}
	
</SCRIPT>

</body>

