<!DOCTYPE html>
<html>
<head>
	<meta charset="<?php echo $cfg_soft_lang; ?>">
	<title>DedeCMSV6程序安装</title>
	<link rel="stylesheet" href="../static/web/css/bootstrap.min.css">
	<link rel="stylesheet" href="../static/web/font/css/font-awesome.min.css">
	<script src="../static/web/js/jquery.min.js"></script>
	<script src="../static/web/js/popper.min.js"></script>
	<script src="../static/web/js/bootstrap.bundle.min.js"></script>
	<script src="../static/web/js/style.js"></script>
	<style>body{font:14px Helvetica Neue,Helvetica,PingFang SC,Tahoma,Arial,sans-serif;color:#343a40;background:#f6f6f6}input,select,.btn{font-size:14px!important}@media (min-width:1170px){.container{max-width:960px}}</style>
</head>
<body>
	<div class="d-flex flex-column flex-md-row align-items-center mb-3 p-3 px-md-5 bg-white border-bottom shadow-sm">
		<h5 class="my-0 mr-md-auto text-success">程序安装</h5>
		<nav class="my-md-0 mr-md-3">
			<a class="p-2 text-dark" href="https://www.dedebiz.com/git" target="_blank">代码托管</a>
			<a class="p-2 text-dark" href="https://www.dedebiz.com/help" target="_blank">帮助中心</a>
			<a class="p-2 text-dark" href="https://www.dedebiz.com/service" target="_blank">技术服务</a>
		</nav>
	</div>
	<main class="container">
		<?php
		if(count($arrMsg) > 0){
			foreach($arrMsg as $msg){
		?>
		<div class="alert alert-warning"><?php echo $msg ?></div>
		<?php
		}
		}
		?>
		<div class="card mb-4 shadow-sm">
			<div class="card-header bg-success text-white">
				<h5 class="my-0 fw-normal text-center">首次运行程序安装DedeCMSV<?php echo $cfg_version_detail;?></h5>
			</div>
			<div class="card-body">
				<form action="index.php" method="post" name="form1">
					<input type="hidden" name="step" value="2" />
					<input type="hidden" name="cookieencode" value="<?php echo $rnd_cookieEncode; ?>">
					<input type="hidden" name="adminmail" value="admin@dedebiz.com">
					<legend>数据库设置</legend>
					<hr>
					<div class="mb-3">
						<label for="dbtype" class="form-label">数据库类型</label>
						<select id="dbtype" name="dbtype" class="form-control form-select">
							<option value="mysql" selected>MySQL</option>
							<option value="sqlite">SQLite</option>
						</select>
						<div class="form-text text-danger">一般为MySQL，SQLite仅用于开发调试不建议生产中使用</div>
					</div>
					<div class="mb-3">
						<label for="dbhost" class="form-label">数据库主机</label>
						<input id="dbhost" name="dbhost" type="text" class="form-control" placeholder="localhost">
					</div>
					<div class="mb-3">
						<label for="dbuser" class="form-label">数据库用户</label>
						<input name="dbuser" id="dbuser" type="text" class="form-control" placeholder="root">
					</div>
					<div class="mb-3">
						<label for="exampleInputPassword1" class="form-label">数据库密码</label>
						<input name="dbpwd" type="text" class="form-control" id="dbpwd" placeholder="">
					</div>
					<div class="mb-3">
						<label for="dbprefix" class="form-label">数据表前缀</label>
						<input name="dbprefix" type="text" class="form-control" id="dbprefix" placeholder="biz_">
						<div class="form-text text-danger">请注意数据库名称默认为biz_</div>
					</div>
					<div class="mb-3">
						<label for="dbname" class="form-label">数据库名称</label>
						<div class="input-group mb-3">
							<input id="dbname" name="dbname" type="text" class="form-control" placeholder="DedeBIZ">
							<div class="input-group-append">
								<button class="btn btn-outline-success" type="button" id="btnCheckConnect">检查连接</button>
							</div>
						</div>
					</div>
					<div id="alertConnect"></div>
					<legend>站点设置</legend>
					<hr>
					<div class="mb-3">
						<label for="adminuser" class="form-label">用户名</label>
						<input name="adminuser" type="text" class="form-control" id="adminuser" placeholder="admin">
						<div class="form-text text-dark">只能用'0-9'、'a-z'、'A-Z'、'.'、'@'、'_'、'-'、'!'以内范围的字符</div>
					</div>
					<div class="mb-3">
						<label for="adminpwd" class="form-label">密码</label>
						<input name="adminpwd" type="text" class="form-control" id="adminpwd" placeholder="admin">
					</div>
					<div class="mb-3">
						<label for="webname" class="form-label">网站名称</label>
						<input name="webname" type="text" class="form-control" id="webname" placeholder="某某公司">
					</div>
					<div class="mb-3">
						<label for="baseurl" class="form-label">网站网址</label>
						<input name="baseurl" type="text" class="form-control" id="baseurl" placeholder="<?php echo $baseurl; ?>">
					</div>
					<div class="mb-3">
						<label for="cmspath" class="form-label">安装目录</label>
						<input name="cmspath" type="text" class="form-control" id="cmspath" value="<?php echo $basepath; ?>" placeholder="<?php echo $basepath; ?>">
						<div class="form-text text-danger">在根目录安装时不必理会</div>
					</div>
					<button type="submit" class="btn btn-success">立即安装</button>
					<span class="ml-2">安装即表示您同意<a href="https://www.dedebiz.com/license?from=install" target="_blank" class="text-success">《站点授权协议》</a></span>
				</form>
			</div>
		</div>
		<footer>
			<div class="row">
				<div class="col-12 col-md">
					<p class="d-block mb-3">© 2022 <a href="https://www.dedebiz.com" target="_blank" class="text-dark">DedeBIZ技术支持</a></p>
				</div>
			</div>
		</footer>
	</main>
	<script>
	$("#btnCheckConnect").click(function() {
		let dbhost = $('#dbhost').val();
		let dbuser = $('#dbuser').val();
		let dbpwd = $('#dbpwd').val();
		if (!dbhost) dbhost = "localhost";
		if (!dbuser) dbuser = "root";
		$.get('index.php?step=10&dbhost=' + dbhost + '&dbuser=' + dbuser + '&dbpwd=' + dbpwd,function(rs){
			console.log(rs);
			let result = JSON.parse(rs);
			if (result.code === 200) {
				ShowAlert("#alertConnect", result.data, "success", 5000);
			} else {
				ShowAlert("#alertConnect", result.data, "danger", 5000);
			}
		})
	})
	</script>
</body>
</html>