first commit

This commit is contained in:
2025-11-28 14:28:58 +08:00
commit 6ef96e6370
314 changed files with 40282 additions and 0 deletions
+147
View File
@@ -0,0 +1,147 @@
<?php
/*
Name:用户操作API
Version:1.0
Author:易如意
Author QQ:51154393
Author Url:www.eruyi.cn
*/
if(!isset($islogin))header("Location: /");//非法访问
if($act == 'add'){
$user = isset($_POST['user']) ? purge($_POST['user']) : '';
$pwd = isset($_POST['pwd']) ? purge($_POST['pwd']) : '';
$appid = isset($_POST['appid']) ? intval($_POST['appid']) : 0;
$reg_time = time();
if($user == '')json(201,'账号不能为空');
if($pwd == '')json(201,'密码不能为空');
if($appid == 0)json(201,'绑定应用不能为空');
if(preg_match ("/^[\w]{5,11}$/",$user)==0)json(201,'账号长度5-11位数');
if(preg_match ("/^[a-zA-Z\d.*_-]{6,18}$/",$pwd)==0)json(201,'密码长度需要满足6-18位数,不支持中文以及.-*_以外特殊字符');
$app_res = Db::table('app')->where('id',$appid)->find();
if(!$app_res)json(201,'应用不存在');
$user_res = Db::table('user')->where(['appid'=>$appid,'user'=>$user])->find();
if($user_res)json(201,'账号已存在');
$add_res = Db::table('user')->add(['user'=>$user,'pwd'=>md5($pwd),'appid'=>$appid,'reg_time'=>$reg_time]);
//die($res);
if($add_res){
if(defined('ADM_LOG') && ADM_LOG == 1){Db::table('log')->add(['group'=>'adm','type'=>'user_add','status'=>200,'time'=>time(),'ip'=>getip(),'data'=>json_encode($_POST)]);}//记录日志
json(200,'添加成功');
}else{
if(defined('ADM_LOG') && ADM_LOG == 1){Db::table('log')->add(['group'=>'adm','type'=>'user_add','status'=>201,'time'=>time(),'ip'=>getip(),'data'=>json_encode($_POST)]);}//记录日志
json(201,'添加失败');
}
}
if($act == 'muladd'){
//测试生成txt文件
$dirname = './muladd/';
if(!is_dir($dirname)){
mkdir($dirname,0775);
}
$num = isset($_POST['num']) ? purge($_POST['num']) : '';
$days = isset($_POST['days']) ? purge($_POST['days']) : '';
$appid = isset($_POST['appid']) ? intval($_POST['appid']) : 0;
$now = isset($_POST['now']) ? intval($_POST['now']) : 0;
$reg_time = time();
if($num <= 0)json(201,'账号个数不能为空');
if($days <= 0)json(201,'会员时间不能为空');
if($appid == 0)json(201,'绑定应用不能为空');
if($num > 1000) {
json(201,'账号个数不能大于1000');
}
$app_res = Db::table('app')->where('id',$appid)->find();
if(!$app_res)json(201,'应用不存在');
if(defined('ADM_LOG') && ADM_LOG == 1){Db::table('log')->add(['group'=>'adm','type'=>'user_add','status'=>200,'time'=>time(),'ip'=>getip(),'data'=>json_encode($_POST)]);}//记录日志
$i = 0;
$arr = array();
$file_name = "{$reg_time}.txt"; //保存的文件名称
$myfile = fopen($dirname . $file_name, "w");
while($i < $num){
//账号名称 随机8位数字
$username = rand(10000000,99999999);
if(in_array($username,$arr)){
$username = rand(10000000,99999999);
}
$arr[] = $username;
//账号密码 随机6位数字
$password = rand(100000,999999);
if($days >= 999999){
$vip = $days;
}else{
$vip = time() + $days * 24 * 3600;
}
$add_res = Db::table('user')->add(['user'=>$username,'pwd'=>md5($password),'appid'=>$appid,'vip'=>$vip,'reg_time'=>$reg_time]);
if($add_res){
//保存数据到文件
fwrite($myfile,"账号:".$username."\n密码:".$password."\n\n");
}
$i++;
}
fclose($myfile);
$res = array(
'code'=>200,
'msg'=>'添加成功',
);
if($now){
$res['data'] = file_get_contents($dirname.$file_name);
}
echo json_encode($res);exit;
}
if($act == 'edit'){
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
$update['fen'] = isset($_POST['fen']) ? intval($_POST['fen']) : 0;
$update['vip'] = isset($_POST['vip']) ? intval($_POST['vip']) : 0;
$update['ban'] = isset($_POST['ban']) ? intval($_POST['ban']) : 0;
$update['ban_notice'] = isset($_POST['ban_notice']) ? purge($_POST['ban_notice']) : '';
$update['openid_qq'] = isset($_POST['openid_qq']) ? purge($_POST['openid_qq']) : '';
$update['openid_wx'] = isset($_POST['openid_wx']) ? purge($_POST['openid_wx']) : '';
$pwd = isset($_POST['pwd']) ? purge($_POST['pwd']) : '';
if($pwd != ''){
$pass = md5($pwd);
$update['pwd'] = $pass;
}
$res = Db::table('user')->where('id',$id)->update($update);
//die($res);
if($res){
if(defined('ADM_LOG') && ADM_LOG == 1){Db::table('log')->add(['group'=>'adm','type'=>'user_edit','status'=>200,'time'=>time(),'ip'=>getip(),'data'=>json_encode($_POST)]);}//记录日志
json(200,'编辑成功');
}else{
if(defined('ADM_LOG') && ADM_LOG == 1){Db::table('log')->add(['group'=>'adm','type'=>'user_edit','status'=>201,'time'=>time(),'ip'=>getip(),'data'=>json_encode($_POST)]);}//记录日志
json(201,'编辑失败');
}
}
if($act == 'del'){//删除用户
$id = isset($_POST['id']) ? $_POST['id'] : '';
if($id){
$ids = '';
foreach ($id as $value) {
$ids .= intval($value).",";
}
$ids = rtrim($ids, ",");
$res = Db::table('user')->where('id','in','('.$ids.')')->del();//false
//die($res);
if($res){
if(defined('ADM_LOG') && ADM_LOG == 1){Db::table('log')->add(['group'=>'adm','type'=>'user_del','status'=>200,'time'=>time(),'ip'=>getip(),'data'=>json_encode($_POST)]);}//记录日志
json(200,'删除成功');
}else{
if(defined('ADM_LOG') && ADM_LOG == 1){Db::table('log')->add(['group'=>'adm','type'=>'user_del','status'=>201,'time'=>time(),'ip'=>getip(),'data'=>json_encode($_POST)]);}//记录日志
json(201,'删除失败');
}
}else{
json(201,'没有需要删除的数据');
}
}
?>
+14
View File
@@ -0,0 +1,14 @@
<?php
/*
* File:后台目录菜单配置文件
* Author:易如意
* QQ51154393
* Urlwww.eruyi.cn
*/
return [
'id' => 'user',
'name' => '用户',
'icons' => 'mdi mdi-account',
'sort' => 3, //排序
];
+391
View File
@@ -0,0 +1,391 @@
<?php
/*
Sort:1
Hidden:false
Name:用户管理
Url:user_adm
Right:user
Version:1.0
Author:易如意
Author QQ:51154393
Author Url:www.eruyi.cn
*/
if(!isset($islogin))header("Location: /");//非法访问
$nums=Db::table('user')->count();//获取用户总数
$page=isset($_GET['page']) ? intval($_GET['page']) : 1;
$url="./?user_adm&page=";
$bnums=($page-1)*$ENUMS;
?>
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box">
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="javascript: void(0);">首页</a></li>
<li class="breadcrumb-item active">用户</li>
</ol>
</div>
<h4 class="page-title"><?php echo $title; ?></h4>
</div> <!-- end page-title-box -->
</div> <!-- end col-->
</div>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="row mb-2">
<div class="col-lg-8">
<button type="button" class="btn btn-danger mb-2 mr-2" data-toggle="modal" data-target="#add"><i class="mdi mdi-account-multiple-plus mr-1"></i>添加用户</button>
<button type="button" class="btn btn-danger mb-2 mr-2" data-toggle="modal" data-target="#muladd"><i class="mdi mdi-account-multiple-plus mr-1"></i>批量添加用户</button>
</div>
<div class="col-lg-4">
<div class="text-lg-right">
<form action="" method="post">
<div class="input-group">
<input type="text" class="form-control" name="so" placeholder="搜索用户" value='<?php echo $so; ?>'>
<span class="mdi mdi-magnify"></span>
<div class="input-group-append">
<button class="btn btn-primary" type="submit">搜索</button>
</div>
</div>
</form>
</div>
</div><!-- end col-->
</div>
<form action="" method="post" name="form_log" id="form_log">
<div class="table-responsive">
<table class="table table-centered table-striped dt-responsive nowrap w-100">
<thead>
<tr>
<th style="width: 20px;">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="all" onclick="checkAll();">
<label class="custom-control-label" for="all">&nbsp;</label>
</div>
</th>
<th style="width: 20px;"><center><span class="badge badge-light-lighten">UID</span></center></th>
<th><span class="badge badge-light-lighten">账号</span></th>
<th style="width: 120px;"><center><span class="badge badge-light-lighten">用户组</span></center></th>
<th style="width: 120px;"><center><span class="badge badge-light-lighten">应用名</span></center></th>
<th style="width: 150px;"><center><span class="badge badge-light-lighten">注册时间</span></center></th>
<th style="width: 100px;"><center><span class="badge badge-light-lighten">在线设备</span></center></th>
<th style="width: 100px;"><center><span class="badge badge-light-lighten">账号状态</span></center></th>
<th style="width: 75px;"><center><span class="badge badge-light-lighten">管理</span></center></th>
</tr>
</thead>
<tbody>
<?php
$user = Db::table('user','as U')->field('U.id,U.pic,U.email,U.user,U.phone,U.name as uname,U.vip,U.reg_time,U.ban,A.name as appname,IFNULL(L.zx,0) as zai')->JOIN('app','as A','U.appid=A.id')->JOIN("(SELECT uid,COUNT(*) AS zx FROM `{$DP}user_logon` where `last_t` > {$UTT} GROUP BY uid) AS L",'U.id=L.uid');
if($so != ''){
$user = $user->where('A.name','like',"%{$so}%")->whereOr('U.id','like',"%{$so}%")->whereOr('U.appid','like',"%{$so}%")->whereOr('U.user','like',"%{$so}%")->whereOr('U.email','like',"%{$so}%")->whereOr('U.phone','like',"%{$so}%")->whereOr('U.name','like',"%{$so}%")->order('id desc');
}else{
$user = $user->order('id desc')->limit($bnums,$ENUMS);
}
$res = $user->select();//false
//die($res);
foreach ($res as $k => $v){$rows = $res[$k];
?>
<tr>
<td>
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" name="ids[]" value="<?php echo $rows['id']; ?>" id="<?php echo 'check_'.$rows['id']; ?>">
<label class="custom-control-label" for="<?php echo 'check_'.$rows['id']; ?>"></label>
</div>
</td>
<td>
<center><?php echo $rows['id']; ?></center>
</td>
<td class="media">
<img class="mr-3 rounded-circle" src="<?php echo get_pic($rows['pic'],true);?>" width="40" alt="Generic placeholder image">
<div class="media-body">
<a href="?user_edit&id=<?php echo $rows['id']; ?>" class="text-title"><h5 class="mt-0 mb-1"><?php echo !empty($rows['user']) ? $rows['user'] : (!empty($rows['email']) ? $rows['email'] : $rows['phone']);?></h5></a>
<span class="font-13"><?php echo $rows['uname'];?></span>
</div>
</td>
<td>
<center>
<?php if($rows['vip']>time() || $rows['vip']=='999999999'): ?><span class="badge badge-danger">会员用户<?php else: ?><span class="badge badge-light">普通用户<?php endif; ?></span>
</center>
</td>
<td>
<center>
<?php if(empty($rows['appname'])):?><span class="badge badge-danger"><i class="mdi mdi-close-circle"></i> 应用不存在
<?php else:?><span class="badge badge-primary"><i class="mdi mdi-cube-outline"></i> <?php echo $rows['appname']; ?>
<?php endif; ?>
</span></center>
</td>
<td>
<center><span class="badge badge-secondary-lighten">
<?php echo date("Y-m-d H:i",$rows['reg_time']);?>
</span></center>
</td>
<td>
<center><?php echo $rows['zai'];?></center>
</td>
<td>
<center><?php if($rows['ban']>0):?><span class="badge badge-danger">禁封<?php else: ?><span class="badge badge-success">正常<?php endif; ?></span></center>
</td>
<td>
<center><a href="./?user_edit&id=<?php echo $rows['id']; ?>" class="action-icon"> <i class="mdi mdi-border-color"></i></a></center>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<div class="progress-w-percent-s"></div>
<div class="form-row">
<div class="form-group col-md-6 mt-2">
<div class="col-sm-4">
<div class="list_footer">
选中项:<a href="javascript:void(0);" onclick="delsubmit()" id="delsubmit">删除</a>
</div>
</div>
</div>
<div class="col-md-6">
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-end">
<?php if(!$so){echo pagination($nums,$ENUMS,$page,$url);}?>
</ul>
</nav>
</div>
</div>
</form>
</div> <!-- end card-body-->
</div> <!-- end card-->
</div> <!-- end col -->
</div>
<!-- end row -->
<div id="muladd" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="muladd">批量添加用户</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<?php if($app_num > 0):?>
<form class="pl-3 pr-3" method="post">
<div class="form-group">
<label class="col-form-label">账号个数</label>
<input class="form-control" type="text" id="user_num" name="user_num" placeholder="账号个数" required>
</div>
<div class="form-group">
<label>会员天数 永久会员填写“9999”</label>
<input class="form-control" type="number" id="user_days" name="user_days" placeholder="会员天数" required>
</div>
<div class="form-group">
<label>绑定应用 *</label>
<select class="form-control" name="mmuladd_appid" id="mmuladd_appid">
<?php
$res = Db::table('app')->order('id desc')->select();
foreach ($res as $k => $v){$rows = $res[$k];
?>
<option value="<?php echo $rows['id']; ?>"><?php echo $rows['name']; ?></option>
<?php } ?>
</select>
</div>
<div class="form-group">
<input type="checkbox" id="export_now" name="export_now">
<label for="export_now"> 生成后立刻导出</label>
</div>
<div class="form-group text-center">
<button class="btn btn-primary" type="submit" name="add_submit" id="muladd_submit" value="确定">确认添加</button>
</div>
</form>
<?php else:?>
<div class="text-center" style="margin-top:4rem!important;margin-bottom:6rem!important">
<img src="../assets/images/no-app.svg" height="120" alt="File not found Image">
<h4 class="text-uppercase mt-3 mb-3">需要添加应用后开启该功能</h4>
<a href="./?app_adm"><button type="button" class="btn btn-dark">添加应用</button></a>
</div>
<?php endif;?>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div id="add" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="add">添加用户</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<?php if($app_num > 0):?>
<form class="pl-3 pr-3" method="post">
<div class="form-group">
<label class="col-form-label">账号</label>
<input class="form-control" type="text" id="add_user" name="add_user" placeholder="账号" required>
</div>
<div class="form-group">
<label>密码</label>
<input class="form-control" type="text" id="add_pwd" name="add_pwd" placeholder="密码" required>
</div>
<div class="form-group">
<label>绑定应用 *</label>
<select class="form-control" name="add_appid" id="add_appid">
<?php
$res = Db::table('app')->order('id desc')->select();
foreach ($res as $k => $v){$rows = $res[$k];
?>
<option value="<?php echo $rows['id']; ?>"><?php echo $rows['name']; ?></option>
<?php } ?>
</select>
</div>
<div class="form-group text-center">
<button class="btn btn-primary" type="submit" name="add_submit" id="add_submit" value="确定">确认添加</button>
</div>
</form>
<?php else:?>
<div class="text-center" style="margin-top:4rem!important;margin-bottom:6rem!important">
<img src="../assets/images/no-app.svg" height="120" alt="File not found Image">
<h4 class="text-uppercase mt-3 mb-3">需要添加应用后开启该功能</h4>
<a href="./?app_adm"><button type="button" class="btn btn-dark">添加应用</button></a>
</div>
<?php endif;?>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script>
$('#muladd_submit').click(function(){
let t = window.jQuery;
var user_num = $("input[name='user_num']").val();
var user_days = $("input[name='user_days']").val();
var mmuladd_appid = $("select[name='mmuladd_appid']").val();
var now = $("input[name='export_now']").is(':checked');
document.getElementById('muladd_submit').innerHTML="<span class=\"spinner-border spinner-border-sm mr-1\" role=\"status\" aria-hidden=\"true\"></span>正在添加";
document.getElementById('muladd_submit').disabled=true;
//$('#export_now_link').attr('download','file').attr('href','');
$.ajax({
cache: false,
type: "POST",//请求的方式
url : "ajax.php?act=user_muladd",//请求的文件名
data : {num:user_num,days:user_days,appid:mmuladd_appid,now:now?1:0},
dataType : 'json',
success : function(data) {
console.log(data);
document.getElementById('muladd_submit').disabled=false;
document.getElementById('muladd_submit').innerHTML="确认添加";
if(data.code == 200){
t.NotificationApp.send("成功",data.msg,"top-center","rgba(0,0,0,0.2)","success");
if(data.data){
//$('#export_now_link').attr('download','file').attr('href',data.data);
download('file',data.data);
}
//window.setTimeout("window.location='"+window.location.href+"'",1000);
}else{
t.NotificationApp.send("失败",data.msg,"top-center","rgba(0,0,0,0.2)","error")
}
}
});
return false;//重要语句:如果是像a链接那种有href属性注册的点击事件,可以阻止它跳转。
});
function download(filename, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename+'.txt');
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
$('#add_submit').click(function() {
let t = window.jQuery;
var add_user = $("input[name='add_user']").val();
var add_pwd = $("input[name='add_pwd']").val();
var add_appid = $("select[name='add_appid']").val();
document.getElementById('add_submit').innerHTML="<span class=\"spinner-border spinner-border-sm mr-1\" role=\"status\" aria-hidden=\"true\"></span>正在添加";
document.getElementById('add_submit').disabled=true;
$.ajax({
cache: false,
type: "POST",//请求的方式
url : "ajax.php?act=user_add",//请求的文件名
data : {pwd:add_pwd,user:add_user,appid:add_appid},
dataType : 'json',
success : function(data) {
console.log(data);
document.getElementById('add_submit').disabled=false;
document.getElementById('add_submit').innerHTML="确认添加";
if(data.code == 200){
t.NotificationApp.send("成功",data.msg,"top-center","rgba(0,0,0,0.2)","success")
window.setTimeout("window.location='"+window.location.href+"'",1000);
}else{
t.NotificationApp.send("失败",data.msg,"top-center","rgba(0,0,0,0.2)","error")
}
}
});
return false;//重要语句:如果是像a链接那种有href属性注册的点击事件,可以阻止它跳转。
});
function checkAll() {
var code_Values = document.getElementsByTagName("input");
var all = document.getElementById("all");
if (code_Values.length) {
for (i = 0; i < code_Values.length; i++) {
if (code_Values[i].type == "checkbox") {
code_Values[i].checked = all.checked;
}
}
} else {
if (code_Values.type == "checkbox") {
code_Values.checked = all.checked;
}
}
}
function delsubmit(){
var id_array=new Array();  
$("input[name='ids[]']:checked").each(function(){  
id_array.push($(this).val());//向数组中添加元素  
});  //获取界面复选框的所有值
//ar chapterstr = id_array.join(',');//把复选框的值以数组形式存放
var url = window.location.href;
let t = window.jQuery;
if(id_array.length<=0){
t.NotificationApp.send("提示","请选择要删除的项目","top-center","rgba(0,0,0,0.2)","warning")
return false;
}
document.getElementById('delsubmit').innerHTML="<div class=\"spinner-border spinner-border-sm mr-1\" style=\"margin-bottom:2px!important\" role=\"status\"></div>删除中";
document.getElementById("delsubmit").className = "text-title";
$("#delsubmit").attr("disabled",true).css("pointer-events","none");
console.log(id_array);
$.ajax({
cache: false,
type: "POST",//请求的方式
url : "ajax.php?act=user_del",//请求的文件名
data : {id:id_array},
dataType : 'json',
success : function(data) {
if(data.code == 200){
t.NotificationApp.send("成功",data.msg,"top-center","rgba(0,0,0,0.2)","success")
}else{
t.NotificationApp.send("失败",data.msg,"top-center","rgba(0,0,0,0.2)","error")
}
//console.log(data);
window.setTimeout("window.location='"+url+"'",1000);
}
});
return false;//重要语句:如果是像a链接那种有href属性注册的点击事件,可以阻止它跳转。
}
</script>
+405
View File
@@ -0,0 +1,405 @@
<?php
/*
Sort:1
Hidden:true
Name:用户编辑
Url:user_edit
Version:1.0
Author:易如意
Author QQ:51154393
Author Url:www.eruyi.cn
*/
if (!isset($islogin)) header("Location: /"); //非法访问
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$res = Db::table('user', 'as U')->field('U.*,A.name as appname,IFNULL(L.zx,0) as zai')->JOIN('app', 'as A', 'U.appid=A.id')->JOIN("(SELECT uid,COUNT(*) AS zx FROM `{$DP}user_logon` where `last_t` > {$UTT} GROUP BY uid) AS L", 'U.id=L.uid')->where('U.id', $id)->find();
?>
<div class="row">
<div class="col-12">
<div class="page-title-box">
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="javascript: void(0);">首页</a></li>
<li class="breadcrumb-item"><a href="user_adm.php">用户管理</a></li>
<li class="breadcrumb-item active">编辑用户</li>
</ol>
</div>
<h4 class="page-title"><?php echo $title; ?></h4>
</div> <!-- end page-title-box -->
</div> <!-- end col-->
</div>
<!-- end page title -->
<div class="row">
<div class="col-sm-12">
<!-- Profile -->
<div class="card">
<div class="card-body profile-user-box">
<div class="row">
<div class="col-sm-8">
<div class="media">
<span class="float-left m-2 mr-4"><img src="<?php echo get_pic($res['pic'], true); ?>" style="height: 100px;" alt="" class="rounded-circle img-thumbnail"></span>
<div class="media-body">
<h4 class="mt-2 mb-1"><?php echo $res['name']; ?></h4>
<p class="font-13">账号:<?php echo !empty($res['user']) ? $res['user'] : (!empty($res['email']) ? $res['email'] : $res['phone']); ?>
<br><?php if ($res['zai'] > 0) : ?><span class="badge badge-success-lighten">在线<?php else : ?><span class="badge badge-dark-lighten">离线<?php endif; ?></span>
<span class="badge badge-primary-lighten"><?php echo $res['appname']; ?></span>
<?php if ($res['inv'] > 0) : ?><span class="badge badge-info-lighten">邀请人ID:<?php echo $res['inv']; ?><?php else : ?><span class="badge badge-info-lighten">无邀请人<?php endif; ?></span>
</p>
<ul class="mb-0 list-inline">
<li class="list-inline-item mr-3">
<h5 class="mb-1"><?php echo $res['reg_ip']; ?></h5>
<p class="mb-0 font-13">注册IP</p>
</li>
<li class="list-inline-item">
<h5 class="mb-1"><?php echo date("Y/m/d H:i:s", $res['reg_time']); ?></h5>
<p class="mb-0 font-13">注册时间</p>
</li>
</ul>
</div>
</div>
</div> <!-- end col-->
<div class="col-sm-4">
<div class="text-center mt-sm-0 mt-3 text-sm-right">
<div class="mt-2">
<?php if ($res['openid_wx']) : ?>
<div id="wx" class="dropdown list-inline-item text-center">
<a href="#" class="dropdown-toggle arrow-none card-drop social-list-item border-primary" data-toggle="dropdown" aria-expanded="false">
<img src="../assets/images/logon-ico/wx.png" class="eruyi-img-login-2"></li>
</a>
<div class="dropdown-menu dropdown-menu-right">
<!-- item-->
<a href="javascript:void(0);" onclick="undo_wx()" class="dropdown-item">解绑微信</a>
</div>
</div>
<?php endif; ?>
<?php if ($res['openid_qq']) : ?>
<div id="qq" class="dropdown list-inline-item text-center">
<a href="#" class="dropdown-toggle arrow-none card-drop social-list-item border-danger" data-toggle="dropdown" aria-expanded="false">
<img src="../assets/images/logon-ico/qq.png" class="eruyi-img-login-2"></li>
</a>
<div class="dropdown-menu dropdown-menu-right">
<!-- item-->
<a href="javascript:void(0);" onclick="undo_qq()" class="dropdown-item">解绑QQ</a>
</div>
</div>
<?php endif; ?>
</div>
</div>
</div> <!-- end col-->
</div> <!-- end row -->
</div> <!-- end card-body/ profile-user-box-->
</div>
<!--end profile/ card -->
</div> <!-- end col-->
</div><!-- end row-->
<div class="row">
<div class="col-md-7">
<div class="card">
<div class="card-body">
<form action="" method="post" id="addimg" name="addimg">
<div class="form-row">
<div class="form-group col-md-12">
<label>发放卡密【显示在优惠券】</label>
<input name="kam" id="kam" type="text" class="form-control" placeholder="多个英文逗号隔开" value="<?php echo $res['kam']; ?>">
</div>
<div class="form-group col-md-12">
<label>用户密码</label>
<input name="pwd" id="pwd" type="text" class="form-control" placeholder="空则不修改密码" value="">
</div>
<div class="form-group col-md-6" hidden>
<label>微信绑定</label>
<input name="openid_qq" id="openid_qq" type="text" class="form-control" value="<?php echo $res['openid_qq']; ?>">
</div>
<div class="form-group col-md-6" hidden>
<label>QQ绑定</label>
<input name="openid_wx" id="openid_wx" type="text" class="form-control" value="<?php echo $res['openid_wx']; ?>">
</div>
<div class="form-group col-md-6">
<label>会员到期</label>
<input name="vip" type="text" class="form-control" data-toggle="input-mask" data-mask-format="0000/00/00 00:00:00" placeholder="输入格式:<?php echo date("Y/m/d H:i:s", time()); ?>" <?php if ($res['vip'] == '999999999') : ?>value="<?php echo $res['vip'] . '99999'; ?>" <?php elseif ($res['vip'] > time()) : ?> value="<?php echo date("Y/m/d H:i:s", $res['vip']); ?>" <?php endif; ?>>
<span class="font-13 text-muted">永久会员格式填写 "9999"</span>
</div>
<div class="form-group col-md-6">
<label>积分</label>
<input name="fen" type="number" class="form-control" placeholder="0" value="<?php echo $res['fen']; ?>" required>
</div>
</div>
</form>
</div> <!-- end card-body -->
</div> <!-- end card-->
<div class="card">
<div class="card-body">
<form>
<div class="eruyi-checkbox">
<input type="checkbox" id="ban_state" <?php if ($res['ban'] > time() or $res['ban'] == 999999999) : ?>checked<?php endif; ?> data-switch="danger" onchange="ban_state_v(this.checked)" />
<label for="ban_state" data-on-label="禁用" data-off-label="正常"></label>
<label class="eruyi-label">用户控制</label>
</div>
<div class="view" name="ban_state_y" id="ban_state_y" <?php if ($res['ban'] > time() or $res['ban'] == 999999999) : ?> style="display: block" <?php endif; ?>>
<p class="text-muted">
用户禁用后,该用户将 <code>禁止所有操作</code>
</p>
<div class="form-row">
<div class="form-group col-md-4">
<label>禁用到期</label>
<input name="ban" type="text" class="form-control" data-toggle="input-mask" data-mask-format="0000/00/00 00:00:00" placeholder="输入格式:<?php echo date("Y/m/d H:i:s", time()); ?>" <?php if ($res['ban'] == '999999999') : ?>value="<?php echo $res['ban'] . '99999'; ?>" <?php elseif ($res['ban'] > time()) : ?> value="<?php echo date("Y/m/d H:i:s", $res['ban']); ?> <?php endif; ?>>
<span class=" font-13 text-muted">永久禁用格式 "9999/99/99"</span>
</div>
<div class="form-group col-md-8">
<label>禁用通知</label>
<input name="ban_notice" type="text" class="form-control" placeholder="禁用通知" value="<?php echo $res['ban_notice']; ?>">
</div>
</div>
</div>
<div class="view" name="ban_state_n" id="ban_state_n" <?php if ($res['ban'] == 0 or $res['ban'] < time()) : ?> style="display: block" <?php endif; ?>>
<p class="text-muted">
当前用户状态 <code>正常</code> ,可以使用软件
</p>
</div>
<div class="form-group">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="ok" name="ok" value="y" required>
<label class="custom-control-label" for="ok">确认是我操作</label>
</div>
</div>
<button type="submit" class="btn btn-block btn-primary" name="submit" id="submit" value="确认">确认修改</button>
</form>
</div> <!-- end card-body -->
</div> <!-- end card -->
</div> <!-- end col -->
<div class="col-md-5">
<div class="card">
<div class="card-body">
<div class="dropdown float-right">
<a href="#" class="dropdown-toggle arrow-none card-drop" data-toggle="dropdown" aria-expanded="false">
<i class="mdi mdi-dots-vertical"></i>
</a>
<div class="dropdown-menu dropdown-menu-right">
<!-- item-->
<a href="javascript:void(0);" onclick="see('log')" class="dropdown-item">用户日志</a>
<!-- item-->
<a href="javascript:void(0);" onclick="see('user_logon')" class="dropdown-item">用户设备</a>
</div>
</div>
<h4 class="header-title mb-3" id="see_name">用户日志</h4>
<div class="table-responsive" name="user_log" id="user_log">
<?php
$res_log = Db::table('log')->where(['uid' => $id])->order('id desc')->limit(0, 6)->select();
if (count($res_log) <= 0) :
?>
<div class="text-center" style="margin-top:6rem!important;margin-bottom:6rem!important">
<img src="../assets/images/startman.svg" height="120" alt="File not found Image">
<h4 class="text-uppercase mt-3">暂无用户日志</h4>
</div>
<?php else : ?>
<div class="table-responsive">
<table class="table table-striped table-sm table-centered mb-0">
<thead>
<tr>
<th><span class="badge badge-light-lighten">操作类型</span></th>
<th><span class="badge badge-light-lighten">操作IP/操作时间</span></th>
<th style="width: 100px;"><span class="badge badge-light-lighten">会员/积分变化</span></th>
</tr>
</thead>
<tbody>
<?php foreach ($res_log as $k => $v) {
$rows_log = $res_log[$k]; ?>
<tr>
<td><?php echo $lang_user[$rows_log['type']]; ?></td>
<td>
<h5 class="font-15 mb-1 font-weight-normal"><?php echo $rows_log['ip']; ?></h5>
<span class="text-muted font-13"><?php echo date("Y/m/d H:i", $rows_log['time']); ?></span>
</td>
<td>
<h5 class="font-15 mb-1 font-weight-normal">会员:<?php echo ($rows_log['vip'] > 0) ? '+' . $rows_log['vip'] . (isset($time_type[$rows_log['type']]) ? $time_type[$rows_log['type']] : "") : $rows_log['vip'] . (isset($time_type[$rows_log['type']]) ? $time_type[$rows_log['type']] : ""); ?></h5>
<span class="text-muted font-13">积分:<?php if ($rows_log['fen'] > 0) {
echo '+' . $rows_log['fen'];
} else {
echo $rows_log['fen'];
} ?></span>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div> <!-- end table-responsive-->
<?php endif; ?>
</div> <!-- end table-responsive-->
<div class="table-responsive" name="user_logon" id="user_logon" style="display: none">
<?php
$res_logon = Db::table('user_logon')->where(['uid' => $id])->order('last_t desc')->limit(0, 5)->select();
if (count($res_logon) <= 0) :
?>
<div class="text-center" style="margin-top:6rem!important;margin-bottom:6rem!important">
<img src="../assets/images/startman.svg" height="120" alt="File not found Image">
<h4 class="text-uppercase mt-3">暂无用户设备</h4>
</div>
<?php else : ?>
<div class="table-responsive">
<table class="table table-striped table-sm table-centered mb-0">
<thead>
<tr>
<th><span class="badge badge-light-lighten">TOKEN/设备信息</span></th>
<th style="width: 100px;"><span class="badge badge-light-lighten">最后活动时间/登录IP</span></th>
</tr>
</thead>
<tbody>
<?php foreach ($res_logon as $k => $v) {
$rows_logon = $res_logon[$k]; ?>
<tr>
<td>
<h5 class="font-15 mb-1 font-weight-normal"><?php echo $rows_logon['token']; ?></h5>
<span class="text-muted font-13"><?php if ($rows_logon['log_in'] == '') {
echo '无设备信息';
} else {
echo $rows_logon['log_in'];
} ?></span>
</td>
<td>
<h5 class="font-15 mb-1 font-weight-normal"><?php echo date("Y/m/d H:i", $rows_logon['last_t']); ?></h5>
<span class="text-muted font-13"><?php echo $rows_logon['log_ip']; ?></span>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div> <!-- end table-responsive-->
<?php endif; ?>
</div> <!-- end table-responsive-->
</div> <!-- end card-body-->
</div> <!-- end card-->
</div><!-- end col-->
</div><!-- end row-->
<script>
$("#user_adm").addClass("active");
$('#submit').click(function() {
let t = window.jQuery;
var ok = document.getElementById("ok").checked;
var ban_state = document.getElementById("ban_state").checked;
var kam = $("input[name='kam']").val();
var pwd = $("input[name='pwd']").val();
var fen = $("input[name='fen']").val();
var vip = $("input[name='vip']").val();
var ban = $("input[name='ban']").val();
var ban_notice = $("input[name='ban_notice']").val();
var openid_qq = $("input[name='openid_qq']").val();
var openid_wx = $("input[name='openid_wx']").val();
var myDate = new Date();
if (vip.substr(0, 10) == '9999/99/99') {
vip = '999999999';
} else {
vip = Date.parse(vip) / 1000;
}
if (isNaN(vip)) {
vip = 0;
}
if (ban_state) {
if (ban.substr(0, 10) == '9999/99/99') {
ban = '999999999';
} else {
ban = Date.parse(ban) / 1000;
}
} else {
ban = 0;
}
if (isNaN(ban) && ban_state) {
t.NotificationApp.send("提示", "禁用时间有误", "top-center", "rgba(0,0,0,0.2)", "warning")
return false;
}
//console.log(vip,ban);
if (!ok) {
t.NotificationApp.send("提示", "请确认是我操作", "top-center", "rgba(0,0,0,0.2)", "warning")
return false;
}
document.getElementById('submit').innerHTML = "<span class=\"spinner-border spinner-border-sm mr-1\" role=\"status\" aria-hidden=\"true\"></span>正在修改";
document.getElementById('submit').disabled = true;
$.ajax({
cache: false,
type: "POST", //请求的方式
url: "ajax.php?act=user_edit", //请求的文件名
data: {
id: <?php echo $id; ?>,
pwd: pwd,
kam: kam,
fen: fen,
vip: vip,
ban: ban,
ban_notice: ban_notice,
openid_qq: openid_qq,
openid_wx: openid_wx
},
dataType: 'json',
success: function(data) {
console.log(data);
document.getElementById('submit').disabled = false;
document.getElementById('submit').innerHTML = "确认修改";
if (data.code == 200) {
t.NotificationApp.send("成功", data.msg, "top-center", "rgba(0,0,0,0.2)", "success")
document.getElementById("ok").checked = false;
//window.setTimeout("window.location='"+window.location.href+"'",1000);
} else {
t.NotificationApp.send("失败", data.msg, "top-center", "rgba(0,0,0,0.2)", "error")
}
}
});
return false; //重要语句:如果是像a链接那种有href属性注册的点击事件,可以阻止它跳转。
});
function ban_state_v(i) {
//console.log(i);
if (i == true) {
$("#ban_state_y").css("display", "block");
$("#ban_state_n").css("display", "none");
} else {
$("#ban_state_y").css("display", "none");
$("#ban_state_n").css("display", "block");
}
}
function see(i) {
if (i == 'log') {
document.getElementById('see_name').innerHTML = "用户日志";
$("#user_log").css("display", "block");
$("#user_logon").css("display", "none");
} else {
document.getElementById('see_name').innerHTML = "用户设备";
$("#user_log").css("display", "none");
$("#user_logon").css("display", "block");
}
}
function undo_qq() {
$("#qq").css("display", "none");
$("#openid_qq").val('');
}
function undo_wx() {
$("#wx").css("display", "none");
$("#openid_wx").val('');
}
</script>