<%@ page language="java" pageEncoding="utf-8"%>
<%@ page import="java.util.List,java.util.Map,com.tom.cache.ConfigCache,com.tom.util.SystemCode, com.tom.util.Config"  %>
<% 
String action = (String) request.getParameter("action");
%>
<!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>
	<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	%>
	<base href="<%=basePath%>" />
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" type="text/css" href="skins/default/style.css" />
	<link rel="stylesheet" type="text/css" href="skins/default/nav.css" />
	<link rel="stylesheet" type="text/css" href="skins/default/validationEngine.css" />
	<script src="inc/jquery.js" type="text/javascript"></script>
	<script src="inc/validationEngine.js" type="text/javascript"></script>
	<script src="inc/util.js" type="text/javascript"></script>
	<title>TomExam</title>
	<style>
		#div_rightinfo{display:none;padding:5px;border:dotted 1px #f00; clear:both;margin-top:5px; background:#ffe}
		#div_sys_accesslist_setting{display:none;padding:5px;border:dotted 1px #cde; clear:both;margin-top:5px;}
		.txtx{font-size:9pt}
	</style>
</head>
<body class="body">
	
	
	<ul id="breadcrumb">
        <li><a href="welcome.jsp"><img src="skins/images/home_blk.gif" alt="Home" class="home" /></a></li>
		<li>系统参数管理</li>
    </ul>
    
    <br />
	欢迎使用 <b><%=Config.get("system_name") %> V<%=Config.get("system_version") %></b> , 
	系统参数管理，选择参数进行设置，请谨慎操作。
	
	<br /><br />

	
	<table class="stable" width="100%" align="center">

		<form action="system/config.do?action=update&key=sys_sitename" method="post">
			<tr>
				<th style="width:150px">系统名称</th>
				<td>
					<input type="text" name="sys_sitename"  class="validate[required] txtfree" value="<%=ConfigCache.getConfigByKey("sys_sitename") %>" size="50" maxlength="50" />
				</td>
				<td><input type="submit" value=" 提 交 " class="btn" /></td>
			</tr>
		</form>

		<form action="system/config.do?action=update&key=sys_register" method="post">
			<tr>
				<th>开放注册</th>
				<td>
					<select name="sys_register">
						<option value="on" style="background:#0f0">开放注册</option>
						<option value="off" style="background:#f00">关闭注册</option>
					</select>
					(是否允许用户注册)
				</td>
				<td><input type="submit" value=" 提 交 " class="btn" /></td>
			</tr>
		</form>

		<form action="system/config.do?action=update&key=sys_userlogin" method="post">
			<tr>
				<th>开放普通用户登陆</th>
				<td>
					<select name="sys_userlogin">
						<option value="on" style="background:#0f0">开放登陆</option>
						<option value="off" style="background:#f00">关闭登陆</option>
					</select>
					(是否允许普通用户登陆)
				</td>
				<td><input type="submit" value=" 提 交 " class="btn" /></td>
			</tr>
		</form>

		<form action="system/config.do?action=update&key=sys_uncheckuser_exam" method="post">
			<tr>
				<th>开放待审核用户答卷</th>
				<td>
					<select name="sys_uncheckuser_exam">
						<option value="on" style="background:#0f0">允许</option>
						<option value="off" style="background:#f00">不允许</option>
					</select>
					(是否允许待审核用户答卷)
				</td>
				<td><input type="submit" value=" 提 交 " class="btn" /></td>
			</tr>
		</form>

		<form action="system/config.do?action=update&key=sys_communication_rate" method="post">
			<tr>
				<th>通讯频率</th>
				<td>
					<input type="text" name="sys_communication_rate"  class="validate[required,custom[onlyNumber]] txtfree"
					value="<%=ConfigCache.getConfigByKey("sys_communication_rate") %>" size="2" maxlength="2" /> 分钟
					(设置过小可能影响系统性能，建议3分钟)
				</td>
				<td><input type="submit" value=" 提 交 " class="btn" /></td>
			</tr>
		</form>

		<form action="system/config.do?action=update&key=sys_access_status" method="post">
			<tr>
				<th>黑白名单设置</th>
				<td>
					<select name="sys_access_status" 
					onchange="javascript:func_sys_access_status(this.value)">
						<option value="not_on" >无</option>
						<option value="black_on" style="background:#000;color:#fff">开启黑名单</option>
						<option value="while_on" >开启白名单</option>
					</select>
					(是否开启黑名单或白名单功能)
					<div id="div_sys_accesslist_setting">
						<textarea name="sys_accesslist_setting" class="txtx" rows="5" cols="60"><%=ConfigCache.getConfigByKey("sys_accesslist_setting") %></textarea>
						<div>
							<b>黑名单</b>：不允许访问的IP<br/>
							<b>白名单</b>：仅允许访问的IP<br/>
							以#分隔，如：192.168.22.43#192.168.22.46，该设置对普通用户有效。
						</div>
					</div>
				</td>
				<td valign="top"><input type="submit" value=" 提 交 " class="btn" onclick="return window.confirm('该操作将影响所有用户的登录权限，请务必谨慎操作，确定吗？');" /></td>
			</tr>
		</form>
		<script>
			function func_sys_access_status(val){
				if('not_on' == val){
					$('#div_sys_accesslist_setting').hide();
				}else if('black_on' == val){
					$('#div_sys_accesslist_setting').show();
				}else if('while_on' == val){
					$('#div_sys_accesslist_setting').show();
				}
			}
		</script>


		<form action="system/config.do?action=update&key=sys_sncode" onsubmit="return window.confirm('确定要注册码修改吗？建议对旧注册码做好备份工作。');" method="post">
			<tr>
				<th>授权信息</th>
				<td>
					<input type="text" name="sys_sncode"  class="validate[required] txtfree"
					value="<%=ConfigCache.getConfigByKey("sys_sncode") %>" size="50" maxlength="50" />
					(请输入正版注册码，<font color="red">请谨慎修改</font>)
					&nbsp; &nbsp; [<a href="javascript:;" onclick="$('#div_rightinfo').toggle();">详情</a>]
					<div id="div_rightinfo">
						<%
						String machinecode = (String)request.getAttribute("machinecode");
						String copyright_info = (String)request.getAttribute("copyright_info");
						if("0000".equals(copyright_info)){
							out.print("<img src=\"skins/images/true.png\" height=\"30\" align=\"absmiddle\" /> 注册码验证通过！");
						}else{
							out.print(copyright_info);
						}
						out.println("<hr size=\"1\" style=\"color:#ddd\" />机"+"器"+"码："+machinecode+"");
						%>
					</div>
				</td>
				<td valign="top"><input type="submit" value=" 提 交 " class="btn" /></td>
			</tr>
		</form>

	</table>
	
	
	
	<script>
		$(function(){
			$("select[name=sys_register]").val('<%=ConfigCache.getConfigByKey("sys_register") %>');
			$("select[name=sys_userlogin]").val('<%=ConfigCache.getConfigByKey("sys_userlogin") %>');
			$("select[name=sys_uncheckuser_exam]").val('<%=ConfigCache.getConfigByKey("sys_uncheckuser_exam") %>');

			var _sys_access_status = '<%=ConfigCache.getConfigByKey("sys_access_status") %>';
			$("select[name=sys_access_status]").val(_sys_access_status);
			if("not_on" != _sys_access_status){
				$('#div_sys_accesslist_setting').show();
			}
		});
	</script>
	

</body>
</html>


