<!--#include file="../inc/function.asp"-->
<!--#include file="../inc/class.asp"-->
<!--#include file="../inc/md5.asp"-->
<!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" />
	    <title>苹果CMS(MacCMS)安装程序</title>
	    <link rel="stylesheet" type="text/css" href="../images/manage.css" />
	    <link rel="stylesheet" type="text/css" href="../images/icon.css" />
	    <link rel="stylesheet" type="text/css" href="style.css" />
	    <script type="text/javascript" src="../js/jquery.js"></script>
	    <script type="text/javascript" src="../js/jquery.validate.js"></script>
	    <script type="text/javascript" src="../js/function.js"></script>
	    <script language="javascript">
		$(function(){
			$("#btnLicense").click(function(){
				window.location.href= "?action=a";
				return false;
			});
			$("#btnStep1a").click(function(){
				location.href= "?action=";
			});
			$("#btnStep1b").click(function(){
				if($("#app_siteurl").val()==""){
					alert("网站域名不能为空");
					$("#app_siteurl").focus();
					return;
				}
				if($("#app_installdir").val()==""){
					alert("网站安装目录不能为空");
					$("#app_installdir").focus();
					return;
				}
				if($("#app_sitename").val()==""){
					alert("网站名称不能为空");
					$("#app_sitename").focus();
					return;
				}
				if($("#m_name").val()==""){
					alert("帐号不能为空");
					$("#m_name").focus();
					return;
				}
				if($("#m_password1").val()==""){
					alert("密码不能为空");
					$("#m_password1").focus();
					return;
				}
				if($("#app_safecode").val()==""){
					alert("安全码不能为空");
					$("#app_safecode").focus();
					return;
				}
				if($("#m_password1").val() != $("#m_password2").val()){
					alert("验证密码不同");
					$("#m_password2").focus();
					return;
				}
				$("#form2").submit();
			});
			$("#btnStep2a").click(function(){
				location.href= "?action=a";
			});
			$("#btnStep2b").click(function(){
				location.href= "?action=c";
			});
		});
		function setdb(dbtype){
			if (dbtype == "access"){
				$("#sql").css("display","none");
				$("#acc").css("display","");
			}
			else{
				$("#sql").css("display","");
				$("#acc").css("display","none");
			}
		}
		</script>
	</head>
	<body>
<%
	dim action : action = be("get","action")
	dim objdb
	dim app_dbpath,app_dbserver,app_dbname,app_dbuser,app_dbpass,app_dbtype,app_installdir,app_sitename,app_siteurl,app_tablepre
	Select case action
		case "a": stepA()
		case "b": stepB()
		case "c": stepC()
		case else : main()
	end select

sub main
dim objxml : set objxml = new AppXmlDom
dim xmlhttpver : xmlhttpver = getXmlHttpVer()
dim xmldomver : xmldomver = objxml.ver
%>
<h1 id="logo">苹果CMS(MacCMS)安装</h1>
<form action="index.asp?action=a" method="post" name="setup" id="setup">
<table class="data-table">
<thead><tr><th colspan="3">系统信息</th></tr></thead>
<tbody>
<tr><td>服务器名</td><td><%=Request.ServerVariables("SERVER_NAME")%></td></tr>
<tr><td>服务器类型及IP</td><td><%=Request.ServerVariables("OS")%>(IP:<%=Request.ServerVariables("LOCAL_ADDR")%>)</td></tr>
<tr><td>脚本解释引擎</td><td><%=ScriptEngine & "/"& ScriptEngineMajorVersion &"."&ScriptEngineMinorVersion&"."& ScriptEngineBuildVersion %></td></tr>
</tbody>
</table>
<table class="data-table">
<thead><tr><th colspan="3">必需的设置</th></tr></thead>
<tbody>
<tr class="thead"><th>测试</th><th class="w100">需求</th><th class="w150">当前</th></tr>
<tr><td>数据库使用</td><td>支持</td><td><%If Not isObjInstalled("ADODB.CONNECTION") Then%><font color="#FF0066"><b>×</b></font><%else%><b>√</b><%end if%></td></tr>
<tr><td>FSO对象</td><td>支持</td><td><%If Not isObjInstalled("Scripting.FileSystemObject") Then%><font color="#FF0066"><b>×</b></font><%else%><b>√</b><%end if%></td></tr>
<tr><td>Stream对象</td><td>支持</td><td><%If Not isObjInstalled("ADODB.Stream") Then%><font color="#FF0066"><b>×</b></font><%else%><b>√</b><%end if%></td></tr>
<tr><td>Dictionary对象</td><td>支持</td><td><%If Not isObjInstalled("SCRIPTING.DICTIONARY") Then%><font color="#FF0066"><b>×</b></font><%else%><b>√</b><%end if%></td></tr>	
<tr><td>Xmlhttp对象</td><td>支持</td><td><%If xmlhttpver =false Then%><font color="#FF0066"><b>×</b></font><%else%><b>√</b><%end if%></td></tr>
<tr><td>Xmldom对象</td><td>支持</td><td><%If xmldomver =false Then%><font color="#FF0066"><b>×</b></font><%else%><b>√</b><%end if%></td></tr>
<tr><td>Persits.jpeg</td><td>可选</td><td><%If Not isObjInstalled("Persits.jpeg") Then%><font color="#FF0066"><b>×</b></font><%else%><b>√</b><%end if%></td></tr>
</tbody>
</table>
<p class="buttons"><button type="button" id="btnLicense">继续</button><button type="button" onclick="location.reload();">再试一次</button></p>
<%
set objxmlhttp=nothing
set objxml=nothing
end sub

sub stepA
	strpath = Request.ServerVariables("SCRIPT_NAME")
	strpath = Left(strpath, InStrRev(LCase(strpath), "/"))
	strpath = replace(strpath,"install/","")
	
	stracc = getRndStr(10) & ".mdb"
