<!--#include file="Inc/System.asp" -->
<!--#include file="Inc/Conn_DbFile.asp" -->
<!--#include file="Inc/MelyySoft.ReName.Asp" -->
<%
Dim Founderr,Errmsg,SucMsg
dim ObjName,ObjInstalled,Dir,InstallFile,Action
ObjName="Scripting.FileSystemObject"  'fso组建
InstallFile="inc/System.Asp"      '文件保存地址
GotoUrl="index.asp"                    '安装成功进入地址
ObjInstalled=IsObjInstalled(ObjName)
RegUrl=Request.ServerVariables("SERVER_NAME")
Dir=replace(lcase(Trim(request.ServerVariables("SCRIPT_NAME"))),"install.asp","")
Action=Trim(request("Action"))
MSProductName="MSCOM2007"  '系统名称
SysTemUrl="Http://www.melyysoft.com/"
MSSN="217740232140515176202340512076237728,217740232140515176504076375137513750,2177402321405151765088403750652737513750" '默认注册码localhost,192.168.0.1下免费使用
If CheckFolderExist("Install.Lock") then FoundErr=True:ErrMsg=ErrMsg+"<li>已执行安装，重复安装请删除Install.Lock"
%>
<html>
<head>
<title><%=MSProductName%>-安装向导</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script src="js/MyCalendar.js"></script>
<style type="text/css">
A:visited{TEXT-DECORATION: none;color: #336699;}
A:active{TEXT-DECORATION: none;color: #336699;}
A:link{text-decoration: none;color: #336699;}
A:hover {BORDER-BOTTOM: 1px dotted; BORDER-LEFT-WIDTH: 1px; BORDER-RIGHT-WIDTH: 1px; BORDER-TOP-WIDTH: 1px; COLOR: #ff6600; TEXT-DECORATION: none}
DIV,FORM,P,TD,BODY{FONT-SIZE:9pt;}
BODY{
margin-top: 5px;margin-bottom: 15px;
	background:#E7E7E7;
	SCROLLBAR-FACE-COLOR: #799AE1; 
	SCROLLBAR-HIGHLIGHT-COLOR: #799AE1; 
	SCROLLBAR-SHADOW-COLOR: #799AE1; 
	SCROLLBAR-DARKSHADOW-COLOR: #799AE1; 
	SCROLLBAR-3DLIGHT-COLOR: #799AE1; 
	SCROLLBAR-ARROW-COLOR: #FFFFFF;
	SCROLLBAR-TRACK-COLOR: #AABFEC;
	font-size: 12px;
	font-style: normal;
	line-height: 18px;
	font-weight: normal;
	font-variant: normal;
	text-transform: none;
	color: #000000;
	text-decoration: none;
	font-family: Verdana;
}
#TableTitleLink A:link,#TableTitleLink A:visited{COLOR:ff6600;}
INPUT1 {
	BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 12px; BORDER-BOTTOM-WIDTH: 1px; BORDER-RIGHT-WIDTH: 1px
}
TEXTAREA1 {
	BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 12px; BORDER-BOTTOM-WIDTH: 1px; BORDER-RIGHT-WIDTH: 1px
}
SELECT {
	BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; FONT-SIZE: 12px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px
}
.Tablebk{BORDER-RIGHT: #006699 1px solid;BORDER-TOP: #006699 1px solid;BORDER-LEFT: #006699 1px solid;BORDER-BOTTOM: #006699 1px solid;}
.Tablebg{height:23px;border-color:#FFFFFF;color:#FFFFFF;text-align:center;font-size: 12px;font-style: normal;font-weight:bold;}
.Tableinfo{background-color: #F1F3F5;height:22px;}
.Tablemain{background-color: #E4EDF9;height:22px;}
.button { 
background-color:#ffffff;
height=20;
font-size:12px;
border:#336699 1px solid
}
</style>
</head>
<body>
<script>
<!--
function winopen(){
var targeturl="<%=SysTemUrl&"Service/Crm/"%>"
newwin=window.open("","","scrollbars")
if (document.all){
newwin.moveTo(0,0)
newwin.resizeTo(screen.width,screen.height)
}
newwin.location=targeturl
}
function CheckStatus(){
var targeturl="Index.asp"
newwin=window.open("","","scrollbars")
if (document.all){
newwin.moveTo(0,0)
newwin.resizeTo(screen.width,screen.height)
}
newwin.location=targeturl
}
function GetRegType(T){
if (document.getElementById('IsLink').checked == true) {
	document.getElementById('ChkIsLink').style.display = '';
	document.getElementById('ChkNoLink').style.display = 'none';
}else{
	document.getElementById('ChkIsLink').style.display = 'none';
	document.getElementById('ChkNoLink').style.display = '';
}
}
//-->
  </script>
<%
If Not FoundErr then
	Dim AgreeLicense
	AgreeLicense = Session("AgreeLicense")
	If AgreeLicense = "" Then
		AgreeLicense = Trim(Request("AgreeLicense"))
		Session("AgreeLicense") = AgreeLicense
	End If
	If AgreeLicense <> "Yes" Then
		Call ShowLicense
		Response.End
	End If
	Select Case Action	
	Case "Setup2"
		Call Setup2()
	Case "Setup3"
		Call Setup3()
	Case else
		Call Setup1()			
	End Select
End If
If FoundErr then
  Call MS_AdminError(0,errmsg,0)
End if
Sub ShowLicense()
    Response.Write "<form name='myform' id='myform' method='POST' action='Install.Asp'>" & vbCrLf
    Response.Write "  <table width='80%' border='0' align='center' cellpadding='2' cellspacing='1' Class='tablebk'>" & vbCrLf
    Response.Write "    <tr class='tablemain'>" & vbCrLf
    Response.Write "      <td height='22' align='center'><strong>阅读许可协议</strong></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='TableInfo'>" & vbCrLf
    Response.Write "      <td align='center'><textarea name='License' cols='120' rows='30' id='License' readonly>"
%>
<!--#include file="License.txt"-->
<%
    Response.Write "</textarea></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='TableInfo'>" & vbCrLf
    Response.Write "      <td align='left'><input name='AgreeLicense' type='checkbox' id='AgreeLicense' value='Yes' onclick='document.myform.submit.disabled=!this.checked;'><label for='AgreeLicense'>我已经阅读并同意此协议</label></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr>" & vbCrLf
    Response.Write "      <td height='40' colspan='2' align='center' class='TableMain'>" & vbCrLf
    Response.Write "        <input name='submit' type='submit' id='submit' value=' 下一步 ' disabled>" & vbCrLf
    Response.Write "      </td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "  </table>" & vbCrLf
    Response.Write "</form>" & vbCrLf

End Sub 
sub Setup1()
%>
<form method="POST" action="Install.asp" id="form" name="form">
  <table width="80%" align="center" border="1" cellspacing="0" cellpadding="4" class=tablebk style="border-collapse: collapse">
    <tr class="tablemain"> 
      <td colspan="2"" align="center">安装向导</td>      
    </tr>
    <tr class="tableinfo"> 
      <td align="right" width="40%">系统目录：</td>
      <td><input name="installdir" type="text" value="<%=Dir%>" size="20" readonly />自动获得</td>
    </tr>
	<tr class="tableinfo"> 
      <td align="right" width="40%">产品英文名：</td>
      <td><input name="MSProductName" type="text" value="<%=MSProductName%>" size="20" readonly />自动获得</td>
    </tr>
    <%
If ObjInstalled=false Then
	Response.Write "<tr class='tablemain'><td height='40' colspan='3'><b><font color=red>你的服务器不支持 FSO(Scripting.FileSystemObject)! 不能使用本功能。<br>请直接修改“Inc/SysTem.asp”文件中的内容。</font></b></td></tr>"
	else%>
	<tr class="tableinfo"> 
      <td align="center" colspan="2">经检测，您的平台环境可以正常运行本系统。请进入下一步！</td>
    </tr>
	<tr class="tableMain">
      <td colspan="2" align="center">      
	    <input name="Action" type="hidden" id="Action" value="Setup2">
        <input name="cmdSave" type="submit" id="cmdSave" value="下一步">
		<input name="submit" type="reset" value="重置">
		</td>
    </tr>
<%	
End If
%>
  </table>
<%
end sub
%>
</form>
</body>
</html>
<%
sub Setup2()
	If ObjInstalled=false Then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>你的服务器不支持 "&ObjNmae&"! </li>"
		exit sub
	end if
	Installdir=trim(request.Form(("installdir")))
	MSVerSion=request.Form(("MSVerSion"))
	msregtype=request.Form(("regtype"))
	MSEndDate=Trim(request.Form(("MSEndDate")))
	If Installdir="" or MSProductName="" then
	    Founderr=true
		Errmsg=Errmsg+"<li>系统目录，产品名称为必填项，不能为空！"
		Exit Sub
	End if
	If not IsValidStr(MSProductName) then
	    Founderr=true
		Errmsg=Errmsg+"<li>产品名称必须是字母、数字或者两者的组合！"
		Exit Sub
	End If	   
	dim fso,hf
	set fso=Server.CreateObject(ObjName)
	set hf=fso.CreateTextFile(Server.mappath(InstallFile),true)
	hf.write "<" & "%" & vbcrlf
	hf.write "Dim Installdir,MSProductName,MSVersion"& vbcrlf
	hf.write "Installdir=" & chr(34) & Installdir & chr(34) & "     '系统目录" & vbcrlf
	hf.write "MSProductName=" & chr(34) & MSProductName & chr(34) & "     '产品名称！" & vbcrlf
	hf.write "%" & ">"
	hf.close
	set hf=nothing
	set fso=nothing
	Response.Redirect "?Action=Setup3"	
end sub
Sub Setup3()
%>
<%
Call CreateFile(Installdir&"Install.Lock","重复安装删除此文件")
If Founderr=true then response.write errmsg
%>
<table align="center" width="80%" align="center" border="1" cellspacing="0" cellpadding="4" class=Tablebk style="border-collapse: collapse">
  <tr align="center" class="tablemain"><td height="22"><strong>恭喜你！</strong></td></tr>
  <tr class="tableinfo"><td height="100" valign=top>系统安装完成！现在你可以使用系统了。<br>为了<font color="red">系统安全</font>，请点击下面的按钮删除此安装文件（Install.asp）<br></td></tr>
  <tr class="tablemain" align="center"><td height="22"><input type="button" onClick="winopen()" value="正版验证" name="button"><input type="button" onClick="CheckStatus()" value="检测安装状态" name="button">
  <input name="ok" type="button" value=" 进入首页 " onClick="location='Index.asp'"></td></tr>
</table>
<%
End Sub
'***************************************************
'函数名：IsObjInstalled
'作  用：检查组件是否已经安装
'参  数：strClassString ----组件名
'返回值：True  ----已经安装
'       False ----没有安装
'***************************************************
Function IsObjInstalled(strClassString)
	On Error Resume Next
	IsObjInstalled = False
	Err = 0
	Dim xTestObj
	Set xTestObj = Server.CreateObject(strClassString)
	If 0 = Err Then IsObjInstalled = True
	Set xTestObj = Nothing
	Err = 0
End Function

'=================================================
'作  用：管理错误提示页
'参  数：isAjax--------
'        Message----------提示内容
'        GotoUrl----------0为上一页(无刷新),1为上一页(刷新),其他为指定页
'web:    www.melyysoft.com MSCMS2.0 2007-12-06
'=================================================
Sub MS_Adminerror(IsAjax,Message,GoToUrl)
%>
<table align="center" width="80%" align="center" border="1" cellspacing="0" cellpadding="4" class=Tablebk style="border-collapse: collapse">
<tr> 
<td >
<table cellpadding=3 cellspacing=1 align=center width="100%">
<tr>
<td width="100%" height=25 align=center class=tablemain>错误提示</td>
</tr>
<tr>
<td width="100%" class=tableinfo><b>产生错误的可能原因：</b>
<font color="red"><%=Message%></font><li><a href="<%=SysTemUrl%>" target="_bank">其他未知错误，请从官方网站获得技术帮助!</a>
</td>
</tr>
<tr>
<td valign=middle align=center class=tablemain><a href="Javascript:history.back(-1)" ><<返回上一页(无刷新)</a><%if Gotourl=0 then%><%elseif Gotourl=1 then%> | <a href="<%=Request.ServerVariables("HTTP_REFERER")%>" ><<返回来源页(刷新模式)</a><%else%> | <a href="<%=Gotourl%>" ><<返回指定页面</a><%end if%></td>
</tr>
</table>
</td>
</tr>
</table>
<%
Response.end
end Sub
%>