<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
		<title>更新首页</title>
		<script src="../static/web/js/jquery.min.js"></script>
		<link rel="stylesheet" href="../static/web/font/css/font-awesome.min.css">
		<link rel="stylesheet" href="../static/web/css/bootstrap.min.css">
		<link rel="stylesheet" href="../static/web/css/admin.css">
		<script src="js/main.js"></script>
	</head>
	<body>
		<form name="form1" action="makehtml_homepage.php" target="stafrm" method="post">
			<input type="hidden" name="dopost" value="make">
			<table align="center" class="table maintable my-3">
				<tr>
					<td bgcolor="#f5f5f5" colspan="2">更新首页</td>
				</tr>
				<tr>
					<td colspan="2">
						<div class="alert alert-info mb-0">首页默认更新文件存放在根目录，如果不是根目录安装网站又想首页更新到网站根目录，使用相对路径来表示首页位置，例：安装在“http://www.abc.com/DedeBIZ/目录”，更新首页为：“http://www.abc.com/index.html”，填写：“../index.html”</div>
					</td>
				</tr>
				<tr>
					<td width="260">选择首页模板：</td>
					<td>
						<input type="text" name="templet" id="templet" value="<?php echo $row['templet']?>" class="admin-input-sm">
						<button type="button" name="set4" value="" class="btn btn-success btn-sm" onclick="SelectTemplets('form1.templet');">选择</button>
					</td>
				</tr>
				<tr>
					<td>首页位置：</td>
					<td><input type="text" name="position" id="position" value="<?php echo $row['position']?>" class="admin-input-sm"></td>
				</tr>
				<tr>
					<td>相关选项：</td>
					<td>
						<label><input type="radio" name="saveset" value="0"> 不保存当前选项</label>
						<label><input type="radio" name="saveset" value="1" checked> 保存当前选项</label>
					</td>
				</tr>
				<tr>
					<td>首页模式:</td>
					<td>
						<label><input type="radio" name="showmod" value="0" <?php echo ($row['showmod']==0)? "checked='checked'" : "";?>> 动态浏览</label>
						<label><input type="radio" name="showmod" value="1" <?php echo ($row['showmod']==1)? "checked='checked'" : "";?>> 生成静态</label>
					</td>
				</tr>
				<?php
				if (!empty($cfg_bizcore_appid) && !empty($cfg_bizcore_key)) {
					$client = new DedeBizClient();
					$data = $client->AdminPWDExists();
					if ($data->code == -1) {
				?>
				<tr>
					<td colspan="2">启动商业组件失败，<a href="https://www.dedebiz.com/start?code=-1008" target="_blank" class="btn btn-warning btn-sm ml-2">如何启动组件</a></td>
				</tr>
				<?php
				} else {
					$data = json_decode($data->data);
					$rs = (array)($data->result);
					if ($rs["admin_pwd_exists"] == "false") {
				?>
				<tr>
					<td>设置密码：</td>
					<td><input name="dedebiz_admin" type="password" id="dedebiz_admin" value="" class="admin-input-sm">设定后所有的DedeBIZ涉及安全操作输入当前操作密码</td>
				</tr>
				<tr>
					<td>重复密码：</td>
					<td><input name="re_dedebiz_admin" type="password" id="re_dedebiz_admin" value="" class="admin-input-sm"></td>
				</tr>
				<?php } else {?>
				<tr>
					<td>操作密码：</td>
					<td><input name="dedebiz_admin" type="password" id="dedebiz_admin" value="" class="admin-input-sm"></td>
				</tr>
				<tr>
					<td>首页状态：</td>
					<td>
						<label><input type="radio" name="lockindex" value="unlock" <?php echo ($rs['index_lock_state']==true)? "checked='checked'" : "";?>> 解锁</label>
						<label><input type="radio" name="lockindex" value="lock" <?php echo ($row['index_lock_state']==false)? "checked='checked'" : "";?>> 锁定</label>
					</td>
				</tr>
				<?php }}} else {?>
				<tr>
					<td colspan="2">启动商业组件失败<a href="https://www.dedebiz.com/start?code=-1008" target="_blank" class="btn btn-warning btn-sm ml-2">启动组件</a></td>
				</tr>
				<?php }?>
				<tr>
					<td bgcolor="#e9ecef" colspan="2" align="center">
						<button type="submit" name="submit" class="btn btn-success btn-sm">开始更新</button>
						<button type="button" name="view" class="btn btn-outline-success btn-sm" onclick="window.open('makehtml_homepage.php?dopost=view&templet='+form1.templet.value);">预览首页</button>
					</td>
				</tr>
				<tr>
					<td colspan="2" id="mtd">
						<div id="mdv" class="admin-win-iframe"><iframe name="stafrm" frameborder="0" id="stafrm" width="100%" height="100%"></iframe></div>
					</td>
				</tr>
			</table>
		</form>
		<script>
			function SelectTemplets(fname) {
				var pos = GetWinPos(800, 600);
				window.open("./dialog/select_templets.php?f=" + fname, "poptempWin","scrollbars=yes,resizable=yes,statebar=no,width=800,height=600,left=" + pos.left + ", top=" + pos.top);
			}
			function htmlSubmit() {
				form1.submit();
				$("#dedebiz_admin").val("");
			}
		</script>
	</body>
</html>