<script type="text/javascript">
	function showmessage(message) {
		window.parent.document.getElementById('notice').value += message + "\r\n";
	}
</script>
<?php
if (@file_exists(ROOT."Cache/install.lock")==false){
	require ROOT.'Application/global.func.php';
	include ROOT."Config/database.inc.php";
	include ROOT."Config/license.php";
	Easy_Db::Connect($database);
	$DB = Easy_Db::getInstance();
	$array['username'] = trim(strtolower($_GET['username']));
	$array['password'] = trim(strtolower($_GET['password']));
	$array['group'] = '超级管理员';
	$path = str_replace(strrchr($_SERVER['PHP_SELF'],"/"),"",$_SERVER['PHP_SELF'])."/";
	$text = @file_get_contents(ROOT."Config/config.inc.php");
	$text = preg_replace("/[$]config\[\'basedir\'](\s+)\=(.+?);/$is","\$config['basedir']$1=\"$path\";",$text);
	$IO = new Easy_Filesystem();
	$IO->wfile(ROOT."Config/config.inc.php", $text);
	unset($text);
	if ($array['username']){
		$sqlline = file_get_contents(ROOT."install/vodcms.sql");
		if (empty($sqlline))
		{
			$sqlline = file_get_contents("http://www.vodcms.com/install/vodcms.txt");
		}
		runquery($sqlline);
		$IO->wfile(ROOT."Config/install.lock","succeed");
		$DB->insert($database['tblpre'].'admin', $array);
		echo "<script language='javascript'>showmessage('建立管理员成功')</script>";
	}else{
		exit('请填写用户名以及登陆密码');
	}
}else{?>
<script type="text/javascript">
	alert('您已经安装过系统了!必须删除Cache/install.lock文件才能覆盖安装!');
</script>
<?php
}
?>
<script type="text/javascript">
window.parent.document.getElementById("laststep").value = '恭喜您点播平台安装成功，点击进入系统首页';
</script>