<?php
require_once('cms_inc.php');
require_once('../system/safe.php');
if(isset($_POST['submit'])){
	if ($_SESSION['verifycode'] != $_POST['verifycode']) {
		alert_href('验证码错误','cms_login.php');
	}
	null_back($_POST['a_name'],'请输入用户名');
	null_back($_POST['a_password'],'请输入密码');
	null_back($_POST['verifycode'],'请输入验证码');
	$a_name = $_POST['a_name'];
	$a_password = $_POST['a_password'];
	$sql = 'select * from cms_admin where a_name = "'.$a_name.'" and a_password = "'.md5($a_password).'"';
	$result = sql_query($sql);
	if(!! $row = sql_fetch_array($result)){
		setcookie('admin_name',$row['a_name']);
		setcookie('admin_password',$row['a_password']);
		setcookie('fannuophpecmsupload','allow',0,'/');
		header('location:cms_channel.php');
	}else{
		alert_href('用户名或密码错误','cms_login.php');
	}
}
?>
<!doctype html>
<html>
<head>
<?php include('./cms_inc_head.php') ?>
<style type="text/css">
body, html {
	width: 100%;
	height: 100%;
}
#layout {
	display: flex;
	justify-content: center;
	flex-direction: row;
	align-items: center;
}
body {
	margin: 0;
	overflow: hidden;
	background: url(loginbg.png) center no-repeat;
}
.background {
	width: 100vw;
	height: 100vh;
}

</style>
</head>
<body>
<div id="layout" class="background">
	<div class="login">
		<div class="name">老董企业网站管理系统</div>
		<div class="version">创业版：<?php echo $system_version;?></div>
		<form method="post">
			<div class="form-group">
				<div class="label"><label for="a_name">用户名/USER NAME</label></div>
				<div class="field">
					<div class="input-group">
						<span class="addon icon-user"> </span>
						<input id="a_name" class="input" name="a_name" type="text" data-validate="required:请输入用户名" value="" />
					</div>
				</div>
			</div>
			<div class="form-group">
				<div class="label"><label for="a_password">密码/PASSWORD</label></div>
				<div class="field">
					<div class="input-group">
						<span class="addon icon-key"> </span>
						<input id="a_password" class="input" name="a_password" type="password" data-validate="required:请输入密码" value="" />
					</div>
				</div>
			</div>
			<div class="form-group">
				<div class="label"><label for="verifycode">验证码</label></div>
				<div class="field">
					<div class="input-group form-auto">
						<span class="addon icon-navicon"></span>
						<input id="verifycode" class="input" name="verifycode" type="text" size="10" data-validate="required:请输入验证码" value="" />
						<img src="../system/verifycode.php" onclick="javascript:this.src='../system/verifycode.php?'+Math.random()" style="cursor:pointer;" alt="点击更换" title="点击更换" />
					</div>
				</div>
			</div>
			<div class="form-group">
				<div class="label"><label></label></div>
				<div class="field">
					<input id="login_submit" class="btn btn-block bg-blue btn-radius" name="submit" type="submit" value="登录后台" />
				</div>
			</div>
			<div class="ac">
				<p>程序开发：<a href="http://www.baidu.com/" target="_blank">老董别克专修</a></p>
			</div>
		</form>
	</div>
</div>
</body>
</html>