%>
<h1 id="logo">苹果CMS(MacCMS)安装</h1>
<form action="index.asp?action=b" method="post" name="form2" id="form2">
		<table class="data-table">
		<thead><tr><th colspan="3">必需的设置</th></tr></thead>
		<tbody>
			<tr><th class="w150">网站域名</th><td><input class="text" type="text" name="app_siteurl" id="app_siteurl" size=40 value="<%=Request.ServerVariables("SERVER_NAME")%>" /></td><td width="220">网站的域名不带http://</td></tr>
			<tr><th>网站名称</th><td><input class="text" type="text" name="app_sitename" id="app_sitename" size=40 value="苹果电影程序" /></td><td>网站的名称</td></tr>
			<tr><th>安装路径</th><td><input class="text" type="text" name="app_installdir" id="app_installdir" size=40 value="<%=strpath%>" /></td><td>网站的路径根目录/，二级目录/2级目录/</td></tr>
			
			<tr><th>网站关键字</th><td><input class="text" type="text" name="app_keywords" id="app_keywords" size=40 value="免费在线电影" /></td><td>网站的关键字</td></tr>
			<tr><th>网站描述</th><td><input class="text" type="text" name="app_description" id="app_description" size=40 value="提供最新最快的影视资讯和在线播放" /></td><td>网站的描述信息</td></tr>
			
			<tr><th>数据库类型</th><td><select name="app_dbtype" id="app_dbtype" onChange="setdb(this.value);">
	              <option value="access">access数据库</option>
	              <option value="mssql">mssql数据库</option>
	              </select></td><td>网站使用数据库的类型</td></tr>
			<tr><th>表前缀</th><td><input class="text" type="text" name="app_tablepre" id="app_tablepre" size=40 value="mac_" /></td><td>数据库表名前缀</td></tr>
			
			<tr id="acc"><th>ACCESS路径：</th><td><input class="text" type="text" name="app_dbpath" id="app_dbpath" size=40 value="<%=stracc%>" /></td><td></td></tr>
			<tr id="sql" style="display:none"><th>SQLSERVER信息：</th><td>
			<p>Sql服务器：&nbsp;&nbsp;&nbsp;<input class="text" type="text" name="app_dbserver" id="app_dbserver" size=25 value="(local)" /></p> 
			<p>Sql数据名称：<input class="text" type="text" name="app_dbname" id="app_dbname" size=25 value="" /></p> 
			<p>Sql数据帐号：<input class="text" type="text" name="app_dbuser" id="app_dbuser" size=25 value="" /></p> 
			<p>Sql数据密码：<input class="text" type="text" name="app_dbpass" id="app_dbpass" size=25 value="" /></p> 
			</td><td></td></tr>
			</tbody>
		</table> 
		<table class="data-table">
		<thead><tr><th colspan="3">初始化管理员</th></tr></thead>
		<tbody>
		<tr><th class="w150">帐号</th><td><input class="text" type="text" name="m_name" id="m_name" size=40 value="admin" /></td><td></td></tr>
		<tr><th>密码</th><td><input class="text" type="password" name="m_password1" id="m_password1" size=40 value="" /></td><td></td></tr>
		<tr><th>确认密码</th><td><input class="text" type="password" name="m_password2" id="m_password2" size=40 value="" /></td><td></td></tr>
		<tr><th>安全码</th><td><input class="text" type="password" name="app_safecode" id="app_safecode" size=40 value="" /></td><td></td></tr>
		</tbody>
		</table>
		</form>
		<p class="buttons"><button type="button" id="btnStep1a">上一步</button><button type="button" id="btnStep1b">下一步</button></p>
<%
end sub

Function isExistTable(tName)
	dim tables:set tables = objdb.dbConn.OpenSchema(20,array(empty,empty,tName,"table")):isExistTable=tables.eof = false:set tables = nothing
End Function

Function isExistIndex(tName,sIndexName)
	Dim Indexs:SET Indexs= objdb.dbConn.OpenSchema(12,array(empty,empty,sIndexName,empty,tName)):isExistIndex=Indexs.eof = false:SET Indexs=Nothing
End Function

sub stepB
	
	app_siteurl = be("post","app_siteurl")
	app_sitename = be("post","app_sitename")
	app_installdir = be("post","app_installdir")
	app_keywords = be("post","app_keywords")
	app_description = be("post","app_description")
	app_dbtype = be("post","app_dbtype")
	app_dbpath = "inc/" & be("post","app_dbpath")
	app_dbserver = be("post","app_dbserver")
	app_dbname = be("post","app_dbname")
	app_dbuser = be("post","app_dbuser")
	app_dbpass = be("post","app_dbpass")
	app_tablepre = be("post","app_tablepre")
	m_name = be("post","m_name")
	m_password1 = be("post","m_password1")
	m_password2 = be("post","m_password2")
	app_safecode = be("post","app_safecode")
	
	dim objStream : Set objStream = server.createobject("ADODB.Stream")
	dim objFile : set objFile = New AppFile
%>
<h1 id="logo">苹果CMS(MacCMS)安装</h1>
<form action="index.asp?action=b" method="post" name="form2" id="form2">
		<table class="data-table">
		<thead><tr><th colspan="3">安装信息</th></tr></thead>
		<tbody>
		<tr>
		<td>
