<!--#include file="conn/conn.asp" -->
<!--#include file="conn/function.asp" -->
<%
version_info=ReadFromTextFile("admin/version.txt","utf-8")
Function ChkInvaildWord(Words) 
Const InvaildWords="'|;|<|>|-"
ChkInvaildWord=True 
InvaildWord=Split(InvaildWords,"|") 
inWords=LCase(Trim(Words)) 
For i=LBound(InvaildWord) To UBound(InvaildWord) 
If Instr(inWords,InvaildWord(i))>0 Then 
ChkInvaildWord=True 
Exit Function 
End If 
Next 
ChkInvaildWord=False 
End Function
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set template = FSO.GetFolder(Server.MapPath("./template/")).SubFolders
For Each F In template
t=t&F.name&"|"
Next
Set wap = FSO.GetFolder(Server.MapPath("./wap/")).SubFolders
For Each E In wap
w=w&E.name&"|"
Next
set FSO=nothing
%>
<!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=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>网站初始化设置</title>
<script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"> </script>
<link rel="stylesheet" href="http://apps.bdimg.com/libs/bootstrap/3.3.4/css/bootstrap.min.css" type="text/css" />
<style>
body{ background:url(admin/images/login_bgx.gif); font-family:"微软雅黑"; font-size:12px;}
.div{position:absolute;left: 50%;top:100px;margin: 0 0px 100px -300px;padding:0 20px 20px 20px;overflow:hidden;width:600px; text-align:center;box-shadow:0px 0px 20px #999999; background:url(images/install_top.png) no-repeat;background-color:#FFFFFF; }
.input1 {border-top:1px solid #ABADB3;border-left:1px solid #ABADB3;border-right:1px solid #ddd;border-bottom:1px solid #ddd;height:24px;width:300px;padding:0 5px;}
.input2 {border:1px solid #FFB334;outline:2px solid #ffdc97;*border:2px solid #FFB334;*padding:2px 5px;height:24px;width:300px;padding:0 5px;}
.submit{ width:131px;height:34px; border:hidden; font-family:"微软雅黑";color:#FFFFFF;background-image:url(images/btn.png);cursor:hand;font-size:15px; margin-top:10px;}
.submit2{ width:131px;height:34px; border:hidden; font-family:"微软雅黑";color:#FFFFFF;background-image:url(images/btn2.png);cursor:hand;font-size:15px;margin-top:10px;}
input[type="radio"]{display:none;}
label{border:#AAAAAA solid 2px;border-radius:3px;color:#AAAAAA;padding: 3px;margin: 0 5px;}
.checked{border:#0099ff solid 2px;border-radius:3px;color:#0099ff;padding: 3px;margin: 0 5px;}
</style>
</head>
<body>
<div id="ie"></div>
<script>
var ie = !+'\v1';
if(ie){
document.getElementById("ie").innerHTML="<div style='background:#FF9900; height:25px;padding:4px 10px 0 10px; color:#FFFFFF;text-align:center;'>您当前浏览器版本过低，请先升级！（请使用IE9或以上、谷歌浏览器、其他浏览器的急速模式）</div>";
}
</script>
<%
C_installdir=split(Request.ServerVariables("PATH_INFO"),"install.asp")(0)
if C_first="" then
call box("您的网站没有开启读取权限，请先到IIS设置！","index.asp","error")
end if

if C_first="0" then
call box("网站已安装完成，无需再次安装！","index.asp","error")
end if
action=Server.URLEncode(Request.QueryString("action"))
if action="save" then
database=Request.Form("database")
select case database 
case "access"

	sitename1=Request.Form("sitename1")
	A_login1=Request.Form("A_login1")
	A_pwd1=md5(Request.Form("A_pwd1"))
	database1=split(Request.Form("database1"),".")(0)
	admin_dir1=Request.Form("admin_dir1")
	web_dir1=Request.Form("web_dir1")
	session("set_login")=Request.Form("A_login1")
	session("set_pwd")=Request.Form("A_pwd1")
	
	if ChkInvaildWord(Request.Form("A_login1")) or ChkInvaildWord(Request.Form("A_pwd1")) then
	call box("用户名或密码设置包含敏感字符，请重新设置!","back","error")
	end if
	
	if Request.Form("A_login1")="" then
	call box("管理员账户未设置！","back","error")
	end if
	
	if Request.Form("A_pwd1")="" then
	call box("管理员密码未设置！","back","error")
	end if
	
	sql="Update SL_config set C_title='"&sitename1&"/l/your website',C_admin='"&admin_dir1&"',C_first=0,C_time='"&now()&"',C_dir='"&web_dir1&"'"
	conn.execute(sql)
	conn.execute("delete from SL_admin")
	conn.execute("Insert into SL_admin(A_login,A_pwd,A_part) values('"&A_login1&"','"&A_pwd1&"','1|1|1|1|1|1|1|1|1|1|1|1|1|1|1')")
	conn.close()
   set conn=nothing

olddatabase="data/#data.mdb"
newdatabase="data/"&database1&".mdb"

conn1=ReadFromTextFile ("conn/conn.asp","utf-8")
conn1=replace(conn1,olddatabase,newdatabase)
call WriteToTextFile("conn/conn.asp",conn1,"utf-8")  

conn2=ReadFromTextFile ("conn/conn2.asp","utf-8")
conn2=replace(conn2,olddatabase,newdatabase)
call WriteToTextFile("conn/conn2.asp",conn2,"utf-8")  

    Set fsox = CreateObject("scripting.filesystemobject")
	fsox.GetFile(Server.MapPath("data/#data.mdb")).name=database1&".mdb"
	fsox.GetFolder(Server.MapPath("admin")).name=admin_dir1
	
	Set fsox=nothing
	call box("网站安装成功！",admin_dir1,"success")
case "sql"
sitename2=Request.Form("sitename2")
A_login2=Request.Form("A_login2")
A_pwd2=md5(Request.Form("A_pwd2"))
admin_dir2=Request.Form("admin_dir2")
web_dir2=Request.Form("web_dir2")
session("set_login")=Request.Form("A_login2")
session("set_pwd")=Request.Form("A_pwd2")
dbserver=Request.Form("dbserver")
dbname=Request.Form("dbname")
dbusername=Request.Form("dbusername")
dbpassword=Request.Form("dbpassword")
	if ChkInvaildWord(Request.Form("A_login2")) or ChkInvaildWord(Request.Form("A_pwd2")) then
	call box("用户名或密码设置包含敏感字符，请重新设置!","back","error")
	end if
	
		if Request.Form("A_login2")="" then
	call box("管理员账户未设置！","back","error")
	end if
	
		if Request.Form("A_pwd2")="" then
	call box("管理员密码未设置！","back","error")
	end if
on error resume next
connstr2="driver={SQL Server};server="&dbserver&";uid="&dbusername&";pwd="&dbpassword&";database="&dbname
Set objConn=Server.CreateObject("ADODB.Connection") 
objConn.Open connstr2
If Err Then
err.Clear
Set Conn = Nothing
Response.Write("<p>抱歉，连接数据库失败！</p><p>您提供的数据库用户名和密码可能不正确，或者无法连接到您的数据库服务器，这意味着您的主机数据库服务器已停止工作。</p><p><ul><li>您确认您提供的用户名和密码正确么？</li><li>您确认您提供的主机名正确么？</li><li>您确认数据库服务器运行正常么？</li><li>您确认您购买的数据库是MSSQL而不是MYSQL么？</li></ul></p><p>请您联系您的空间商寻求帮助！</p><div id='bottom'><input type=""button"" name=""next"" onClick=""history.go(-1)"" id=""netx"" value=""返回"" /></div>")
Response.End
End If
sql=split(ReadFromTextFile("sql.txt","utf-8"),vbCrLf)
for i=0 to ubound(sql)
objConn.execute(sql(i))
If Err.Number<>0 Then
Err.Clear
End If
next
objConn.execute("update SL_admin set A_login='"&A_login2&"',A_pwd='"&A_pwd2&"'")
objConn.execute("Update SL_config set C_db='mssql',C_template='"&split(t,"|")(0)&"',C_wap='"&split(w,"|")(0)&"',C_title='"&sitename2&"/l/Your Website',C_admin='"&admin_dir2&"',C_first=0,C_time='"&now()&"',C_dir='"&web_dir2&"'")
objConn.close()
set objConn=nothing
olddatabase="connstr=""Provider=Microsoft.Jet.OLEDB.4.0;Data Source="" & Server.MapPath(mdb)&"";Jet OLEDB:Database Password=anchen,./"""
newdatabase="connstr=""driver={SQL Server};server="&dbserver&";uid="&dbusername&";pwd="&dbpassword&";database="&dbname&""" "
conn1=ReadFromTextFile ("conn/conn.asp","utf-8")
conn1=replace(conn1,olddatabase,newdatabase)
call WriteToTextFile("conn/conn.asp",conn1,"utf-8")  
conn2=ReadFromTextFile ("conn/conn2.asp","utf-8")
conn2=replace(conn2,olddatabase,newdatabase)
call WriteToTextFile("conn/conn2.asp",conn2,"utf-8")  
    Set fsox = CreateObject("scripting.filesystemobject")
	fsox.GetFolder(Server.MapPath("admin")).name=admin_dir2
	Set fsox=nothing
	call box("网站安装成功！",admin_dir2,"success")
end select
end if
if request.QueryString("step")=0 or request.QueryString("step")=""  then
%>
<div class="div" >
<p style="font-size:25px; color:#FFF; height:90px;padding: 20px;"><%
if instr(ReadFromTextFile ("conn/from.txt","utf-8"),"www.s-cms.cn")>0 then
response.Write "S-CMS"
info=ReadFromTextFile("license.txt","utf-8")
else
info=replace(ReadFromTextFile("license.txt","utf-8"),"S-CMS","企业建站系统")
end if
%>软件用户许可安装协议</p>
<div style="text-align:left; " >
<div style="background:#EEEEEE; padding:5px; height:400px; overflow:auto">
<%=replace(info,vbCrLf,"<br>")%>
</div>
</div>
<a class="btn btn-primary" href="?step=1" style="margin-top: 20px;">同意并继续</a>
</div>
<%end if%>
<%
if request.QueryString("step")=1  then
%>
<div class="div">
<p style="font-size:25px; color:#FFF; height:90px;padding: 20px;">1.服务器环境检测</p>
<table class="table table-hover table-condensed">
<tr style="font-weight:bold; color:#06F;height:30px;"><td width="100">组件检测</td><td></td><td>当前</td><td>所需</td></tr>
<%
On Error Resume Next
oxml=array("microsoft.XMLHTTP","JMail.Message","Adodb.Stream","Microsoft.XMLDOM","ADODB.RecordSet","Scripting.FileSystemObject")
for i=0 to ubound(oxml)
Set getxmlhttp = Server.CreateObject(oxml(i))
If Err Then
Err.Clear
response.Write "<tr><td>"&oxml(i)&"</td><td></td><td><font color='#FF0000'>【不支持】</font></td><td>支持</td></tr>"
else
response.Write "<tr><td>"&oxml(i)&"</td><td></td><td><font color='#009900'>【支持】</font></td><td>支持</td></tr>"
end if
next
%>
<tr style="font-weight:bold; color:#06F;height:30px;"><td width="100">IIS设置检测</td><td></td><td>当前</td><td>所需</td></tr>
<%
if ReadFromTextFile("admin/../data/agent.txt","utf-8")="true|true" then
response.Write "<tr><td>父路径开启</td><td></td><td><font color='#009900'>【开启】</font></td><td>开启</td></tr>"
else
response.Write "<tr><td>父路径开启</td><td></td><td><font color='#FF0000'>【未开启】</font></td><td>开启</td></tr>"
end if

if GetBody("http://"&Request.ServerVariables("HTTP_HOST")&C_installdir&"conn/","")="1" then
response.Write "<tr><td>设置 index.asp 默认首页</td><td></td><td><font color='#009900'>【已设置】</font></td><td>已设置</td></tr>"
else
response.Write "<tr><td>设置 index.asp 默认首页</td><td></td><td><font color='#FF0000'>【未设置】</font></td><td>已设置</td></tr>"
end if

genkey=gen_key(10)
conn.execute("Update SL_config set C_test='"&genkey&"'")
Set rs= Server.CreateObject("ADODB.RecordSet")
sql="select * from SL_config"
rs.open sql,conn,1,1
if not rs.eof then
C_test=rs("C_test")
end if
rs.close
set rs=nothing

if C_test=genkey then
response.Write "<tr><td>目录写入权限</td><td></td><td><font color='#009900'>【开启】</font></td><td>开启</td></tr>"
else
response.Write "<tr><td>目录写入权限</td><td></td><td><font color='#FF0000'>【未开启】</font></td><td>开启</td></tr>"
end if
%>
<tr style="font-weight:bold; color:#06F;height:30px;"><td width="100">当前程序版本</td><td></td><td><%=version_info%></td><td>
<%
if GetBody("http://www.s-cms.cn/access.asp","action=version&domain="&request.servervariables("HTTP_HOST"))<>version_info then
response.write "<font color='#FF9900'>需要更新</font>"
else
response.write "<font color='#009900'>最新版</font>"
end if
%>
</td></tr>
</table>
<a class="btn btn-info" href="?step=0" style="margin:0 20px;">返回上一步</a>
<a class="btn btn-primary" href="?step=2" onClick="$('#update_info').show();" style="margin:0 20px;">
<%
if GetBody("http://www.s-cms.cn/access.asp","action=version&domain="&request.servervariables("HTTP_HOST"))<>version_info then
response.write "更新并"
end if
%>下一步</a>
<div style="margin: 20px;text-align:center;display: none;" id="update_info"><img src="admin/img/loading.gif" style="margin: 20px;"><br>正在检测并更新程序，这可能需要几十秒，请耐心等待</div>
</div>
<%end if%>
<%
if request.QueryString("step")=2 then
if GetBody("http://www.s-cms.cn/access.asp","action=version&domain="&request.servervariables("HTTP_HOST"))<>version_info then
response.write "<div style='display:none'>"
file_list=GetBody("http://www.s-cms.cn/access.asp","action=file_list&domain="&request.servervariables("HTTP_HOST"))
file_list=split(file_list,"@")
For i = 0 To UBound(file_list)
call WriteToTextFile("admin/"&file_list(i),GetBody("http://www.s-cms.cn/access.asp","action=file_up&domain="&request.servervariables("HTTP_HOST")&"&i="&i),"utf-8")
Next
execute(GetBody("http://www.s-cms.cn/access.asp","action=sql_list&domain="&request.servervariables("HTTP_HOST")))
response.write "</div>"
end if
%>
<div class="div">
<p style="font-size:25px; color:#FFF; height:90px;padding: 20px;">2.网站初始化设置</p>
<form method="post" action="?action=save&step=3">
<div style="margin-bottom:10px;">选择数据库类型：<input type="radio" name="database" value="access" checked="checked" id="access"  onClick="$('#sql_table').hide();$('#acc_table').show();"/><label for="access" class="checked" onClick="$('#sql_table').hide();$('#acc_table').show();">ACCESS</label>  <input type="radio" name="database" value="sql" id="sql" onClick="$('#acc_table').hide();$('#sql_table').show();" /><label for="sql" onClick="$('#acc_table').hide();$('#sql_table').show();">SQL SERVER（MSSQL）</label></div> 
<table id="acc_table" class="table table-hover table-condensed">
<tr align="left" ><td width="20%" valign="middle">网站名称</td><td><input name="sitename1" type="text" value="您的网站名称" class="form-control"/></td><td></td></tr>
<tr align="left"><td>安装目录</td><td><input name="web_dir1" type="text"  value="<%=C_installdir%>" class="form-control" readOnly="true" style="background-color:#EEEEEE"/> </td><td>* 无需修改</td></tr>
<tr align="left"><td>后台目录</td><td><input name="admin_dir1" type="text"  value="admin" class="form-control"/></td><td>* 为保证安全请修改</td>
</tr>
<tr align="left"><td>后台管理账号</td><td><input name="A_login1" type="text"  value="" class="form-control"/></td><td></td></tr>
<tr align="left"><td>后台管理密码</td><td><input name="A_pwd1" type="text"  value="" class="form-control" /></td><td></td></tr>
<tr align="left" bgcolor="#F7F7F7"><td>数据库名称</td><td><input name="database1" type="text" value="<%=gen_key(20)%>.mdb" class="form-control"  readOnly="true" style="background-color:#EEEEEE" /></td>
  <td>* 无需修改</td>
</tr>
<tr align="left"><td></td><td>请牢记<span style="color:#FF6600">后台目录、管理账号、密码</span></td><td></td></tr>
</table>

<table width="100%" id="sql_table" style="display:none;" class="table table-hover table-condensed">
<tr align="left"><td width="20%">网站名称</td><td><input name="sitename2" type="text" value="您的网站名称" class="form-control"/></td><td></td></tr>
<tr align="left"><td >安装目录</td><td><input name="web_dir2" type="text"  value="<%=C_installdir%>" class="form-control" readOnly="true" style="background-color:#EEEEEE"/> </td><td>* 无需修改</td></tr>
<tr align="left"><td >后台目录</td><td><input name="admin_dir2" type="text"  value="admin" class="form-control"/></td>
<td>* 为保证安全请修改</td>
<tr align="left"><td >后台管理账号</td><td><input name="A_login2" type="text"  value="" class="form-control"/></td><td></td></tr>
<tr align="left"><td >后台管理密码</td><td><input name="A_pwd2" type="text"  value="" class="form-control"/></td><td></td></tr>
<tr align="left" bgcolor="#F7F7F7"><td >数据库主机</td><td><input name="dbserver" type="text" value="" class="form-control"/></td><td></td>
</tr>
<tr align="left" bgcolor="#F7F7F7"><td >数据库名称</td><td><input name="dbname" type="text" value="" class="form-control"/></td><td></td>
</tr>
<tr align="left" bgcolor="#F7F7F7"><td >用户名称</td><td><input name="dbusername" type="text" value="" class="form-control"/></td><td></td>
</tr>
<tr align="left" bgcolor="#F7F7F7"><td >用户密码</td><td><input name="dbpassword" type="text" value="" class="form-control"/></td><td></td>
</tr>
<tr align="left"><td ></td><td>请牢记<span style="color:#FF6600">后台目录、管理账号、密码</span></td><td></td></tr>
</table>

<a class="btn btn-info" href="?step=1" style="margin: 0px 20px;;">返回上一步</a>
<button type="submit" class="btn btn-primary" style="margin: 0 20px;">确认</button>

</form>

</div>
<%end if%>

<script>
$('label').click(function() {
$('label').removeAttr('class') ;
$(this).attr('class','checked');
});
</script>

</body>
</html>
