-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusermanagement.php
217 lines (202 loc) · 8.03 KB
/
usermanagement.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<!-- <link rel="icon" href="../../favicon.ico"> -->
<title>Forum</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/main.css" rel="stylesheet">
<!-- jQuery -->
<script src="js/jquery-2.1.4.min.js"></script>
<!-- Bootstrap -->
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.twbsPagination.min.js"></script>
</head>
<body>
<?php
/**
* Created by PhpStorm.
* User: Henry
* Date: 2015/6/16
* Time: 12:01
*/
include('connect.php');
require('checkvalid.php');
$username = $_SESSION['username'];
$u_id = $_SESSION['u_id'];
$role = $_SESSION['role'];
$status = $_SESSION['status'];
if($role != 0){
?>
<script>
alert("权限不足!");
location.href = "index.php";
</script>
<?php
exit();
}
?>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="nav-wrapper">
<div class="container-fluid">
<ul class="nav navbar-nav ">
<li class="divider-vertical"></li>
<li><a href="index.php"><b>论坛首页</b></a></li>
</ul>
<form class="navbar-form navbar-left" role="search" method="post" action="posts.php">
<div class="form-group">
<input type="text" name="keyword" class="form-control" placeholder="帖子主题">
</div>
<button type="submit" class="btn btn-default" name="search">搜索</button>
</form>
<ul class="nav navbar-nav navbar-right">
<li>
<div class="navbar-header">
<img alt="avatar" src="<?php echo $_SESSION['avatar']; ?>" class="img-nav img-rounded">
</div>
</li>
<li class="dropdown">
<a href="#" id="username-nav" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><?php echo $username ?>
<!-- <span class="caret"></span> -->
</a>
<ul class="dropdown-menu" role="menu">
<li><a href="editinfo.php">编辑信息</a></li>
<li><a href="message.php">短消息</a></li>
<?php if($_SESSION['role'] == 0){ ?>
<li><a href="usermanagement.php">用户管理</a></li>
<li><a href="boardmanagement.php">版块管理</a></li>
<?php } ?>
<li class="divider"></li>
<li><a href="logout.php">注销</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="divider-vertical"></li>
<li><a>浏览 <span class="sr-only">(current)</span></a></li>
<li class="divider-vertical"></li>
<li><a href="top10.php">热门帖子</a></li>
<li class="divider-vertical"></li>
<li><a>公告</a></li>
<li class="divider-vertical"></li>
<li class="divider-vertical-invisable"></li>
<li class="divider-vertical-invisable"></li>
<li class="divider-vertical-invisable"></li>
<li class="divider-vertical-invisable"></li>
</ul>
</div>
</div>
</nav>
<div class="panel panel-default panel-size">
<div class="panel-heading">
<ol class="breadcrumb breadcrumb-post">
<li class="active">用户管理</li>
</ol>
</div>
<div class="panel-body" style="padding-bottom: 0px">
<table class="table table-striped table-hover table-content">
<thead>
<tr>
<th>用户ID</th>
<th>用户名</th>
<th>性别</th>
<th>个性签名</th>
<th>手机</th>
<th>邮箱</th>
<th>发帖数</th>
<th>组别</th>
<th>状态</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT count(*) FROM `user_simple`;";
$query = mysql_query($sql);
$user_number = mysql_fetch_array($query)[0];
if(!isset($_GET['page'])){
$pagestart = 0;
}else {
$pagestart = ($_GET['page'] - 1) * 10;
}
$sql = "SELECT `u_id`, `username`, `role`, `status` FROM `user_simple` order by `u_id`"." LIMIT ".$pagestart.", 10;";
$sql2 = "SELECT `gender`, `description`, `phone`, `email`, `posts_counts` FROM `user_details` order by `u_id`"." LIMIT ".$pagestart.", 10;";
$query = mysql_query($sql);
$query2 = mysql_query($sql2);
while ($row = mysql_fetch_array($query, MYSQL_BOTH)) {
$row2 = mysql_fetch_array($query2, MYSQL_BOTH);
?>
<tr class="table-hover">
<td width="10%">
<p style="margin-bottom: 0px"><?php echo $row['u_id'] ?></p>
</td>
<td width="10%">
<p style="margin-bottom: 0px"><?php echo $row['username'] ?></p>
</td>
<td width="10%">
<p style="margin-bottom: 0px"><?php echo ($row2['gender'] == 'M') ? "男" : "女" ?></p>
</td>
<td width="15%">
<p style="margin-bottom: 0px"><?php echo $row2['description'] ?></p>
</td>
<td width="15%">
<p style="margin-bottom: 0px"><?php echo $row2['phone'] ?></p>
</td>
<td width="10%">
<p style="margin-bottom: 0px"><?php echo $row2['email'] ?></p>
</td>
<td width="10%">
<p style="margin-bottom: 0px"><?php echo $row2['posts_counts'] ?></p>
</td>
<td width="10%">
<p style="margin-bottom: 0px"><?php echo ($row['role'] == 0) ? "管理员" : (($row['role'] == 1) ? "学生" : "教师") ?></p>
</td>
<td width="10%" align="center">
<?php if($row['status']){ ?>
<button class="btn btn-danger btn-xs btn-admit" onclick="javascript:if(confirm('确定恢复正常?'))location='changestatus.php?u_id=<?php echo $row['u_id'] ?>¤tstatus=1'">禁言</button>
<?php }else{ ?>
<button class="btn btn-success btn-xs btn-forbid" onclick="javascript:if(confirm('确定禁言用户?'))location='changestatus.php?u_id=<?php echo $row['u_id'] ?>¤tstatus=0'">正常</button>
<?php } ?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
<div class="text-center">
<ul class="pagination">
</ul>
</div>
<script type="text/javascript">
$('.pagination').twbsPagination({
totalPages: <?php echo ceil($user_number / 10.0) ?>,
visiblePages: 5,
href : '?page={{number}}'
// onPageClick: function (event, page) {
// $('#page-content').text('Page ' + page);
// }
});
$(".btn-forbid").mouseover(function () {
this.innerHTML = "禁言"
})
$(".btn-forbid").mouseout(function () {
this.innerHTML = "正常"
})
$(".btn-admit").mouseover(function () {
this.innerHTML = "恢复"
})
$(".btn-admit").mouseout(function () {
this.innerHTML = "禁言"
})
</script>
</body>
</html>