forked from dengqiuhua/duty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
133 lines (116 loc) · 4.89 KB
/
login.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
header("content-Type: text/html; charset=utf-8");
session_start();
if($_POST['username']&&$_POST['password']){
$username=trim($_POST['username']);
$password=trim($_POST['password']);
$url=$_GET['url'];
if(login($username,$password)){
$url_return=rawurldecode($url);
//echo "<script>alert('');</script>";
$_SESSION['user']='dengqiuhua';
header("location:$url_return");
}else{
$url_error='/login.php?status=fail&u='.$username.'&url='.$url;
header("location:$url_error");
}
}
//登入
function login($username,$password){
if($username=='dengqiuhua' && md5($password)=='e10adc3949ba59abbe56e057f20f883e'){
return true;
}
return false;
}
//退出
if(isset($_GET['act'])&&$_GET['act']=='loginout'){
unset($_SESSION['user']);
header("location:login.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
Remove this if you use the .htaccess -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>登录-duty</title>
<meta name="description" content="">
<meta name="author" content="邓秋华">
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and delete these references -->
<link rel="shortcut icon" href="style/images/favicon.ico">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<link rel="stylesheet" href="style/css/bootstrap.css" />
<script type="text/javascript" src="style/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="style/js/bootstrap.js"></script>
</head>
<body>
<div id="container" class="container-fluid">
<?php
$nav=6;
require("header.php");
?>
<div class="row-fluid" style="min-height:500px; margin-top: 5%; margin-left: 30%;margin-right: 30%;">
<div class="span5 well">
<div id="index_form">
<div class="page-header">
<h3>登入</h3>
</div>
<form class="form-horizontal" action="" method="post" onsubmit="return validateLoginForm();">
<div class="control-group">
<label class="control-label" for="inputEmail">用户名</label>
<div class="controls">
<input type="text" name="username" id="inputEmail" style="height:29px;"
value="<?=$_GET&&isset($_GET['u'])?$_GET['u']:'';?>" placeholder="用户名">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">密码</label>
<div class="controls">
<input type="password" name="password" id="inputPassword" style="height:29px;" placeholder="密码" value="">
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" class="btn btn-info">登录</button>
</div>
</div>
<?php
if(isset($_GET['status']) && $_GET['status']=='fail'){
?>
<div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>用户名或密码错误!</strong>
</div>
<?php
}
?>
</form>
<script type="text/javascript">
//登入验证
var validateLoginForm = function () {
if ($.trim($("input[name=username]").val()) == "") {
$("input[name=username]").focus().css("border", "1px solid red");
return false;
}
if ($.trim($("input[name=password]").val()) == "") {
$("input[name=password]").focus().css("border", "1px solid red");
return false;
}
return true;
};
$(function () {
$("input[name=username],input[name=password]").on("keyup", function () {
$(this).css("border", "1px solid #ccc");
});
});
</script>
</div>
</div>
</div>
<!--/row-->
</div>
</body>
</html>