<!--#include file="inc/MainClass.asp"-->
<%
dim action : action = getForm("action", "get")
dim currentDir

Select  case action
	case "install" : install
	case else : main
End Select

Sub main
%>
<html>
<head>
<title>站点安装</title>
<script>
function checkSelected(){
	for(i=0;i<installform.playermode.length;i++){
		if(installform.playermode[i].checked==true) return true;
	}
	alert("请选择播放器设置")
	return false; 
}
</script>
<link href="template/default/images/public.css" rel="stylesheet" type="text/css" />
<style>body{text-align:center}#installbox{background-color:white;border:1px solid #1B76B7;margin:0 auto;width:600px;text-align:left;margin-top:5em}.msgtitle{padding:3px 3px;color:white;font-weight:700;line-height:21px;height:25px;font-size:12px;border-bottom:1px solid #1B76B7; text-indent:3px; background-color:#1B76B7}#msgbody{font-size:12px;line-height:25px}#msgbottom{text-align:center;height:20px;line-height:20px;font-size:12px;background-color:#1b76b7;color:#FFFFFF}label{cursor:pointer;display:block;padding-left:50px;height:25px;line-height:25px}label:hover{background-color:#f5f5f5}h3{font-size:18px;font-family:"黑体";font-weight:400;border-bottom:1px solid #f3f3f3;padding:20px 0 5px 30px;color:#333}input{border-width:0}</style>

</head>
<body>
<form action="?action=install"  method="post"  name="installform">
<div id='installbox'><div class='msgtitle'>Maxcms2.0一键安装</div><div id='msgbody'>
<h3>页面运行模式：</h3>
<label for="sitemode0"><input type="radio"  name="sitemode" id="sitemode0" value="dynamic" class="radio"  checked />动态模式</label>
<label for="sitemode1"><input type="radio"  name="sitemode" id="sitemode1" value="static" class="radio" />静态模式(<font color="blue">详细配置请登陆系统后台站点配置</font>)</label>
<h3>播放器选择：</h3>
<label for="playermode0"><input type="radio"  name="playermode" id="playermode0"  value="1" class="radio" />站内(<font color="blue">站内播放，</font><font color="red">可自动播放，可连播</font><font color="blue">，更多播放器参数请在js/player.js里修改</font>)</label>
<label for="playermode1"><input type="radio"  name="playermode" id="playermode1" value="0" class="radio"  />
站外(<font color="blue">指视频站默认提供的原始引用地址，不能自动播放，不能连播</font>)</label>
<h3>
<input type="submit" class="btn"  value="开始安装"  onClick="return checkSelected()"/></h3>
</div><div id='msgbottom'>Powered By <%=siteName%></div></div>
</form>
</body>
</html>
<%
End Sub

Sub install
	dim url : url=Request.ServerVariables("URL") : currentDir=mid(url,2,instrRev(url,"/")-1) : installSub : alertMsg "MaxcmsV2.0程序安装成功，请用默认账号密码admin登录后台","admin/index.asp"
End Sub

Sub installSub
	dim templateobj,configPath,configStr,installPath,installStr,sitemode,playermode,playerJsPath,indexPath
	indexPath="index.asp" : configPath="inc/config.asp" : installPath="install.asp" : playerJsPath="js/play.js"
	sitemode=getForm("sitemode","post") : playermode=getForm("playermode","post")
	if isNul(sitemode) or isNul(playermode) then die "安装前请选择相关设置"
	'die sitemode&"|"&playermode
	set templateobj = mainClassObj.createObject("MainClass.template")
	configStr=loadFile(configPath)
	configStr=templateobj.regExpReplace(configStr,"sitePath=""(\S*?)"""&vbcrlf,"sitePath="""&currentDir&""""&vbcrlf)
	configStr=templateobj.regExpReplace(configStr,"accessFilePath=""(\S+?)"""&vbcrlf,"accessFilePath=""/"&currentDir&"inc/datas.asp"""&vbcrlf)
	configStr=templateobj.regExpReplace(configStr,"runMode=""(\S+?)"""&vbcrlf,"runMode="""&sitemode&""""&vbcrlf)
	createTextFile configStr,configPath
	
	configStr=loadFile(playerJsPath)
	configStr=templateobj.regExpReplace(configStr,"var\sautoPlay=""\d+"";","var autoPlay="""&playermode&""";")
	createTextFile configStr,playerJsPath
	
	configStr=loadFile(indexPath)
	configStr=templateobj.regExpReplace(configStr,"<%"&vbcrlf&"alertMsg ""请先安装程序，正在跳转到安装文件""\,""install\.asp""","<%")
	createTextFile configStr,indexPath
	
	installStr=templateobj.regExpReplace(loadFile(installPath),"-->"&vbcrlf&"<%"&vbcrlf,"-->"&vbcrlf&"<%"&vbcrlf&"die ""暂停安装<br>(*^__^*) ……您已经安装过了，如需要再次安装，请删除该文件的第三行代码即可"""&vbcrlf)
	createTextFile installStr,installPath
	set templateobj=nothing
End Sub
%>