代码拉取完成,页面将自动刷新
<?php
include_once('config/config.php');
$LoginAdmin = checkAuth();
$sql = "select `id`,`username`,`avatar` from `pre_admin`";
$result = all($sql);
// pre($result);
if($_GET)
{
$deleteid = $_GET['deleteid'] ?? 0;
$res = del('admin',"`id` = $deleteid");
if($res['code'] === 0){
showMsg($res['msg']);
}else{
showMsg($res['msg'],'admin.php');
}
}
// pre($result);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include_once('common/meta.php'); ?>
</head>
<body>
<!-- 引入头部 -->
<?php include_once('common/header.php');?>
<!-- 引入菜单栏 -->
<?php include_once('common/menu.php'); ?>
<div class="content">
<div class="header">
<h1 class="page-title">管理员列表</h1>
</div>
<ul class="breadcrumb">
<li><a href="index.php">Home</a> <span class="divider">/</span></li>
<li class="active">管理员管理</li>
</ul>
<div class="container-fluid">
<div class="row-fluid">
<div class="btn-toolbar">
<button class="btn btn-primary" onClick="location='adminAdd.php'"><i class="icon-plus"></i>添加管理员</button>
</div>
<div class="well">
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>昵称</th>
<th>头像</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php foreach($result as $item) {?>
<tr>
<td><?php echo $item['id'];?></td>
<td><?php echo $item['username'];?></td>
<td>
<a href="<?php echo @is_file(ltrim($item['avatar'],'/')) ? $item['avatar'] : '/assets/images/avatar.png';?>" target="_blank">
<img src="<?php echo @is_file(ltrim($item['avatar'],'/')) ? $item['avatar'] : '/assets/images/avatar.png';?>" width="35" alt="">
</a>
</td>
<td>
<a onclick="edit(<?php echo $item['id']; ?>)" href="#"><i class="icon-pencil"></i></a>
<a onclick="del(<?php echo $item['id'];?>)" href="#"><i class="icon-remove"></i></a>
</td>
</tr>
<?php }?>
</tbody>
</table>
</div>
<!-- <div class="modal small hide fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">删除数据提醒</h3>
</div>
<div class="modal-body">
<p class="error-text"><i class="icon-warning-sign modal-icon"></i>是否确认删除该管理员?</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
<button id="confirm" class="btn btn-danger" data-dismiss="modal">确认</button>
</div>
</div> -->
<!-- 引入底部 -->
<?php include_once('common/footer.php'); ?>
</div>
</div>
</div>
</body>
</html>
<?php include_once('common/script.php'); ?>
<script>
// 管理员删除
function del(id){
console.log('id',id);
let login_id = <?php echo $LoginAdmin['id']; ?>;
if(login_id !== 1){
alert('没有对应权限,请联系超级管理员');
return;
}
let value = confirm("确认删除该管理员?");
if(value){
location.href = 'admin.php?deleteid=' + id;
}
}
// 管理员编辑
function edit(id){
let login_id = <?php echo $LoginAdmin['id']; ?>;
if(login_id === 1){
location.href = 'adminEdit.php?id=' + id;
}else if(login_id === id){
location.href = 'adminEdit.php?id=' + id;
}else{
alert('没有权限,不是本人或超级管理员');
return;
}
}
</script>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。