<textarea style="width:100%;border:4px solid #f8E9FF;font-size:12px;" rows="25" readonly>
<%
	configstr = objFile.getFile("../inc/config.asp")
	configstr = regReplace(configstr,"app_siteurl=""(\S*?)""","app_siteurl="""&app_siteurl&"""")
	configstr = regReplace(configstr,"app_sitename=""(\S*?)""","app_sitename="""&app_sitename&"""")
	configstr = regReplace(configstr,"app_installdir=""(\S*?)""","app_installdir="""&app_installdir&"""")
	configstr = regReplace(configstr,"app_keywords=""(\S*?)""","app_keywords="""&app_keywords&"""")
	configstr = regReplace(configstr,"app_description=""(\S*?)""","app_description="""&app_description&"""")
	configstr = regReplace(configstr,"app_dbtype=""(\S*?)""","app_dbtype="""&app_dbtype&"""")
	configstr = regReplace(configstr,"app_dbpath=""(\S*?)""","app_dbpath="""&app_dbpath&"""")
	configstr = regReplace(configstr,"app_dbserver=""(\S*?)""","app_dbserver="""&app_dbserver&"""")
	configstr = regReplace(configstr,"app_dbname=""(\S*?)""","app_dbname="""&app_dbname&"""")
	configstr = regReplace(configstr,"app_dbuser=""(\S*?)""","app_dbuser="""&app_dbuser&"""")
	configstr = regReplace(configstr,"app_dbpass=""(\S*?)""","app_dbpass="""&app_dbpass&"""")
	configstr = regReplace(configstr,"app_safecode=""(\S*?)""","app_safecode="""&app_safecode&"""")
	configstr = regReplace(configstr,"app_tablepre=""(\S*?)""","app_tablepre="""&app_tablepre&"""")
	configstr = regReplace(configstr, "app_install=(\d+?)", "app_install=1")
	objFile.createFile "../inc/config.asp",configstr
	writeA "成功写入配置文件..." & vbcrlf & vbcrlf
	
	dim dbck:dbck=true
	dim constr
	
	On Error Resume next
	if app_dbtype="access" then
		constr = "Provider=Microsoft.Jet.OLEdb.4.0;Data Source=" & server.mappath("../" & app_dbpath)
		if not objfile.isFileExists("../"&app_dbpath) then
			SET x=Server.CreateObject("ADOX.Catalog")
			x.Create constr
			SET x=Nothing
			if err then dbck=false : writeE  "数据库设置出错：access请检查服务器是否支持ADOX.Catalog!"  & vbcrlf
			writeA "成功创建access数据库文件" & vbcrlf
		end if
		
	else
		constr = "Provider=Sqloledb;Data Source=" & app_dbserver & ";Initial Catalog=" & app_dbname & ";User ID=" & app_dbuser & ";Password=" & app_dbpass & ";"
		Dim sqldb:Set sqldb=Server.CreateObject("ADODB.Connection")
		sqldb.ConnectionTimeout=3:sqldb.open constr
		sqldb.close:Set sqldb = nothing
		if err then dbck=false : writea  "数据库设置出错：sqlserver请检查数据库连接信息!"  & vbcrlf
			
	end if
	err.clear
	
	if dbck then
	set objdb = new AppDataBase
	objdb.ConnStr = constr
	objdb.CreatConn
	
	writeA "开始创建数据库结构..." & vbcrlf
	
	if not isExistTable(""&app_tablepre&"art") then
	objdb.dbConn.execute "create table "&app_tablepre&"art (a_id int identity (1, 1) not null primary key ,a_title varchar (255) ,a_subtitle varchar (255) ,a_entitle varchar (255) ,a_letter char(1) , a_from varchar (64) ,a_color varchar (8) ,a_type int default 0 ,a_topic int default 0 ,a_level int default 0 ,a_pic varchar (255) ,a_author varchar (255) ,a_content text ,a_hits int default 0 ,a_dayhits int default 0 ,a_weekhits int default 0 ,a_monthhits int default 0 ,a_hide int default 0 ,a_addtime datetime ,a_time datetime ,a_hitstime datetime,a_maketime datetime )"
	writea "创建数据表 "&app_tablepre&"art" & vbcrlf
	end if
	
	if not isExistTable(""&app_tablepre&"art_topic") then
	objdb.dbConn.execute "create table "&app_tablepre&"art_topic (t_id int identity (1, 1) not null primary key ,t_name varchar (64) ,t_enname varchar (128) ,t_sort int default 0 ,t_template varchar (128) ,t_pic varchar (255) ,t_des varchar (255) )"
	writea "创建数据表 "&app_tablepre&"art_topic" & vbcrlf
	end if
	
	if not isExistTable(""&app_tablepre&"art_type") then
	objdb.dbConn.execute "create table "&app_tablepre&"art_type (t_id int identity (1, 1) not null primary key ,t_name varchar (64) ,t_enname varchar (128) ,t_sort int default 0 ,t_pid int default 0 ,t_key varchar (255) ,t_des varchar (255) ,t_template varchar (64) ,t_arttemplate varchar (64) ,t_hide int default 0 ,t_union text )"
	writea "创建数据表 "&app_tablepre&"art_type" & vbcrlf
	end if
	
	if not isExistTable(""&app_tablepre&"comment") then
	objdb.dbConn.execute "create table "&app_tablepre&"comment (c_id int identity (1, 1) not null primary key ,c_type int default 0 ,c_vid int default 0 ,c_rid int default 0 ,c_audit int default 0,c_name varchar (64) ,c_ip varchar (32) ,c_content varchar (128) ,c_time datetime )"
	writea "创建数据表 "&app_tablepre&"comment" & vbcrlf
	end if
	
	if not isExistTable(""&app_tablepre&"gbook") then
	objdb.dbConn.execute "create table "&app_tablepre&"gbook (g_id int identity (1, 1) not null primary key ,g_vid int default 0 ,g_audit int default 0 ,g_name varchar (64) ,g_content varchar (255) ,g_reply varchar (255) ,g_ip varchar (32) ,g_time datetime ,g_replytime datetime )"
	writea "创建数据表 "&app_tablepre&"gbook" & vbcrlf
	end if
	
	if not isExistTable(""&app_tablepre&"link") then
	objdb.dbConn.execute "create table "&app_tablepre&"link (l_id int identity (1, 1) not null primary key ,l_name varchar (64) ,l_type varchar (8) ,l_url varchar (255) ,l_sort int default 0 ,l_logo varchar (255) )"
	writea "创建数据表 "&app_tablepre&"link" & vbcrlf
	end if
	
	if not isExistTable(""&app_tablepre&"manager") then
	objdb.dbConn.execute "create table "&app_tablepre&"manager (m_id int identity (1, 1) not null primary key ,m_name varchar (32) ,m_password varchar (32) ,m_levels text ,m_status int default 0 ,m_logintime datetime ,m_loginip varchar (32) ,m_random varchar (64) )"
	writea "创建数据表 "&app_tablepre&"manager" & vbcrlf
	end if
	
	if not isExistTable(""&app_tablepre&"mood") then
	objdb.dbConn.execute "create table "&app_tablepre&"mood (m_id int identity (1, 1) not null primary key ,m_type int default 0 ,m_vid int default 0 ,mood1 int default 0 ,mood2 int default 0 ,mood3 int default 0 ,mood4 int default 0 ,mood5 int default 0 ,mood6 int default 0 ,mood7 int default 0 ,mood8 int default 0 ,mood9 int default 0 )"
	writea "创建数据表 "&app_tablepre&"mood" & vbcrlf
	end if
	
	if not isExistTable(""&app_tablepre&"user") then
	objdb.dbConn.execute "create table "&app_tablepre&"user (u_id int identity (1, 1) not null primary key ,u_qid varchar (32),u_name varchar (32) ,u_group int default 0 ,u_password varchar (32) ,u_qq varchar (16) ,u_email varchar (32) ,u_phone varchar (16) ,u_status int default 0 ,u_question varchar (255) ,u_answer varchar (255) ,u_points int default 0 ,u_regtime datetime ,u_logintime datetime ,u_loginnum int default 0 ,u_tj int default 0 ,u_ip varchar (32) ,u_random varchar (64) ,u_fav text ,u_plays text ,u_downs text ,u_flag int default 0 ,u_start varchar (64) ,u_end varchar (64) )"
	writea "创建数据表 "&app_tablepre&"user" & vbcrlf
	end if
	
	if not isExistTable(""&app_tablepre&"user_card") then
	objdb.dbConn.execute "create table "&app_tablepre&"user_card (c_id int identity (1, 1) not null primary key ,c_number varchar (32) ,c_pass varchar (32) ,c_money int default 0 ,c_point int default 0 ,c_used int default 0 ,c_sale int default 0 ,c_user int default 0 ,c_addtime datetime ,c_usetime datetime )"
	writea "创建数据表 "&app_tablepre&"user_card" & vbcrlf
	end if
	
	if not isExistTable(""&app_tablepre&"user_group") then
	objdb.dbConn.execute "create table "&app_tablepre&"user_group (ug_id int identity (1, 1) not null primary key ,ug_name varchar (32) ,ug_type varchar (255) ,ug_popedom varchar (32) ,ug_upgrade int default 0 ,ug_popvalue int default 0 )"
	writea "创建数据表 "&app_tablepre&"user_group" & vbcrlf
	end if
	
	if not isExistTable(""&app_tablepre&"user_visit") then
	objdb.dbConn.execute "create table "&app_tablepre&"user_visit (uv_id int identity (1, 1) not null primary key ,uv_uid int default 0 ,uv_ip varchar (32) ,uv_ly varchar (128) ,uv_time datetime )"
	writea "创建数据表 "&app_tablepre&"user_visit" & vbcrlf
	end if
	
	if not isExistTable(""&app_tablepre&"vod") then
	objdb.dbConn.execute "create table "&app_tablepre&"vod (d_id int identity (1, 1) not null primary key ,d_name varchar (255) ,d_subname varchar (255) ,d_enname varchar (255) ,d_type int default 0 ,d_letter char(1) ,d_state int default 0 ,d_color varchar (8) ,d_pic varchar (255) ,d_picthumb varchar (255) ,d_picslide varchar (255) ,d_starring varchar (255) ,d_directed varchar (255) ,d_area varchar (32) ,d_year varchar (32) ,d_language varchar (32) ,d_level int default 0 ,d_stint int default 0 ,d_stintdown int default 0 ,d_hits int default 0 ,d_dayhits int default 0 ,d_weekhits int default 0 ,d_monthhits int default 0 ,d_topic int default 0 ,d_duration int default 0 ,d_content text ,d_remarks varchar (255) ,d_hide int default 0 ,d_good int default 0 ,d_bad int default 0 ,d_usergroup int default 0 ,d_score int default 0 ,d_scorecount int default 0 ,d_addtime datetime ,d_time datetime ,d_hitstime datetime ,d_maketime datetime ,d_playfrom varchar (255) ,d_playserver varchar (255) ,d_playurl text ,d_downfrom varchar (255) ,d_downserver varchar (255) ,d_downurl text )"
	writea "创建数据表 "&app_tablepre&"vod" & vbcrlf
	end if
	
	if not isExistTable(""&app_tablepre&"vod_topic") then
	objdb.dbConn.execute "create table "&app_tablepre&"vod_topic (t_id int identity (1, 1) not null primary key ,t_name varchar (64) ,t_enname varchar (128) ,t_sort int default 0 ,t_template varchar (128) ,t_pic varchar (255) ,t_des varchar (255) )"
	writea "创建数据表 "&app_tablepre&"vod_topic" & vbcrlf
	end if
	
	if not isExistTable(""&app_tablepre&"vod_type") then
	objdb.dbConn.execute "create table "&app_tablepre&"vod_type (t_id int identity (1, 1) not null primary key ,t_name varchar (64) ,t_enname varchar (128) ,t_sort int not null ,t_pid int default 0 ,t_key varchar (255) ,t_des varchar (255) ,t_template varchar (64) ,t_vodtemplate varchar (64) ,t_playtemplate varchar (64) ,t_downtemplate varchar (64) ,t_hide int default 0 ,t_union text )"
	writea "创建数据表 "&app_tablepre&"vod_type" & vbcrlf
	end if	
	
	if not isExistTable("nodownload") AND app_dbtype="access" then
		getConn().execute "create table nodownload(notdown image)"
		getConn().execute "insert into nodownload (notdown) values ('┼氠潯┼')"
		echo "创建数据表 nodownload" & vbcrlf
	end if
	
	
	if Not isExistIndex(""&app_tablepre&"art","a_type") then objdb.dbConn.execute "CREATE INDEX a_type ON "&app_tablepre&"art (a_type)":writea "创建索引 "&app_tablepre&"art.a_type" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"art","a_topic") then objdb.dbConn.execute "CREATE INDEX a_topic ON "&app_tablepre&"art (a_topic)":writea "创建索引 "&app_tablepre&"art.a_topic" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"art","a_hits") then objdb.dbConn.execute "CREATE INDEX a_hits ON "&app_tablepre&"art (a_hits)":writea "创建索引 "&app_tablepre&"art.a_hits" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"art","a_dayhits") then objdb.dbConn.execute "CREATE INDEX a_dayhits ON "&app_tablepre&"art (a_dayhits)":writea "创建索引 "&app_tablepre&"art.a_dayhits" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"art","a_weekhits") then objdb.dbConn.execute "CREATE INDEX a_weekhits ON "&app_tablepre&"art (a_weekhits)":writea "创建索引 "&app_tablepre&"art.a_weekhits" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"art","a_monthhits") then objdb.dbConn.execute "CREATE INDEX a_monthhits ON "&app_tablepre&"art (a_monthhits)":writea "创建索引 "&app_tablepre&"art.a_monthhits" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"art","a_hide") then objdb.dbConn.execute "CREATE INDEX a_hide ON "&app_tablepre&"art (a_hide)":writea "创建索引 "&app_tablepre&"art.a_hide" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"art","a_time") then objdb.dbConn.execute "CREATE INDEX a_time ON "&app_tablepre&"art (a_time)":writea "创建索引 "&app_tablepre&"art.a_time" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"art","a_addtime") then objdb.dbConn.execute "CREATE INDEX a_addtime ON "&app_tablepre&"art (a_addtime)":writea "创建索引 "&app_tablepre&"art.a_addtime" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"art","a_maketime") then objdb.dbConn.execute "CREATE INDEX a_maketime ON "&app_tablepre&"art (a_maketime)":writea "创建索引 "&app_tablepre&"art.a_maketime" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"art","a_letter") then objdb.dbConn.execute "CREATE INDEX a_letter ON "&app_tablepre&"art (a_letter)":writea "创建索引 "&app_tablepre&"art.a_letter" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"art","a_level") then objdb.dbConn.execute "CREATE INDEX a_level ON "&app_tablepre&"art (a_level)":writea "创建索引 "&app_tablepre&"art.a_level" & vbcrlf
	
	if Not isExistIndex(""&app_tablepre&"art_topic","t_sort") then objdb.dbConn.execute "CREATE INDEX t_sort ON "&app_tablepre&"art_topic (t_sort)":writea "创建索引 "&app_tablepre&"art_topic.t_sort" & vbcrlf
	
	if Not isExistIndex(""&app_tablepre&"art_type","t_pid") then objdb.dbConn.execute "CREATE INDEX t_pid ON "&app_tablepre&"art_type (t_pid)":writea "创建索引 "&app_tablepre&"art_type.t_pid" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"art_type","t_sort") then objdb.dbConn.execute "CREATE INDEX t_sort ON "&app_tablepre&"art_type (t_sort)":writea "创建索引 "&app_tablepre&"art_type.t_sort" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"art_type","t_hide") then objdb.dbConn.execute "CREATE INDEX t_hide ON "&app_tablepre&"art_type (t_hide)":writea "创建索引 "&app_tablepre&"art_type.t_hide" & vbcrlf
	
	if Not isExistIndex(""&app_tablepre&"comment","c_vid") then objdb.dbConn.execute "CREATE INDEX c_vid ON "&app_tablepre&"comment (c_vid)":writea "创建索引 "&app_tablepre&"comment.c_vid" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"comment","c_type") then objdb.dbConn.execute "CREATE INDEX c_type ON "&app_tablepre&"comment (c_type)":writea "创建索引 "&app_tablepre&"comment.c_type" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"comment","c_rid") then objdb.dbConn.execute "CREATE INDEX c_rid ON "&app_tablepre&"comment (c_rid)":writea "创建索引 "&app_tablepre&"comment.c_rid" & vbcrlf	
	if Not isExistIndex(""&app_tablepre&"comment","c_audit") then objdb.dbConn.execute "CREATE INDEX c_audit ON "&app_tablepre&"comment (c_audit)":writea "创建索引 "&app_tablepre&"comment.c_audit" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"comment","c_time") then objdb.dbConn.execute "CREATE INDEX c_time ON "&app_tablepre&"comment (c_time)":writea "创建索引 "&app_tablepre&"comment.c_time" & vbcrlf
	
	
	if Not isExistIndex(""&app_tablepre&"gbook","g_vid") then objdb.dbConn.execute "CREATE INDEX g_vid ON "&app_tablepre&"gbook (g_vid)":writea "创建索引 "&app_tablepre&"gbook.g_vid" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"gbook","g_audit") then objdb.dbConn.execute "CREATE INDEX g_audit ON "&app_tablepre&"gbook (g_audit)":writea "创建索引 "&app_tablepre&"gbook.g_audit" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"gbook","g_time") then objdb.dbConn.execute "CREATE INDEX g_time ON "&app_tablepre&"gbook (g_time)":writea "创建索引 "&app_tablepre&"gbook.g_time" & vbcrlf
	
	
	if Not isExistIndex(""&app_tablepre&"link","l_sort") then objdb.dbConn.execute "CREATE INDEX l_sort ON "&app_tablepre&"link (l_sort)":writea "创建索引 "&app_tablepre&"link.l_sort" & vbcrlf
	
	if Not isExistIndex(""&app_tablepre&"mood","m_type") then objdb.dbConn.execute "CREATE INDEX m_type ON "&app_tablepre&"mood (m_type)":writea "创建索引 "&app_tablepre&"mood.m_type" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"mood","m_vid") then objdb.dbConn.execute "CREATE INDEX m_vid ON "&app_tablepre&"mood (m_vid)":writea "创建索引 "&app_tablepre&"mood.m_vid" & vbcrlf
	
	if Not isExistIndex(""&app_tablepre&"vod","d_type") then objdb.dbConn.execute "CREATE INDEX d_type ON "&app_tablepre&"vod (d_type)":writea "创建索引 "&app_tablepre&"vod.d_type" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod","d_state") then objdb.dbConn.execute "CREATE INDEX d_state ON "&app_tablepre&"vod (d_state)":writea "创建索引 "&app_tablepre&"vod.d_state" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod","d_level") then objdb.dbConn.execute "CREATE INDEX d_level ON "&app_tablepre&"vod (d_level)":writea "创建索引 "&app_tablepre&"vod.d_level" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod","d_hits") then objdb.dbConn.execute "CREATE INDEX d_hits ON "&app_tablepre&"vod (d_hits)":writea "创建索引 "&app_tablepre&"vod.d_hits" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod","d_dayhits") then objdb.dbConn.execute "CREATE INDEX d_dayhits ON "&app_tablepre&"vod (d_dayhits)":writea "创建索引 "&app_tablepre&"vod.d_dayhits" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod","d_weekhits") then objdb.dbConn.execute "CREATE INDEX d_weekhits ON "&app_tablepre&"vod (d_weekhits)":writea "创建索引 "&app_tablepre&"vod.d_weekhits" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod","d_monthhits") then objdb.dbConn.execute "CREATE INDEX d_monthhits ON "&app_tablepre&"vod (d_monthhits)":writea "创建索引 "&app_tablepre&"vod.d_monthhits" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod","d_stint") then objdb.dbConn.execute "CREATE INDEX d_stint ON "&app_tablepre&"vod (d_stint)":writea "创建索引 "&app_tablepre&"vod.d_stint" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod","d_stintdown") then objdb.dbConn.execute "CREATE INDEX d_stintdown ON "&app_tablepre&"vod (d_stintdown)":writea "创建索引 "&app_tablepre&"vod.d_stintdown" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod","d_hide") then objdb.dbConn.execute "CREATE INDEX d_hide ON "&app_tablepre&"vod (d_hide)":writea "创建索引 "&app_tablepre&"vod.d_hide" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod","d_usergroup") then objdb.dbConn.execute "CREATE INDEX d_usergroup ON "&app_tablepre&"vod (d_usergroup)":writea "创建索引 "&app_tablepre&"vod.d_usergroup" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod","d_score") then objdb.dbConn.execute "CREATE INDEX d_score ON "&app_tablepre&"vod (d_score)":writea "创建索引 "&app_tablepre&"vod.d_score" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod","d_topic") then objdb.dbConn.execute "CREATE INDEX d_topic ON "&app_tablepre&"vod (d_topic)":writea "创建索引 "&app_tablepre&"vod.d_topic" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod","d_addtime") then objdb.dbConn.execute "CREATE INDEX d_addtime ON "&app_tablepre&"vod (d_addtime)":writea "创建索引 "&app_tablepre&"vod.d_addtime" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod","d_time") then objdb.dbConn.execute "CREATE INDEX d_time ON "&app_tablepre&"vod (d_time)":writea "创建索引 "&app_tablepre&"vod.d_time" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod","d_maketime") then objdb.dbConn.execute "CREATE INDEX d_maketime ON "&app_tablepre&"vod (d_maketime)":writea "创建索引 "&app_tablepre&"vod.d_maketime" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod","d_letter") then objdb.dbConn.execute "CREATE INDEX d_letter ON "&app_tablepre&"vod (d_letter)":writea "创建索引 "&app_tablepre&"vod.d_letter" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod","d_name") then objdb.dbConn.execute "CREATE INDEX d_name ON "&app_tablepre&"vod (d_name)":writea "创建索引 "&app_tablepre&"vod.d_name" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod","d_enname") then objdb.dbConn.execute "CREATE INDEX d_enname ON "&app_tablepre&"vod (d_enname)":writea "创建索引 "&app_tablepre&"vod.d_enname" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod","d_year") then objdb.dbConn.execute "CREATE INDEX d_year ON "&app_tablepre&"vod (d_year)":writea "创建索引 "&app_tablepre&"vod.d_year" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod","d_area") then objdb.dbConn.execute "CREATE INDEX d_area ON "&app_tablepre&"vod (d_area)":writea "创建索引 "&app_tablepre&"vod.d_area" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod","d_language") then objdb.dbConn.execute "CREATE INDEX d_language ON "&app_tablepre&"vod (d_language)":writea "创建索引 "&app_tablepre&"vod.d_language" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod","d_starring") then objdb.dbConn.execute "CREATE INDEX d_starring ON "&app_tablepre&"vod (d_starring)":writea "创建索引 "&app_tablepre&"vod.d_starring" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod","d_directed") then objdb.dbConn.execute "CREATE INDEX d_directed ON "&app_tablepre&"vod (d_directed)":writea "创建索引 "&app_tablepre&"vod.d_directed" & vbcrlf
	
	if Not isExistIndex(""&app_tablepre&"vod_topic","t_sort") then objdb.dbConn.execute "CREATE INDEX t_sort ON "&app_tablepre&"vod_topic (t_sort)":writea "创建索引 "&app_tablepre&"vod_topic.t_sort" & vbcrlf
	
	if Not isExistIndex(""&app_tablepre&"vod_type","t_sort") then objdb.dbConn.execute "CREATE INDEX t_sort ON "&app_tablepre&"vod_type (t_sort)":writea "创建索引 "&app_tablepre&"vod_type.t_sort" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod_type","t_pid") then objdb.dbConn.execute "CREATE INDEX t_pid ON "&app_tablepre&"vod_type (t_pid)":writea "创建索引 "&app_tablepre&"vod_type.t_pid" & vbcrlf
	if Not isExistIndex(""&app_tablepre&"vod_type","t_hide") then objdb.dbConn.execute "CREATE INDEX t_hide ON "&app_tablepre&"vod_type (t_hide)":writea "创建索引 "&app_tablepre&"vod_type.t_hide" & vbcrlf
	
	writea "数据库结构创建完成..." & vbcrlf
	
	objdb.dbConn.execute "insert into "&app_tablepre&"manager(m_name,m_password,m_status,m_levels) values('"&m_name&"','"&md5(m_password1,2)&"',1,'2, 3, 4, 5, 6, 7, 8')"
	
	writeA "管理员帐号"&m_name&"初始化成功..." &vbcrlf
	
	objdb.dbConn.Execute "INSERT into "&app_tablepre&"user_group (ug_name,ug_type,ug_popedom,ug_upgrade,ug_popvalue) values ('普通会员','','',0,1)"
	writeA "默认会员组初始化完毕..." & vbCrLf
		
	objdb.dbConn.Execute "INSERT into "&app_tablepre&"vod_type (t_name,t_enname,t_sort,t_pid,t_key,t_des,t_template,t_vodtemplate,t_playtemplate,t_downtemplate,t_hide,t_union)  VALUES ('电影','dianying',1,0,'','','vodlist.html','vod.html','vodplay.html','voddown.html',0,'')"
	objdb.dbConn.Execute "INSERT into "&app_tablepre&"vod_type (t_name,t_enname,t_sort,t_pid,t_key,t_des,t_template,t_vodtemplate,t_playtemplate,t_downtemplate,t_hide,t_union)  VALUES ('连续剧','lianxuju',2,0,'','','vodlist.html','vod.html','vodplay.html','voddown.html',0,'')"
	objdb.dbConn.Execute "INSERT into "&app_tablepre&"vod_type (t_name,t_enname,t_sort,t_pid,t_key,t_des,t_template,t_vodtemplate,t_playtemplate,t_downtemplate,t_hide,t_union)  VALUES ('综艺','zongyi',3,0,'','','vodlist.html','vod.html','vodplay.html','voddown.html',0,'')"
	objdb.dbConn.Execute "INSERT into "&app_tablepre&"vod_type (t_name,t_enname,t_sort,t_pid,t_key,t_des,t_template,t_vodtemplate,t_playtemplate,t_downtemplate,t_hide,t_union)  VALUES ('动漫','dongman',4,0,'','','vodlist.html','vod.html','vodplay.html','voddown.html',0,'')"
	
	objdb.dbConn.Execute "INSERT into "&app_tablepre&"vod_type (t_name,t_enname,t_sort,t_pid,t_key,t_des,t_template,t_vodtemplate,t_playtemplate,t_downtemplate,t_hide,t_union)  VALUES ('动作片','dongzuopian',11,1,'','','vodlist.html','vod.html','vodplay.html','voddown.html',0,'')"
	objdb.dbConn.Execute "INSERT into "&app_tablepre&"vod_type (t_name,t_enname,t_sort,t_pid,t_key,t_des,t_template,t_vodtemplate,t_playtemplate,t_downtemplate,t_hide,t_union)  VALUES ('喜剧片','xijupian',12,1,'','','vodlist.html','vod.html','vodplay.html','voddown.html',0,'')"
	objdb.dbConn.Execute "INSERT into "&app_tablepre&"vod_type (t_name,t_enname,t_sort,t_pid,t_key,t_des,t_template,t_vodtemplate,t_playtemplate,t_downtemplate,t_hide,t_union)  VALUES ('爱情片','aiqingpian',13,1,'','','vodlist.html','vod.html','vodplay.html','voddown.html',0,'')"
	objdb.dbConn.Execute "INSERT into "&app_tablepre&"vod_type (t_name,t_enname,t_sort,t_pid,t_key,t_des,t_template,t_vodtemplate,t_playtemplate,t_downtemplate,t_hide,t_union)  VALUES ('科幻片','kehuanpian',14,1,'','','vodlist.html','vod.html','vodplay.html','voddown.html',0,'')"
	objdb.dbConn.Execute "INSERT into "&app_tablepre&"vod_type (t_name,t_enname,t_sort,t_pid,t_key,t_des,t_template,t_vodtemplate,t_playtemplate,t_downtemplate,t_hide,t_union)  VALUES ('恐怖片','kongbupian',14,1,'','','vodlist.html','vod.html','vodplay.html','voddown.html',0,'')"
	objdb.dbConn.Execute "INSERT into "&app_tablepre&"vod_type (t_name,t_enname,t_sort,t_pid,t_key,t_des,t_template,t_vodtemplate,t_playtemplate,t_downtemplate,t_hide,t_union)  VALUES ('剧情片','juqingpian',16,1,'','','vodlist.html','vod.html','vodplay.html','voddown.html',0,'')"
	objdb.dbConn.Execute "INSERT into "&app_tablepre&"vod_type (t_name,t_enname,t_sort,t_pid,t_key,t_des,t_template,t_vodtemplate,t_playtemplate,t_downtemplate,t_hide,t_union)  VALUES ('战争片','zhanzhengpian',17,1,'','','vodlist.html','vod.html','vodplay.html','voddown.html',0,'')"
	objdb.dbConn.Execute "INSERT into "&app_tablepre&"vod_type (t_name,t_enname,t_sort,t_pid,t_key,t_des,t_template,t_vodtemplate,t_playtemplate,t_downtemplate,t_hide,t_union)  VALUES ('国产剧','guochanju',21,2,'','','vodlist.html','vod.html','vodplay.html','voddown.html',0,'')"
	objdb.dbConn.Execute "INSERT into "&app_tablepre&"vod_type (t_name,t_enname,t_sort,t_pid,t_key,t_des,t_template,t_vodtemplate,t_playtemplate,t_downtemplate,t_hide,t_union)  VALUES ('港台剧','gangtaiju',22,2,'','','vodlist.html','vod.html','vodplay.html','voddown.html',0,'')"
	objdb.dbConn.Execute "INSERT into "&app_tablepre&"vod_type (t_name,t_enname,t_sort,t_pid,t_key,t_des,t_template,t_vodtemplate,t_playtemplate,t_downtemplate,t_hide,t_union)  VALUES ('日韩剧','rihanju',23,2,'','','vodlist.html','vod.html','vodplay.html','voddown.html',0,'')"
	objdb.dbConn.Execute "INSERT into "&app_tablepre&"vod_type (t_name,t_enname,t_sort,t_pid,t_key,t_des,t_template,t_vodtemplate,t_playtemplate,t_downtemplate,t_hide,t_union)  VALUES ('欧美剧','oumeiju',24,2,'','','vodlist.html','vod.html','vodplay.html','voddown.html',0,'')"
	
	objdb.dbConn.Execute "INSERT into "&app_tablepre&"art_type (t_name,t_enname,t_sort,t_pid,t_key,t_des,t_template,t_arttemplate,t_hide,t_union)  VALUES ('站内新闻','zhanneixinwen',1,0,'','','artlist.html','art.html',0,'')"
	objdb.dbConn.Execute "INSERT into "&app_tablepre&"art_type (t_name,t_enname,t_sort,t_pid,t_key,t_des,t_template,t_arttemplate,t_hide,t_union)  VALUES ('娱乐动态','yuledongtai',2,0,'','','artlist.html','art.html',0,'')"
	objdb.dbConn.Execute "INSERT into "&app_tablepre&"art_type (t_name,t_enname,t_sort,t_pid,t_key,t_des,t_template,t_arttemplate,t_hide,t_union)  VALUES ('八卦爆料','baguabaoliao',3,0,'','','artlist.html','art.html',0,'')"
	objdb.dbConn.Execute "INSERT into "&app_tablepre&"art_type (t_name,t_enname,t_sort,t_pid,t_key,t_des,t_template,t_arttemplate,t_hide,t_union)  VALUES ('影片资讯','yingpianzixun',4,0,'','','artlist.html','art.html',0,'')"
	objdb.dbConn.Execute "INSERT into "&app_tablepre&"art_type (t_name,t_enname,t_sort,t_pid,t_key,t_des,t_template,t_arttemplate,t_hide,t_union)  VALUES ('明星资讯','mingxingzixun',5,0,'','','artlist.html','art.html',0,'')"
	objdb.dbConn.Execute "INSERT into "&app_tablepre&"art_type (t_name,t_enname,t_sort,t_pid,t_key,t_des,t_template,t_arttemplate,t_hide,t_union)  VALUES ('电视资讯','dianshizixun',6,0,'','','artlist.html','art.html',0,'')"
	
	writeA "数据分类初始化成功..." &vbcrlf
	updateCacheFile
	end if
%>
</textarea>
</td>
</tr>
</table>
<p class="buttons"><button type="button" id="btnStep2a">上一步</button><button type="button" id="btnStep2b">下一步</button></p>
<%
	set objStream=nothing
	set objFile=nothing
	set objdb=nothing
end sub
 
sub stepC
%>
<h1 id="logo">苹果CMS(MacCMS)安装</h1>
<iframe id="tongji" name="tongji" src="http://www.maccms.com/tongji.html?7.0" MARGINWIDTH="0" MARGINHEIGHT="0" HSPACE="0" VSPACE="0" FRAMEBORDER="0" SCROLLING="no" width="0" height="0"></iframe>
<table class="data-table">
		<thead><tr><th colspan="3">安装完成</th></tr></thead>
		<tbody>
		<tr>
		<td>
<textarea style="width:100%;border:4px solid #f8E9FF;font-size:12px;" rows="20" readonly>
<%
	dim objFso : set objFso=server.createobject("Scripting.FileSystemObject")
	dim objStream : Set objStream = server.createobject("ADODB.Stream")
	dim objFile : set objFile = New AppFile
	
	if objFile.IsFileExists("index.asp") Then
		if not objFile.delfile ("index.asp") then writea "自动删除install/index.asp，请手工删除!" else writea "成功删除安装文件install/index.asp..." &vbcrlf
    end if
    
    writeA "5秒后自动跳转到后台管理登录页面..."
    set objFso =nothing
    set objStream=nothing
    set objFile=nothing
    set objdb=nothing
%>
</textarea>
</td>
</tr>
</table>
<script> setTimeout("gonextpage();",5000); function gonextpage(){location.href='../admin/index.asp';} </script>
<%
end sub
%>
</body>
</html>