1 Star 0 Fork 0

sky/company

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
admin.php 4.78 KB
一键复制 编辑 原始数据 按行查看 历史
sky 提交于 2024-01-04 15:13 . 提交项目
<?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>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/JIE_XIAOQIU/company.git
git@gitee.com:JIE_XIAOQIU/company.git
JIE_XIAOQIU
company
company
master

搜索帮助