<%@ LANGUAGE = VBScript CodePage = 936%>
<!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>ACTCMS安装程序</title>
<link href="css.css" rel="stylesheet" type="text/css" />
<!--#include file="../act_Inc/Md5.asp"-->
</head>
<body>
<%
	response.buffer=true
	session.codepage=936
	response.charset="gb2312"



	Dim A,SysSetting,helpjs,Fso
	A=request("A")

	Set Fso = Server.CreateObject("scripting.FileSystemObject")
	If Fso.FileExists(Server.MapPath("../ACT_inc/lock/Install.lock")) Then Response.Write "您已经安装过ACTCMS,如果需要重新安装，请删除 ACT_inc/lock/Install.lock 文件！" : Response.End
	Set Fso = Nothing

	Select Case A
		Case "1"
			Call main()
		Case "2"
			Call seting()
		Case "3"
			Call save()
		Case Else 
			Call main()
	End Select 

Sub save()
	If request("webname")="" Then 
		 Response.Write ("<script>alert('错误提示:\n\n网站名称不能为空!');history.back();</script>")
	 	 response.End 
	End If 

	If request("webtitle")="" Then 
		 Response.Write ("<script>alert('错误提示:\n\n网站标题不能为空!');history.back();</script>")
	 	 response.End 
	End If 

	If request("webadmin")="" Then 
		 Response.Write ("<script>alert('错误提示:\n\n站长姓名不能为空!');history.back();</script>")
	 	 response.End 
	End If 

	If request("adminmail")="" Then 
		 Response.Write ("<script>alert('错误提示:\n\n管理员信箱不能为空!');history.back();</script>")
	 	 response.End 
	End If 
	If request("loginname")="" Then 
		 Response.Write ("<script>alert('错误提示:\n\n登录帐号不能为空!');history.back();</script>")
	 	 response.End 
	End If 
	If request("password")="" Then 
		 Response.Write ("<script>alert('错误提示:\n\n登录密码不能为空!');history.back();</script>")
	 	 response.End 
	End If 
	If request("admindir")="" Then 
		 Response.Write ("<script>alert('错误提示:\n\n后台目录不能为空!');history.back();</script>")
	 	 response.End 
	End If 
	
	If request("webhc")="" Then 
		 Response.Write ("<script>alert('错误提示:\n\n缓存名称不能为空!');history.back();</script>")
	 	 response.End 
	End If 
	db = "../"&request("webdb")&"" 'ACCESS数据库的文件名，请使用相对于网站根目录的的绝对路径
	Connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
	'On Error Resume Next
	Set Conn = Server.CreateObject("ADODB.Connection")
	Conn.Open Connstr
	If Err Then
		Err.Clear
		Set Conn = Nothing
		Response.Write "数据库连接出错， [<a href=""http://www.actcms.com/install.htm"">Help</a>]"
		Response.End
	End If
	SysSetting=""&request("webname")&"^@$@^"&request("webtitle")&"^@$@^"&request("AutoDomain")&"^@$@^"&request("InstallDir")&"^@$@^index.asp^@$@^images/logo.gif^@$@^"&request("webadmin")&"^@$@^"&request("adminmail")&"^@$@^"&request("admindir")&"^@$@^"&request("InstallDir")&"templets/Index.htm^@$@^1024^@$@^jpg|gif|bmp|png|swf|rar|exe^@$@^0^@$@^0^@$@^1^@$@^1^@$@^admin|manager|actcms|user|管理员|网站管理员|左岸^@$@^"&request("InstallDir")&"templets/reg.htm^@$@^"&request("InstallDir")&"templets/reglist.htm^@$@^"

	Set Rs=server.CreateObject("adodb.recordset") 
	Rs.OPen "Select ActCMS_SysSetting,helpjs from Config_ACT",Conn,1,3
	Rs("ActCMS_SysSetting")=CStr(SysSetting)
	helpjs=Rs("helpjs")
	Rs.Update
	Rs.close 
	
	Set Rs=server.CreateObject("adodb.recordset") 
	Rs.OPen "Select * from Admin_ACT Where Id =1",Conn,1,3
	Rs("Admin_Name")=request("loginname")
	Rs("PassWord")=md5(request("password"))
	Rs.Update
	Call FSOSaveFile(Replace(helpjs,"{ACTCMS}",request("InstallDir")),request("InstallDir")&"ACT_inc/ActHelp.js")	
	Dim Connfile
	Connfile = "<" & "%" &"@ LANGUAGE = VBScript CodePage = 936"& "%" & ">"& vbCrLf
	Connfile = Connfile &  "<" & "%" & vbCrLf
	Connfile = Connfile &  "Option Explicit" & vbCrLf
	Connfile = Connfile &  "response.buffer=true" & vbCrLf
	Connfile = Connfile &  "session.codepage=936" & vbCrLf
	Connfile = Connfile &  "response.charset=""gb2312""" & vbCrLf
	Connfile = Connfile &  "Dim Conn,db,MyDbPath,startime" & vbCrLf
	Connfile = Connfile &  "Const isSqlDataBase = 0" & vbCrLf
	Connfile = Connfile &  "Const MsxmlVersion="".3.0""  '系统采用XML版本设置" & vbCrLf
	Connfile = Connfile &  "Const AcTCMSN="""&request("webhc")&"""'系统缓存名称.在一个URL下安装多个ACTCMS请设置不同名称" & vbCrLf
	Connfile = Connfile &  "Dim NowString,ConnStr" & vbCrLf
	Connfile = Connfile &  "NowString = ""Now()""" & vbCrLf
	Connfile = Connfile &  "startime = Timer()" & vbCrLf& vbCrLf
	Connfile = Connfile &  "MyDbPath ="""&request("InstallDir")&"""'系统安装目录,如在虚拟目录下安装.请填写 /虚拟目录名称/" & vbCrLf
	Connfile = Connfile &  "db = """&request("webdb")&""" 'ACCESS数据库的文件名" & vbCrLf
	Connfile = Connfile &  "Connstr = ""Provider=Microsoft.Jet.OLEDB.4.0;Data Source="" & Server.MapPath(MyDbPath & db)" & vbCrLf
	Connfile = Connfile &  "Sub ConnectionDatabase()" & vbCrLf
	Connfile = Connfile &  "	On Error Resume Next" & vbCrLf
	Connfile = Connfile &  "	Set Conn = Server.CreateObject(""ADODB.Connection"")" & vbCrLf
	Connfile = Connfile &  "	Conn.Open Connstr" & vbCrLf
	Connfile = Connfile &  "	If Err Then" & vbCrLf
	Connfile = Connfile &  "		Err.Clear" & vbCrLf
	Connfile = Connfile &  "		Set Conn = Nothing" & vbCrLf
	Connfile = Connfile &  "		Response.Write ""数据库连接出错，请检查Conn.asp文件中的数据库参数设置 [<a href=http://www.actcms.com/install.htm>Help</a>] &nbsp;[<a href='install/index.asp'>点击安装</a>]""" & vbCrLf
	Connfile = Connfile &  "		Response.End" & vbCrLf
	Connfile = Connfile &  "	End If" & vbCrLf
	Connfile = Connfile &  "End Sub" & vbCrLf& vbCrLf
	Connfile = Connfile &  "Sub CloseConn()" & vbCrLf
	Connfile = Connfile &  "	On Error Resume Next" & vbCrLf
	Connfile = Connfile &  "	If IsObject(Conn) Then" & vbCrLf
	Connfile = Connfile &  "		Conn.Close:Set Conn = Nothing" & vbCrLf
	Connfile = Connfile &  "	End If" & vbCrLf
	Connfile = Connfile &  "End Sub" & vbCrLf
	Connfile = Connfile &  "%" & ">" 


	Dim adminfile
		adminfile = adminfile &  "<" & "%" & vbCrLf
		adminfile = adminfile &  "Const CheckCode="& request("yzm")&"  '是否启用后台管理验证码 是： True  否： False " & vbCrLf
		adminfile = adminfile &  "Const CheckManageCode="& request("rzm")&"  '是否启用后台管理认证码 是： True  否： False " & vbCrLf
		adminfile = adminfile &  "Const CheckManageCodeContent="""& request("glrzm")&"""  '后台管理认证码，请修改，这样即使有人知道了您的后台用户名和密码也不能登录后台 " & vbCrLf
		adminfile = adminfile &  "%" & ">" 

	Call FSOSaveFile(Connfile,request("InstallDir")&"Conn.asp")	
	Call FSOSaveFile(adminfile,request("InstallDir")&request("admindir")&"/CheckCode.asp")	
	Call FSOSaveFile("Powered By www.actcms.com 系统安装时间"&Now()&"",request("InstallDir")&"act_inc/lock/Install.lock")	
	Application.Contents.RemoveAll
   Response.Write ("<script language=""Javascript""> alert('系统安装成功,点击确定进入后台');location.href='" & request("InstallDir")&request("admindir")&"/Login.asp" & "';</script>")
End Sub 


Function FSOSaveFile(Templetcontent,FileName)
	On Error Resume Next
	Dim FileFSO,FileType
	 Set FileFSO = Server.CreateObject("ADODB.Stream")
		With FileFSO
		.Type = 2
		.Mode = 3
		.Open
		.Charset = "gb2312"
		.Position = FileFSO.Size
		.WriteText  Templetcontent&	 vbcrlf 
		.SaveToFile Server.MapPath(FileName),2
		.Close
		End With
	Set FileType = nothing
	Set FileFSO = nothing
End Function

Sub main
%>
<table width="830" border="0" align="center" cellpadding="0" cellspacing="0" >
  <tr>
    <td align="center">〓 许可协议 〓</td>
  </tr>
  <tr>
    <td>
	<div class="pact">
            <p>本软件是自由软件，遵循 Apache License 2.0 许可协议 &lt;<a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">http://www.apache.org/licenses/LICENSE-2.0</a>&gt;<p>
            <p>本软件的版权归 ACTCMS官方 所有，且受《中华人民共和国计算机软件保护条例》等知识产权法律及国际条约与惯例的保护。<p>
            <p>本协议适用且仅适用于 ACTCMS 2.x 版本，ACTCMS官方拥有对本协议的最终解释权。<p>
            <p>无论个人或组织、盈利与否、用途如何（包括以学习和研究为目的），均需仔细阅读本协议，在理解、同意、并遵守本协议的全部条款后，方可开始使用本软件。<p>
            <h4><strong>一、协议许可和限制</strong></h4>
            <ol>
              <p>1、未经作者书面许可，不得衍生出私有软件。<p>
              <p>2、不管首页是否以ACTCMS系统生成，网站首页最下面保留清晰可见的支持信息并链接到ACTCMS站，不得以友情链接等方式代替，若网站性质等因素所限，不适合保留支持信息，请和作者签订《ACTCMS 2.0授权合同》<p>
              <p>3、您拥有使用本软件构建的网站全部内容所有权，并独立承担与这些内容的相关法律义务。<p>
              <p>4、未经官方许可，禁止在 ACTCMS 的整体或任何部分基础上以发展任何派生版本、修改版本或第三方版本用于重新分发<p>
              <p>5、您将本软件应用在商业用途时，需遵守以下几条：
      <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1、使用本软件建设网站时，无需支付使用费用，但需保留ACTCMS支持链接信息。<p>
                  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2、本源码可以用在商业用途，但不可以更名销售，若有OEM需求，请和作者联系。<p>
                  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3、若网站性质等因素所限，不适合保留支持信息，请与作者联系取得书面授权。<p>
				  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4、使用者所生成的网站，首页要包含软件的版权信息；不得对后台版权进行修改。<p>
              <p>
            <h4><strong>二、有限担保和免责声明</strong></h4>
              <p>1、本软件及所附带的文件是作为不提供任何明确的或隐含的赔偿或担保的形式提供的。<p>
              <p>2、用户出于自愿而使用本软件，您必须了解使用本软件的风险，在尚未购买产品技术服务之前，我们不承诺提供任何形式的技术支持、使用担保，也不承担任何因使用本软件而产生问题的相关责任。<p>
              <p>3、ACTCMS官方不对使用本软件构建的网站中的文章或信息承担责任。<p>
            <br>
            <p>本协议保留作者的版权信息在许可协议文本之内，不得擅自修改其信息。</p>
            <p>2008-3，第1.0版 (ACTCMS官方保留对此许可协议的更新及解释权力)<br />
           &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;协议著作权所有 &copy; ACTCMS.com&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; 软件版权所有 &copy; ACTCMS.com</p>
            <p>
	</td>
  </tr>
  <tr>
    <td>
<div class="readpact boxcenter">
	<input name="readpact" type="checkbox" id="readpact" value="" /><label for="readpact"><strong>我已经阅读并同意此协议</strong></label>
</div>
<div class="butbox boxcenter">
	<input type="button" class="nextbut" value="" onclick="document.getElementById('readpact').checked ?window.location.href='index.asp?A=2' : alert('您必须同意软件许可协议才能安装！');" />
</div>
	</td>
  </tr>
</table>
<%End Sub 
	Public Function AutoDomain()
		Dim TempPath
		If Request.ServerVariables("SERVER_PORT") = "80" Then
			AutoDomain = Request.ServerVariables("SERVER_NAME")
		Else
			AutoDomain = Request.ServerVariables("SERVER_NAME") & ":" & Request.ServerVariables("SERVER_PORT")
		End If
		 If Instr(UCASE(AutoDomain),"/W3SVC")<>0 Then
			   AutoDomain=Left(AutoDomain,Instr(AutoDomain,"/W3SVC"))
		 End If
		 AutoDomain = "http://" & AutoDomain
	End Function
Sub seting()
	dim strDir,strAdminDir,InstallDir
	strDir=Trim(request.ServerVariables("SCRIPT_NAME"))
	strAdminDir=split(strDir,"/")(Ubound(split(strDir,"/"))-1) & "/"
	InstallDir=left(strDir,instr(lcase(strDir),"/"&Lcase(strAdminDir)))
	
	If Instr(UCASE(InstallDir),"/W3SVC")<>0 Then
	   InstallDir=Left(InstallDir,Instr(InstallDir,"/W3SVC"))
	End If

 %>
<form id="form1" name="form1" method="post" action="index.asp?A=3">
  <table width="700" border="0" align="center" cellpadding="0" cellspacing="0"  class="twbox">
    <tr  onmouseover="overColor(this)" onmouseout="outColor(this)">
      <td colspan="2" align="center">ACTCMS 2.0Beta1-系统安装</td>
    </tr>
    <tr onmouseover="overColor(this)" onmouseout="outColor(this)">
      <td width="260" align="right"><strong>网站名称：</strong></td>
      <td width="528"><input name="webname" type="text" id="webname" value="我的网站" class="textipt" style="width:150px" /></td>
    </tr>

    <tr onmouseover="overColor(this)" onmouseout="outColor(this)">
      <td width="260" align="right"><strong>网站标题：</strong></td>
      <td width="528"><input name="webtitle" type="text" id="webtitle" value="我的网站"  class="textipt" style="width:150px" /></td>
    </tr>

    <tr onmouseover="overColor(this)" onmouseout="outColor(this)">
      <td width="260" align="right"><strong>站长姓名：</strong></td>
      <td width="528"><input name="webadmin" type="text" id="webadmin" value="左岸"  class="textipt" style="width:150px" /></td>
    </tr>

    <tr onmouseover="overColor(this)" onmouseout="outColor(this)">
      <td width="260" align="right"><strong>管理员信箱：</strong></td>
      <td><input name="adminmail" type="text" id="adminmail" class="textipt" value="admin@yourmail.com" style="width:150px" /></td>
    </tr>
    <tr onmouseover="overColor(this)" onmouseout="outColor(this)">
      <td width="260" align="right"><strong>网站网址：</strong></td>
      <td><input name="AutoDomain" type="text" class="textipt" id="AutoDomain" style="width:150px" value="<%=AutoDomain%>" /></td>
    </tr>
    <tr onmouseover="overColor(this)" onmouseout="outColor(this)">
      <td width="260" align="right"><strong>CMS安装目录：</strong></td>
      <td><input name="InstallDir" type="text" class="textipt" id="InstallDir" style="width:150px" value="<%=InstallDir%>" /></td>
    </tr>
    <tr onmouseover="overColor(this)" onmouseout="outColor(this)">
      <td width="260" align="right"><strong>后台目录：</strong></td>
      <td><input name="admindir" type="text" class="textipt" id="admindir" style="width:150px" value="admin" />
	  请确认是否有该文件夹</td>
    </tr>

    <tr onmouseover="overColor(this)" onmouseout="outColor(this)">
      <td width="260" align="right"><strong>缓存名称：</strong></td>
      <td><input name="webhc" type="text" class="textipt" id="webhc" style="width:150px" value="AcTCMSN" />
	  系统缓存名称.在一个URL下安装多个ACTCMS请设置不同名称</td>
    </tr>

	<tr onmouseover="overColor(this)" onmouseout="outColor(this)">
      <td width="260" align="right"><strong>后台登陆验证码：</strong></td>
      <td>
		<input Checked id="yzm1" type="radio" name="yzm" value="true">
		<label for="yzm1"><font color="green">正常 &nbsp;</font></label>
		<input  id="yzm2" type="radio" name="yzm" value="false">
		<label for="yzm2"><font color="red">关闭 &nbsp;</font></label>
	  </td>
    </tr>

	<tr onmouseover="overColor(this)" onmouseout="outColor(this)">
      <td width="260" align="right"><strong>后台登陆认证码：</strong></td>
      <td>
		<input Checked id="rzm1" type="radio" name="rzm" value="true"  onclick="glrzms.style.display='';" >
		<label for="rzm1"><font color="green">正常 &nbsp;</font></label>
		<input  id="rzm2" type="radio" name="rzm" value="false"  onclick="glrzms.style.display='none';">
		<label for="rzm2"><font color="red">关闭 &nbsp;</font></label>
	  </td>
    </tr>


    <tr id="glrzms" onmouseover="overColor(this)" onmouseout="outColor(this)">
      <td width="260" align="right"><strong>管理认证码：</strong></td>
      <td>
	  <input name="glrzm" type="text" class="textipt" id="glrzm" style="width:150px" value="actcms" />
	  请修改,这样即使有人知道了后台用户名和密码也不能登录后台</td>
    </tr>

	<tr onmouseover="overColor(this)" onmouseout="outColor(this)">
      <td width="260" align="right"><strong>数据库名称：</strong></td>
      <td><input name="webdb" type="text" class="textipt" id="webdb" style="width:150px" value="data_act/actcms.mdb" />
	  不需要加安装目录名称</td>
    </tr>

	<tr onmouseover="overColor(this)" onmouseout="outColor(this)">
      <td width="260" align="right"><strong>登录帐号：</strong></td>
      <td><input name="loginname" type="text" id="loginname" class="textipt" value="admin"  style="width:150px" /></td>
    </tr>
    <tr onmouseover="overColor(this)" onmouseout="outColor(this)">
      <td align="right"><strong>登录密码：</strong></td>
      <td><input name="password" type="text" id="password" class="textipt" value="admin888" style="width:150px" /></td>
    </tr>


    <tr onmouseover="overColor(this)" onmouseout="outColor(this)">
      <td colspan="2" align="right">
	  <div class="butbox boxcenter">
	<input type="button" class="backbut" value="" onclick="history.back();" style="margin-right:20px" />
	<input name="提交" type="submit" class="setupbut" value="" />
</div></td>
    </tr>
  </table>
</form>
<script language="JavaScript" type="text/javascript">
function overColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="td1"
		Obj.bgColor="";
	}
	
}

function outColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="td2";
		Obj.bgColor="";
	}
}
</script>

<%
End Sub 
%>
</body>
</html>
