<?php
session_start();
ini_set('date.timezone','Asia/Shanghai');
header("Content-Type:text/html;Charset=utf-8");
error_reporting(0);
/*
------------------------------------
Willow Management System
copyright 2012 Gerry
author Gerry Peng <kkgerry@163.com>
version 1.0
------------------------------------
*/
$Willow_User_id = NULL;
if(isset($_COOKIE['#WILLOW_M_COOKIES#'])){
	$Willow_User_id = $_COOKIE['#WILLOW_M_COOKIES#']['willow_m_users_id'];
}else{
	if(isset($_SESSION['#WILLOW_M_COOKIES#'])){
		$Willow_User_id = $_SESSION['#WILLOW_M_COOKIES#']['willow_m_users_id'];
	}
}

if($Willow_User_id){
	echo '<script>location.href="#WILLOW_M_DEFAULT#";</script>';
	die();
}
include('willow-manage/inc/Gerry-Identify-Code.php');
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login Willow Manangement system</title>
<style type="text/css">
body{background:#FFF;margin:0px; padding:0px;}
body,td,th {
	font:12px/1.6 Verdana, "微软雅黑"; color:#333;
}
.willow_login{ background:url(images/login_background.jpg) no-repeat 0px 0px; width:670px; height:445px; 	position: absolute;	top: 50%;	left: 50%;	margin: -20% 0 0 -25%; text-align:left;}
.willow_table{ margin:150px 0px 0px 230px;}
.willow_table td{ padding:5px;}
.willow_table td span{ color:#F00;}
.willow_input{ border:1px solid #bfbdbe; padding:5px;}
.willow_title{ font-size:18px; font-family:"微软雅黑";}
</style>
<script language="javascript">
function check_login(){
	
	var form = document.willow_login_form;
	
	if(form.willow_username.value.length < 4 || form.willow_username.value.length > 12){
		document.getElementById('willow_user_alert').innerHTML = '账号错误！';
		form.willow_username.focus();
		return false;
	}
	document.getElementById('willow_user_alert').innerHTML = '';
	
	if(form.willow_password.value.length < 4 || form.willow_password.value.length > 16){
		document.getElementById('willow_pwd_alert').innerHTML = '密码错误！';
		form.willow_password.focus();
		return false;
	}	
	document.getElementById('willow_pwd_alert').innerHTML = '';
	
	
	
	if(form.willow_identify.value.length != 4){
		document.getElementById('willow_identify_alert').innerHTML = '验证码错误！';
		form.willow_identify.focus();
		return false;
	}
	
	if(isNaN(form.willow_identify.value)){
		document.getElementById('willow_identify_alert').innerHTML = '验证码必须是数字！';
		form.willow_identify.focus();
		return false;
	}
	document.getElementById('willow_identify_alert').innerHTML = '';
	
	form.action='willow-logon.php';
}

</script>
</head>

<body>
<div class="willow_login">
<form name="willow_login_form" method="post" onsubmit="return check_login();">
<table width="410" border="0" cellspacing="0" cellpadding="0" class="willow_table">
  <tr>
    <td width="17%" align="center" class="title">账　号</td>
    <td width="83%"><input name="willow_username" type="text" class="willow_input" style="width:120px;" />&nbsp;<span id="willow_user_alert"></span></td>
  </tr>
  <tr>
    <td align="center">密　码</td>
    <td><input name="willow_password" type="password" class="willow_input" style="width:120px;" />&nbsp;<span id="willow_pwd_alert"></span></td>
    </tr>
  <tr>
    <td align="center">验证码</td>
    <td><input name="willow_identify" type="text"  class="willow_input" style="width:45px" maxlength="4" />&nbsp;
<?php
echo _Get_Identify(4);
?>&nbsp;&nbsp;<label style="cursor:pointer; text-decoration:underline; color:#0047b6;" class="text_blue" onclick="location.reload();">刷新</label>&nbsp;<span id="willow_identify_alert"></span></td>
    </tr>
  <tr>
    <td>&nbsp;</td>
    <td><label><input type="checkbox" name="willow_remember" id="radio" value="1" />记住我的登录状态</label></td>
    </tr>
    <td>&nbsp;</td>
    <td><input name="button" type="image" src="images/willow-login-button.jpg" onclick="check_login();" /></td>
    </tr>
  </table>
</form>
</div>

</body>
</html>