first commit
This commit is contained in:
@@ -0,0 +1,262 @@
|
||||
<?php
|
||||
/*
|
||||
Name:应用管理API
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
Author QQ:51154393
|
||||
Author Url:www.eruyi.cn
|
||||
*/
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
if ($act == 'add') { //添加APP
|
||||
$name = isset($_POST['name']) ? purge($_POST['name']) : '';
|
||||
$bb = isset($_POST['bb']) ? purge($_POST['bb']) : '';
|
||||
$appid = isset($_POST['appid']) ? intval($_POST['appid']) : 0;
|
||||
if ($name == '') json(201, '应用名字不能为空');
|
||||
$app_res = Db::table('app')->where('name', $name)->find();
|
||||
if ($app_res) json(201, '应用名称重复');
|
||||
if ($appid > 0) {
|
||||
$app_res = Db::table('app')->where('id', $appid)->find();
|
||||
if (!$app_res) json(201, '继承应用不存在');
|
||||
$app_res['name'] = $name;
|
||||
$app_res['appkey'] = md5(time());
|
||||
if ($bb != '') $app_res['app_bb'] = $bb;
|
||||
$app_res['appkey'] = md5(time());
|
||||
unset($app_res['id']);
|
||||
$add = $app_res;
|
||||
} else {
|
||||
if ($bb == '') $bb = '1.0.0';
|
||||
$add = ['name' => $name, 'app_bb' => $bb, 'appkey' => md5(time())];
|
||||
}
|
||||
$res = Db::table('app')->add($add);
|
||||
//die($res);
|
||||
if ($res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'app_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' => 'app_add', 'status' => 201, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
json(201, '添加失败');
|
||||
}
|
||||
}
|
||||
if ($act == 'edit') { //编辑应用
|
||||
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
|
||||
$update['name'] = isset($_POST['name']) ? purge($_POST['name']) : '';
|
||||
$update['appkey'] = isset($_POST['appkey']) ? purge($_POST['appkey']) : '';
|
||||
|
||||
$update['state'] = isset($_POST['state']) ? purge($_POST['state']) : 'y'; //应用状态
|
||||
$update['mi_state'] = isset($_POST['mi_state']) ? purge($_POST['mi_state']) : 'y'; //加密状态
|
||||
$update['smtp_state'] = isset($_POST['smtp_state']) ? purge($_POST['smtp_state']) : 'n'; //邮箱状态
|
||||
$update['pay_state'] = isset($_POST['pay_state']) ? purge($_POST['pay_state']) : 'n'; //支付状态
|
||||
$update['logon_state'] = isset($_POST['logon_state']) ? purge($_POST['logon_state']) : 'y'; //登录状态
|
||||
$update['reg_state'] = isset($_POST['reg_state']) ? purge($_POST['reg_state']) : 'y'; //注册状态
|
||||
|
||||
$update['reg_ipon'] = isset($_POST['reg_ipon']) ? intval($_POST['reg_ipon']) : ''; //IP重复注册间隔
|
||||
$update['reg_inon'] = isset($_POST['reg_inon']) ? intval($_POST['reg_inon']) : ''; //设备重复注册间隔
|
||||
$update['reg_award'] = isset($_POST['reg_award']) ? purge($_POST['reg_award']) : ''; //注册奖励类型
|
||||
$update['reg_award_num'] = isset($_POST['reg_award_num']) ? intval($_POST['reg_award_num']) : 0; //注册奖励数
|
||||
$update['inv_award'] = isset($_POST['inv_award']) ? purge($_POST['inv_award']) : ''; //邀请奖励类型
|
||||
$update['inv_award_num'] = isset($_POST['inv_award_num']) ? intval($_POST['inv_award_num']) : 0; //邀请奖励数
|
||||
$update['reg_notice'] = isset($_POST['reg_notice']) ? purge($_POST['reg_notice']) : ''; //注册关闭通知
|
||||
|
||||
$update['logon_way'] = isset($_POST['logon_way']) ? intval($_POST['logon_way']) : 0; //登录方式
|
||||
$update['logon_check_in'] = isset($_POST['logon_check_in']) ? purge($_POST['logon_check_in']) : ''; //登录时验证设备信息
|
||||
$update['logon_check_t'] = isset($_POST['logon_check_t']) ? intval($_POST['logon_check_t']) : 0; //设备换绑间隔时间
|
||||
$update['logon_num'] = isset($_POST['logon_num']) ? intval($_POST['logon_num']) : 0; //多设备登录数
|
||||
$update['diary_award'] = isset($_POST['diary_award']) ? purge($_POST['diary_award']) : ''; //签到奖励类型
|
||||
$update['diary_award_num'] = isset($_POST['diary_award_num']) ? intval($_POST['diary_award_num']) : 0; //签到奖励数
|
||||
$update['logon_notice'] = isset($_POST['logon_notice']) ? purge($_POST['logon_notice']) : ''; //登录关闭通知
|
||||
|
||||
$update['smtp_host'] = isset($_POST['smtp_host']) ? purge($_POST['smtp_host']) : ''; //邮箱服务器
|
||||
$update['smtp_user'] = isset($_POST['smtp_user']) ? purge($_POST['smtp_user']) : ''; //邮箱账号
|
||||
$update['smtp_pass'] = isset($_POST['smtp_pass']) ? purge($_POST['smtp_pass']) : ''; //邮箱密码
|
||||
$update['smtp_port'] = isset($_POST['smtp_port']) ? intval($_POST['smtp_port']) : 25; //邮箱端口
|
||||
|
||||
$update['pay_url'] = isset($_POST['pay_url']) ? purge($_POST['pay_url']) : ''; //支付地址
|
||||
$update['pay_id'] = isset($_POST['pay_id']) ? purge($_POST['pay_id']) : ''; //支付ID
|
||||
$update['pay_key'] = isset($_POST['pay_key']) ? purge($_POST['pay_key']) : ''; //支付KEY
|
||||
$update['pay_ali_state'] = isset($_POST['pay_ali_state']) ? purge($_POST['pay_ali_state']) : 'y'; //支付宝状态
|
||||
$update['pay_wx_state'] = isset($_POST['pay_wx_state']) ? purge($_POST['pay_wx_state']) : 'y'; //微信状态
|
||||
$update['pay_qq_state'] = isset($_POST['pay_qq_state']) ? purge($_POST['pay_qq_state']) : 'y'; //QQ状态
|
||||
$update['pay_notify'] = isset($_POST['pay_notify']) ? purge($_POST['pay_notify']) : ''; //异步通知地址
|
||||
$update['mi_type'] = isset($_POST['mi_type']) ? intval($_POST['mi_type']) : 0; //加密类型
|
||||
$update['mi_sign'] = isset($_POST['mi_sign']) ? purge($_POST['mi_sign']) : ''; //数据签名
|
||||
$update['mi_time'] = isset($_POST['mi_time']) ? intval($_POST['mi_time']) : 0; //时间校验
|
||||
$update['mi_rsa_private_key'] = isset($_POST['mi_rsa_private_key']) ? purge($_POST['mi_rsa_private_key']) : ''; //RSA私钥
|
||||
$update['mi_rsa_public_key'] = isset($_POST['mi_rsa_public_key']) ? purge($_POST['mi_rsa_public_key']) : ''; //RSA公钥
|
||||
$update['mi_rc4_key'] = isset($_POST['mi_rc4_key']) ? purge($_POST['mi_rc4_key']) : ''; //RC4秘钥
|
||||
$update['mode'] = isset($_POST['mode']) ? purge($_POST['mode']) : 'y'; //运营模式
|
||||
|
||||
$update['app_bb'] = isset($_POST['app_bb']) ? purge($_POST['app_bb']) : '1.0'; //APP版本
|
||||
$update['app_nurl'] = isset($_POST['app_nurl']) ? purge($_POST['app_nurl']) : ''; //更新链接
|
||||
$update['app_nshow'] = isset($_POST['app_nshow']) ? purge($_POST['app_nshow']) : ''; //更新内容
|
||||
$update['notice'] = isset($_POST['notice']) ? purge($_POST['notice']) : ''; //关闭通知
|
||||
|
||||
$update['ui_state'] = isset($_POST['ui_state']) ? purge($_POST['ui_state']) : 'y'; //加密状态
|
||||
$update['app_json'] = isset($_POST['app_json']) ? purge($_POST['app_json']) : '';
|
||||
$update['kami_url'] = isset($_POST['kami_url']) ? purge($_POST['kami_url']) : '';
|
||||
$update['app_jsonb'] = isset($_POST['app_jsonb']) ? purge($_POST['app_jsonb']) : '';
|
||||
$update['app_huodong'] = isset($_POST['app_huodong']) ? purge($_POST['app_huodong']) : '';
|
||||
$update['ui_paybackg'] = isset($_POST['ui_paybackg']) ? purge($_POST['ui_paybackg']) : '';
|
||||
$update['ui_kefu'] = isset($_POST['ui_kefu']) ? purge($_POST['ui_kefu']) : '';
|
||||
$update['ui_community'] = isset($_POST['ui_community']) ? purge($_POST['ui_community']) : '';
|
||||
$update['ui_button3backg'] = isset($_POST['ui_button3backg']) ? purge($_POST['ui_button3backg']) : '';
|
||||
$update['ui_buttonadimg'] = isset($_POST['ui_buttonadimg']) ? purge($_POST['ui_buttonadimg']) : '';
|
||||
$update['ui_group'] = isset($_POST['ui_group']) ? purge($_POST['ui_group']) : '88888888';
|
||||
$update['ui_logo'] = isset($_POST['ui_logo']) ? purge($_POST['ui_logo']) : '';
|
||||
$update['ui_startad'] = isset($_POST['ui_startad']) ? purge($_POST['ui_startad']) : '';
|
||||
$update['ui_removersc'] = isset($_POST['ui_removersc']) ? purge($_POST['ui_removersc']) : '';
|
||||
$update['ui_remove_parses'] = isset($_POST['ui_remove_parses']) ? purge($_POST['ui_remove_parses']) : '';
|
||||
$update['ui_remove_class'] = isset($_POST['ui_remove_class']) ? purge($_POST['ui_remove_class']) : '';
|
||||
$update['ui_parse_name'] = isset($_POST['ui_parse_name']) ? purge($_POST['ui_parse_name']) : '';
|
||||
$update['app_about'] = isset($_POST['app_about']) ? purge($_POST['app_about']) : '';
|
||||
|
||||
// json(201,$update['ui_state']);
|
||||
$app_res = Db::table('app')->where('name', $update['name'])->find();
|
||||
if ($app_res) {
|
||||
if ($app_res['id'] != $id) json(201, '应用名称重复');
|
||||
}
|
||||
|
||||
$res = Db::table('app')->where('id', $id)->update($update);
|
||||
//die($res);
|
||||
if ($res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'app_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' => 'app_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('app')->where('id', 'in', '(' . $ids . ')')->del(); //false
|
||||
//die($res);
|
||||
if ($res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'app_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' => 'app_del', 'status' => 201, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
json(201, '删除失败');
|
||||
}
|
||||
} else {
|
||||
json(201, '没有需要删除的数据');
|
||||
}
|
||||
}
|
||||
//站点管理
|
||||
if ($act == 'siteadd') {
|
||||
$name = isset($_POST['name']) ? purge($_POST['name']) : '';
|
||||
$type = isset($_POST['type']) ? purge($_POST['type']) : 'Spider';
|
||||
$api = isset($_POST['api']) ? purge($_POST['api']) : 'csp_AppYsV2';
|
||||
$extend = isset($_POST['extend']) ? purge($_POST['extend']) : '';
|
||||
$parse = isset($_POST['parse']) ? purge($_POST['parse']) : '';
|
||||
$appid = isset($_POST['appid']) ? intval($_POST['appid']) : 0;
|
||||
$searchable = isset($_POST['searchable']) ? intval($_POST['searchable']) : 0;
|
||||
$quicksearch = isset($_POST['quicksearch']) ? intval($_POST['quicksearch']) : 0;
|
||||
$filterable = isset($_POST['filterable']) ? intval($_POST['filterable']) : 0;
|
||||
|
||||
if ($name == '') json(201, '请设置网站名称');
|
||||
if ($api == '') json(201, '请设置api');
|
||||
// if($extend == '')json(201,'请设置扩展接口');
|
||||
if ($appid == 0) json(201, '绑定应用为空');
|
||||
|
||||
$app_res = Db::table('app')->where('id', $appid)->find();
|
||||
if (!$app_res) json(201, '应用不存在');
|
||||
$site_res = Db::table('site')->where(['appid' => $appid, 'name' => $name])->find();
|
||||
if ($site_res) json(201, '商品已存在');
|
||||
|
||||
$add_res = Db::table('site')->add(['name' => $name, 'type' => $type, 'api' => $api, 'extend' => $extend, 'parse' => $parse, 'appid' => $appid, 'searchable' => $searchable, 'quicksearch' => $quicksearch, 'filterable' => $filterable]);
|
||||
//die($res);
|
||||
if ($add_res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'site_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' => 'site_add', 'status' => 201, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
json(201, '添加失败');
|
||||
}
|
||||
}
|
||||
if ($act == 'siteedit') {
|
||||
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
|
||||
$update['name'] = isset($_POST['name']) ? purge($_POST['name']) : '';
|
||||
$update['type'] = isset($_POST['type']) ? purge($_POST['type']) : 'Spider';
|
||||
$update['api'] = isset($_POST['api']) ? purge($_POST['api']) : 'csp_AppYsV2';
|
||||
$update['extend'] = isset($_POST['extend']) ? purge($_POST['extend']) : '';
|
||||
$update['parse'] = isset($_POST['parse']) ? purge($_POST['parse']) : '';
|
||||
$update['appid'] = isset($_POST['appid']) ? intval($_POST['appid']) : 0;
|
||||
$update['state'] = isset($_POST['state']) ? purge($_POST['state']) : 'y';
|
||||
$update['searchable'] = isset($_POST['searchable']) ? intval($_POST['searchable']) : 0;
|
||||
$update['quicksearch'] = isset($_POST['quicksearch']) ? intval($_POST['quicksearch']) : 0;
|
||||
$update['filterable'] = isset($_POST['filterable']) ? intval($_POST['filterable']) : 0;
|
||||
|
||||
if ($update['name'] == '') json(201, '请设置网站名称');
|
||||
if ($update['api'] == '') json(201, '请设置api');
|
||||
// if($update['extend'] == '')json(201,'请设置扩展接口');
|
||||
if ($update['appid'] == 0) json(201, '绑定应用为空');
|
||||
|
||||
$app_res = Db::table('app')->where('id', $update['appid'])->find();
|
||||
if (!$app_res) json(201, '应用不存在');
|
||||
|
||||
$site_res = Db::table('site')->where(['appid' => $update['appid'], 'name' => $update['name']])->find();
|
||||
if ($site_res) {
|
||||
if ($site_res['id'] != $id) json(201, '商品已存在');
|
||||
}
|
||||
|
||||
$res = Db::table('site')->where('id', $id)->update($update);
|
||||
//die($res);
|
||||
if ($res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'site_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' => 'site_edit', 'status' => 201, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
json(201, '编辑失败');
|
||||
}
|
||||
}
|
||||
if ($act == 'sitedel') { //删除商品
|
||||
$id = isset($_POST['id']) ? $_POST['id'] : '';
|
||||
if ($id) {
|
||||
$ids = '';
|
||||
foreach ($id as $value) {
|
||||
$ids .= intval($value) . ",";
|
||||
}
|
||||
$ids = rtrim($ids, ",");
|
||||
$res = Db::table('site')->where('id', 'in', '(' . $ids . ')')->del(); //false
|
||||
//die($res);
|
||||
if ($res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'site_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' => 'site_del', 'status' => 201, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
json(201, '删除失败');
|
||||
}
|
||||
} else {
|
||||
json(201, '没有需要删除的数据');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/*
|
||||
Name:应用扩展配置API
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
Author QQ:51154393
|
||||
Author Url:www.eruyi.cn
|
||||
*/
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
if ($act == 'add') { //添加配置
|
||||
$api = isset($_POST['api']) ? purge($_POST['api']) : '';
|
||||
$name = isset($_POST['name']) ? purge($_POST['name']) : '';
|
||||
$data = isset($_POST['data']) ? purge($_POST['data']) : '';
|
||||
$type = isset($_POST['type']) ? intval($_POST['type']) : 0;
|
||||
$appid = isset($_POST['appid']) ? intval($_POST['appid']) : 0;
|
||||
$state = isset($_POST['state']) ? purge($_POST['state']) : 'y';
|
||||
if ($api == '') json(201, '接口名称为空');
|
||||
if ($name == '') json(201, '接口名称为空');
|
||||
if ($data == '') json(201, '扩展配置为空');
|
||||
if ($appid == 0) json(201, '绑定应用为空');
|
||||
$app_res = Db::table('app')->where('id', $appid)->find();
|
||||
if (!$app_res) json(201, '应用不存在');
|
||||
$exten_res = Db::table('app_exten')->where(['name' => $name])->find();
|
||||
if ($exten_res) json(201, '接口名已存在,换个名字吧');
|
||||
$add_res = Db::table('app_exten')->add(['api' => $api, 'name' => $name, 'data' => $data, 'appid' => $appid, 'state' => $state, 'type' => $type]);
|
||||
if ($add_res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'exten_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' => 'exten_add', 'status' => 201, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
json(201, '添加失败');
|
||||
}
|
||||
}
|
||||
if ($act == 'edit') { //编辑配置
|
||||
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
|
||||
$update['api'] = isset($_POST['api']) ? purge($_POST['api']) : '';
|
||||
$update['name'] = isset($_POST['name']) ? purge($_POST['name']) : '';
|
||||
$update['data'] = isset($_POST['data']) ? purge($_POST['data']) : '';
|
||||
$update['type'] = isset($_POST['type']) ? intval($_POST['type']) : 0;
|
||||
$update['appid'] = isset($_POST['appid']) ? intval($_POST['appid']) : 0;
|
||||
$update['state'] = isset($_POST['state']) ? purge($_POST['state']) : 'n';
|
||||
if ($update['api'] == '') json(201, '接口为空');
|
||||
if ($update['name'] == '') json(201, '接口名称为空');
|
||||
if ($update['data'] == '') json(201, '扩展配置为空');
|
||||
if ($update['appid'] == 0) json(201, '绑定应用为空');
|
||||
$app_res = Db::table('app')->where('id', $update['appid'])->find();
|
||||
if (!$app_res) json(201, '应用不存在');
|
||||
$exten_res = Db::table('app_exten')->where(['name' => $update['name']])->find();
|
||||
if ($exten_res) {
|
||||
if ($exten_res['id'] != $id) json(201, '接口名已存在');
|
||||
}
|
||||
$res = Db::table('app_exten')->where('id', $id)->update($update);
|
||||
//die($res);
|
||||
if ($res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'exten_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' => 'exten_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('app_exten')->where('id', 'in', '(' . $ids . ')')->del(); //false
|
||||
//die($res);
|
||||
if ($res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'exten_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' => 'exten_del', 'status' => 201, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
json(201, '删除失败');
|
||||
}
|
||||
} else {
|
||||
json(201, '没有需要删除的数据');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/*
|
||||
Name:首页广告API
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
Author QQ:51154393
|
||||
Author Url:www.eruyi.cn
|
||||
*/
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
if ($act == 'add') { //添加配置
|
||||
$name = isset($_POST['name']) ? purge($_POST['name']) : '';
|
||||
$data = isset($_POST['data']) ? purge($_POST['data']) : '';
|
||||
$appid = isset($_POST['appid']) ? intval($_POST['appid']) : 0;
|
||||
$searchable = isset($_POST['searchable']) ? purge($_POST['searchable']) : 'n';
|
||||
if ($name == '') json(201, '变量名称为空');
|
||||
// if(preg_match ("/^[\w]{1,32}$/",$name)==0)json(201,'变量名称不合格');
|
||||
if ($data == '') json(201, '扩展配置为空');
|
||||
if ($appid == 0) json(201, '绑定应用为空');
|
||||
$app_res = Db::table('app')->where('id', $appid)->find();
|
||||
if (!$app_res) json(201, '应用不存在');
|
||||
$homead_res = Db::table('app_homead')->where(['name' => $name])->find();
|
||||
if ($homead_res) json(201, '变量名已存在');
|
||||
$add_res = Db::table('app_homead')->add(['name' => $name, 'data' => $data, 'appid' => $appid, 'searchable' => $searchable]);
|
||||
//die($add_res);
|
||||
if ($add_res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'homead_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' => 'homead_add', 'status' => 201, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
json(201, '添加失败');
|
||||
}
|
||||
}
|
||||
if ($act == 'edit') { //编辑配置
|
||||
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
|
||||
$update['name'] = isset($_POST['name']) ? purge($_POST['name']) : '';
|
||||
$update['data'] = isset($_POST['data']) ? purge($_POST['data']) : '';
|
||||
$update['appid'] = isset($_POST['appid']) ? intval($_POST['appid']) : 0;
|
||||
$update['searchable'] = isset($_POST['searchable']) ? intval($_POST['searchable']) : 0;
|
||||
if ($update['name'] == '') json(201, '变量名称为空');
|
||||
if ($update['data'] == '') json(201, '扩展配置为空');
|
||||
if ($update['appid'] == 0) json(201, '绑定应用为空');
|
||||
$app_res = Db::table('app')->where('id', $update['appid'])->find();
|
||||
if (!$app_res) json(201, '应用不存在');
|
||||
$homead_res = Db::table('app_homead')->where(['name' => $update['name']])->find();
|
||||
if ($homead_res) {
|
||||
if ($homead_res['id'] != $id) json(201, '变量名已存在');
|
||||
}
|
||||
$res = Db::table('app_homead')->where('id', $id)->update($update);
|
||||
//die($res);
|
||||
if ($res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'homead_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' => 'homead_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('app_homead')->where('id', 'in', '(' . $ids . ')')->del(); //false
|
||||
//die($res);
|
||||
if ($res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'homead_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' => 'homead_del', 'status' => 201, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
json(201, '删除失败');
|
||||
}
|
||||
} else {
|
||||
json(201, '没有需要删除的数据');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/*
|
||||
Name:应用扩展配置API
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
Author QQ:51154393
|
||||
Author Url:www.eruyi.cn
|
||||
*/
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
if ($act == 'add') { //添加配置
|
||||
$name = isset($_POST['name']) ? purge($_POST['name']) : '';
|
||||
$data = isset($_POST['data']) ? purge($_POST['data']) : '';
|
||||
$appid = isset($_POST['appid']) ? intval($_POST['appid']) : 0;
|
||||
$searchable = isset($_POST['searchable']) ? purge($_POST['searchable']) : 'n';
|
||||
if ($name == '') json(201, '变量名称为空');
|
||||
// if(preg_match ("/^[\w]{1,32}$/",$name)==0)json(201,'变量名称不合格');
|
||||
if ($data == '') json(201, '扩展配置为空');
|
||||
if ($appid == 0) json(201, '绑定应用为空');
|
||||
$app_res = Db::table('app')->where('id', $appid)->find();
|
||||
if (!$app_res) json(201, '应用不存在');
|
||||
$level_res = Db::table('app_level')->where(['name' => $name])->find();
|
||||
if ($level_res) json(201, '变量名已存在');
|
||||
$add_res = Db::table('app_level')->add(['name' => $name, 'data' => $data, 'appid' => $appid, 'searchable' => $searchable]);
|
||||
//die($add_res);
|
||||
if ($add_res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'level_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' => 'level_add', 'status' => 201, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
json(201, '添加失败');
|
||||
}
|
||||
}
|
||||
if ($act == 'edit') { //编辑配置
|
||||
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
|
||||
$update['name'] = isset($_POST['name']) ? purge($_POST['name']) : '';
|
||||
$update['data'] = isset($_POST['data']) ? purge($_POST['data']) : '';
|
||||
$update['appid'] = isset($_POST['appid']) ? intval($_POST['appid']) : 0;
|
||||
$update['searchable'] = isset($_POST['searchable']) ? intval($_POST['searchable']) : 0;
|
||||
if ($update['name'] == '') json(201, '变量名称为空');
|
||||
if ($update['data'] == '') json(201, '扩展配置为空');
|
||||
if ($update['appid'] == 0) json(201, '绑定应用为空');
|
||||
$app_res = Db::table('app')->where('id', $update['appid'])->find();
|
||||
if (!$app_res) json(201, '应用不存在');
|
||||
$level_res = Db::table('app_level')->where(['name' => $update['name']])->find();
|
||||
if ($level_res) {
|
||||
if ($level_res['id'] != $id) json(201, '变量名已存在');
|
||||
}
|
||||
$res = Db::table('app_level')->where('id', $id)->update($update);
|
||||
//die($res);
|
||||
if ($res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'level_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' => 'level_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('app_level')->where('id', 'in', '(' . $ids . ')')->del(); //false
|
||||
//die($res);
|
||||
if ($res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'level_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' => 'level_del', 'status' => 201, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
json(201, '删除失败');
|
||||
}
|
||||
} else {
|
||||
json(201, '没有需要删除的数据');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
Name:通知API
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
Author QQ:51154393
|
||||
Author Url:www.eruyi.cn
|
||||
*/
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
if ($act == 'add') { //添加通知
|
||||
$adm = isset($_POST['adm']) && !empty($_POST['adm']) ? purge($_POST['adm']) : '管理员';
|
||||
$content = isset($_POST['content']) ? purge($_POST['content']) : '';
|
||||
$appid = isset($_POST['appid']) ? intval($_POST['appid']) : 0;
|
||||
if ($content == '') json(201, '通知内容为空');
|
||||
if ($appid == 0) json(201, '绑定应用为空');
|
||||
$app_res = Db::table('app')->where('id', $appid)->find();
|
||||
if (!$app_res) json(201, '应用不存在');
|
||||
$add_res = Db::table('app_notice')->add(['adm' => $adm, 'content' => $content, 'appid' => $appid, 'time' => time()]);
|
||||
//die($add_res);
|
||||
if ($add_res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'notice_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' => 'notice_add', 'status' => 201, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
json(201, '添加失败');
|
||||
}
|
||||
}
|
||||
if ($act == 'del') { //删除通知
|
||||
$id = isset($_POST['id']) && !empty($_POST['id']) ? intval($_POST['id']) : json(201, '请选择需要删除的数据');
|
||||
$res = Db::table('app_notice')->where('id', $id)->del(); //false
|
||||
if ($res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'notice_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' => 'notice_del', 'status' => 201, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
json(201, '删除失败');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/*
|
||||
* File:后台目录菜单配置文件
|
||||
* Author:易如意
|
||||
* QQ:51154393
|
||||
* Url:www.eruyi.cn
|
||||
*/
|
||||
|
||||
return [
|
||||
'id' => 'app',
|
||||
'name' => '应用',
|
||||
'icons' => 'mdi mdi-cube-outline',
|
||||
'sort' => 0, //排序
|
||||
];
|
||||
@@ -0,0 +1,321 @@
|
||||
<?php
|
||||
/*
|
||||
Sort:1
|
||||
Hidden:false
|
||||
Name:应用管理
|
||||
Url:app_adm
|
||||
Right:app
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
Author QQ:51154393
|
||||
Author Url:www.eruyi.cn
|
||||
*/
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
$nums = Db::table('app')->count(); //获取用户总数
|
||||
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
|
||||
$url = "./?app_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-cube-outline 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="搜索应用名称、ID" 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"> </label>
|
||||
</div>
|
||||
</th>
|
||||
<th style="width: 20px;">
|
||||
<center><span class="badge badge-light-lighten">APPID</span></center>
|
||||
</th>
|
||||
<th><span class="badge badge-light-lighten">应用名</span></th>
|
||||
<th style="width: 150px;">
|
||||
<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: 150px;">
|
||||
<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: 150px;">
|
||||
<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: 75px;">
|
||||
<center><span class="badge badge-light-lighten">管理</span></center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$app = Db::table('app', 'as A')->field('A.id,A.name,A.state,A.mode,A.app_bb,IFNULL(U.us,0) as unum,IFNULL(Q.qs,0) as qnum,IFNULL(L.zx,0) as znum')->JOIN("(SELECT appid,COUNT(*) AS us FROM {$DP}user GROUP BY appid) AS U", 'A.id=U.appid')->JOIN("(SELECT appid,COUNT(*) AS qs FROM {$DP}log where `type` = 'clock' GROUP BY appid) AS Q", 'A.id=Q.appid')->JOIN("(SELECT appid,COUNT(*) AS zx FROM {$DP}user_logon where `last_t` > {$UTT} GROUP BY appid) AS L", 'A.id=L.appid');
|
||||
if ($so) {
|
||||
$app = $app->where('A.id', 'like', "%{$so}%")->whereOr('A.name', 'like', "%{$so}%")->whereOr('A.appkey', 'like', "%{$so}%")->order('id desc');
|
||||
} else {
|
||||
$app = $app->order('id desc')->limit($bnums, $ENUMS);
|
||||
}
|
||||
$res = $app->select(); //false
|
||||
//die($sql);
|
||||
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>
|
||||
<span class="badge badge-primary">
|
||||
<i class="mdi mdi-cube-outline"></i>
|
||||
<?php echo $rows['name']; ?>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<center><span class="badge badge-primary">
|
||||
|
||||
<?php echo $rows['app_bb']; ?>
|
||||
</span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><span class="badge badge-secondary-lighten">
|
||||
<i class="mdi mdi-account"></i>
|
||||
<?php echo $rows['unum']; ?>
|
||||
</span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><span class="badge badge-secondary-lighten">
|
||||
<i class="mdi mdi-calendar-check-outline"></i>
|
||||
<?php echo $rows['qnum']; ?>
|
||||
</span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><span class="badge badge-secondary-lighten">
|
||||
<i class="mdi mdi-airplane"></i>
|
||||
<?php echo $rows['znum']; ?>
|
||||
</span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><?php if ($rows['mode'] == 'n') : ?>
|
||||
<span class="badge badge-success-lighten">免费
|
||||
<?php else : ?><span class="badge badge-danger-lighten">收费
|
||||
<?php endif; ?></span>
|
||||
</center>
|
||||
</td>
|
||||
<td>
|
||||
<center><?php if ($rows['state'] == 'n') : ?><span class="badge badge-danger">关闭<?php else : ?><span class="badge badge-success">正常<?php endif; ?></span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><a href="./?app_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="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">
|
||||
<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_name" name="add_name" placeholder="应用名称" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>应用版本</label>
|
||||
<input class="form-control" type="text" id="add_bb" name="add_bb" placeholder="1.0.0" value="" required>
|
||||
</div>
|
||||
<?php if ($app_num > 0) : ?>
|
||||
<div class="form-group">
|
||||
<label>继承应用设置</label>
|
||||
<select class="form-control" name="add_appid" id="add_appid">
|
||||
<option value="null">不继承</option>
|
||||
<?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>
|
||||
<?php endif; ?>
|
||||
<div class="form-group text-center">
|
||||
<button class="btn btn-primary" type="submit" name="add_submit" id="add_submit" value="确定">确认添加</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
|
||||
<script>
|
||||
$('#add_submit').click(function() {
|
||||
let t = window.jQuery;
|
||||
var add_name = $("input[name='add_name']").val();
|
||||
var add_bb = $("input[name='add_bb']").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=app_add", //请求的文件名
|
||||
data: {
|
||||
bb: add_bb,
|
||||
name: add_name,
|
||||
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=app_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>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,397 @@
|
||||
<?php
|
||||
/*
|
||||
Sort:3
|
||||
Hidden:false
|
||||
Name:扩展接口
|
||||
Url:app_exten
|
||||
Right:app_exten
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
Author QQ:51154393
|
||||
Author Url:www.eruyi.cn
|
||||
*/
|
||||
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
$nums = Db::table('app_exten')->count();
|
||||
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
|
||||
$url = "./?app_exten&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" onclick="modal_cut('add',0,0,0,0)" class="btn btn-danger mb-2 mr-2" data-toggle="modal" data-target="#modal"><i class="mdi mdi-briefcase-plus-outline 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"> </label>
|
||||
</div>
|
||||
</th>
|
||||
<th style="width: 100px;">
|
||||
<center><span class="badge badge-light-lighten">变量名</span></center>
|
||||
</th>
|
||||
<th><span class="badge badge-light-lighten">配置内容</span></th>
|
||||
<th style="width: 150px;">
|
||||
<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
|
||||
$app = Db::table('app_exten', 'as K')->field('K.*,A.name as appname')->JOIN('app', 'as A', 'K.appid=A.id');
|
||||
if ($so) {
|
||||
$app = $app->where('K.name', 'like', "%{$so}%")->whereOr('K.data', 'like', "%{$so}%")->order('id desc');
|
||||
} else {
|
||||
$app = $app->order('id desc')->limit($bnums, $ENUMS);
|
||||
}
|
||||
$res = $app->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['name']; ?></center>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo mb_substr($rows['data'], 0, 50, 'utf-8') . "..." ?>
|
||||
</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><a href="javascript:void(0);" onclick="modal_cut('edit',<?php echo $rows['id']; ?>,'<?php echo $rows['api']; ?>','<?php echo $rows['name']; ?>','<?php echo $rows['data']; ?>',<?php echo $rows['appid']; ?>,'<?php echo $rows['state']; ?>','<?php echo $rows['type']; ?>')" class="action-icon"> <i class="mdi mdi-border-color" data-toggle="modal" data-target="#modal"></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="modal" 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="modal_title">添加应用扩展配置</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-6 pr-6" method="post">
|
||||
<input class="form-control" type="number" id="exten_id" name="exten_id" value="" placeholder="配置ID" hidden>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label>接口类型</label>
|
||||
<select class="form-control" name="exten_type" id="exten_type">
|
||||
<option value="0">XML</option>
|
||||
<option value="1">JSON</option>
|
||||
<option value="2">多JSON</option>
|
||||
<option value="3">聚合接口</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label>接口名称</label>
|
||||
<input type="text" id="exten_name" name="exten_name" class="form-control" placeholder="扩展名称" value="" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-form-label">扩展接口【多个用英文(,)隔开】</label>
|
||||
<input class="form-control" type="text" id="exten_api" name="exten_api" placeholder="第三方接口" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>扩展内容【要应用的flag,多个用英文(,)隔开】</label>
|
||||
<textarea id="exten_data" name="exten_data" class="form-control" maxlength="255" rows="3" placeholder="如:youku,优酷,mgtv"><?php echo $res['exten_data']; ?></textarea>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>绑定应用</label>
|
||||
<select class="form-control" name="exten_appid" id="exten_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="eruyi-checkbox">
|
||||
<label class="eruyi-label">状态</label>
|
||||
<input type="checkbox" id="state" <?php if ($rows['state'] == 'y') : ?>checked<?php endif; ?> data-switch="success" onchange="" />
|
||||
<label for="state" data-on-label="开启" data-off-label="关闭"></label>
|
||||
</div>
|
||||
|
||||
<div id="add" class="form-group text-center">
|
||||
<button class="btn btn-primary" type="submit" name="add_submit" id="add_submit" value="确定">确认添加</button>
|
||||
</div>
|
||||
<div id="edit" class="form-group text-center" hidden>
|
||||
<button class="btn btn-primary" type="submit" name="edit_submit" id="edit_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>
|
||||
$('#add_submit').click(function() {
|
||||
var state = document.getElementById("state").checked;
|
||||
if (state) {
|
||||
state = 'y';
|
||||
} else {
|
||||
state = 'n';
|
||||
}
|
||||
let t = window.jQuery;
|
||||
var exten_api = $("input[name='exten_api']").val();
|
||||
var exten_type = $("select[name='exten_type']").val();
|
||||
var exten_name = $("input[name='exten_name']").val();
|
||||
var exten_data = $("textarea[name='exten_data']").val();
|
||||
var exten_appid = $("select[name='exten_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=app_exten_add", //请求的文件名
|
||||
data: {
|
||||
api: exten_api,
|
||||
name: exten_name,
|
||||
data: exten_data,
|
||||
appid: exten_appid,
|
||||
state: state,
|
||||
type: exten_type
|
||||
},
|
||||
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属性注册的点击事件,可以阻止它跳转。
|
||||
});
|
||||
|
||||
$('#edit_submit').click(function() {
|
||||
var state = document.getElementById("state").checked;
|
||||
if (state) {
|
||||
state = 'y';
|
||||
} else {
|
||||
state = 'n';
|
||||
}
|
||||
let t = window.jQuery;
|
||||
var exten_id = $("input[name='exten_id']").val();
|
||||
var exten_api = $("input[name='exten_api']").val();
|
||||
var exten_type = $("select[name='exten_type']").val();
|
||||
var exten_name = $("input[name='exten_name']").val();
|
||||
var exten_data = $("textarea[name='exten_data']").val();
|
||||
var exten_appid = $("select[name='exten_appid']").val();
|
||||
document.getElementById('edit_submit').innerHTML = "<span class=\"spinner-border spinner-border-sm mr-1\" role=\"status\" aria-hidden=\"true\"></span>正在编辑";
|
||||
document.getElementById('edit_submit').disabled = true;
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "POST", //请求的方式
|
||||
url: "ajax.php?act=app_exten_edit", //请求的文件名
|
||||
data: {
|
||||
id: exten_id,
|
||||
api: exten_api,
|
||||
name: exten_name,
|
||||
data: exten_data,
|
||||
appid: exten_appid,
|
||||
state: state,
|
||||
type: exten_type
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
console.log(data);
|
||||
document.getElementById('edit_submit').disabled = false;
|
||||
document.getElementById('edit_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 modal_cut(type, id, api, name, data, appid, state, apitype) {
|
||||
if (type == 'add') {
|
||||
document.getElementById("modal_title").innerHTML = "添加应用扩展配置";
|
||||
document.getElementById("add").removeAttribute("hidden");
|
||||
document.getElementById("edit").setAttribute("hidden", true);
|
||||
document.getElementById("exten_id").value = '';
|
||||
document.getElementById("exten_api").value = '';
|
||||
document.getElementById("exten_name").value = '';
|
||||
document.getElementById("exten_data").value = '';
|
||||
document.getElementById("state").value = '';
|
||||
document.getElementById("exten_type")[apitype].selected = true;
|
||||
} else {
|
||||
document.getElementById("modal_title").innerHTML = "编辑应用扩展配置";
|
||||
document.getElementById("edit").removeAttribute("hidden");
|
||||
document.getElementById("add").setAttribute("hidden", true);
|
||||
document.getElementById("exten_id").value = id;
|
||||
document.getElementById("exten_api").value = api;
|
||||
document.getElementById("exten_name").value = name;
|
||||
document.getElementById("exten_data").value = data;
|
||||
document.getElementById("exten_appid").value = appid;
|
||||
if (state == 'y') {
|
||||
document.getElementById("state").checked = true;
|
||||
} else {
|
||||
document.getElementById("state").checked = false;
|
||||
}
|
||||
document.getElementById("exten_type")[apitype].selected = true;
|
||||
}
|
||||
}
|
||||
|
||||
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=app_exten_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>
|
||||
@@ -0,0 +1,371 @@
|
||||
<?php
|
||||
/*
|
||||
Sort:4
|
||||
Hidden:false
|
||||
Name:首页广告
|
||||
Url:app_homead
|
||||
Right:app_homead
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
Author QQ:51154393
|
||||
Author Url:www.eruyi.cn
|
||||
*/
|
||||
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
$nums = Db::table('app_homead')->count();
|
||||
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
|
||||
$url = "./?app_homead&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" onclick="modal_cut('add',0,0,0,0)" class="btn btn-danger mb-2 mr-2" data-toggle="modal" data-target="#modal"><i class="mdi mdi-briefcase-plus-outline 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"> </label>
|
||||
</div>
|
||||
</th>
|
||||
<th style="width: 100px;">
|
||||
<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: 150px;">
|
||||
<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
|
||||
$app = Db::table('app_homead', 'as K')->field('K.*,A.name as appname')->JOIN('app', 'as A', 'K.appid=A.id');
|
||||
if ($so) {
|
||||
$app = $app->where('K.name', 'like', "%{$so}%")->whereOr('K.data', 'like', "%{$so}%")->order('id desc');
|
||||
} else {
|
||||
$app = $app->order('id desc')->limit($bnums, $ENUMS);
|
||||
}
|
||||
$res = $app->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['name']; ?></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><?php if ($rows['searchable'] == '0') : ?><span class="badge badge-danger">关闭<?php else : ?><span class="badge badge-success">开启<?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><a href="javascript:void(0);" onclick="modal_cut('edit',<?php echo $rows['id']; ?>,'<?php echo $rows['name']; ?>','<?php echo $rows['data']; ?>',<?php echo $rows['appid']; ?>,'<?php echo $rows['searchable']; ?>')" class="action-icon"> <i class="mdi mdi-border-color" data-toggle="modal" data-target="#modal"></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="modal" 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="modal_title">添加应用扩展配置</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-6 pr-6" method="post">
|
||||
<input class="form-control" type="number" id="homead_id" name="homead_id" value="" placeholder="配置ID" hidden>
|
||||
<!--style="display:none" -->
|
||||
<div class="form-group">
|
||||
<label class="col-form-label">扩展变量</label>
|
||||
<input class="form-control" type="text" id="homead_name" name="homead_name" placeholder="变量名称仅限字母加数字" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>扩展内容</label>
|
||||
<textarea id="homead_data" name="homead_data" class="form-control" maxlength="255" rows="4" placeholder="扩展内容"><?php echo $res['homead_data']; ?></textarea>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>绑定应用</label>
|
||||
<select class="form-control" name="homead_appid" id="homead_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="eruyi-checkbox">
|
||||
<label class="eruyi-label">按OK键搜索</label>
|
||||
<input type="checkbox" id="searchable" <?php if ($rows['searchable'] == 'y') : ?>checked<?php endif; ?> data-switch="success" onchange="" />
|
||||
<label for="searchable" data-on-label="开启" data-off-label="关闭"></label>
|
||||
</div>
|
||||
|
||||
<div id="add" class="form-group text-center">
|
||||
<button class="btn btn-primary" type="submit" name="add_submit" id="add_submit" value="确定">确认添加</button>
|
||||
</div>
|
||||
|
||||
<div id="edit" class="form-group text-center" hidden>
|
||||
<button class="btn btn-primary" type="submit" name="edit_submit" id="edit_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>
|
||||
$('#add_submit').click(function() {
|
||||
var searchable = document.getElementById("searchable").checked;
|
||||
if (searchable) {
|
||||
searchable = 1;
|
||||
} else {
|
||||
searchable = 0;
|
||||
}
|
||||
let t = window.jQuery;
|
||||
var homead_name = $("input[name='homead_name']").val();
|
||||
var homead_data = $("textarea[name='homead_data']").val();
|
||||
var homead_appid = $("select[name='homead_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=app_homead_add", //请求的文件名
|
||||
data: {
|
||||
name: homead_name,
|
||||
data: homead_data,
|
||||
appid: homead_appid,
|
||||
searchable: searchable
|
||||
},
|
||||
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属性注册的点击事件,可以阻止它跳转。
|
||||
});
|
||||
|
||||
$('#edit_submit').click(function() {
|
||||
var searchable = document.getElementById("searchable").checked;
|
||||
if (searchable) {
|
||||
searchable = 1;
|
||||
} else {
|
||||
searchable = 0;
|
||||
}
|
||||
let t = window.jQuery;
|
||||
var homead_id = $("input[name='homead_id']").val();
|
||||
var homead_name = $("input[name='homead_name']").val();
|
||||
var homead_data = $("textarea[name='homead_data']").val();
|
||||
var homead_appid = $("select[name='homead_appid']").val();
|
||||
document.getElementById('edit_submit').innerHTML = "<span class=\"spinner-border spinner-border-sm mr-1\" role=\"status\" aria-hidden=\"true\"></span>正在编辑";
|
||||
document.getElementById('edit_submit').disabled = true;
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "POST", //请求的方式
|
||||
url: "ajax.php?act=app_homead_edit", //请求的文件名
|
||||
data: {
|
||||
id: homead_id,
|
||||
name: homead_name,
|
||||
data: homead_data,
|
||||
appid: homead_appid,
|
||||
searchable: searchable
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
console.log(data);
|
||||
document.getElementById('edit_submit').disabled = false;
|
||||
document.getElementById('edit_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 modal_cut(type, id, name, data, appid, searchable) {
|
||||
if (type == 'add') {
|
||||
document.getElementById("modal_title").innerHTML = "添加应用扩展配置";
|
||||
document.getElementById("add").removeAttribute("hidden");
|
||||
document.getElementById("edit").setAttribute("hidden", true);
|
||||
document.getElementById("homead_id").value = '';
|
||||
document.getElementById("homead_name").value = '';
|
||||
document.getElementById("homead_data").value = '';
|
||||
} else {
|
||||
document.getElementById("modal_title").innerHTML = "编辑应用扩展配置";
|
||||
document.getElementById("edit").removeAttribute("hidden");
|
||||
document.getElementById("add").setAttribute("hidden", true);
|
||||
document.getElementById("homead_id").value = id;
|
||||
document.getElementById("homead_name").value = name;
|
||||
document.getElementById("homead_data").value = data;
|
||||
document.getElementById("homead_appid").value = appid;
|
||||
if (searchable == 1) {
|
||||
document.getElementById("searchable").checked = true;
|
||||
} else {
|
||||
document.getElementById("searchable").checked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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=app_homead_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>
|
||||
@@ -0,0 +1,371 @@
|
||||
<?php
|
||||
/*
|
||||
Sort:4
|
||||
Hidden:false
|
||||
Name:屏保设置
|
||||
Url:app_level
|
||||
Right:app_level
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
Author QQ:51154393
|
||||
Author Url:www.eruyi.cn
|
||||
*/
|
||||
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
$nums = Db::table('app_level')->count();
|
||||
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
|
||||
$url = "./?app_level&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" onclick="modal_cut('add',0,0,0,0)" class="btn btn-danger mb-2 mr-2" data-toggle="modal" data-target="#modal"><i class="mdi mdi-briefcase-plus-outline 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"> </label>
|
||||
</div>
|
||||
</th>
|
||||
<th style="width: 100px;">
|
||||
<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: 150px;">
|
||||
<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
|
||||
$app = Db::table('app_level', 'as K')->field('K.*,A.name as appname')->JOIN('app', 'as A', 'K.appid=A.id');
|
||||
if ($so) {
|
||||
$app = $app->where('K.name', 'like', "%{$so}%")->whereOr('K.data', 'like', "%{$so}%")->order('id desc');
|
||||
} else {
|
||||
$app = $app->order('id desc')->limit($bnums, $ENUMS);
|
||||
}
|
||||
$res = $app->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['name']; ?></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><?php if ($rows['searchable'] == '0') : ?><span class="badge badge-danger">关闭<?php else : ?><span class="badge badge-success">开启<?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><a href="javascript:void(0);" onclick="modal_cut('edit',<?php echo $rows['id']; ?>,'<?php echo $rows['name']; ?>','<?php echo $rows['data']; ?>',<?php echo $rows['appid']; ?>,'<?php echo $rows['searchable']; ?>')" class="action-icon"> <i class="mdi mdi-border-color" data-toggle="modal" data-target="#modal"></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="modal" 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="modal_title">添加应用扩展配置</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-6 pr-6" method="post">
|
||||
<input class="form-control" type="number" id="level_id" name="level_id" value="" placeholder="配置ID" hidden>
|
||||
<!--style="display:none" -->
|
||||
<div class="form-group">
|
||||
<label class="col-form-label">扩展变量</label>
|
||||
<input class="form-control" type="text" id="level_name" name="level_name" placeholder="变量名称仅限字母加数字" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>扩展内容</label>
|
||||
<textarea id="level_data" name="level_data" class="form-control" maxlength="255" rows="4" placeholder="扩展内容"><?php echo $res['level_data']; ?></textarea>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>绑定应用</label>
|
||||
<select class="form-control" name="level_appid" id="level_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="eruyi-checkbox">
|
||||
<label class="eruyi-label">按OK键搜索</label>
|
||||
<input type="checkbox" id="searchable" <?php if ($rows['searchable'] == 'y') : ?>checked<?php endif; ?> data-switch="success" onchange="" />
|
||||
<label for="searchable" data-on-label="开启" data-off-label="关闭"></label>
|
||||
</div>
|
||||
|
||||
<div id="add" class="form-group text-center">
|
||||
<button class="btn btn-primary" type="submit" name="add_submit" id="add_submit" value="确定">确认添加</button>
|
||||
</div>
|
||||
|
||||
<div id="edit" class="form-group text-center" hidden>
|
||||
<button class="btn btn-primary" type="submit" name="edit_submit" id="edit_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>
|
||||
$('#add_submit').click(function() {
|
||||
var searchable = document.getElementById("searchable").checked;
|
||||
if (searchable) {
|
||||
searchable = 1;
|
||||
} else {
|
||||
searchable = 0;
|
||||
}
|
||||
let t = window.jQuery;
|
||||
var level_name = $("input[name='level_name']").val();
|
||||
var level_data = $("textarea[name='level_data']").val();
|
||||
var level_appid = $("select[name='level_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=app_level_add", //请求的文件名
|
||||
data: {
|
||||
name: level_name,
|
||||
data: level_data,
|
||||
appid: level_appid,
|
||||
searchable: searchable
|
||||
},
|
||||
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属性注册的点击事件,可以阻止它跳转。
|
||||
});
|
||||
|
||||
$('#edit_submit').click(function() {
|
||||
var searchable = document.getElementById("searchable").checked;
|
||||
if (searchable) {
|
||||
searchable = 1;
|
||||
} else {
|
||||
searchable = 0;
|
||||
}
|
||||
let t = window.jQuery;
|
||||
var level_id = $("input[name='level_id']").val();
|
||||
var level_name = $("input[name='level_name']").val();
|
||||
var level_data = $("textarea[name='level_data']").val();
|
||||
var level_appid = $("select[name='level_appid']").val();
|
||||
document.getElementById('edit_submit').innerHTML = "<span class=\"spinner-border spinner-border-sm mr-1\" role=\"status\" aria-hidden=\"true\"></span>正在编辑";
|
||||
document.getElementById('edit_submit').disabled = true;
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "POST", //请求的方式
|
||||
url: "ajax.php?act=app_level_edit", //请求的文件名
|
||||
data: {
|
||||
id: level_id,
|
||||
name: level_name,
|
||||
data: level_data,
|
||||
appid: level_appid,
|
||||
searchable: searchable
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
console.log(data);
|
||||
document.getElementById('edit_submit').disabled = false;
|
||||
document.getElementById('edit_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 modal_cut(type, id, name, data, appid, searchable) {
|
||||
if (type == 'add') {
|
||||
document.getElementById("modal_title").innerHTML = "添加应用扩展配置";
|
||||
document.getElementById("add").removeAttribute("hidden");
|
||||
document.getElementById("edit").setAttribute("hidden", true);
|
||||
document.getElementById("level_id").value = '';
|
||||
document.getElementById("level_name").value = '';
|
||||
document.getElementById("level_data").value = '';
|
||||
} else {
|
||||
document.getElementById("modal_title").innerHTML = "编辑应用扩展配置";
|
||||
document.getElementById("edit").removeAttribute("hidden");
|
||||
document.getElementById("add").setAttribute("hidden", true);
|
||||
document.getElementById("level_id").value = id;
|
||||
document.getElementById("level_name").value = name;
|
||||
document.getElementById("level_data").value = data;
|
||||
document.getElementById("level_appid").value = appid;
|
||||
if (searchable == 1) {
|
||||
document.getElementById("searchable").checked = true;
|
||||
} else {
|
||||
document.getElementById("searchable").checked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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=app_level_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>
|
||||
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
/*
|
||||
Sort:5
|
||||
Hidden:false
|
||||
Name:应用公告
|
||||
Url:app_notice
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
Author QQ:51154393
|
||||
Author Url:www.eruyi.cn
|
||||
*/
|
||||
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
|
||||
if (Db::table('app_notice')->exist()) { //判断数据表是否存在
|
||||
$nums = Db::table('app_notice')->count();
|
||||
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
|
||||
$url = "./?app_notice&page=";
|
||||
$bnums = ($page - 1) * $ENUMS;
|
||||
} else {
|
||||
$sql = "CREATE TABLE IF NOT EXISTS `{$DP}app_notice` (
|
||||
`id` int(10) NOT NULL AUTO_INCREMENT,
|
||||
`content` varchar(255) NOT NULL COMMENT '内容',
|
||||
`appid` varchar(255) NOT NULL COMMENT '应用id',
|
||||
`time` int(10) NOT NULL COMMENT '时间戳',
|
||||
`adm` varchar(255) NOT NULL COMMENT '发布人',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;";
|
||||
$res = Db::establish($sql);
|
||||
if ($res) {
|
||||
echo "<script>location.href='./?app_notice';</script>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!-- 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">
|
||||
<?php if ($app_num > 0) : ?>
|
||||
<textarea class="form-control form-control-light mb-2" placeholder="请输入要发布的内容" id="add_content" name="add_content" rows="3"></textarea>
|
||||
<div class="row mt-2">
|
||||
<div class="col-lg-8">
|
||||
<form class="form-inline">
|
||||
<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>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="text-lg-right">
|
||||
<div class="btn-group ml-2">
|
||||
<button type="button" class="btn btn-primary btn-sm" name="add_submit" id="add_submit">发布公告</button>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- end col-->
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="text-center" style="margin-top:6rem!important;margin-bottom:10rem!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> <!-- end card-body-->
|
||||
</div> <!-- end card-->
|
||||
</div> <!-- end col -->
|
||||
</div>
|
||||
<!-- end row -->
|
||||
<?php
|
||||
$res = Db::table('app_notice', 'as N')->field('N.*,A.name as appname')->JOIN('app', 'as A', 'N.appid=A.id')->order('id desc')->limit($bnums, $ENUMS)->select();
|
||||
foreach ($res as $k => $v) {
|
||||
$rows = $res[$k];
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card mb-0 mt-2">
|
||||
<div class="card-body">
|
||||
<div class="media">
|
||||
<img src="../assets/images/users/avatar-1.jpg" alt="image" class="mr-3 d-none d-sm-block avatar-sm rounded-circle">
|
||||
<div class="media-body">
|
||||
<h5 class="mb-1 mt-0"><?php echo $rows['adm']; ?></h5>
|
||||
<p><span class="badge badge-light"><?php echo date("Y-m-d H:i:s", $rows['time']); ?></span>
|
||||
<?php if (empty($rows['appname'])) : ?><span class="badge badge-danger-lighten"><i class="mdi mdi-close-circle"></i> 应用不存在
|
||||
<?php else : ?><span class="badge badge-primary-lighten"><i class="mdi mdi-cube-outline"></i> <?php echo $rows['appname']; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
</p>
|
||||
<p class="mb-0 text-muted">
|
||||
<span class="font-italic"><?php echo $rows['content']; ?></span>
|
||||
</p>
|
||||
</div> <!-- end media-body -->
|
||||
<a id="delsubmit" href="javascript:void(0);" onclick="del(<?php echo $rows['id']; ?>)" class="dropdown-toggle arrow-none card-drop">
|
||||
<i class="mdi mdi-delete"></i>
|
||||
</a>
|
||||
</div> <!-- end media -->
|
||||
</div> <!-- end card-body -->
|
||||
</div> <!-- end col -->
|
||||
</div> <!-- end col -->
|
||||
</div><!-- end row -->
|
||||
<?php } ?>
|
||||
|
||||
<div class="mb-0 mt-2">
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination justify-content-end">
|
||||
<?php if (!$so) {
|
||||
echo pagination($nums, $ENUMS, $page, $url);
|
||||
} ?>
|
||||
</ul>
|
||||
</nav>
|
||||
</div> <!-- end card-->
|
||||
|
||||
<script>
|
||||
$('#add_submit').click(function() {
|
||||
let t = window.jQuery;
|
||||
var add_name = $("input[name='exten_name']").val();
|
||||
var add_content = $("textarea[name='add_content']").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;
|
||||
console.log(add_content);
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "POST", //请求的方式
|
||||
url: "ajax.php?act=app_notice_add", //请求的文件名
|
||||
data: {
|
||||
adm: add_name,
|
||||
content: add_content,
|
||||
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 del(id) {
|
||||
let t = window.jQuery;
|
||||
document.getElementById("delsubmit").innerHTML = "<div class=\"spinner-border spinner-border-sm mr-1\" style=\"margin-bottom:2px!important\" role=\"status\"></div>";
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "POST", //请求的方式
|
||||
url: "ajax.php?act=app_notice_del", //请求的文件名
|
||||
data: {
|
||||
id: id
|
||||
},
|
||||
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='" + window.location.href + "'", 1000);
|
||||
}
|
||||
});
|
||||
return false; //重要语句:如果是像a链接那种有href属性注册的点击事件,可以阻止它跳转。
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,393 @@
|
||||
<?php
|
||||
/*
|
||||
Sort:2
|
||||
Hidden:false
|
||||
Name:添加站点
|
||||
Url:app_site
|
||||
Right:site
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
Author QQ:51154393
|
||||
Author Url:www.eruyi.cn
|
||||
*/
|
||||
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
$nums = Db::table('site')->count(); //获取商品总数
|
||||
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
|
||||
$url = "./?app_site&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-cart-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"> </label>
|
||||
</div>
|
||||
</th>
|
||||
<th style="width: 20px;">
|
||||
<center><span class="badge badge-light-lighten">ID</span></center>
|
||||
</th>
|
||||
<th><span class="badge badge-light-lighten">站点名称</span></th>
|
||||
<th style="width: 150px;">
|
||||
<center><span class="badge badge-light-lighten">api</span></center>
|
||||
</th>
|
||||
<th style="width: 150px;">
|
||||
<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: 150px;">
|
||||
<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: 150px;">
|
||||
<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
|
||||
$site = Db::table('site', 'as G')->field('G.*,A.name as appname,IFNULL(D.ds,0) as dnum,IFNULL(C.sc,0) as cnum')->JOIN('app', 'as A', 'G.appid=A.id')->JOIN("(SELECT gid,COUNT(*) AS sc FROM {$DP}site_order where `state` = 2 GROUP BY gid) AS C", 'G.id=C.gid')->JOIN("(SELECT gid,COUNT(*) AS ds FROM {$DP}site_order GROUP BY gid) AS D", 'G.id=D.gid');
|
||||
if ($so) {
|
||||
$site = $site->where('G.name', 'like', "%{$so}%")->whereOr('G.jie', 'like', "%{$so}%")->whereOr('A.name', 'like', "%{$so}%")->order('id desc');
|
||||
} else {
|
||||
$site = $site->order('id desc')->limit($bnums, $ENUMS);
|
||||
}
|
||||
$res = $site->select();
|
||||
// die(print_r($site));
|
||||
foreach ($res as $k => $v) {
|
||||
$rows = $res[$k];
|
||||
if (empty($rows['appname'])) continue;
|
||||
?>
|
||||
<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>
|
||||
<?php echo $rows['name']; ?>
|
||||
</td>
|
||||
<td>
|
||||
<center><span class="badge badge-info-lighten"><?php echo mb_substr($rows['api'], 0, 50, 'utf-8') . "..."; ?></span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><?php if ($rows['searchable'] == '0') : ?><span class="badge badge-danger">关闭<?php else : ?><span class="badge badge-success">开启<?php endif; ?></span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><?php if ($rows['quicksearch'] == '0') : ?><span class="badge badge-danger">关闭<?php else : ?><span class="badge badge-success">开启<?php endif; ?></span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><?php if ($rows['filterable'] == '0') : ?><span class="badge badge-danger">关闭<?php else : ?><span class="badge badge-success">开启<?php endif; ?></span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><?php if ($rows['state'] == 'n') : ?><span class="badge badge-danger">停用<?php else : ?><span class="badge badge-success">启动<?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><a href="./?app_siteedit&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="add" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<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_name" name="add_name" placeholder="站点名称" required>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label>接口类型</label>
|
||||
<select class="form-control" name="add_type" id="add_type" onchange="type_change()">
|
||||
<option value="XML">XML</option>
|
||||
<option value="JSON">JSON</option>
|
||||
<option value="Spider">自定义爬虫</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-8">
|
||||
<label>api</label>
|
||||
<input type="text" id="add_api" name="add_api" class="form-control" placeholder="csp_AppYsV2" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>PlayUrl</label>
|
||||
<input type="text" id="add_parse" name="add_parse" class="form-control" placeholder="解析接口" value="">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label id="add_extend_name" name="add_extend_name">扩展信息</label>
|
||||
<input type="text" id="add_extend" name="add_extend" class="form-control" placeholder="ext" value="">
|
||||
</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-row">
|
||||
<div class="eruyi-checkbox">
|
||||
<label class="eruyi-label">普通搜索</label>
|
||||
<input type="checkbox" id="searchable" <?php if ($res['searchable'] == 'y') : ?>checked<?php endif; ?> data-switch="success" onchange="reg_state_v(this.checked)" />
|
||||
<label for="searchable" data-on-label="开启" data-off-label="关闭"></label>
|
||||
</div>
|
||||
<div class="eruyi-checkbox">
|
||||
<label class="eruyi-label">快速搜索</label>
|
||||
<input type="checkbox" id="quicksearch" <?php if ($res['quicksearch'] == 'y') : ?>checked<?php endif; ?> data-switch="success" onchange="reg_state_v(this.checked)" />
|
||||
<label for="quicksearch" data-on-label="开启" data-off-label="关闭"></label>
|
||||
</div>
|
||||
<div class="eruyi-checkbox">
|
||||
<label class="eruyi-label">参与筛选</label>
|
||||
<input type="checkbox" id="filterable" <?php if ($res['filterable'] == 'y') : ?>checked<?php endif; ?> data-switch="success" onchange="reg_state_v(this.checked)" />
|
||||
<label for="filterable" data-on-label="开启" data-off-label="关闭"></label>
|
||||
</div>
|
||||
<br /><br /><br /><br />
|
||||
</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>
|
||||
function reg_state_v(i) {
|
||||
console.log(i);
|
||||
if (i == true) {
|
||||
$("#reg_state_y").css("display", "block");
|
||||
$("#reg_state_n").css("display", "none");
|
||||
} else {
|
||||
$("#reg_state_y").css("display", "none");
|
||||
$("#reg_state_n").css("display", "block");
|
||||
}
|
||||
}
|
||||
|
||||
function type_change() {
|
||||
if ($('#add_type').val() == 'Spider') {
|
||||
// document.getElementById("add_extend_name").innerHTML = "扩展接口";
|
||||
} else {
|
||||
// document.getElementById("add_extend_name").innerHTML = "要显示的分类,留空全显";
|
||||
}
|
||||
}
|
||||
|
||||
$('#add_submit').click(function() {
|
||||
let t = window.jQuery;
|
||||
var add_name = $("input[name='add_name']").val();
|
||||
var add_type = $("select[name='add_type']").val();
|
||||
var add_api = $("input[name='add_api']").val();
|
||||
var add_extend = $("input[name='add_extend']").val();
|
||||
var add_parse = $("input[name='add_parse']").val();
|
||||
var add_appid = $("select[name='add_appid']").val();
|
||||
var filterable = document.getElementById("filterable").checked;
|
||||
if (filterable) {
|
||||
filterable = 1;
|
||||
} else {
|
||||
filterable = 0;
|
||||
}
|
||||
var searchable = document.getElementById("searchable").checked;
|
||||
if (searchable) {
|
||||
searchable = 1;
|
||||
} else {
|
||||
searchable = 0;
|
||||
}
|
||||
var quicksearch = document.getElementById("quicksearch").checked;
|
||||
if (quicksearch) {
|
||||
quicksearch = 1;
|
||||
} else {
|
||||
quicksearch = 0;
|
||||
}
|
||||
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=app_siteadd", //请求的文件名
|
||||
data: {
|
||||
name: add_name,
|
||||
type: add_type,
|
||||
api: add_api,
|
||||
extend: add_extend,
|
||||
parse: add_parse,
|
||||
appid: add_appid,
|
||||
filterable: filterable,
|
||||
searchable: searchable,
|
||||
quicksearch: quicksearch
|
||||
},
|
||||
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=app_sitedel", //请求的文件名
|
||||
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>
|
||||
@@ -0,0 +1,221 @@
|
||||
<?php
|
||||
/*
|
||||
Sort:1
|
||||
Hidden:true
|
||||
Name:编辑站点
|
||||
Url:app_siteedit
|
||||
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('site')->where(['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="site_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 -->
|
||||
|
||||
<!-- Form row -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form action="" method="post" id="addimg" name="addimg">
|
||||
<div class="eruyi-checkbox">
|
||||
<input type="checkbox" id="state" <?php if ($res['state'] == 'y') : ?>checked<?php endif; ?> data-switch="success" onchange="state_v(this.checked)" />
|
||||
<label for="state" data-on-label="正常" data-off-label="停售"></label>
|
||||
<label class="eruyi-label">站点状态</label>
|
||||
</div>
|
||||
|
||||
<div class="view" name="state_y" id="state_y" <?php if ($res['state'] == 'y') : ?> style="display: block" <?php endif; ?>>
|
||||
<p class="text-muted">
|
||||
正常状态情况下,可以被 <code>站点列表接口</code> 正常输出
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="view" name="state_n" id="state_n" <?php if ($res['state'] == 'n') : ?> style="display: block" <?php endif; ?>>
|
||||
<p class="text-muted">
|
||||
停售状态情况下,<code>站点列表接口</code> 不在输出此站点
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="f_user" class="col-form-label">站点名称 *</label>
|
||||
<input type="text" class="form-control" id="name" name="name" placeholder="站点名称" value="<?php echo $res['name']; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-2">
|
||||
<label class="col-form-label">接口类型</label>
|
||||
<select class="form-control" name="type" id="type" onchange="type_change()">
|
||||
<option value="XML" <?php if ($res['type'] == 'XML') echo 'selected = "selected"'; ?>>XML</option>
|
||||
<option value="JSON" <?php if ($res['type'] == 'JSON') echo 'selected = "selected"'; ?>>JSON</option>
|
||||
<option value="Spider" <?php if ($res['type'] == 'Spider') echo 'selected = "selected"'; ?>>自定义爬虫</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-10">
|
||||
<label class="col-form-label">API <a href="https://docs.qq.com/doc/p/657e7d526d48833e75d7a903a6235ddb98eb241e" target="_biank">如何对接自己的苹果CMS,请联系客服</a></label>
|
||||
<input type="text" class="form-control" id="api" name="api" placeholder="站点名称" value="<?php echo $res['api']; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="f_psw" class="col-form-label">PlayUrl</label>
|
||||
<input type="parse" class="form-control" id="parse" name="parse" placeholder="playUrl" value="<?php echo $res['parse']; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="f_psw" class="col-form-label" id="extend_name" name="extend_name">扩展信息</label>
|
||||
<input type="extend" class="form-control" id="extend" name="extend" placeholder="ext" value="<?php echo $res['extend']; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="f_vip" class="col-form-label">绑定应用 *</label>
|
||||
<select class="form-control" name="appid" id="appid">
|
||||
<?php
|
||||
$app_res = Db::table('app')->order('id desc')->select();
|
||||
foreach ($app_res as $k => $v) {
|
||||
$rows = $app_res[$k];
|
||||
?>
|
||||
<option value="<?php echo $rows['id']; ?>" <?php if ($res['appid'] == $rows['id']) echo 'selected = "selected"'; ?>><?php echo $rows['name']; ?></option>
|
||||
<?php } ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="custom-control custom-checkbox">
|
||||
|
||||
<input type="checkbox" class="custom-control-input" id="searchable" <?php if ($res['searchable'] == '1') : ?> checked <?php endif; ?> name="searchable" value="y" required>
|
||||
<label class="custom-control-label" for="searchable">普通搜索</label>
|
||||
</div>
|
||||
<div class="custom-control custom-checkbox">
|
||||
|
||||
<input type="checkbox" class="custom-control-input" id="quicksearch" <?php if ($res['quicksearch'] == '1') : ?> checked <?php endif; ?> name="quicksearch" value="y" required>
|
||||
<label class="custom-control-label" for="quicksearch">快速搜索</label>
|
||||
</div>
|
||||
<div class="custom-control custom-checkbox">
|
||||
|
||||
<input type="checkbox" class="custom-control-input" id="filterable" <?php if ($res['filterable'] == '1') : ?> checked <?php endif; ?> name="filterable" value="y" required>
|
||||
<label class="custom-control-label" for="filterable">参与筛选</label>
|
||||
</div>
|
||||
<br /><br />
|
||||
</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><!-- end row -->
|
||||
|
||||
<script>
|
||||
$("#site_adm").addClass("active");
|
||||
$('#submit').click(function() {
|
||||
let t = window.jQuery;
|
||||
var state = document.getElementById("state").checked;
|
||||
if (state) {
|
||||
state = 'y';
|
||||
} else {
|
||||
state = 'n';
|
||||
}
|
||||
var filterable = document.getElementById("filterable").checked;
|
||||
if (filterable) {
|
||||
filterable = 1;
|
||||
} else {
|
||||
filterable = 0;
|
||||
}
|
||||
var searchable = document.getElementById("searchable").checked;
|
||||
if (searchable) {
|
||||
searchable = 1;
|
||||
} else {
|
||||
searchable = 0;
|
||||
}
|
||||
var quicksearch = document.getElementById("quicksearch").checked;
|
||||
if (quicksearch) {
|
||||
quicksearch = 1;
|
||||
} else {
|
||||
quicksearch = 0;
|
||||
}
|
||||
var name = $("input[name='name']").val();
|
||||
var type = $("select[name='type']").val();
|
||||
var api = $("input[name='api']").val();
|
||||
var extend = $("input[name='extend']").val();
|
||||
var parse = $("input[name='parse']").val();
|
||||
var appid = $("select[name='appid']").val();
|
||||
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=app_siteedit", //请求的文件名
|
||||
data: {
|
||||
id: <?php echo $id; ?>,
|
||||
name: name,
|
||||
type: type,
|
||||
api: api,
|
||||
extend: extend,
|
||||
parse: parse,
|
||||
state: state,
|
||||
appid: appid,
|
||||
filterable: filterable,
|
||||
searchable: searchable,
|
||||
quicksearch: quicksearch
|
||||
},
|
||||
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 type_change() {
|
||||
if ($('#type').val() == 'Spider') {
|
||||
// document.getElementById("extend_name").innerHTML = "扩展接口";
|
||||
} else {
|
||||
// document.getElementById("extend_name").innerHTML = "要显示的分类,留空全显";
|
||||
}
|
||||
}
|
||||
|
||||
function state_v(i) {
|
||||
if (i == true) {
|
||||
$("#state_y").css("display", "block");
|
||||
$("#state_n").css("display", "none");
|
||||
} else {
|
||||
$("#state_y").css("display", "none");
|
||||
$("#state_n").css("display", "block");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/*
|
||||
Name:积分API
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
if ($act == 'add') { //添加积分事件
|
||||
$add['name'] = isset($_POST['name']) ? purge($_POST['name']) : '';
|
||||
$add['fen_num'] = isset($_POST['fen_num']) ? intval($_POST['fen_num']) : 0;
|
||||
$add['vip_num'] = isset($_POST['vip_num']) ? intval($_POST['vip_num']) : 0;
|
||||
$add['appid'] = isset($_POST['appid']) ? intval($_POST['appid']) : 0;
|
||||
|
||||
if ($add['name'] == '') json(201, '积分事件名称为空');
|
||||
if ($add['fen_num'] == 0) json(201, '请正确填写消耗积分数');
|
||||
if ($add['vip_num'] < 0) json(201, '请正确填写兑换会员数');
|
||||
if ($add['appid'] == 0) json(201, '绑定应用为空');
|
||||
|
||||
$app_res = Db::table('app')->where('id', $add['appid'])->find();
|
||||
if (!$app_res) json(201, '应用不存在');
|
||||
|
||||
$fen_res = Db::table('fen')->where(['name' => $add['name'], 'appid' => $add['appid']])->find();
|
||||
if ($fen_res) json(201, '积分事件名称已存在');
|
||||
|
||||
$add_res = Db::table('fen')->add($add);
|
||||
//die($add_res);
|
||||
if ($add_res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'fen_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' => 'fen_add', 'status' => 201, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
json(201, '添加失败');
|
||||
}
|
||||
}
|
||||
if ($act == 'edit') { //编辑积分事件
|
||||
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
|
||||
$update['name'] = isset($_POST['name']) ? purge($_POST['name']) : '';
|
||||
$update['fen_num'] = isset($_POST['fen_num']) ? intval($_POST['fen_num']) : 0;
|
||||
$update['vip_num'] = isset($_POST['vip_num']) ? intval($_POST['vip_num']) : 0;
|
||||
$update['appid'] = isset($_POST['appid']) ? intval($_POST['appid']) : 0;
|
||||
|
||||
if ($update['name'] == '') json(201, '积分事件名称为空');
|
||||
if ($update['fen_num'] == 0) json(201, '请正确填写消耗积分数');
|
||||
if ($update['vip_num'] < 0) json(201, '请正确填写兑换会员数');
|
||||
if ($update['appid'] == 0) json(201, '绑定应用为空');
|
||||
|
||||
$app_res = Db::table('app')->where('id', $update['appid'])->find();
|
||||
if (!$app_res) json(201, '应用不存在');
|
||||
|
||||
$fen_res = Db::table('fen')->where(['name' => $update['name'], 'appid' => $update['appid']])->find();
|
||||
if ($fen_res) {
|
||||
if ($fen_res['id'] != $id) json(201, '积分事件名称已存在');
|
||||
}
|
||||
|
||||
$res = Db::table('fen')->where('id', $id)->update($update);
|
||||
//die($res);
|
||||
if ($res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'fen_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' => 'fen_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('fen')->where('id', 'in', '(' . $ids . ')')->del(); //false
|
||||
//die($res);
|
||||
if ($res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'fen_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' => 'fen_del', 'status' => 201, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
json(201, '删除失败');
|
||||
}
|
||||
} else {
|
||||
json(201, '没有需要删除的数据');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
Name:积分事件订单API
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
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('fen_order')->where('id', 'in', '(' . $ids . ')')->del(); //false
|
||||
//die($res);
|
||||
if ($res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'fen_o_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' => 'fen_o_del', 'status' => 201, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
json(201, '删除失败');
|
||||
}
|
||||
} else {
|
||||
json(201, '没有需要删除的数据');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/*
|
||||
* File:后台目录菜单配置文件
|
||||
* Author:易如意
|
||||
* QQ:51154393
|
||||
* Url:www.eruyi.cn
|
||||
*/
|
||||
|
||||
return [
|
||||
'id' => 'fen',
|
||||
'name' => '积分',
|
||||
'icons' => 'mdi mdi-coin',
|
||||
'sort' => 6, //排序
|
||||
];
|
||||
@@ -0,0 +1,419 @@
|
||||
<?php
|
||||
/*
|
||||
Sort:1
|
||||
Hidden:false
|
||||
Name:积分管理
|
||||
Url:fen_adm
|
||||
Right:fen
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
Author QQ:51154393
|
||||
Author Url:www.eruyi.cn
|
||||
*/
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
$nums = Db::table('fen')->count(); //获取商品总数
|
||||
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
|
||||
$url = './?fen_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" onclick="modal_cut('add',0,0,0,0,0,0)" class="btn btn-danger mb-2 mr-2" data-toggle="modal" data-target="#modal"><i class="mdi mdi-coins 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"> </label>
|
||||
</div>
|
||||
</th>
|
||||
<th style="width: 20px;">
|
||||
<center><span class="badge badge-light-lighten">ID</span></center>
|
||||
</th>
|
||||
<th><span class="badge badge-light-lighten">事件名称</span></th>
|
||||
<th style="width: 150px;">
|
||||
<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: 150px;">
|
||||
<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: 75px;">
|
||||
<center><span class="badge badge-light-lighten">编辑</span></center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$fen = Db::table('fen', 'as F')->field('F.*,A.name as appname')->JOIN('app', 'as A', 'F.appid=A.id');
|
||||
if ($so) {
|
||||
$fen = $fen->where('F.name', 'like', "%{$so}%")->whereOr('A.name', 'like', "%{$so}%")->order('id desc');
|
||||
} else {
|
||||
$fen = $fen->order('id desc')->limit($bnums, $ENUMS);
|
||||
}
|
||||
$res = $fen->select(); //false
|
||||
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>
|
||||
<?php echo $rows['name']; ?>
|
||||
</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><?php if ($rows['vip_num'] <= 0) : ?><span class="badge badge-warning-lighten">消耗积分<?php else : ?><span class="badge badge-danger-lighten">兑换会员<?php endif; ?></span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><span class="badge badge-info-lighten">
|
||||
<?php if ($rows['fen_num'] > 0) {
|
||||
echo '+' . $rows['fen_num'];
|
||||
} else {
|
||||
echo $rows['fen_num'];
|
||||
} ?>
|
||||
</span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><?php if ($rows['state'] == 'n') : ?><span class="badge badge-danger">禁用<?php else : ?><span class="badge badge-success">正常<?php endif; ?></span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><a href="javascript:void(0);" onclick="modal_cut('edit',<?php echo $rows['id']; ?>,'<?php echo $rows['name']; ?>','<?php if ($rows['vip_num'] <= 0) {
|
||||
echo 'fen';
|
||||
} else {
|
||||
echo 'vip';
|
||||
} ?>',<?php echo $rows['fen_num']; ?>,<?php echo $rows['vip_num']; ?>,<?php echo $rows['appid']; ?>)" class="action-icon"> <i class="mdi mdi-border-color" data-toggle="modal" data-target="#modal"></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="modal" 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="modal_title">添加积分事件</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">
|
||||
<input class="form-control" type="number" id="modal_id" name="modal_id" value="" placeholder="事件ID" hidden>
|
||||
<div class="form-group">
|
||||
<label class="col-form-label">积分事件名称 *</label>
|
||||
<input class="form-control" type="text" id="modal_name" name="modal_name" placeholder="事件名称" required>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label>事件类型 *</label>
|
||||
<select class="form-control" name="modal_type" id="modal_type" onchange="type_change(this.value)">
|
||||
<option value="fen">消耗积分</option>
|
||||
<option value="vip">兑换会员</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-8">
|
||||
<label id="type_a">消耗积分数 *</label>
|
||||
<div class="input-group">
|
||||
<input type="number" id="modal_fen_num" name="modal_fen_num" class="form-control" placeholder="0" value="">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">积分</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="alert alert-warning alert-dismissible fade show" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<strong>提示 - </strong> 消耗积分填写负数,增加积分填写正数
|
||||
</div>
|
||||
<div id="modal_vip" class="form-row" hidden>
|
||||
<div class="form-group col-md-12">
|
||||
<label id="type_a">获得会员 *</label>
|
||||
<div class="input-group">
|
||||
<input type="number" id="modal_vip_num" name="modal_vip_num" class="form-control" placeholder="0" value="">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="type_b">小时</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>绑定应用 *</label>
|
||||
<select class="form-control" name="modal_appid" id="modal_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 id="add" class="form-group text-center">
|
||||
<button class="btn btn-primary" type="submit" name="add_submit" id="add_submit" value="确定">确认添加</button>
|
||||
</div>
|
||||
<div id="edit" class="form-group text-center" hidden>
|
||||
<button class="btn btn-primary" type="submit" name="edit_submit" id="edit_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>
|
||||
$('#add_submit').click(function() {
|
||||
let t = window.jQuery;
|
||||
var modal_name = $("input[name='modal_name']").val();
|
||||
var modal_fen_num = $("input[name='modal_fen_num']").val();
|
||||
var modal_vip_num = $("input[name='modal_vip_num']").val();
|
||||
var modal_appid = $("select[name='modal_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=fen_add", //请求的文件名
|
||||
data: {
|
||||
name: modal_name,
|
||||
fen_num: modal_fen_num,
|
||||
vip_num: modal_vip_num,
|
||||
appid: modal_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属性注册的点击事件,可以阻止它跳转。
|
||||
});
|
||||
|
||||
$('#edit_submit').click(function() {
|
||||
let t = window.jQuery;
|
||||
var modal_id = $("input[name='modal_id']").val();
|
||||
var modal_name = $("input[name='modal_name']").val();
|
||||
var modal_fen_num = $("input[name='modal_fen_num']").val();
|
||||
var modal_vip_num = $("input[name='modal_vip_num']").val();
|
||||
var modal_appid = $("select[name='modal_appid']").val();
|
||||
document.getElementById('edit_submit').innerHTML = "<span class=\"spinner-border spinner-border-sm mr-1\" role=\"status\" aria-hidden=\"true\"></span>正在添加";
|
||||
document.getElementById('edit_submit').disabled = true;
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "POST", //请求的方式
|
||||
url: "ajax.php?act=fen_edit", //请求的文件名
|
||||
data: {
|
||||
id: modal_id,
|
||||
name: modal_name,
|
||||
fen_num: modal_fen_num,
|
||||
vip_num: modal_vip_num,
|
||||
appid: modal_appid
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
console.log(data);
|
||||
document.getElementById('edit_submit').disabled = false;
|
||||
document.getElementById('edit_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 modal_cut(cut, id, name, type, fen, vip, appid) {
|
||||
if (cut == 'add') {
|
||||
document.getElementById("modal_title").innerHTML = "添加积分事件";
|
||||
document.getElementById("add").removeAttribute("hidden");
|
||||
document.getElementById("edit").setAttribute("hidden", true);
|
||||
document.getElementById("modal_name").value = '';
|
||||
document.getElementById("modal_type").value = 'fen';
|
||||
document.getElementById("modal_vip").setAttribute("hidden", true);
|
||||
document.getElementById("modal_fen_num").value = '';
|
||||
document.getElementById("modal_vip_num").value = '';
|
||||
} else {
|
||||
document.getElementById("modal_title").innerHTML = "编辑积分事件";
|
||||
document.getElementById("edit").removeAttribute("hidden");
|
||||
document.getElementById("add").setAttribute("hidden", true);
|
||||
document.getElementById("modal_id").value = id;
|
||||
document.getElementById("modal_name").value = name;
|
||||
document.getElementById("modal_type").value = type;
|
||||
if (type == 'vip') {
|
||||
document.getElementById("modal_vip").removeAttribute("hidden");
|
||||
} else {
|
||||
document.getElementById("modal_vip").setAttribute("hidden", true);
|
||||
}
|
||||
document.getElementById("modal_fen_num").value = fen;
|
||||
document.getElementById("modal_vip_num").value = vip;
|
||||
document.getElementById("modal_appid").value = appid;
|
||||
}
|
||||
}
|
||||
|
||||
function type_change(i) {
|
||||
if (i == 'vip') {
|
||||
document.getElementById("modal_vip").removeAttribute("hidden");
|
||||
} else {
|
||||
document.getElementById("modal_vip").setAttribute("hidden", true);
|
||||
}
|
||||
}
|
||||
|
||||
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=fen_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>
|
||||
@@ -0,0 +1,291 @@
|
||||
<?php
|
||||
/*
|
||||
Sort:2
|
||||
Hidden:false
|
||||
Name:积分订单
|
||||
Url:fen_order
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
Author QQ:51154393
|
||||
Author Url:www.eruyi.cn
|
||||
*/
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
|
||||
$appid = isset($_GET['app']) ? intval($_GET['app']) : 0;
|
||||
$see = isset($_GET['see']) ? intval($_GET['see']) : 0;
|
||||
$fen_order = Db::table('fen_order', 'as Fo')->field('Fo.*,F.appid,F.name as fname,F.fen_num,F.vip_num')->JOIN('fen', 'as F', 'Fo.fid=F.id');
|
||||
|
||||
if ($see > 0 && $appid > 0) {
|
||||
if ($see == 1) {
|
||||
$nums = $fen_order->where('F.vip_num', 0)->where('F.appid', $appid)->count();
|
||||
} else {
|
||||
$nums = $fen_order->where('F.vip_num', '>=', 1)->where('F.appid', $appid)->count();
|
||||
}
|
||||
$url = "./?fen_order&see={$see}&app={$appid}&page=";
|
||||
} elseif ($see > 0 && $appid <= 0) {
|
||||
if ($see == 1) {
|
||||
$nums = $fen_order->where('F.vip_num', 0)->where('F.appid', $appid)->count();
|
||||
} else {
|
||||
$nums = $fen_order->where('F.vip_num', '>=', 1)->where('F.appid', $appid)->count();
|
||||
}
|
||||
$url = "./?fen_order&see={$see}&page=";
|
||||
} elseif ($see <= 0 && $appid > 0) {
|
||||
$nums = $fen_order->where('F.appid', $appid)->count();
|
||||
$url = "./?fen_order&app={$appid}&page=";
|
||||
} else {
|
||||
$nums = $fen_order->count();
|
||||
$url = "./?fen_order&page=";
|
||||
}
|
||||
//die($nums);
|
||||
$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">
|
||||
<form class="form-inline">
|
||||
<select class="form-control" name="appid" id="appid" onchange="get_screen(this.value,<?php echo $see; ?>,<?php echo $page; ?>)">
|
||||
<option value="0">全部</option>
|
||||
<?php
|
||||
$res = Db::table('app')->order('id desc')->select();
|
||||
foreach ($res as $k => $v) {
|
||||
$rows = $res[$k];
|
||||
?>
|
||||
<option value="<?php echo $rows['id']; ?>" <?php if ($appid == $rows['id']) echo 'selected = "selected"'; ?>><?php echo $rows['name']; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<label for="status-select" class="mr-2"></label>
|
||||
<select class="form-control" name="see" id="see" onchange="get_screen(<?php echo $appid; ?>,this.value,<?php echo $page; ?>)">
|
||||
<option value="0" <?php if ($see == 0) echo 'selected = "selected"'; ?>>全部</option>
|
||||
<option value="1" <?php if ($see == 1) echo 'selected = "selected"'; ?>>消耗积分</option>
|
||||
<option value="2" <?php if ($see == 2) echo 'selected = "selected"'; ?>>兑换会员</option>
|
||||
</select>
|
||||
</form>
|
||||
</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"> </label>
|
||||
</div>
|
||||
</th>
|
||||
<th style="width: 20px;">
|
||||
<center><span class="badge badge-light-lighten">ID</span></center>
|
||||
</th>
|
||||
<th style="width: 100px;"><span class="badge badge-light-lighten">用户账号</span></th>
|
||||
<th style="width: 100px;"><span class="badge badge-light-lighten">事件名称</span></th>
|
||||
<th><span class="badge badge-light-lighten">事件标记</span></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: 150px;">
|
||||
<center><span class="badge badge-light-lighten">应用名称</span></center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$fen_order = Db::table('fen_order', 'as Fo')->field('Fo.*,F.appid,F.name as fname,F.fen_num,F.vip_num,U.user,U.email,U.phone,A.name as appname')->JOIN('fen', 'as F', 'Fo.fid=F.id')->JOIN('user', 'as U', 'Fo.uid=U.id')->JOIN('app', 'as A', 'F.appid=A.id');
|
||||
if ($so) {
|
||||
$fen_order->where('F.name', 'like', "%{$so}%")->whereOr('U.user', 'like', "%{$so}%")->whereOr('U.email', 'like', "%{$so}%")->whereOr('U.phone', 'like', "%{$so}%")->whereOr('A.name', 'like', "%{$so}%")->order('id desc');
|
||||
} else {
|
||||
if ($see > 0 && $appid > 0) {
|
||||
if ($see == 1) {
|
||||
$fen_order = $fen_order->where('F.vip_num', 0)->where('F.appid', $appid);
|
||||
} else {
|
||||
$fen_order = $fen_order->where('F.vip_num', '>=', 1)->where('F.appid', $appid);
|
||||
}
|
||||
} elseif ($see > 0 && $appid <= 0) {
|
||||
if ($see == 1) {
|
||||
$fen_order = $fen_order->where('F.vip_num', 0)->where('F.appid', $appid);
|
||||
} else {
|
||||
$fen_order = $fen_order->where('F.vip_num', '>=', 1)->where('F.appid', $appid);
|
||||
}
|
||||
} elseif ($see <= 0 && $appid > 0) {
|
||||
$fen_order = $fen_order->where('F.appid', $appid);
|
||||
}
|
||||
$fen_order = $fen_order->order('id desc')->limit($bnums, $ENUMS);
|
||||
}
|
||||
$res = $fen_order->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>
|
||||
<?php echo !empty($rows['user']) ? $rows['user'] : (!empty($rows['email']) ? $rows['email'] : $rows['phone']); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $rows['fname']; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $rows['mark']; ?>
|
||||
</td>
|
||||
<td>
|
||||
<center><span class="badge badge-info-lighten">
|
||||
<?php if ($rows['fen_num'] > 0) {
|
||||
echo '+' . $rows['fen_num'];
|
||||
} else {
|
||||
echo $rows['fen_num'];
|
||||
} ?>
|
||||
</span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><?php if ($rows['vip_num'] <= 0) : ?><span class="badge badge-warning-lighten">消耗积分<?php else : ?><span class="badge badge-danger-lighten">兑换会员<?php endif; ?></span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><span class="badge badge-primary">
|
||||
<i class="mdi mdi-cube-outline"></i>
|
||||
<?php echo $rows['appname']; ?>
|
||||
</span></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 -->
|
||||
|
||||
<script>
|
||||
function get_screen(appid, see) {
|
||||
var url = '';
|
||||
if (appid > 0) {
|
||||
url = '&app=' + appid;
|
||||
}
|
||||
if (see > 0) {
|
||||
if (url == '') {
|
||||
url = '&see=' + see;
|
||||
} else {
|
||||
url = url + '&see=' + see;
|
||||
}
|
||||
}
|
||||
location.href = './?fen_order' + url;
|
||||
}
|
||||
|
||||
|
||||
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=fen_o_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>
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/*
|
||||
Name:商品API
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
Author QQ:51154393
|
||||
Author Url:www.eruyi.cn
|
||||
*/
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
if ($act == 'add') {
|
||||
$name = isset($_POST['name']) ? purge($_POST['name']) : '';
|
||||
$type = isset($_POST['type']) ? purge($_POST['type']) : 'vip';
|
||||
$amount = isset($_POST['amount']) ? intval($_POST['amount']) : 0;
|
||||
$money = isset($_POST['money']) ? purge($_POST['money']) : '1.00';
|
||||
$jie = isset($_POST['jie']) ? purge($_POST['jie']) : '';
|
||||
$appid = isset($_POST['appid']) ? intval($_POST['appid']) : 0;
|
||||
if ($name == '') json(201, '请设置商品名称');
|
||||
if ($amount <= 0) json(201, '请设置购买数量');
|
||||
if ($appid == 0) json(201, '绑定应用为空');
|
||||
$app_res = Db::table('app')->where('id', $appid)->find();
|
||||
if (!$app_res) json(201, '应用不存在');
|
||||
$goods_res = Db::table('goods')->where(['appid' => $appid, 'name' => $name])->find();
|
||||
if ($goods_res) json(201, '商品已存在');
|
||||
$add_res = Db::table('goods')->add(['name' => $name, 'type' => $type, 'amount' => $amount, 'money' => $money, 'jie' => $jie, 'appid' => $appid]);
|
||||
//die($res);
|
||||
if ($add_res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'goods_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' => 'goods_add', 'status' => 201, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
json(201, '添加失败');
|
||||
}
|
||||
}
|
||||
if ($act == 'edit') {
|
||||
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
|
||||
$update['name'] = isset($_POST['name']) ? purge($_POST['name']) : '';
|
||||
$update['type'] = isset($_POST['type']) ? purge($_POST['type']) : 'vip';
|
||||
$update['amount'] = isset($_POST['amount']) ? intval($_POST['amount']) : 0;
|
||||
$update['money'] = isset($_POST['money']) ? purge($_POST['money']) : '1.00';
|
||||
$update['jie'] = isset($_POST['jie']) ? purge($_POST['jie']) : '';
|
||||
$update['appid'] = isset($_POST['appid']) ? intval($_POST['appid']) : 0;
|
||||
$update['state'] = isset($_POST['state']) ? purge($_POST['state']) : 'y';
|
||||
if ($update['name'] == '') json(201, '请设置商品名称');
|
||||
if ($update['amount'] <= 0) json(201, '请设置购买数量');
|
||||
if ($update['appid'] == 0) json(201, '绑定应用为空');
|
||||
$app_res = Db::table('app')->where('id', $update['appid'])->find();
|
||||
if (!$app_res) json(201, '应用不存在');
|
||||
$goods_res = Db::table('goods')->where(['appid' => $update['appid'], 'name' => $update['name']])->find();
|
||||
if ($goods_res) {
|
||||
if ($goods_res['id'] != $id) json(201, '商品已存在');
|
||||
}
|
||||
$res = Db::table('goods')->where('id', $id)->update($update);
|
||||
//die($res);
|
||||
if ($res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'goods_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' => 'goods_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('goods')->where('id', 'in', '(' . $ids . ')')->del(); //false
|
||||
//die($res);
|
||||
if ($res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'goods_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' => 'goods_del', 'status' => 201, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
json(201, '删除失败');
|
||||
}
|
||||
} else {
|
||||
json(201, '没有需要删除的数据');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
Name:商品订单API
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
Author QQ:51154393
|
||||
Author Url:www.eruyi.cn
|
||||
*/
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
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('goods_order')->where('id', 'in', '(' . $ids . ')')->del(); //false
|
||||
//die($res);
|
||||
if ($res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'goods_o_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' => 'goods_o_del', 'status' => 201, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
json(201, '删除失败');
|
||||
}
|
||||
} else {
|
||||
json(201, '没有需要删除的数据');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/*
|
||||
* File:后台目录菜单配置文件
|
||||
* Author:易如意
|
||||
* QQ:51154393
|
||||
* Url:www.eruyi.cn
|
||||
*/
|
||||
|
||||
return [
|
||||
'id'=>'goods',
|
||||
'name' => '商品',
|
||||
'icons'=>'mdi mdi-cart',
|
||||
'sort' => 5,//排序
|
||||
];
|
||||
@@ -0,0 +1,366 @@
|
||||
<?php
|
||||
/*
|
||||
Sort:1
|
||||
Hidden:false
|
||||
Name:商品管理
|
||||
Url:goods_adm
|
||||
Right:goods
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
Author QQ:51154393
|
||||
Author Url:www.eruyi.cn
|
||||
*/
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
$nums = Db::table('goods')->count(); //获取商品总数
|
||||
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
|
||||
$url = "./?goods_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-cart-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"> </label>
|
||||
</div>
|
||||
</th>
|
||||
<th style="width: 20px;">
|
||||
<center><span class="badge badge-light-lighten">ID</span></center>
|
||||
</th>
|
||||
<th><span class="badge badge-light-lighten">商品名称</span></th>
|
||||
<th style="width: 150px;">
|
||||
<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: 150px;">
|
||||
<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: 150px;">
|
||||
<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: 75px;">
|
||||
<center><span class="badge badge-light-lighten">管理</span></center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$goods = Db::table('goods', 'as G')->field('G.*,A.name as appname,IFNULL(D.ds,0) as dnum,IFNULL(C.sc,0) as cnum')->JOIN('app', 'as A', 'G.appid=A.id')->JOIN("(SELECT gid,COUNT(*) AS sc FROM {$DP}goods_order where `state` = 2 GROUP BY gid) AS C", 'G.id=C.gid')->JOIN("(SELECT gid,COUNT(*) AS ds FROM {$DP}goods_order GROUP BY gid) AS D", 'G.id=D.gid');
|
||||
if ($so) {
|
||||
$goods = $goods->where('G.name', 'like', "%{$so}%")->whereOr('G.jie', 'like', "%{$so}%")->whereOr('A.name', 'like', "%{$so}%")->order('id desc');
|
||||
} else {
|
||||
$goods = $goods->order('id desc')->limit($bnums, $ENUMS);
|
||||
}
|
||||
$res = $goods->select();
|
||||
// die(print_r($res));
|
||||
foreach ($res as $k => $v) {
|
||||
$rows = $res[$k];
|
||||
if (empty($rows['appname'])) continue;
|
||||
?>
|
||||
<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>
|
||||
<?php echo $rows['name']; ?>
|
||||
</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-info-lighten">
|
||||
<i class="mdi mdi-cash-usd"></i>
|
||||
<?php echo $rows['money']; ?>
|
||||
</span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><?php if ($rows['type'] == 'fen') : ?><span class="badge badge-warning-lighten">积分<?php else : ?><span class="badge badge-danger-lighten">会员<?php endif; ?></span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><span class="badge badge-secondary-lighten">
|
||||
<i class="mdi mdi-cart-outline"></i>
|
||||
<?php echo $rows['dnum']; ?>
|
||||
</span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><span class="badge badge-secondary-lighten">
|
||||
<i class="mdi mdi-cart"></i>
|
||||
<?php echo $rows['cnum']; ?>
|
||||
</span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><?php if ($rows['state'] == 'n') : ?><span class="badge badge-danger">停售<?php else : ?><span class="badge badge-success">正常<?php endif; ?></span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><a href="./?goods_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="add" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<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_name" name="add_name" placeholder="应用名称" required>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label>商品类型</label>
|
||||
<select class="form-control" name="add_type" id="add_type" onchange="type_change()">
|
||||
<option value="vip">会员</option>
|
||||
<option value="fen">积分</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-8">
|
||||
<label id="type_a">会员天数</label>
|
||||
<div class="input-group">
|
||||
<input type="number" id="add_amount" name="add_amount" class="form-control" placeholder="0" value="">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="type_b">天</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>商品金额</label>
|
||||
<div class="input-group">
|
||||
<input type="number" id="add_money" name="add_money" class="form-control" placeholder="1.00" value="">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">元</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>商品介绍</label>
|
||||
<textarea id="add_jie" name="add_jie" class="form-control" maxlength="70" rows="4" placeholder="给商品做个介绍或者备注,可空"></textarea>
|
||||
</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>
|
||||
$('#add_submit').click(function() {
|
||||
let t = window.jQuery;
|
||||
var add_name = $("input[name='add_name']").val();
|
||||
var add_type = $("select[name='add_type']").val();
|
||||
var add_amount = $("input[name='add_amount']").val();
|
||||
var add_money = $("input[name='add_money']").val();
|
||||
var add_jie = $("textarea[name='add_jie']").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=goods_add", //请求的文件名
|
||||
data: {
|
||||
name: add_name,
|
||||
type: add_type,
|
||||
amount: add_amount,
|
||||
money: add_money,
|
||||
jie: add_jie,
|
||||
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 type_change() {
|
||||
if ($('#add_type').val() == 'vip') {
|
||||
document.getElementById('type_a').innerHTML = "会员天数";
|
||||
document.getElementById('type_b').innerHTML = "天";
|
||||
} else {
|
||||
document.getElementById('type_a').innerHTML = "积分数量";
|
||||
document.getElementById('type_b').innerHTML = "积分";
|
||||
}
|
||||
}
|
||||
|
||||
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=goods_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>
|
||||
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
/*
|
||||
Sort:1
|
||||
Hidden:true
|
||||
Name:商品编辑
|
||||
Url:goods_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('goods')->where(['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="goods_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 -->
|
||||
|
||||
<!-- Form row -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form action="" method="post" id="addimg" name="addimg">
|
||||
<div class="eruyi-checkbox">
|
||||
<input type="checkbox" id="state" <?php if ($res['state'] == 'y') : ?>checked<?php endif; ?> data-switch="success" onchange="state_v(this.checked)" />
|
||||
<label for="state" data-on-label="正常" data-off-label="停售"></label>
|
||||
<label class="eruyi-label">商品状态</label>
|
||||
</div>
|
||||
|
||||
<div class="view" name="state_y" id="state_y" <?php if ($res['state'] == 'y') : ?> style="display: block" <?php endif; ?>>
|
||||
<p class="text-muted">
|
||||
正常状态情况下,可以被 <code>商品列表接口</code> 正常输出
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="view" name="state_n" id="state_n" <?php if ($res['state'] == 'n') : ?> style="display: block" <?php endif; ?>>
|
||||
<p class="text-muted">
|
||||
停售状态情况下,<code>商品列表接口</code> 不在输出此商品
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="f_user" class="col-form-label">商品名称 *</label>
|
||||
<input type="text" class="form-control" id="name" name="name" placeholder="商品名称" value="<?php echo $res['name']; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-2">
|
||||
<label class="col-form-label">商品类型</label>
|
||||
<select class="form-control" name="type" id="type" onchange="type_change()">
|
||||
<option value="vip" <?php if ($res['type'] == 'vip') echo 'selected = "selected"'; ?>>会员</option>
|
||||
<option value="fen" <?php if ($res['type'] == 'fen') echo 'selected = "selected"'; ?>>积分</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-10">
|
||||
<label class="col-form-label" id="amount_name"> <?php if ($res['type'] == 'vip') : ?>会员天数 *<?php else : ?>积分数 *<?php endif; ?></label>
|
||||
<div class="input-group">
|
||||
<input type="number" id="amount" name="amount" class="form-control" placeholder="<?php echo $res['amount']; ?>" value="<?php echo $res['amount']; ?>" required>
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="amount_a"><?php if ($res['type'] == 'vip') : ?>天<?php else : ?>积分<?php endif; ?></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="f_psw" class="col-form-label">商品金额 *</label>
|
||||
<input type="number" class="form-control" id="money" name="money" placeholder="商品金额" value="<?php echo $res['money']; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="f_psw" class="col-form-label">商品介绍</label>
|
||||
<textarea id="jie" name="jie" class="form-control" maxlength="70" rows="4" placeholder="给商品做个介绍或者备注,可空"><?php echo $res['jie']; ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="f_vip" class="col-form-label">绑定应用 *</label>
|
||||
<select class="form-control" name="appid" id="appid">
|
||||
<?php
|
||||
$app_res = Db::table('app')->order('id desc')->select();
|
||||
foreach ($app_res as $k => $v) {
|
||||
$rows = $app_res[$k];
|
||||
?>
|
||||
<option value="<?php echo $rows['id']; ?>" <?php if ($res['appid'] == $rows['id']) echo 'selected = "selected"'; ?>><?php echo $rows['name']; ?></option>
|
||||
<?php } ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</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><!-- end row -->
|
||||
|
||||
<script>
|
||||
$("#goods_adm").addClass("active");
|
||||
$('#submit').click(function() {
|
||||
let t = window.jQuery;
|
||||
var ok = document.getElementById("ok").checked;
|
||||
var state = document.getElementById("state").checked;
|
||||
if (state) {
|
||||
state = 'y';
|
||||
} else {
|
||||
state = 'n';
|
||||
}
|
||||
var name = $("input[name='name']").val();
|
||||
var type = $("select[name='type']").val();
|
||||
var amount = $("input[name='amount']").val();
|
||||
var money = $("input[name='money']").val();
|
||||
var jie = $("textarea[name='jie']").val();
|
||||
var appid = $("select[name='appid']").val();
|
||||
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=goods_edit", //请求的文件名
|
||||
data: {
|
||||
id: <?php echo $id; ?>,
|
||||
name: name,
|
||||
type: type,
|
||||
amount: amount,
|
||||
money: money,
|
||||
jie: jie,
|
||||
state: state,
|
||||
appid: appid
|
||||
},
|
||||
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 type_change() {
|
||||
if ($('#type').val() == 'vip') {
|
||||
document.getElementById('amount_name').innerHTML = " 会员天数 *";
|
||||
document.getElementById('amount_a').innerHTML = "天";
|
||||
} else {
|
||||
document.getElementById('amount_name').innerHTML = " 积分数 *";
|
||||
document.getElementById('amount_a').innerHTML = "积分";
|
||||
}
|
||||
}
|
||||
|
||||
function state_v(i) {
|
||||
if (i == true) {
|
||||
$("#state_y").css("display", "block");
|
||||
$("#state_n").css("display", "none");
|
||||
} else {
|
||||
$("#state_y").css("display", "none");
|
||||
$("#state_n").css("display", "block");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,306 @@
|
||||
<?php
|
||||
/*
|
||||
Sort:2
|
||||
Hidden:false
|
||||
Name:商品订单
|
||||
Url:goods_order
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
Author QQ:51154393
|
||||
Author Url:www.eruyi.cn
|
||||
*/
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
|
||||
$see = isset($_GET['see']) ? intval($_GET['see']) : -1;
|
||||
$appid = isset($_GET['app']) ? intval($_GET['app']) : 0;
|
||||
$goods = Db::table('goods_order', 'as O')->field('O.*,G.appid,G.type,A.name as appname')->JOIN("goods", "as G", 'O.gid=G.id')->JOIN('app', 'as A', 'G.appid=A.id');
|
||||
if ($see >= 0 && $appid > 0) {
|
||||
$nums = $goods->where('O.state', $see)->where('G.appid', $appid)->count();
|
||||
$url = "./?goods_order&see={$see}&app={$appid}&page=";
|
||||
} elseif ($see >= 0 && $appid <= 0) {
|
||||
$nums = $goods->where('O.state', $see)->count();
|
||||
$url = "./?goods_order&see={$see}&page=";
|
||||
} elseif ($see < 0 && $appid > 0) {
|
||||
$nums = $goods->where('G.appid', $appid)->count();
|
||||
$url = "./?goods_order&app={$appid}&page=";
|
||||
} else {
|
||||
$nums = $goods->count();
|
||||
$url = "./?goods_order&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 row-->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row mb-2">
|
||||
<div class="col-lg-8">
|
||||
<form class="form-inline">
|
||||
<select class="form-control" name="appid" id="appid" onchange="get_screen(this.value,<?php echo $see; ?>)">
|
||||
<option value="0">全部</option>
|
||||
<?php
|
||||
$res = Db::table('app')->order('id desc')->select();
|
||||
foreach ($res as $k => $v) {
|
||||
$rows = $res[$k];
|
||||
?>
|
||||
<option value="<?php echo $rows['id']; ?>" <?php if ($appid == $rows['id']) echo 'selected = "selected"'; ?>><?php echo $rows['name']; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<label for="status-select" class="mr-2"></label>
|
||||
<select class="form-control" name="see" id="see" onchange="get_screen(<?php echo $appid; ?>,this.value)">
|
||||
<option value="-1" <?php if ($see == -1) echo 'selected = "selected"'; ?>>全部</option>
|
||||
<option value="2" <?php if ($see == 2) echo 'selected = "selected"'; ?>>已支付</option>
|
||||
<option value="0" <?php if ($see == 0) echo 'selected = "selected"'; ?>>未支付</option>
|
||||
<option value="1" <?php if ($see == 1) echo 'selected = "selected"'; ?>>充值失败</option>
|
||||
</select>
|
||||
</form>
|
||||
</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"> </label>
|
||||
</div>
|
||||
</th>
|
||||
<th style="width: 20px;">
|
||||
<center><span class="badge badge-light-lighten">ID</span></center>
|
||||
</th>
|
||||
<th><span class="badge badge-light-lighten">订单号</span></th>
|
||||
<th style="width: 150px;">
|
||||
<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: 150px;">
|
||||
<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: 150px;">
|
||||
<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: 150px;">
|
||||
<center><span class="badge badge-light-lighten">订单状态</span></center>
|
||||
</th>
|
||||
<th style="width: 150px;">
|
||||
<center><span class="badge badge-light-lighten">支付类型</span></center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$goods = Db::table('goods_order', 'as O')->field('O.*,U.user,U.email,U.phone,G.appid,G.type,A.name as appname')->JOIN("goods", "as G", 'O.gid=G.id')->JOIN('app', 'as A', 'G.appid=A.id')->JOIN("user", 'as U', 'O.Uid=U.id');
|
||||
if ($so) {
|
||||
$goods = $goods->where('A.name', 'like', "%{$so}%")->whereOr('O.order', 'like', "%{$so}%")->whereOr('U.user', 'like', "%{$so}%")->whereOr('U.email', 'like', "%{$so}%")->whereOr('U.phone', 'like', "%{$so}%")->whereOr('O.name', 'like', "%{$so}%")->order('id desc');
|
||||
} else {
|
||||
if ($see >= 0 && $appid > 0) {
|
||||
$goods = $goods->where('O.state', $see)->where('G.appid', $appid);
|
||||
} elseif ($see >= 0 && $appid <= 0) {
|
||||
$goods = $goods->where('O.state', $see);
|
||||
} elseif ($see < 0 && $appid > 0) {
|
||||
$goods = $goods->where('G.appid', $appid);
|
||||
}
|
||||
$goods = $goods->order('id desc')->limit($bnums, $ENUMS);
|
||||
}
|
||||
$res = $goods->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>
|
||||
<?php echo $rows['order']; ?>
|
||||
</td>
|
||||
<td>
|
||||
<center><span class="badge badge-primary">
|
||||
<i class="mdi mdi-cube-outline"></i>
|
||||
<?php echo $rows['appname']; ?>
|
||||
</span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><?php echo $rows['name']; ?></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><?php if ($rows['type'] == 'fen') : ?><span class="badge badge-primary">积分<?php else : ?><span class="badge badge-danger">会员<?php endif; ?></span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><span class="badge badge-info-lighten">
|
||||
<i class="mdi mdi-cash-usd"></i>
|
||||
<?php echo $rows['money']; ?>
|
||||
</span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><?php echo !empty($rows['user']) ? $rows['user'] : (!empty($rows['email']) ? $rows['email'] : $rows['phone']); ?></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><?php echo date("Y-m-d H:i", $rows['o_time']); ?></center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<center>
|
||||
<?php if ($rows['state'] == 0) : ?><span class="badge badge-warning-lighten">等待支付
|
||||
<?php elseif ($rows['state'] == 1) : ?><span class="badge badge-danger-lighten">充值失败
|
||||
<?php elseif ($rows['state'] == 2) : ?><span class="badge badge-success-lighten">支付成功
|
||||
<?php elseif ($rows['state'] == 3) : ?><span class="badge badge-danger-lighten">未找到用户
|
||||
<?php elseif ($rows['state'] == 4) : ?><span class="badge badge-danger-lighten">未知商品类型
|
||||
<?php elseif ($rows['state'] == 9) : ?><span class="badge badge-danger-lighten">永久会员
|
||||
<?php endif; ?></span>
|
||||
</center>
|
||||
</td>
|
||||
<td>
|
||||
<center>
|
||||
<?php if ($rows['p_type'] == 'ali') : ?><span class="badge badge-info">支付宝
|
||||
<?php elseif ($rows['p_type'] == 'wx') : ?><span class="badge badge-success">微信
|
||||
<?php elseif ($rows['p_type'] == 'qq') : ?><span class="badge badge-dark">QQ钱包<?php endif; ?></span>
|
||||
</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 -->
|
||||
|
||||
<script>
|
||||
function get_screen(appid, see) {
|
||||
var url = '';
|
||||
if (appid > 0) {
|
||||
url = '&app=' + appid;
|
||||
}
|
||||
if (see >= 0) {
|
||||
if (url == '') {
|
||||
url = '&see=' + see;
|
||||
} else {
|
||||
url = url + '&see=' + see;
|
||||
}
|
||||
}
|
||||
location.href = './?goods_order' + url;
|
||||
}
|
||||
|
||||
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=goods_o_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>
|
||||
@@ -0,0 +1,313 @@
|
||||
<?php
|
||||
/*
|
||||
* File:后台首页
|
||||
* Author:易如意
|
||||
* QQ:51154393
|
||||
* Url:www.eruyi.cn
|
||||
*/
|
||||
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问拦截
|
||||
$domain = $_SERVER['SERVER_NAME'];
|
||||
$serverapp = $_SERVER['SERVER_SOFTWARE'];
|
||||
$mysql_ver = DB::getInstance()->getMysqlVersion();
|
||||
$php_ver = PHP_VERSION;
|
||||
$uploadfile_maxsize = ini_get('upload_max_filesize');
|
||||
if (function_exists("imagecreate")) {
|
||||
if (function_exists('gd_info')) {
|
||||
$ver_info = gd_info();
|
||||
$gd_ver = $ver_info['GD Version'];
|
||||
} else {
|
||||
$gd_ver = '支持';
|
||||
}
|
||||
} else {
|
||||
$gd_ver = '不支持';
|
||||
}
|
||||
|
||||
$u_num = Db::table('user')->count();
|
||||
$jt_us = Db::table('user')->where('reg_time', 'between', [timeRange('t_a'), timeRange('t_b')])->count(); //今日新用户
|
||||
$zt_us = Db::table('user')->where('reg_time', 'between', [timeRange('zt_a'), timeRange('zt_b')])->count(); //昨天新用户
|
||||
if ($zt_us > 0) {
|
||||
$user_scale = $jt_us - $zt_us;
|
||||
} else {
|
||||
$user_scale = $jt_us;
|
||||
}
|
||||
|
||||
$jt_qs = Db::table('log')->where('type', 'clock')->where('time', 'between', [timeRange('t_a'), timeRange('t_b')])->count(); //今日签到
|
||||
$zt_qs = Db::table('log')->where('type', 'clock')->where('time', 'between', [timeRange('zt_a'), timeRange('zt_b')])->count(); //昨天签到
|
||||
|
||||
if ($zt_qs > 0) {
|
||||
$diary_scale = $jt_qs - $zt_qs; //
|
||||
} else {
|
||||
$diary_scale = $jt_qs;
|
||||
}
|
||||
|
||||
$order_num = Db::table('goods_order')->count(); //获取订单总数
|
||||
|
||||
$jt_os = Db::table('goods_order')->where('o_time', 'between', [timeRange('t_a'), timeRange('t_b')])->count(); //今日订单数
|
||||
$zt_os = Db::table('goods_order')->where('o_time', 'between', [timeRange('zt_a'), timeRange('zt_b')])->count(); //昨天订单数
|
||||
|
||||
if ($zt_os > 0) {
|
||||
$order_scale = $jt_os - $zt_os; //
|
||||
} else {
|
||||
$order_scale = $jt_os;
|
||||
}
|
||||
|
||||
$jt_ms = Db::table('goods_order')->where('p_time', 'between', [timeRange('t_a'), timeRange('t_b')])->sum('money'); //今日收益
|
||||
if ($jt_ms == null) {
|
||||
$jt_ms = 0;
|
||||
}
|
||||
|
||||
$zt_ms = Db::table('goods_order')->where('p_time', 'between', [timeRange('zt_a'), timeRange('zt_b')])->sum('money'); //昨天收益
|
||||
if ($zt_ms == null) {
|
||||
$zt_ms = 0;
|
||||
}
|
||||
|
||||
if ($zt_ms > 0) {
|
||||
$money_scale = $jt_ms - $zt_ms; //
|
||||
} else {
|
||||
$money_scale = $jt_ms;
|
||||
}
|
||||
?>
|
||||
<!-- 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">统计</h4>
|
||||
</div> <!-- end page-title-box -->
|
||||
</div> <!-- end col-->
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<!-- end row -->
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div class="row">
|
||||
<div class="col-lg-3">
|
||||
<div class="card widget-flat">
|
||||
<div class="card-body">
|
||||
<div class="float-right">
|
||||
<i class="mdi mdi-account-multiple widget-icon"></i>
|
||||
</div>
|
||||
<h5 class="text-muted font-weight-normal mt-0" title="Number of Customers">用户总数</h5>
|
||||
<h3 class="mt-3 mb-3"><?php echo $u_num; ?></h3>
|
||||
<p class="mb-0 text-muted">
|
||||
<?php if ($user_scale >= 0) : ?>
|
||||
<span class="text-success mr-2"><i class="mdi mdi-arrow-up-bold"></i> <?php echo $user_scale; ?></span>
|
||||
<?php else : ?>
|
||||
<span class="text-danger mr-2"><i class="mdi mdi-arrow-down-bold"></i> <?php echo $user_scale; ?></span>
|
||||
<?php endif; ?>
|
||||
<span class="text-nowrap">对比昨天</span>
|
||||
</p>
|
||||
</div> <!-- end card-body-->
|
||||
</div> <!-- end card-->
|
||||
</div> <!-- end col-->
|
||||
|
||||
<div class="col-lg-3">
|
||||
<div class="card widget-flat">
|
||||
<div class="card-body">
|
||||
<div class="float-right">
|
||||
<i class="mdi mdi-account-check widget-icon"></i>
|
||||
</div>
|
||||
<h5 class="text-muted font-weight-normal mt-0" title="Number of Orders">今天签到</h5>
|
||||
<h3 class="mt-3 mb-3"><?php echo $jt_qs ?></h3>
|
||||
<p class="mb-0 text-muted">
|
||||
<?php if ($diary_scale >= 0) : ?>
|
||||
<span class="text-success mr-2"><i class="mdi mdi-arrow-up-bold"></i> <?php echo $diary_scale; ?></span>
|
||||
<?php else : ?>
|
||||
<span class="text-danger mr-2"><i class="mdi mdi-arrow-down-bold"></i> <?php echo $diary_scale; ?></span>
|
||||
<?php endif; ?>
|
||||
<span class="text-nowrap">对比昨天</span>
|
||||
</p>
|
||||
</div> <!-- end card-body-->
|
||||
</div> <!-- end card-->
|
||||
</div> <!-- end col-->
|
||||
|
||||
<div class="col-lg-3">
|
||||
<div class="card widget-flat">
|
||||
<div class="card-body">
|
||||
<div class="float-right">
|
||||
<i class="mdi mdi-calendar-text widget-icon"></i>
|
||||
</div>
|
||||
<h5 class="text-muted font-weight-normal mt-0" title="Number of Orders">订单总数</h5>
|
||||
<h3 class="mt-3 mb-3"><?php echo $order_num; ?></h3>
|
||||
<p class="mb-0 text-muted">
|
||||
<?php if ($order_scale >= 0) : ?>
|
||||
<span class="text-success mr-2"><i class="mdi mdi-arrow-up-bold"></i> <?php echo $order_scale; ?></span>
|
||||
<?php else : ?>
|
||||
<span class="text-danger mr-2"><i class="mdi mdi-arrow-down-bold"></i> <?php echo $order_scale; ?></span>
|
||||
<?php endif; ?>
|
||||
<span class="text-nowrap">对比昨天</span>
|
||||
</p>
|
||||
</div> <!-- end card-body-->
|
||||
</div> <!-- end card-->
|
||||
</div> <!-- end col-->
|
||||
|
||||
<div class="col-lg-3">
|
||||
<div class="card widget-flat">
|
||||
<div class="card-body">
|
||||
<div class="float-right">
|
||||
<i class="mdi mdi-cash-multiple widget-icon"></i>
|
||||
</div>
|
||||
<h5 class="text-muted font-weight-normal mt-0" title="Growth">今日收益</h5>
|
||||
<h3 class="mt-3 mb-3"><?php echo $jt_ms; ?></h3>
|
||||
<p class="mb-0 text-muted">
|
||||
<?php if ($money_scale >= 0) : ?>
|
||||
<span class="text-success mr-2"><i class="mdi mdi-arrow-up-bold"></i> <?php echo $money_scale; ?></span>
|
||||
<?php else : ?>
|
||||
<span class="text-danger mr-2"><i class="mdi mdi-arrow-down-bold"></i> <?php echo $money_scale; ?></span>
|
||||
<?php endif; ?>
|
||||
<span class="text-nowrap">对比昨天</span>
|
||||
</p>
|
||||
</div> <!-- end card-body-->
|
||||
</div> <!-- end card-->
|
||||
</div> <!-- end col-->
|
||||
</div> <!-- end row -->
|
||||
|
||||
</div> <!-- end col -->
|
||||
</div> <!-- end row -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xl-8">
|
||||
<div class="card">
|
||||
<div class="card-body" style="height: 507px;">
|
||||
<a href="./?log" class="btn btn-sm btn-link float-right mb-3">更多
|
||||
<i class="mdi mdi-chevron-double-right ml-1"></i>
|
||||
</a>
|
||||
<h4 class="header-title mt-2">用户日志</h4>
|
||||
<?php
|
||||
$res_log = Db::table('log', 'as LOG')->field('LOG.*,U.pic,U.user,U.email,U.phone,U.name')->JOIN("user", 'as U', 'LOG.uid=U.id')->order('id desc')->limit(0, 5)->select();
|
||||
//$res_log = Db::table('user_log')->order('id desc')->limit(0,5)->select();
|
||||
if (count($res_log) <= 0) :
|
||||
?>
|
||||
<div class="text-center" style="margin-top:6.5rem!important">
|
||||
<img src="../assets/images/startman.svg" height="120" alt="File not found Image">
|
||||
<h4 class="text-uppercase mt-3">暂无用户日志</h4>
|
||||
</div>
|
||||
<?php else : foreach ($res_log as $k => $v) {
|
||||
$rows = $res_log[$k]; ?>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-centered table-hover mb-0" id="user_log">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="media">
|
||||
<img class="mr-3 rounded-circle" src="<?php echo ($rows['group'] == 'adm') ? '../assets/images/users/avatar-1.jpg' : get_pic($rows['pic'], true); ?>" width="40" alt="Generic placeholder image">
|
||||
<div class="media-body">
|
||||
<a href="<?php echo ($rows['group'] == 'adm') ? 'javascript:void(0);' : './?user_edit&id=' . $rows['uid']; ?>" class="text-title">
|
||||
<h5 class="mt-0 mb-1 line-limit-length" style="width:150px!important"><?php echo ($rows['group'] == 'adm') ? $user : (!empty($rows['user']) ? $rows['user'] : (!empty($rows['email']) ? $rows['email'] : $rows['phone'])); ?></h5>
|
||||
</a>
|
||||
<span class="font-13"><?php echo ($rows['group'] == 'adm') ? '管理员' : $rows['name']; ?></span>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<h5 class="font-14 mb-1 font-weight-normal line-limit-length" style="width:80px!important"><?php echo ($rows['group'] == 'adm') ? $lang_adm[$rows['type']] : $lang_user[$rows['type']]; ?></h5>
|
||||
<span class="text-muted font-13">类型</span>
|
||||
</td>
|
||||
<td>
|
||||
<h5 class="font-14 mb-1 font-weight-normal line-limit-length" style="width:120px!important"><?php echo date("Y-m-d H:i", $rows['time']); ?></h5>
|
||||
<span class="text-muted font-13">时间</span>
|
||||
</td>
|
||||
<td>
|
||||
<h5 class="font-14 mb-1 font-weight-normal line-limit-length" style="width:100px!important"><?php echo $rows['ip']; ?></h5>
|
||||
<span class="text-muted font-13">IP</span>
|
||||
</td>
|
||||
<td>
|
||||
<h5 class="font-14 mb-1 font-weight-normal line-limit-length" style="width:80px!important"><?php echo ($rows['fen'] > 0) ? '+' . $rows['fen'] : $rows['fen']; ?></h5>
|
||||
<span class="text-muted font-13">积分变化</span>
|
||||
</td>
|
||||
<td>
|
||||
<h5 class="font-14 mb-1 font-weight-normal line-limit-length" style="width:80px!important"><?php echo ($rows['vip'] > 0) ? '+' . $rows['vip'] . (isset($time_type[$rows['type']]) ? $time_type[$rows['type']] : "") : $rows['vip'] . (isset($time_type[$rows['type']]) ? $time_type[$rows['type']] : ""); ?></h5>
|
||||
<span class="text-muted font-13">会员变化</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div> <!-- end table-responsive-->
|
||||
<?php }
|
||||
endif; ?>
|
||||
</div> <!-- end card-body-->
|
||||
</div> <!-- end card-->
|
||||
</div> <!-- end col-->
|
||||
<div class="col-xl-4">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title mb-3">服务器信息</h4>
|
||||
<div class="chart inline-legend grid">
|
||||
<p>当前版本:<?php echo EDITION; ?>
|
||||
<span id="edition_data">
|
||||
<a id="edition_url" href="javascript:void(0);" target="_blank"><span class="badge badge-success-lighten" id="edition">最新</span></a>
|
||||
</span>
|
||||
</p>
|
||||
<p>当前域名:<?php echo $domain; ?></p>
|
||||
<p>PHP版本:<?php echo $php_ver; ?></p>
|
||||
<p>MySQL版本:<?php echo $mysql_ver; ?></p>
|
||||
<p>服务器环境:<?php echo $serverapp; ?></p>
|
||||
<p>GD图形处理库:<?php echo $gd_ver; ?></p>
|
||||
<p>服务器空间允许上传最大文件:<?php echo $uploadfile_maxsize; ?></p>
|
||||
</div>
|
||||
</div> <!-- end card-body-->
|
||||
<!-- <div class="card-body" id="news"></div> -->
|
||||
</div>
|
||||
<!-- end card-->
|
||||
</div>
|
||||
</div>
|
||||
<!-- end row-->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
|
||||
</div> <!-- end card-->
|
||||
</div> <!-- end col-->
|
||||
</div>
|
||||
<!-- end row -->
|
||||
|
||||
<script>
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "GET", //请求的方式
|
||||
url: "edition.php", //请求的文件名
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
if (data.code == 200) {
|
||||
var msg;
|
||||
var HTML;
|
||||
if (data.msg.file_new.length > 0) {
|
||||
msg = "您有 " + data.msg.file_new.length + " 文件需要更新";
|
||||
HTML = '<a href="./?web_file"><span class="badge badge-danger-lighten mr-1" id="edition">' + msg + '</span></a>'
|
||||
}
|
||||
if (data.msg.file_md5.length > 0) {
|
||||
msg = " 被修改文件: " + data.msg.file_md5.length;
|
||||
if (HTML == null) {
|
||||
HTML = '<a href="./?web_file"><span class="badge badge-danger-lighten mr-1" id="edition">' + msg + '</span></a>'
|
||||
} else {
|
||||
HTML = HTML + '<a href="./?web_file"><span class="badge badge-danger-lighten mr-1" id="edition">' + msg + '</span></a>'
|
||||
}
|
||||
}
|
||||
if (data.msg.file_lose.length > 0) {
|
||||
msg = " 丢失文件: " + data.msg.file_lose.length;
|
||||
if (HTML == null) {
|
||||
HTML = '<a href="./?web_file"><span class="badge badge-danger-lighten mr-1" id="edition">' + msg + '</span></a>'
|
||||
} else {
|
||||
HTML = HTML + '<a href="./?web_file"><span class="badge badge-danger-lighten mr-1" id="edition">' + msg + '</span></a>'
|
||||
}
|
||||
}
|
||||
if (msg == null) {
|
||||
document.getElementById("edition").className = "badge badge-success-lighten";
|
||||
document.getElementById("edition").innerHTML = "最新";
|
||||
} else {
|
||||
document.getElementById("edition_data").innerHTML = HTML;
|
||||
}
|
||||
} else {
|
||||
document.getElementById("edition").className = "badge badge-danger-lighten";
|
||||
document.getElementById("edition").innerHTML = '发现新版本';
|
||||
document.getElementById("edition_url").href = data.msg.new_url;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
/*
|
||||
Name:卡密API
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
Author QQ:51154393
|
||||
Author Url:www.eruyi.cn
|
||||
*/
|
||||
if (!isset($islogin)) header("Location: /");
|
||||
if ($act == 'add') {
|
||||
$appid = isset($_POST['appid']) ? intval($_POST['appid']) : 0;
|
||||
$note = isset($_POST['note']) ? purge($_POST['note']) : '';
|
||||
$type = isset($_POST['type']) ? purge($_POST['type']) : 'vip';
|
||||
$amount = isset($_POST['amount']) ? intval($_POST['amount']) : 1;
|
||||
$num = isset($_POST['num']) ? intval($_POST['num']) : 1;
|
||||
$out = isset($_POST['out']) ? intval($_POST['out']) : 0;
|
||||
$k_length = isset($_POST['k_length']) ? intval($_POST['k_length']) : 10;
|
||||
if ($amount <= 0) json(201, '请设置卡密获得数');
|
||||
if ($appid == 0) json(201, '绑定应用为空');
|
||||
$app_res = Db::table('app')->where('id', $appid)->find();
|
||||
if (!$app_res) json(201, '应用不存在');
|
||||
$str = '';
|
||||
for ($i = 1; $i <= $num; $i++) {
|
||||
$key = getcode($k_length);
|
||||
if ($out == 1) {
|
||||
$add_res = Db::table('kami')->add(['kami' => $key, 'type' => $type, 'amount' => $amount, 'note' => $note, 'appid' => $appid, 'new' => 'y']);
|
||||
} else {
|
||||
$add_res = Db::table('kami')->add(['kami' => $key, 'type' => $type, 'amount' => $amount, 'note' => $note, 'appid' => $appid]);
|
||||
}
|
||||
|
||||
if (!$add_res) {
|
||||
$key = getcode($k_length);
|
||||
$add_res = Db::table('kami')->add(['kami' => $key, 'type' => $type, 'amount' => $amount, 'note' => $note, 'appid' => $appid]);
|
||||
}
|
||||
$str .= $key . "\r\n";
|
||||
}
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'kami_add', 'status' => 200, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
if ($out == 1) {
|
||||
$str = "==============卡密开始================\r\n\r\n" . $str . "\r\n==============卡密结束================";
|
||||
json(202, $str);
|
||||
} else {
|
||||
json(200, '添加成功');
|
||||
}
|
||||
}
|
||||
if ($act == 'note') {
|
||||
$id = isset($_POST['kid']) ? intval($_POST['kid']) : 0;
|
||||
$note = isset($_POST['note']) ? purge($_POST['note']) : '';
|
||||
if ($id <= 0) json(201, '需要修改的卡密有误');
|
||||
$k_res = Db::table('kami')->where('id', $id)->find();
|
||||
if (!$k_res) json(201, '卡密不存在');
|
||||
|
||||
$res = Db::table('kami')->where('id', $id)->update(['note' => $note]);
|
||||
//die($res);
|
||||
if ($res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'kami_note', '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' => 'kami_note', 'status' => 201, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
json(201, '编辑失败');
|
||||
}
|
||||
}
|
||||
if ($act == 'state') {
|
||||
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
|
||||
$state = isset($_POST['state']) ? purge($_POST['state']) : 'y';
|
||||
if ($id <= 0) json(201, '需要修改的卡密有误');
|
||||
$k_res = Db::table('kami')->where('id', $id)->find();
|
||||
if (!$k_res) json(201, '卡密不存在');
|
||||
|
||||
$res = Db::table('kami')->where('id', $id)->update(['state' => $state]); //,false
|
||||
//die($res);
|
||||
if ($res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'kami_state', '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' => 'kami_state', '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('kami')->where('id', 'in', '(' . $ids . ')')->del(); //false
|
||||
//die($res);
|
||||
if ($res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'kami_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' => 'kami_del', 'status' => 201, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
json(201, '删除失败');
|
||||
}
|
||||
} else {
|
||||
json(201, '没有需要删除的数据');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/*
|
||||
* File:后台目录菜单配置文件
|
||||
* Author:易如意
|
||||
* QQ:51154393
|
||||
* Url:www.eruyi.cn
|
||||
*/
|
||||
|
||||
return [
|
||||
'id'=>'kami',
|
||||
'name' => '卡密',
|
||||
'icons'=>'mdi mdi-credit-card',
|
||||
'sort' => 4//排序
|
||||
];
|
||||
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
/*
|
||||
Sort:2
|
||||
Hidden:false
|
||||
Name:添加卡密
|
||||
Url:kami_add
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
Author QQ:51154393
|
||||
Author Url:www.eruyi.cn
|
||||
*/
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
|
||||
?>
|
||||
<!-- 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>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<?php if ($app_num > 0) : ?>
|
||||
<form class="needs-validation" novalidate action="" method="post">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-2">
|
||||
<label class="col-form-label">卡密类型</label>
|
||||
<select class="form-control" name="add_type" id="add_type" onchange="type_change(this.value)">
|
||||
<option value="vip" selected="selected">会员</option>
|
||||
<option value="fen">积分</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-10">
|
||||
<label class="col-form-label" id="amount_name"> 会员天数 *</label>
|
||||
<div class="input-group">
|
||||
<input type="number" id="add_amount" name="add_amount" class="form-control" placeholder="会员天数,永久卡9个9" value="" required>
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="amount_a">天</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label class="col-form-label">生成数量</label>
|
||||
<input type="number" class="form-control" id="add_num" name="add_num" placeholder="生成数量" value="1" required>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label class="col-form-label">卡密长度</label>
|
||||
<input type="number" class="form-control" id="k_length" name="k_length" placeholder="卡密长度" value="10" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label class="col-form-label">卡密备注</label>
|
||||
<input type="text" class="form-control" id="add_note" name="add_note" placeholder="卡密备注" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label class="col-form-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>
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" name="out" id="out" value="1">
|
||||
<label class="custom-control-label" for="out">生成后立即导出</label>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-block btn-xs btn-success" name="add_submit" id="add_submit" type="submit" value="确定">确认生成</button>
|
||||
</form>
|
||||
<?php else : ?>
|
||||
<div class="text-center" style="margin-top:6rem!important;margin-bottom:10rem!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> <!-- end card-body-->
|
||||
</div> <!-- end card-->
|
||||
</div> <!-- end col -->
|
||||
</div><!-- end row -->
|
||||
|
||||
<script>
|
||||
$('#add_submit').click(function() {
|
||||
let t = window.jQuery;
|
||||
var out = document.getElementById("out").checked;
|
||||
if (out) {
|
||||
out = 1;
|
||||
} else {
|
||||
out = 0;
|
||||
}
|
||||
var add_type = $("select[name='add_type']").val();
|
||||
var add_amount = $("input[name='add_amount']").val();
|
||||
var add_num = $("input[name='add_num']").val();
|
||||
var k_length = $("input[name='k_length']").val();
|
||||
var add_note = $("input[name='add_note']").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=kami_add", //请求的文件名
|
||||
data: {
|
||||
type: add_type,
|
||||
amount: add_amount,
|
||||
num: add_num,
|
||||
out: out,
|
||||
k_length: k_length,
|
||||
note: add_note,
|
||||
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 if (data.code == 202) {
|
||||
t.NotificationApp.send("成功", "正在生成卡密文件", "top-center", "rgba(0,0,0,0.2)", "success");
|
||||
download(add_type + '_' + add_num + '_' + add_appid, data.msg);
|
||||
} 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 + 'km.txt');
|
||||
|
||||
element.style.display = 'none';
|
||||
document.body.appendChild(element);
|
||||
|
||||
element.click();
|
||||
|
||||
document.body.removeChild(element);
|
||||
}
|
||||
|
||||
function type_change(i) {
|
||||
|
||||
if (i == 'vip') {
|
||||
document.getElementById('amount_name').innerHTML = " 会员天数 *";
|
||||
document.getElementById('add_amount').setAttribute("placeholder", "会员天数,永久卡9个9");
|
||||
document.getElementById('amount_a').innerHTML = "天";
|
||||
} else {
|
||||
document.getElementById('amount_name').innerHTML = " 积分数 *";
|
||||
document.getElementById('add_amount').setAttribute("placeholder", "积分数");
|
||||
document.getElementById('amount_a').innerHTML = "积分";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,416 @@
|
||||
<?php
|
||||
/*
|
||||
Sort:1
|
||||
Hidden:false
|
||||
Name:卡密管理
|
||||
Url:kami_adm
|
||||
Right:kami
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
Author QQ:51154393
|
||||
Author Url:www.eruyi.cn
|
||||
*/
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
|
||||
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
|
||||
$see = isset($_GET['see']) ? intval($_GET['see']) : 0;
|
||||
$appid = isset($_GET['app']) ? intval($_GET['app']) : 0;
|
||||
if ($see > 0 && $appid > 0) {
|
||||
if ($see == 1) {
|
||||
$nums = Db::table('kami')->where('appid', $appid)->where('use_time', 0)->count();
|
||||
} else {
|
||||
$nums = Db::table('kami')->where('appid', $appid)->where('use_time', '>', 0)->count();
|
||||
}
|
||||
$url = "./?kami_adm&see={$see}&app={$appid}&page=";
|
||||
} elseif ($see > 0 && $appid <= 0) {
|
||||
if ($see == 1) {
|
||||
$nums = Db::table('kami')->where('use_time', 0)->count();
|
||||
} else {
|
||||
$nums = Db::table('kami')->where('use_time', '>', '0')->count();
|
||||
}
|
||||
$url = "./?kami_adm&see={$see}&page=";
|
||||
} elseif ($see <= 0 && $appid > 0) {
|
||||
$nums = Db::table('kami')->where('appid', $appid)->count();
|
||||
$url = "./?kami_adm&app={$appid}&page=";
|
||||
} else {
|
||||
$nums = Db::table('kami')->count();
|
||||
$url = "./?kami_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 row-->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row mb-2">
|
||||
<div class="col-lg-8">
|
||||
<form class="form-inline">
|
||||
<select class="form-control" name="appid" id="appid" onchange="get_screen(this.value,<?php echo $see; ?>)">
|
||||
<option value="0">全部</option>
|
||||
<?php
|
||||
$res = Db::table('app')->order('id desc')->select();
|
||||
foreach ($res as $k => $v) {
|
||||
$rows = $res[$k];
|
||||
?>
|
||||
<option value="<?php echo $rows['id']; ?>" <?php if ($appid == $rows['id']) echo 'selected = "selected"'; ?>><?php echo $rows['name']; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<label for="status-select" class="mr-2"></label>
|
||||
<select class="form-control" name="see" id="see" onchange="get_screen(<?php echo $appid; ?>,this.value)">
|
||||
<option value="0" <?php if ($see == 0) echo 'selected = "selected"'; ?>>全部</option>
|
||||
<option value="1" <?php if ($see == 1) echo 'selected = "selected"'; ?>>未使用</option>
|
||||
<option value="2" <?php if ($see == 2) echo 'selected = "selected"'; ?>>已使用</option>
|
||||
</select>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="text-lg-right">
|
||||
<form id="sousuo" 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"> </label>
|
||||
</div>
|
||||
</th>
|
||||
<th style="width: 20px;">
|
||||
<center><span class="badge badge-light-lighten">ID</span></center>
|
||||
</th>
|
||||
<th style="width: 200px;"><span class="badge badge-light-lighten">卡密</span></th>
|
||||
<th><span class="badge badge-light-lighten">备注</span></th>
|
||||
<th style="width: 150px;">
|
||||
<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: 200px;">
|
||||
<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: 150px;">
|
||||
<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
|
||||
$kami = Db::table('kami', 'as K')->field('K.*,A.name as appname')->JOIN('app', 'as A', 'K.appid=A.id');
|
||||
if ($so) {
|
||||
$kami = $kami->where('K.kami', 'like', "%{$so}%")->whereOr('K.note', 'like', "%{$so}%")->whereOr('A.name', 'like', "%{$so}%")->order('id desc');
|
||||
} else {
|
||||
if ($see > 0 && $appid > 0) {
|
||||
if ($see == 1) {
|
||||
$kami = $kami->where('K.appid', $appid)->where('K.use_time', "0");
|
||||
} else {
|
||||
$kami = $kami->where('K.appid', $appid)->where('K.use_time', '>', "0");
|
||||
}
|
||||
} elseif ($see > 0 && $appid <= 0) {
|
||||
if ($see == 1) {
|
||||
$kami = $kami->where('K.use_time', "0");
|
||||
} else {
|
||||
$kami = $kami->where('K.use_time', '>', "0");
|
||||
}
|
||||
} elseif ($see <= 0 && $appid > 0) {
|
||||
$kami = $kami->where('K.appid', $appid);
|
||||
}
|
||||
$kami = $kami->order('id desc')->limit($bnums, $ENUMS);
|
||||
}
|
||||
$res = $kami->select(); //false
|
||||
//die($sql.$see);
|
||||
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>
|
||||
<?php echo $rows['kami']; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
if ($rows['note'] == '') {
|
||||
echo "<a href=\"javascript:void(0);\" onclick=\"note_id(" . $rows['id'] . ",'" . $rows['note'] . "')\"> <span class=\"badge badge-light\" data-toggle=\"modal\" data-target=\"#note-modal\"><i class=\"mdi mdi-comment-processing\"></i> 未备注</span></a>";
|
||||
} else {
|
||||
echo "<a href=\"javascript:void(0);\" onclick=\"note_id(" . $rows['id'] . ",'" . $rows['note'] . "')\"> <span class=\"badge badge-info\" data-toggle=\"modal\" data-target=\"#note-modal\"><i class=\"mdi mdi-comment-processing\"></i> " . $rows['note'] . "</span></a>";
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<center><?php if ($rows['type'] == 'fen') : ?><span class="badge badge-warning-lighten">积分卡[<?php echo $rows['amount']; ?>]<?php else : ?><span class="badge badge-danger-lighten">会员卡[ <?php if ($rows['amount'] == 999999999) {
|
||||
echo '永久卡';
|
||||
} else {
|
||||
echo $rows['amount'] . '天';
|
||||
} ?> ]<?php endif; ?></span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center>
|
||||
<?php if ($rows['user']) : ?><span class="badge badge-warning-lighten">
|
||||
<?php echo $rows['user'];
|
||||
else : ?><span class="badge badge-success-lighten">未绑定<?php endif; ?></span>
|
||||
</center>
|
||||
</td>
|
||||
<td>
|
||||
<center>
|
||||
<?php if ($rows['use_time'] == 0) : ?><span class="badge badge-info-lighten">未使用
|
||||
<?php else : ?><span class="badge badge-warning-lighten"><?php echo date("Y-m-d H:i", $rows['use_time']);
|
||||
endif; ?></span>
|
||||
</center>
|
||||
</td>
|
||||
<td>
|
||||
<center>
|
||||
<?php if ($rows['new'] == 'n') : ?><span class="badge badge-dark-lighten">未导出
|
||||
<?php else : ?><span class="badge badge-dark">已导出<?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>
|
||||
<?php if ($rows['state'] == 'y') : ?><a href="javascript:void(0);" onclick="edit_state(<?php echo $rows['id']; ?>,'<?php echo $rows['state']; ?>')"><span id="state_<?php echo $rows['id']; ?>" class="badge badge-success">正常
|
||||
<?php else : ?><a href="javascript:void(0);" onclick="edit_state(<?php echo $rows['id']; ?>,'<?php echo $rows['state']; ?>')"><span id="state_<?php echo $rows['id']; ?>" class="badge badge-danger">禁用
|
||||
<?php endif; ?></span></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="note-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
<div class="text-center mt-2 mb-4"></div>
|
||||
<form class="pl-3 pr-3" action="" name="note_log" id="note_log" method="post">
|
||||
<div class="form-group">
|
||||
<input class="form-control" type="text" style="display:none" id="kid" name="kid" value="">
|
||||
<!--style="display:none" -->
|
||||
<label for="username">备注</label>
|
||||
<input class="form-control" type="text" id="note" name="note" required="" placeholder="备注内容">
|
||||
</div>
|
||||
<div class="form-group text-center">
|
||||
<button class="btn btn-primary" type="submit" name="submit_note" id="submit_note" value="确认">确认备注</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
|
||||
<script>
|
||||
$('#submit_note').click(function() {
|
||||
let t = window.jQuery;
|
||||
var note = $("input[name='note']").val();
|
||||
var kid = $("input[name='kid']").val();
|
||||
document.getElementById('submit_note').innerHTML = "<span class=\"spinner-border spinner-border-sm mr-1\" role=\"status\" aria-hidden=\"true\"></span>正在备注";
|
||||
document.getElementById('submit_note').disabled = true;
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "POST", //请求的方式
|
||||
url: "ajax.php?act=kami_note", //请求的文件名
|
||||
data: {
|
||||
note: note,
|
||||
kid: kid
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
console.log(data);
|
||||
document.getElementById('submit_note').disabled = false;
|
||||
document.getElementById('submit_note').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 note_id(i, s) {
|
||||
var kid = document.getElementById("kid");
|
||||
var note = document.getElementById("note");
|
||||
kid.value = i;
|
||||
note.value = s;
|
||||
}
|
||||
|
||||
function get_screen(appid, see) {
|
||||
var url = '';
|
||||
if (appid > 0) {
|
||||
url = '&app=' + appid;
|
||||
}
|
||||
if (see > 0) {
|
||||
if (url == '') {
|
||||
url = '&see=' + see;
|
||||
} else {
|
||||
url = url + '&see=' + see;
|
||||
}
|
||||
}
|
||||
location.href = './?kami_adm' + url;
|
||||
}
|
||||
|
||||
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 edit_state(id, state) {
|
||||
let t = window.jQuery;
|
||||
var badge = document.getElementById("state_" + id).className;
|
||||
if (badge == 'badge badge-danger') {
|
||||
state = 'y'
|
||||
document.getElementById("state_" + id).className = "badge badge-success";
|
||||
document.getElementById("state_" + id).innerHTML = "正常";
|
||||
} else {
|
||||
state = 'n'
|
||||
document.getElementById("state_" + id).className = "badge badge-danger";
|
||||
document.getElementById("state_" + id).innerHTML = "禁用";
|
||||
}
|
||||
//console.log(badge);
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "POST", //请求的方式
|
||||
url: "ajax.php?act=kami_state", //请求的文件名
|
||||
data: {
|
||||
id: id,
|
||||
state: state
|
||||
},
|
||||
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")
|
||||
}
|
||||
}
|
||||
});
|
||||
return false; //重要语句:如果是像a链接那种有href属性注册的点击事件,可以阻止它跳转。
|
||||
}
|
||||
|
||||
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=kami_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>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/*
|
||||
Name:用户日志API
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
Author QQ:51154393
|
||||
Author Url:www.eruyi.cn
|
||||
*/
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
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('log')->where('id', 'in', '(' . $ids . ')')->del(); //false
|
||||
//die($res);
|
||||
if ($res) {
|
||||
json(200, '删除成功');
|
||||
}
|
||||
json(201, '删除失败');
|
||||
} else {
|
||||
json(201, '没有需要删除的数据');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
<?php
|
||||
/*
|
||||
Sort:10
|
||||
icons:mdi mdi-clipboard-text-play-outline
|
||||
Hidden:false
|
||||
Name:系统日志
|
||||
Url:log
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
Author QQ:51154393
|
||||
Author Url:www.eruyi.cn
|
||||
*/
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
|
||||
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
|
||||
$see = isset($_GET['see']) ? purge($_GET['see']) : 'all';
|
||||
|
||||
if ($see != 'all') {
|
||||
$nums = Db::table('log')->where('`group`', $see)->count();
|
||||
$url = "./?log&see={$see}&page=";
|
||||
} else {
|
||||
$nums = Db::table('log')->count(); //获取用户日志总数
|
||||
$url = "./?log&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">
|
||||
<form class="form-inline">
|
||||
<select class="form-control" name="see" id="see" onchange="get_screen(this.value)">
|
||||
<option value="all" <?php if ($see == 'all') echo 'selected = "selected"'; ?>>全部</option>
|
||||
<option value="user" <?php if ($see == 'user') echo 'selected = "selected"'; ?>>用户日志</option>
|
||||
<option value="adm" <?php if ($see == 'adm') echo 'selected = "selected"'; ?>>管理员日志</option>
|
||||
</select>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="text-lg-right">
|
||||
<form id="sousuo" 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"> </label>
|
||||
</div>
|
||||
</th>
|
||||
<th style="width: 20px;">
|
||||
<center><span class="badge badge-light-lighten">ID</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: 100px;">
|
||||
<center><span class="badge badge-light-lighten">积分变化</span></center>
|
||||
</th>
|
||||
<th style="width: 100px;">
|
||||
<center><span class="badge badge-light-lighten">VIP变化</span></center>
|
||||
</th>
|
||||
<th style="width: 150px;">
|
||||
<center><span class="badge badge-light-lighten">操作IP</span></center>
|
||||
</th>
|
||||
<th style="width: 150px;">
|
||||
<center><span class="badge badge-light-lighten">日志时间</span></center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$log = Db::table('log', 'as LOG')->field('LOG.*,U.pic,U.user,U.email,U.phone,U.name,A.name as appname')->JOIN('app', 'as A', 'LOG.appid=A.id')->JOIN("user", 'as U', 'LOG.uid=U.id');
|
||||
|
||||
if ($so) {
|
||||
$lang = array_merge($lang_adm, $lang_user);
|
||||
$lang_val = !empty(array_search($so, $lang)) ? array_search($so, $lang) : $so;
|
||||
$log = $log->where('A.name', 'like', "%{$so}%")->whereOr('LOG.type', 'like', "%{$lang_val}%")->whereOr('U.user', 'like', "%{$so}%")->whereOr('U.email', 'like', "%{$so}%")->whereOr('U.phone', 'like', "%{$so}%")->whereOr('U.name', 'like', "%{$so}%")->order('id desc');
|
||||
} else {
|
||||
if ($see != 'all') {
|
||||
$log = $log->where('LOG.group', $see);
|
||||
}
|
||||
$log = $log->order('id desc')->limit($bnums, $ENUMS);
|
||||
}
|
||||
$res = $log->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 ($rows['group'] == 'adm') ? '../assets/images/users/avatar-1.jpg' : get_pic($rows['pic'], true); ?>" width="40" alt="Generic placeholder image">
|
||||
<div class="media-body">
|
||||
|
||||
<a href="<?php echo ($rows['group'] == 'adm') ? 'javascript:void(0);' : './?user_edit&id=' . $rows['uid']; ?>" class="text-title">
|
||||
<h5 class="mt-0 mb-1"><?php echo ($rows['group'] == 'adm') ? $user : (!empty($rows['user']) ? $rows['user'] : (!empty($rows['email']) ? $rows['email'] : $rows['phone'])); ?></h5>
|
||||
</a>
|
||||
<span class="font-13"><?php echo ($rows['group'] == 'adm') ? '管理员' : $rows['name']; ?></span>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<center>
|
||||
<?php echo ($rows['group'] == 'adm') ? '<span class="badge badge-light">后台操作' : '<span class="badge badge-primary">' . $rows['appname']; ?>
|
||||
</span></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><?php echo ($rows['group'] == 'adm') ? $lang_adm[$rows['type']] : $lang_user[$rows['type']]; ?></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><?php echo ($rows['fen'] > 0) ? '+' . $rows['fen'] : $rows['fen']; ?></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><?php echo ($rows['vip'] > 0) ? '+' . $rows['vip'] . (isset($time_type[$rows['type']]) ? $time_type[$rows['type']] : "") : $rows['vip'] . (isset($time_type[$rows['type']]) ? $time_type[$rows['type']] : ""); ?></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><?php echo $rows['ip']; ?></center>
|
||||
</td>
|
||||
<td>
|
||||
<center><?php echo date("Y-m-d H:i", $rows['time']); ?></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 -->
|
||||
|
||||
<script>
|
||||
function get_screen(see) {
|
||||
if (see != 'all') {
|
||||
location.href = './?log&see=' + see;
|
||||
} else {
|
||||
location.href = './?log';
|
||||
}
|
||||
}
|
||||
|
||||
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=log_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>
|
||||
@@ -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,'没有需要删除的数据');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/*
|
||||
* File:后台目录菜单配置文件
|
||||
* Author:易如意
|
||||
* QQ:51154393
|
||||
* Url:www.eruyi.cn
|
||||
*/
|
||||
|
||||
return [
|
||||
'id' => 'user',
|
||||
'name' => '用户',
|
||||
'icons' => 'mdi mdi-account',
|
||||
'sort' => 3, //排序
|
||||
];
|
||||
@@ -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"> </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>
|
||||
@@ -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>
|
||||
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
/*
|
||||
Name:系统配置API
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
Author QQ:51154393
|
||||
Author Url:www.eruyi.cn
|
||||
*/
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问
|
||||
if ($act == 'set') {
|
||||
$app_debug = isset($_POST['app_debug']) ? intval($_POST['app_debug']) : 0;
|
||||
$default_return_type = isset($_POST['default_return_type']) ? intval($_POST['default_return_type']) : 0;
|
||||
$user_token_time = isset($_POST['user_token_time']) ? intval($_POST['user_token_time']) : 0;
|
||||
$data_page_enums = isset($_POST['data_page_enums']) ? intval($_POST['data_page_enums']) : 0;
|
||||
$default_timezone = isset($_POST['default_timezone']) ? purge($_POST['default_timezone']) : '';
|
||||
$index_template = isset($_POST['index_template']) ? purge($_POST['index_template']) : '';
|
||||
$api_extend_mulu = isset($_POST['api_extend_mulu']) ? purge($_POST['api_extend_mulu']) : '';
|
||||
$adm_extend_mulu = isset($_POST['adm_extend_mulu']) ? purge($_POST['adm_extend_mulu']) : '';
|
||||
$user_pic_mulu = isset($_POST['user_pic_mulu']) ? purge($_POST['user_pic_mulu']) : '';
|
||||
$log_del = isset($_POST['log_del']) ? intval($_POST['log_del']) : 0;
|
||||
$log_key = isset($_POST['log_key']) ? purge($_POST['log_key']) : '';
|
||||
if ($user_token_time == '') json(201, '用户在线状态有效期有误');
|
||||
if ($default_timezone == '') json(201, '系统时区有误');
|
||||
if ($api_extend_mulu == '') json(201, '接口扩展目录有误');
|
||||
if ($adm_extend_mulu == '') json(201, '后台扩展目录有误');
|
||||
if ($user_pic_mulu == '') json(201, '用户头像目录有误');
|
||||
if ($log_key == '') json(201, '日志key不可为空');
|
||||
$userdata = file_get_contents('../include/config.php');
|
||||
$userdata = preg_replace("/\'APP_DEBUG',(\d+)/", "'APP_DEBUG',{$app_debug}", $userdata);
|
||||
$userdata = preg_replace("/\'DEFAULT_RETURN_TYPE',(\d+)/", "'DEFAULT_RETURN_TYPE',{$default_return_type}", $userdata);
|
||||
$userdata = preg_replace("/\'USER_TOKEN_TIME',(\d+)/", "'USER_TOKEN_TIME',{$user_token_time}", $userdata);
|
||||
$userdata = preg_replace("/\'DATA_PAGE_ENUMS',(\d+)/", "'DATA_PAGE_ENUMS',{$data_page_enums}", $userdata);
|
||||
$userdata = preg_replace("/\'DEFAULT_TIMEZONE','(.*?)'/", "'DEFAULT_TIMEZONE','{$default_timezone}'", $userdata);
|
||||
$userdata = preg_replace("/\'INDEX_TEMPLATE','(.*?)'/", "'INDEX_TEMPLATE','{$index_template}'", $userdata);
|
||||
$userdata = preg_replace("/\'API_EXTEND_MULU','(.*?)'/", "'API_EXTEND_MULU','{$api_extend_mulu}'", $userdata);
|
||||
$userdata = preg_replace("/\'ADM_EXTEND_MULU','(.*?)'/", "'ADM_EXTEND_MULU','{$adm_extend_mulu}'", $userdata);
|
||||
$userdata = preg_replace("/\'USER_PIC_MULU','(.*?)'/", "'USER_PIC_MULU','{$user_pic_mulu}'", $userdata);
|
||||
$userdata = preg_replace("/\'LOG_DEL',(\d+)/", "'LOG_DEL',{$log_del}", $userdata);
|
||||
$userdata = preg_replace("/\'LOG_KEY','(.*?)'/", "'LOG_KEY','{$log_key}'", $userdata);
|
||||
$adm_res = file_put_contents('../include/config.php', $userdata);
|
||||
if ($adm_res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'web_set', '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' => 'web_set', 'status' => 201, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
json(201, '修改失败');
|
||||
}
|
||||
}
|
||||
if ($act == 'pswd') {
|
||||
$user = isset($_POST['user']) ? purge($_POST['user']) : '';
|
||||
$pwd = isset($_POST['pwd']) ? purge($_POST['pwd']) : '';
|
||||
$okpwd = isset($_POST['okpwd']) ? purge($_POST['okpwd']) : '';
|
||||
if ($user == '') json(201, '账号不能为空');
|
||||
if ($pwd == '') json(201, '密码不能为空');
|
||||
if ($okpwd == '') json(201, '请确认密码');
|
||||
if ($okpwd != $pwd) json(201, '确认密码有误');
|
||||
$userdata = file_get_contents('userdata.php');
|
||||
//json(201,$userdata);
|
||||
$userdata = preg_replace('/\$user = \'.*?\'/', '$user = \'' . $user . '\'', $userdata);
|
||||
$userdata = preg_replace('/\$pass = \'.*?\'/', '$pass = \'' . $pwd . '\'', $userdata);
|
||||
$userdata = preg_replace('/\$cookie = \'.*?\'/', '$cookie = \'' . md5($user . $pwd . time()) . '\'', $userdata);
|
||||
$adm_res = file_put_contents('userdata.php', $userdata);
|
||||
if ($adm_res) {
|
||||
if (defined('ADM_LOG') && ADM_LOG == 1) {
|
||||
Db::table('log')->add(['group' => 'adm', 'type' => 'web_pswd', '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' => 'web_pswd', 'status' => 201, 'time' => time(), 'ip' => getip(), 'data' => json_encode($_POST)]);
|
||||
} //记录日志
|
||||
json(201, '修改失败');
|
||||
}
|
||||
}
|
||||
if ($act == 'downfile') {
|
||||
$fileurl = isset($_POST['fileurl']) ? purge($_POST['fileurl']) : '';
|
||||
$home = isset($_POST['home']) ? purge($_POST['home']) : '';
|
||||
$mulu = isset($_POST['mulu']) ? purge($_POST['mulu']) : '';
|
||||
$filename = isset($_POST['filename']) ? purge($_POST['filename']) : '';
|
||||
if ($fileurl == '') json(201, '文件下载地址为空');
|
||||
if ($home == '') json(201, '扩展类型为空');
|
||||
if ($filename == '') json(201, '文件名称为空');
|
||||
if ($home == 'adm') {
|
||||
$save_dir = FCPATH . ADM_EXTEND_MULU . $mulu;
|
||||
} else {
|
||||
$save_dir = FCPATH . API_EXTEND_MULU . $mulu;
|
||||
}
|
||||
$res = getFile($fileurl, $save_dir, $filename, 1);
|
||||
if (is_array($res) && !empty($res)) {
|
||||
json(200, '更新成功');
|
||||
}
|
||||
json(201, '更新失败');
|
||||
}
|
||||
function getFile($url, $save_dir = '', $filename = '', $type = 0)
|
||||
{
|
||||
if (trim($url) == '') {
|
||||
return false;
|
||||
}
|
||||
//创建保存目录
|
||||
if (!file_exists($save_dir) && !mkdir($save_dir, 0777, true)) {
|
||||
return false;
|
||||
}
|
||||
//获取远程文件所采用的方法
|
||||
if ($type) {
|
||||
$ch = curl_init();
|
||||
$timeout = 5;
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
|
||||
$content = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
} else {
|
||||
ob_start();
|
||||
readfile($url);
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
//echo $content;
|
||||
$size = strlen($content);
|
||||
//文件大小
|
||||
$fp2 = @fopen($save_dir . $filename, 'w');
|
||||
fwrite($fp2, $content);
|
||||
fclose($fp2);
|
||||
unset($content, $url);
|
||||
if ($size == 0) {
|
||||
return false;
|
||||
}
|
||||
return array(
|
||||
'file_name' => $filename,
|
||||
'save_path' => $save_dir . $filename,
|
||||
'file_size' => $size
|
||||
);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
/*
|
||||
Sort:2
|
||||
Hidden:false
|
||||
icons:mdi mdi-account-edit
|
||||
Name:修改密码
|
||||
Url:web_edit
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
QQ:51154393
|
||||
Url:www.eruyi.cn
|
||||
*/
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问拦截
|
||||
?>
|
||||
|
||||
<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">管理员信息</h4>
|
||||
</div> <!-- end page-title-box -->
|
||||
</div> <!-- end col-->
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
<!-- Form row -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<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 for="f_user" class="col-form-label">账号</label>
|
||||
<input type="text" class="form-control" id="username" name="username" placeholder="用户账号" value="<?php echo $user; ?>" required>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="f_psw" class="col-form-label">确认密码</label>
|
||||
<input type="password" class="form-control" id="password" name="password" placeholder="空则不修改密码" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="f_psw" class="col-form-label">确认密码</label>
|
||||
<input type="password" class="form-control" id="okpassword" name="okpassword" placeholder="空则不修改密码" value="">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" id="ok" name="ok" required>
|
||||
<label class="custom-control-label" for="ok">确认是我操作</label>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-block btn-primary" id="submit" value="确认">确认修改</button>
|
||||
|
||||
</form>
|
||||
|
||||
</div> <!-- end card-body -->
|
||||
</div> <!-- end card-->
|
||||
</div> <!-- end col -->
|
||||
</div><!-- end row -->
|
||||
|
||||
<script>
|
||||
$('#submit').click(function() {
|
||||
let t = window.jQuery;
|
||||
var user = $("input[name='username']").val();
|
||||
var pwd = $("input[name='password']").val();
|
||||
var okpwd = $("input[name='okpassword']").val();
|
||||
var ok = document.getElementById("ok").checked;
|
||||
//console.log(okpwd);
|
||||
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=web_pswd", //请求的文件名
|
||||
data: {
|
||||
user: user,
|
||||
pwd: pwd,
|
||||
okpwd: okpwd
|
||||
},
|
||||
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")
|
||||
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属性注册的点击事件,可以阻止它跳转。
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
/*
|
||||
Sort:1
|
||||
Hidden:true
|
||||
icons:mdi mdi-cogs
|
||||
Name:文件更新
|
||||
Url:web_file
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
QQ:51154393
|
||||
Url:www.eruyi.cn
|
||||
*/
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问拦截
|
||||
?>
|
||||
<!-- 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 -->
|
||||
|
||||
<!-- end row -->
|
||||
<div class="row">
|
||||
<div class="col-12" id="file_list">
|
||||
<div class="card" id="loading">
|
||||
<div class="card-body" style="margin-top:8rem!important;margin-bottom:8rem!important">
|
||||
<center>
|
||||
<div class="spinner-grow text-danger" role="status"></div>
|
||||
</center>
|
||||
<center>
|
||||
<p>正在加载中</p>
|
||||
</center>
|
||||
</div>
|
||||
<!--end card-body-->
|
||||
</div>
|
||||
<!--end card-->
|
||||
</div>
|
||||
<!--end col -->
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function file_submit(submit, url, home, mulu, filename) {
|
||||
if (submit.indexOf("file_new") != -1) {
|
||||
document.getElementById(submit).innerHTML = "<span class=\"spinner-border spinner-border-sm mr-1\" role=\"status\" aria-hidden=\"true\"></span>正在更新";
|
||||
} else if (submit.indexOf("file_md5") != -1) {
|
||||
document.getElementById(submit).innerHTML = "<span class=\"spinner-border spinner-border-sm mr-1\" role=\"status\" aria-hidden=\"true\"></span>正在覆盖";
|
||||
} else if (submit.indexOf("file_lose") != -1) {
|
||||
document.getElementById(submit).innerHTML = "<span class=\"spinner-border spinner-border-sm mr-1\" role=\"status\" aria-hidden=\"true\"></span>正在下载";
|
||||
}
|
||||
document.getElementById(submit).disabled = true;
|
||||
//console.log(url,home,mulu,filename);
|
||||
let t = window.jQuery;
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "POST", //请求的方式
|
||||
url: "ajax.php?act=web_downfile", //请求的文件名
|
||||
data: {
|
||||
fileurl: url,
|
||||
home: home,
|
||||
mulu: mulu,
|
||||
filename: filename
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
if (data.code == 200) {
|
||||
if (submit.indexOf("file_new") != -1) {
|
||||
document.getElementById(submit).innerHTML = "<i class=\"mdi mdi-check-all mr-1\"></i>更新成功";
|
||||
} else if (submit.indexOf("file_md5") != -1) {
|
||||
document.getElementById(submit).innerHTML = "<i class=\"mdi mdi-check-all mr-1\"></i>覆盖成功";
|
||||
} else if (submit.indexOf("file_lose") != -1) {
|
||||
document.getElementById(submit).innerHTML = "<i class=\"mdi mdi-check-all mr-1\"></i>下载成功";
|
||||
}
|
||||
t.NotificationApp.send("成功", data.msg, "top-center", "rgba(0,0,0,0.2)", "success")
|
||||
} else {
|
||||
if (submit.indexOf("file_new") != -1) {
|
||||
document.getElementById(submit).innerHTML = "<i class=\"mdi mdi-check-all mr-1\"></i>立即更新";
|
||||
} else if (submit.indexOf("file_md5") != -1) {
|
||||
document.getElementById(submit).innerHTML = "<i class=\"mdi mdi-check-all mr-1\"></i>立即覆盖";
|
||||
} else if (submit.indexOf("file_lose") != -1) {
|
||||
document.getElementById(submit).innerHTML = "<i class=\"mdi mdi-check-all mr-1\"></i>立即下载";
|
||||
}
|
||||
document.getElementById(submit).disabled = false;
|
||||
t.NotificationApp.send("失败", data.msg, "top-center", "rgba(0,0,0,0.2)", "error")
|
||||
}
|
||||
//console.log(data);
|
||||
}
|
||||
});
|
||||
return false; //重要语句:如果是像a链接那种有href属性注册的点击事件,可以阻止它跳转。
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "GET", //请求的方式
|
||||
url: "edition.php", //请求的文件名
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
document.getElementById("loading").setAttribute("hidden", true);
|
||||
if (data.code == 200) {
|
||||
var json_data = false;
|
||||
if (data.msg.file_new.length > 0) {
|
||||
json_data = true;
|
||||
$("#file_list").append('<div class="card" id="file_new"><div class="card-body" id="file_new_home"><h4 class="mt-0 mb-3">需要更新的文件(' + data.msg.file_new.length + ')</h4></div></div>');
|
||||
for (var i in data.msg.file_new) { //遍历json数组时,这么写p为索引,0,1
|
||||
var mulu = data.msg.file_new[i].mulu;
|
||||
if (mulu.indexOf("/") != -1) {
|
||||
mulu = mulu.replace('/', '_');
|
||||
}
|
||||
if (mulu.indexOf("/") != -1) {
|
||||
mulu = mulu.replace('/', '');
|
||||
}
|
||||
if (!document.getElementById("file_new_" + data.msg.file_new[i].home + "_" + mulu)) {
|
||||
$("#file_new_home").append("<div class=\"media mt-2\" id=\"file_new_home_list\"><img class=\"mr-3 avatar-sm\" src=\"../assets/images/Folder.png\" style=\"width:2rem!important;height:2rem!important\"><div class=\"media-body\"><h6 class=\"mt-0\">文件夹</h5>路径:extend/" + data.msg.file_new[i].home + "/" + data.msg.file_new[i].mulu + "<div id=\"file_new_" + data.msg.file_new[i].home + "_" + mulu + "\"><div class=\"media mt-3\"><a class=\"pr-3\"><img src=\"../assets/images/phpfile.png\" class=\"avatar-sm\" style=\"width:2rem!important;height:2rem!important\"></a><div class=\"media-body\"><h5 class=\"mt-0\">" + data.msg.file_new[i].nav + "</h5>文件名:" + data.msg.file_new[i].file + " 版本:" + data.msg.file_new[i].version + "<br>文件MD5:" + data.msg.file_new[i].md5 + "</div><div class=\"text-right\"><div class=\"btn-group mb-2 ml-2\"><button id=\"file_new_submit_" + i + "\" onclick=\"file_submit('file_new_submit_" + i + "','" + data.msg.file_new[i].fileurl + "','" + data.msg.file_new[i].home + "','" + data.msg.file_new[i].mulu + "','" + data.msg.file_new[i].file + "')\" type=\"button\" class=\"btn btn-success btn-sm\">立即更新</button></div></div></div></div></div></div>");
|
||||
} else {
|
||||
$("#file_new_" + data.msg.file_new[i].home + "_" + mulu).append("<div class=\"media mt-3\"><a class=\"pr-3\"><img src=\"../assets/images/phpfile.png\" class=\"avatar-sm\" style=\"width:2rem!important;height:2rem!important\"></a><div class=\"media-body\"><h5 class=\"mt-0\">" + data.msg.file_new[i].nav + "</h5>文件名:" + data.msg.file_new[i].file + " 版本:" + data.msg.file_new[i].version + "<br>文件MD5:" + data.msg.file_new[i].md5 + "</div><div class=\"text-right\"><div class=\"btn-group mb-2 ml-2\"><button id=\"file_new_submit_" + i + "\" onclick=\"file_submit('" + data.msg.file_new[i].fileurl + "','" + data.msg.file_new[i].home + "','" + data.msg.file_new[i].mulu + "','" + data.msg.file_new[i].file + "')\" type=\"button\" class=\"btn btn-success btn-sm\">立即更新</button></div></div></div>");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (data.msg.file_md5.length > 0) {
|
||||
json_data = true;
|
||||
$("#file_list").append('<div class="card" id="file_md5"><div class="card-body" id="file_md5_home"><h4 class="mt-0 mb-3">被修改的文件(' + data.msg.file_md5.length + ')</h4></div></div>');
|
||||
for (var i in data.msg.file_md5) { //遍历json数组时,这么写p为索引,0,1
|
||||
var mulu = data.msg.file_md5[i].mulu;
|
||||
if (mulu.indexOf("/") != -1) {
|
||||
mulu = mulu.replace('/', '_');
|
||||
}
|
||||
if (mulu.indexOf("/") != -1) {
|
||||
mulu = mulu.replace('/', '');
|
||||
}
|
||||
if (!document.getElementById("file_md5_" + data.msg.file_md5[i].home + "_" + mulu)) {
|
||||
$("#file_md5_home").append("<div class=\"media mt-2\" id=\"file_md5_home_list\"><img class=\"mr-3 avatar-sm\" src=\"../assets/images/Folder.png\" style=\"width:2rem!important;height:2rem!important\"><div class=\"media-body\"><h6 class=\"mt-0\">文件夹</h5>路径:extend/" + data.msg.file_md5[i].home + "/" + data.msg.file_md5[i].mulu + "<div id=\"file_md5_" + data.msg.file_md5[i].home + "_" + mulu + "\"><div class=\"media mt-3\"><a class=\"pr-3\"><img src=\"../assets/images/phpfile.png\" class=\"avatar-sm\" style=\"width:2rem!important;height:2rem!important\"></a><div class=\"media-body\"><h5 class=\"mt-0\">" + data.msg.file_md5[i].nav + "</h5>文件名:" + data.msg.file_md5[i].file + " 版本:" + data.msg.file_md5[i].version + "<br>文件MD5:" + data.msg.file_md5[i].md5 + "</div><div class=\"text-right\"><div class=\"btn-group mb-2 ml-2\"><button id=\"file_md5_submit_" + i + "\" onclick=\"file_submit('file_md5_submit_" + i + "','" + data.msg.file_md5[i].fileurl + "','" + data.msg.file_md5[i].home + "','" + data.msg.file_md5[i].mulu + "','" + data.msg.file_md5[i].file + "')\" type=\"button\" class=\"btn btn-dark btn-sm\">立即覆盖</button></div></div></div></div></div></div>");
|
||||
} else {
|
||||
$("#file_md5_" + data.msg.file_md5[i].home + "_" + mulu).append("<div class=\"media mt-3\"><a class=\"pr-3\"><img src=\"../assets/images/phpfile.png\" class=\"avatar-sm\" style=\"width:2rem!important;height:2rem!important\"></a><div class=\"media-body\"><h5 class=\"mt-0\">" + data.msg.file_md5[i].nav + "</h5>文件名:" + data.msg.file_md5[i].file + " 版本:" + data.msg.file_md5[i].version + "<br>文件MD5:" + data.msg.file_md5[i].md5 + "</div><div class=\"text-right\"><div class=\"btn-group mb-2 ml-2\"><button id=\"file_md5_submit_" + i + "\" onclick=\"file_submit('file_md5_submit_" + i + "','" + data.msg.file_md5[i].fileurl + "','" + data.msg.file_md5[i].home + "','" + data.msg.file_md5[i].mulu + "','" + data.msg.file_md5[i].file + "')\" type=\"button\" class=\"btn btn-dark btn-sm\">立即覆盖</button></div></div></div>");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (data.msg.file_lose.length > 0) {
|
||||
json_data = true;
|
||||
$("#file_list").append('<div class="card" id="file_lose"><div class="card-body" id="file_lose_home"><h4 class="mt-0 mb-3">缺失的文件(' + data.msg.file_lose.length + ')</h4></div></div>');
|
||||
for (var i in data.msg.file_lose) { //遍历json数组时,这么写p为索引,0,1
|
||||
var mulu = data.msg.file_lose[i].mulu;
|
||||
if (mulu.indexOf("/") != -1) {
|
||||
mulu = mulu.replace('/', "_");
|
||||
}
|
||||
if (mulu.indexOf("/") != -1) {
|
||||
mulu = mulu.replace('/', '');
|
||||
}
|
||||
if (!document.getElementById("file_lose_" + data.msg.file_lose[i].home + "_" + mulu)) {
|
||||
$("#file_lose_home").append("<div class=\"media mt-2\" id=\"file_lose_home_list\"><img class=\"mr-3 avatar-sm\" src=\"../assets/images/Folder.png\" style=\"width:2rem!important;height:2rem!important\"><div class=\"media-body\"><h6 class=\"mt-0\">文件夹</h5>路径:extend/" + data.msg.file_lose[i].home + "/" + data.msg.file_lose[i].mulu + "<div id=\"file_lose_" + data.msg.file_lose[i].home + "_" + mulu + "\"><div class=\"media mt-3\"><a class=\"pr-3\"><img src=\"../assets/images/phpfile.png\" class=\"avatar-sm\" style=\"width:2rem!important;height:2rem!important\"></a><div class=\"media-body\"><h5 class=\"mt-0\">" + data.msg.file_lose[i].nav + "</h5>文件名:" + data.msg.file_lose[i].file + " 版本:" + data.msg.file_lose[i].version + "<br>文件MD5:" + data.msg.file_lose[i].md5 + "</div><div class=\"text-right\"><div class=\"btn-group mb-2 ml-2\"><button id=\"file_lose_submit_" + i + "\" onclick=\"file_submit('file_lose_submit_" + i + "','" + data.msg.file_lose[i].fileurl + "','" + data.msg.file_lose[i].home + "','" + data.msg.file_lose[i].mulu + "','" + data.msg.file_lose[i].file + "')\" type=\"button\" class=\"btn btn-danger btn-sm\">立即下载</button></div></div></div></div></div></div>");
|
||||
} else {
|
||||
$("#file_lose_" + data.msg.file_lose[i].home + "_" + mulu).append("<div class=\"media mt-3\"><a class=\"pr-3\"><img src=\"../assets/images/phpfile.png\" class=\"avatar-sm\" style=\"width:2rem!important;height:2rem!important\"></a><div class=\"media-body\"><h5 class=\"mt-0\">" + data.msg.file_lose[i].nav + "</h5>文件名:" + data.msg.file_lose[i].file + " 版本:" + data.msg.file_lose[i].version + "<br>文件MD5:" + data.msg.file_lose[i].md5 + "</div><div class=\"text-right\"><div class=\"btn-group mb-2 ml-2\"><button id=\"file_lose_submit_" + i + "\" onclick=\"file_submit('file_lose_submit_" + i + "','" + data.msg.file_lose[i].fileurl + "','" + data.msg.file_lose[i].home + "','" + data.msg.file_lose[i].mulu + "','" + data.msg.file_lose[i].file + "')\" type=\"button\" class=\"btn btn-danger btn-sm\">立即下载</button></div></div></div>");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (json_data == false) {
|
||||
$("#file_list").append('<div class="card"><div class="text-center" style="margin-top:8rem!important;margin-bottom:8rem!important"><img src="../assets/images/normal.svg" height="80" alt="File not found Image"><h4 class="text-uppercase mt-3">你的系统非常棒,没有任何问题</h4></div></div>');
|
||||
}
|
||||
} else {
|
||||
$("#file_list").append('<div class="card"><div class="text-center" style="margin-bottom:8rem!important"><img src="../assets/images/upgrade.svg" width="100%" alt="File not found Image"><h4 class="text-uppercase mt-3 mb-4">当前程序需要升级至' + data.msg.edition + '</h4><a href="' + data.msg.new_url + '" target="_blank"><button type="button" class="btn btn-danger">立即升级</button></a></div></div>');
|
||||
}
|
||||
},
|
||||
error: function(xhr, state, errorThrown) {
|
||||
document.getElementById("loading").setAttribute("hidden", true);
|
||||
$("#file_list").append('<div class="card"><div class="text-center" style="margin-top:8rem!important;margin-bottom:8rem!important"><img src="../assets/images/maintenance.svg" height="120" alt="File not found Image"><h4 class="text-uppercase mt-3 mb-4">服务器数据读取获失败,请刷新重试</h4><a href="./?web_file"><button type="button" class="btn btn-dark">立即刷新</button></a></div></div>');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,248 @@
|
||||
<?php
|
||||
/*
|
||||
Sort:1
|
||||
Hidden:false
|
||||
icons:mdi mdi-cogs
|
||||
Name:系统设置
|
||||
Url:web_set
|
||||
Version:1.0
|
||||
Author:易如意
|
||||
QQ:51154393
|
||||
Url:www.eruyi.cn
|
||||
*/
|
||||
if (!isset($islogin)) header("Location: /"); //非法访问拦截
|
||||
?>
|
||||
<!-- 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 -->
|
||||
|
||||
<!-- end row -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<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 class="col-form-label">错误输出</label>
|
||||
<select class="form-control" name="app_debug" id="app_debug">
|
||||
<option value="0" <?php if (APP_DEBUG == 0) echo 'selected = "selected"'; ?>>关闭</option>
|
||||
<option value="1" <?php if (APP_DEBUG == 1) echo 'selected = "selected"'; ?>>开启</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label class="col-form-label">数据输出格式</label>
|
||||
<select class="form-control" name="default_return_type" id="default_return_type">
|
||||
<option value="0" <?php if (DEFAULT_RETURN_TYPE == 0) echo 'selected = "selected"'; ?>>JSON</option>
|
||||
<option value="1" <?php if (DEFAULT_RETURN_TYPE == 1) echo 'selected = "selected"'; ?>>XML</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="f_user" class="col-form-label">用户在线状态有效期</label>
|
||||
|
||||
<div class="input-group">
|
||||
<input type="number" class="form-control" id="user_token_time" name="user_token_time" placeholder="用户在线状态有效期" value="<?php echo USER_TOKEN_TIME; ?>" required>
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="basic-addon1">秒</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="f_user" class="col-form-label">后台管理每页数据</label>
|
||||
|
||||
<div class="input-group">
|
||||
<input type="number" class="form-control" id="data_page_enums" name="data_page_enums" placeholder="后台管理每页数据" value="<?php echo DATA_PAGE_ENUMS; ?>" required>
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="basic-addon1">条</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="f_user" class="col-form-label">系统时区</label> :<a href='https://www.php.net/manual/en/timezones.php' target="_blank">查看合法时区的列表</a>
|
||||
<input type="text" class="form-control" id="default_timezone" name="default_timezone" placeholder="系统时区" value="<?php echo DEFAULT_TIMEZONE; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label class="col-form-label">首页模板目录</label>
|
||||
<select class="form-control" name="index_template" id="index_template">
|
||||
<?php $template_arr = myScanDir(FCPATH . 'template/', 1);
|
||||
foreach ($template_arr as $value) { ?>
|
||||
<option value="<?php echo $value; ?>" <?php if (INDEX_TEMPLATE == $value) echo 'selected = "selected"'; ?>><?php echo $value; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="f_user" class="col-form-label">接口扩展目录</label>
|
||||
<input type="text" class="form-control" id="api_extend_mulu" name="api_extend_mulu" placeholder="接口扩展目录" value="<?php echo API_EXTEND_MULU; ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="f_user" class="col-form-label">后台扩展目录</label>
|
||||
<input type="text" class="form-control" id="adm_extend_mulu" name="adm_extend_mulu" placeholder="后台扩展目录" value="<?php echo ADM_EXTEND_MULU; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="f_user" class="col-form-label">用户头像目录</label>
|
||||
<input type="text" class="form-control" id="user_pic_mulu" name="user_pic_mulu" placeholder="用户头像目录" value="<?php echo USER_PIC_MULU; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label class="col-form-label">管理员操作日志</label>
|
||||
<select class="form-control" name="adm_log" id="adm_log">
|
||||
<option value="0" <?php if (ADM_LOG == 0) echo 'selected = "selected"'; ?>>关闭</option>
|
||||
<option value="1" <?php if (ADM_LOG == 1) echo 'selected = "selected"'; ?>>开启</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label class="col-form-label">用户操作日志</label>
|
||||
<select class="form-control" name="user_log" id="user_log">
|
||||
<option value="0" <?php if (USER_LOG == 0) echo 'selected = "selected"'; ?>>关闭</option>
|
||||
<option value="1" <?php if (USER_LOG == 1) echo 'selected = "selected"'; ?>>开启</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="f_user" class="col-form-label">日志保留</label>
|
||||
<div class="input-group">
|
||||
<input type="number" class="form-control" id="log_del" name="log_del" placeholder="日志保留天数" value="<?php echo LOG_DEL; ?>" required>
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="basic-addon1">天</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-8">
|
||||
<label class="col-form-label">日志KEY</label>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="log_key" name="log_key" value="<?php echo LOG_KEY; ?>">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-success" type="button" id="bian_key">随机更换KEY</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="alert alert-warning alert-dismissible fade show" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<strong>提示 - </strong> 自动清理日志功能需要使用《计划任务》,任务API(每天/次):<?php echo dirname(WEB_URL) . '/api.php?act=log&key='; ?><span id='log_key_url'><?php echo LOG_KEY; ?></span>
|
||||
</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>
|
||||
|
||||
<script>
|
||||
$('#submit').click(function() {
|
||||
let t = window.jQuery;
|
||||
var app_debug = $("select[name='app_debug']").val();
|
||||
var default_return_type = $("select[name='default_return_type']").val();
|
||||
var user_token_time = $("input[name='user_token_time']").val();
|
||||
var data_page_enums = $("input[name='data_page_enums']").val();
|
||||
var default_timezone = $("input[name='default_timezone']").val();
|
||||
var index_template = $("select[name='index_template']").val();
|
||||
var api_extend_mulu = $("input[name='api_extend_mulu']").val();
|
||||
var adm_extend_mulu = $("input[name='adm_extend_mulu']").val();
|
||||
var user_pic_mulu = $("input[name='user_pic_mulu']").val();
|
||||
var adm_log = $("select[name='adm_log']").val();
|
||||
var user_log = $("select[name='user_log']").val();
|
||||
var log_del = $("input[name='log_del']").val();
|
||||
var log_key = $("input[name='log_key']").val();
|
||||
var ok = document.getElementById("ok").checked;
|
||||
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=web_set", //请求的文件名
|
||||
data: {
|
||||
app_debug: app_debug,
|
||||
default_return_type: default_return_type,
|
||||
user_token_time: user_token_time,
|
||||
data_page_enums: data_page_enums,
|
||||
default_timezone: default_timezone,
|
||||
index_template: index_template,
|
||||
api_extend_mulu: api_extend_mulu,
|
||||
adm_extend_mulu: adm_extend_mulu,
|
||||
user_pic_mulu: user_pic_mulu,
|
||||
adm_log: adm_log,
|
||||
user_log: user_log,
|
||||
log_del: log_del,
|
||||
log_key: log_key
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
console.log(data);
|
||||
document.getElementById('submit').disabled = false;
|
||||
document.getElementById('submit').innerHTML = "确认修改";
|
||||
if (data.code == 200) {
|
||||
document.getElementById('log_key_url').innerHTML = log_key;
|
||||
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属性注册的点击事件,可以阻止它跳转。
|
||||
});
|
||||
|
||||
$('#bian_key').click(function() {
|
||||
var log_key = randomString(32);
|
||||
$("#log_key").val(log_key);
|
||||
});
|
||||
|
||||
function randomString(len) {
|
||||
len = len || 32;
|
||||
var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
|
||||
var maxPos = $chars.length;
|
||||
var pwd = '';
|
||||
for (i = 0; i < len; i++) {
|
||||
pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
|
||||
}
|
||||
return pwd;
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/*
|
||||
Name:请求验证码
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['smtp_state'] == 'n') out(121, $app_res); //判断邮箱是否可用
|
||||
if ($app_res['logon_way'] == 1) out(164, $app_res); //不是账号登录方式不允许使用当前操作
|
||||
$email = isset($data_arr['email']) && !empty($data_arr['email']) ? purge($data_arr['email']) : out(110, '邮箱账号为空', $app_res); //请输入账号
|
||||
$type = isset($data_arr['type']) ? purge($data_arr['type']) : 'reg'; //验证码类型,reg=注册,seek=找回密码
|
||||
if (!check_email($email)) out(116, '邮箱不合法', $app_res); //账号长度5~11位,不支持中文和特殊字符
|
||||
$code = mt_rand(1000, 9999); //生成验证码
|
||||
if ($type == '' or $type == 'reg') {
|
||||
if ($app_res['reg_state'] == 'n') out(103, $app_res['reg_notice'], $app_res); //判断是否可注册
|
||||
$res_user = Db::table('user')->where(['email' => $email, 'appid' => $appid])->find(); //false
|
||||
if ($res_user) out(115, '您的邮箱已经注册过账号了', $app_res); //账号已存在
|
||||
$title = $app_res['name'] . '注册账号';
|
||||
$muban = "您注册账号的验证码是:" . $code . ",请不要把验证码泄露给其他人<br/>【" . $app_res['name'] . "】";
|
||||
} else if ($type == 'seek') {
|
||||
$res_user = Db::table('user')->where(['email' => $email, 'appid' => $appid])->find(); //false
|
||||
if (!$res_user) out(122, $app_res); //账号不存在
|
||||
if ($res_user['ban'] > time() || $res_user['ban'] == 999999999) out(114, $res_user['ban_notice'], $app_res); //账号被禁用
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'time' => time(), 'ip' => getip(), 'appid' => $appid]); //记录日志
|
||||
}
|
||||
$title = $app_res['name'] . '找回密码';
|
||||
$muban = "您找回密码的验证码是:" . $code . ",请不要把验证码泄露给其他人<br/>【" . $app_res['name'] . "】";
|
||||
} else if ($type == 'untie') {
|
||||
$res_user = Db::table('user')->where(['email' => $email, 'appid' => $appid])->find(); //false
|
||||
if (!$res_user) out(122, $app_res); //邮箱不存在
|
||||
if ($res_user['ban'] > time() || $res_user['ban'] == 999999999) out(114, $res_user['ban_notice'], $app_res); //账号被禁用
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'time' => time(), 'ip' => getip(), 'appid' => $appid]); //记录日志
|
||||
}
|
||||
$title = $app_res['name'] . '解绑邮箱';
|
||||
$muban = "您解绑邮箱的验证码是:" . $code . ",请不要把验证码泄露给其他人<br/>【" . $app_res['name'] . "】";
|
||||
} else if ($type == 'bind') {
|
||||
$res_user = Db::table('user')->where(['email' => $email, 'appid' => $appid])->find(); //false
|
||||
if ($res_user) out(115, '您的邮箱已经绑定过账号了', $app_res); //账号已存在
|
||||
|
||||
$title = $app_res['name'] . '绑定邮箱';
|
||||
$muban = "您绑定邮箱的验证码是:" . $code . ",请不要把验证码泄露给其他人<br/>【" . $app_res['name'] . "】";
|
||||
}
|
||||
$res_code = Db::table('captcha')->where(['email' => $email, 'appid' => $appid])->order('id DESC')->find(); //false
|
||||
if ($res_code && $res_code['time'] > time() - 180) out(123, $app_res); //验证码频率过快
|
||||
$config = array();
|
||||
$config['from_email'] = $app_res['smtp_user']; //发信邮箱
|
||||
$config['smtp_user'] = $app_res['smtp_user']; //发信邮箱
|
||||
$config['smtp_port'] = $app_res['smtp_port']; //发信端口
|
||||
$config['smtp_host'] = $app_res['smtp_host']; //发信服务器
|
||||
$config['from_name'] = $app_res['name']; //发信标题
|
||||
$config['smtp_pass'] = $app_res['smtp_pass']; //发信密码
|
||||
$config['reply_email'] = $app_res['smtp_user']; //回复电子邮件
|
||||
$config['reply_name'] = $app_res['name']; //回复名称
|
||||
$config['email_to'] = $email; //收信人
|
||||
if ($app_res['smtp_user'] == '' or $app_res['smtp_pass'] == '') json(201, '验证码不可用');
|
||||
$rs = send_mail($config['email_to'], $app_res['name'], $title, $muban, '', $config);
|
||||
if ($rs) {
|
||||
$time = time();
|
||||
$add_res = Db::table('captcha')->add(['email' => $email, 'code' => $code, 'time' => $time, 'appid' => $appid]);
|
||||
if ($add_res) {
|
||||
out(200, '发送成功', $app_res); //验证码发送成功
|
||||
}
|
||||
out(201, '验证码入库失败', $app_res); //验证码发送失败
|
||||
} else {
|
||||
out(201, '发送失败', $app_res); //验证码发送失败
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/*
|
||||
Name:修改名称
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['logon_way'] == 1) out(164, $app_res); //不是账号登录方式不允许使用当前操作
|
||||
$token = isset($data_arr['token']) && !empty($data_arr['token']) ? purge($data_arr['token']) : out(125, $app_res); //请输TOKEN
|
||||
$name = isset($data_arr['name']) && !empty($data_arr['name']) ? purge(base64_decode($data_arr['name'])) : out(129, $app_res); //请输账号
|
||||
$res_logon = Db::table('user_logon', 'as logon')->field('U.*')->JOIN('user', 'as U', 'logon.uid=U.id')->where('U.appid', $appid)->where('logon.token', $token)->find(); //false
|
||||
if (!$res_logon) out(127, $app_res); //TOKEN不存在或已失效
|
||||
if ($res_logon['ban'] > time() || $res_logon['ban'] == 999999999) out(114, $res_logon['ban_notice'], $app_res); //账号被禁用
|
||||
$res = Db::table('user')->where('id', $res_logon['id'])->update(['name' => $name]);
|
||||
Db::table('user_logon')->where('token', $token)->update(['last_t' => time()]); //记录活动时间
|
||||
//die($res);
|
||||
if ($res) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_logon['id'], 'type' => $act, 'status' => 200, 'time' => time(), 'ip' => getip(), 'appid' => $appid]); //记录日志
|
||||
}
|
||||
out(200, '修改成功', $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_logon['id'], 'type' => $act, 'status' => 201, 'time' => time(), 'ip' => getip(), 'appid' => $appid]); //记录日志
|
||||
}
|
||||
out(201, '修改失败', $app_res);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/*
|
||||
Name:修改密码
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['logon_way'] == 1) out(164, $app_res); //不是账号登录方式不允许使用当前操作
|
||||
$user = isset($data_arr['user']) && !empty($data_arr['user']) ? purge($data_arr['user']) : out(110, $app_res); //请输账号
|
||||
$pwd = isset($data_arr['password']) && !empty($data_arr['password']) ? purge($data_arr['password']) : out(111, $app_res); //请输入密码
|
||||
$newpwd = isset($data_arr['newpassword']) && !empty($data_arr['newpassword']) ? purge($data_arr['newpassword']) : out(111, '请输入新密码', $app_res); //请输入密码
|
||||
$res_user = Db::table('user')->where(['pwd' => md5($pwd), 'appid' => $appid], "(", ")")->where('(user', $user)->whereOr(['email' => $user, 'phone' => $user], ")")->find(); //false
|
||||
if (!$res_user) out(113, $app_res); //账号密码不正确
|
||||
if ($res_user['ban'] > time() || $res_user['ban'] == 999999999) out(114, $res_user['ban_notice'], $app_res); //账号被禁用
|
||||
$res = Db::table('user')->where('id', $res_user['id'])->update(['pwd' => md5($newpwd)]);
|
||||
//die($res);
|
||||
if ($res) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 200, 'time' => time(), 'ip' => getip(), 'appid' => $appid]); //记录日志
|
||||
}
|
||||
out(200, '修改成功', $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 201, 'time' => time(), 'ip' => getip(), 'appid' => $appid]); //记录日志
|
||||
}
|
||||
out(201, '修改失败', $app_res);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*
|
||||
Name:APP接口拦截器
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
$app_res = Db::table('app')->where('id', $appid)->find();
|
||||
if (!$app_res) out(101); //应用不存在
|
||||
if ($app_res['state'] == 'n') out(102, $app_res['notice'], $app_res); //应用关闭
|
||||
$bmd = ['ini', 'pay']; //白名单接口
|
||||
if ($app_res['mi_state'] == 'y' && !in_array($act, $bmd)) { //数据已加密
|
||||
if ($app_res['mi_type'] == 0) { //明文模式
|
||||
$data_arr = $_REQUEST; //将post或GET数据移交给data_arr
|
||||
if ($app_res['mi_sign'] == 'y') { //数据签名
|
||||
if ($sign == '') out(104, $app_res); //签名为空
|
||||
$s = Arr_sign($data_arr, $app_res['appkey']); //生成签名
|
||||
if ($s != strtolower($sign)) out(106, $app_res); //签名有误
|
||||
}
|
||||
} else if ($app_res['mi_type'] == 1) { //RC4加密
|
||||
if ($data == '') out(107, $app_res); //数据为空
|
||||
$rc4_data = mi_rc4($data, $app_res['mi_rc4_key'], 1); //RC4解密
|
||||
$data_arr = txt_Arr($rc4_data); //将rc4解密后的数据转为数组移交给data_arr
|
||||
if ($app_res['mi_sign'] == 'y') { //数据签名
|
||||
if ($sign == '') out(104, $app_res); //签名为空
|
||||
$s = Arr_sign($data_arr, $app_res['appkey']); //生成签名
|
||||
if ($s != strtolower($sign)) out(106, $app_res); //签名有误
|
||||
}
|
||||
} else if ($app_res['mi_type'] == 2) { //RSA加密
|
||||
if ($data == '') out(107, $app_res); //数据为空
|
||||
$rsa_data = RSA_SMI($data, $app_res['mi_rsa_private_key'], 1); //RSA私钥解密
|
||||
$data_arr = txt_Arr($rsa_data); //将rsa解密后的数据转为数组移交给data_arr
|
||||
if ($app_res['mi_sign'] == 'y') { //数据签名
|
||||
if ($sign == '') out(104, $app_res); //签名为空
|
||||
$s = Arr_sign($data_arr, $app_res['appkey']); //生成签名
|
||||
if ($s != strtolower($sign)) out(106, $app_res); //签名有误
|
||||
}
|
||||
}
|
||||
if ($app_res['mi_time'] > 0) {
|
||||
if (!isset($data_arr['t'])) out(108, $app_res); //没有时间变量
|
||||
$sign_t = time() - intval($data_arr['t']); //服务器时间-客户端时间,对比时间差
|
||||
if ($sign_t > $app_res['mi_time']) out(105, $app_res); //客户端时间小于服务器时间
|
||||
}
|
||||
} else {
|
||||
$data_arr = $_REQUEST; //将post或GET数据移交给data_arr
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/*
|
||||
Name:充值卡密
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['logon_way'] == 0 || $app_res['logon_way'] == 2) {
|
||||
$user = isset($data_arr['account']) ? purge($data_arr['account']) : ''; //请输入账号
|
||||
$token = isset($data_arr['token']) ? purge($data_arr['token']) : ''; //请输TOKEN
|
||||
} elseif ($app_res['logon_way'] == 1) {
|
||||
$mainkm = isset($data_arr['mainkm']) && !empty($data_arr['mainkm']) ? purge($data_arr['mainkm']) : out(110, '请输入出卡密', $app_res); //主卡密
|
||||
}
|
||||
$kami = isset($data_arr['kami']) && !empty($data_arr['kami']) ? purge($data_arr['kami']) : out(148, $app_res); //卡密为空
|
||||
$res_kami = Db::table('kami')->where('appid', $appid)->where('kami', $kami)->find(); //false
|
||||
if (!$res_kami) out(149, $app_res); //卡密不存在
|
||||
if (!empty($res_kami['user']) or !empty($res_kami['use_time'])) out(150, $app_res); //卡密已使用
|
||||
if ($res_kami['state'] == 'n') out(151, $app_res); //卡密被禁用
|
||||
if (!empty($user)) { //账号充值
|
||||
$res_user = Db::table('user')->where(['appid' => $appid], "(", ")")->where('(user', $user)->whereOr(['email' => $user, 'phone' => $user], ")")->find(); //false
|
||||
if (!$res_user) out(122, $app_res); //账号不存在
|
||||
if ($res_user['ban'] > time() || $res_user['ban'] == 999999999) out(114, $res_user['ban_notice'], $app_res); //账号被禁用
|
||||
$user = !empty($res_user['user']) ? $res_user['user'] : (!empty($res_user['email']) ? $res_user['email'] : $res_user['phone']);
|
||||
if ($res_kami['type'] == 'vip') {
|
||||
if ($res_user['vip'] == '999999999') out(199, $app_res); //已经是永久会员了
|
||||
if ($res_user['vip'] > time()) { //没有过期
|
||||
$vip = $res_user['vip'] + 86400 * $res_kami['amount'];
|
||||
} else { //已过期
|
||||
$vip = time() + 86400 * $res_kami['amount'];
|
||||
}
|
||||
$res = Db::table('user')->where('id', $res_user['id'])->update(['vip' => $vip]); //更新用户资料
|
||||
if ($res) {
|
||||
Db::table('kami')->where('id', $res_kami['id'])->update(['use_time' => time(), 'user' => $user]); //更新卡密信息
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 200, 'vip' => $res_kami['amount'], 'time' => time(), 'ip' => getip(), 'appid' => $appid]); //记录日志
|
||||
}
|
||||
out(200, '充值成功', $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 201, 'vip' => $res_kami['amount'], 'time' => time(), 'ip' => getip(), 'appid' => $appid]); //记录日志
|
||||
}
|
||||
out(201, '充值失败', $app_res);
|
||||
}
|
||||
} elseif ($res_kami['type'] == 'fen') {
|
||||
$fen = $res_user['fen'] + $res_kami['amount'];
|
||||
$res = Db::table('user')->where('id', $res_user['id'])->update(['fen' => $fen]); //更新用户资料
|
||||
if ($res) {
|
||||
Db::table('kami')->where('id', $res_kami['id'])->update(['use_time' => time(), 'user' => $user]); //更新卡密信息
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 200, 'fen' => $res_kami['amount'], 'time' => time(), 'ip' => getip(), 'appid' => $appid]); //记录日志
|
||||
}
|
||||
out(200, '充值成功', $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 201, 'fen' => $res_kami['amount'], 'time' => time(), 'ip' => getip(), 'appid' => $appid]); //记录日志
|
||||
}
|
||||
out(201, '充值失败', $app_res);
|
||||
}
|
||||
}
|
||||
} elseif (!empty($token)) { //token充值
|
||||
$res_logon = Db::table('user_logon', 'as logon')->field('U.*')->JOIN('user', 'as U', 'logon.uid=U.id')->where('U.appid', $appid)->where('logon.token', $token)->find(); //false
|
||||
if (!$res_logon) out(127, $app_res); //TOKEN不存在或已失效
|
||||
if ($res_logon['ban'] > time() || $res_logon['ban'] == 999999999) out(114, $res_logon['ban_notice'], $app_res); //账号被禁用
|
||||
$user = !empty($res_logon['user']) ? $res_logon['user'] : (!empty($res_logon['email']) ? $res_logon['email'] : $res_logon['phone']);
|
||||
if ($res_kami['type'] == 'vip') {
|
||||
if ($res_logon['vip'] == '999999999') out(199, $app_res); //已经是永久会员了
|
||||
if ($res_logon['vip'] > time()) { //没有过期
|
||||
$vip = $res_logon['vip'] + 86400 * $res_kami['amount'];
|
||||
} else { //已过期
|
||||
$vip = time() + 86400 * $res_kami['amount'];
|
||||
}
|
||||
$res = Db::table('user')->where('id', $res_logon['id'])->update(['vip' => $vip]); //更新用户资料
|
||||
if ($res) {
|
||||
Db::table('kami')->where('id', $res_kami['id'])->update(['use_time' => time(), 'user' => $user]); //更新卡密信息
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_logon['id'], 'type' => $act, 'status' => 200, 'vip' => $res_kami['amount'], 'time' => time(), 'ip' => getip(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(200, '充值成功', $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_logon['id'], 'type' => $act, 'status' => 201, 'vip' => $res_kami['amount'], 'time' => time(), 'ip' => getip(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '充值失败', $app_res);
|
||||
}
|
||||
} elseif ($res_kami['type'] == 'fen') {
|
||||
$fen = $res_logon['fen'] + $res_kami['amount'];
|
||||
$res = Db::table('user')->where('id', $res_logon['id'])->update(['fen' => $fen]); //更新用户资料
|
||||
if ($res) {
|
||||
Db::table('kami')->where('id', $res_kami['id'])->update(['use_time' => time(), 'user' => $user]); //更新卡密信息
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_logon['id'], 'type' => $act, 'status' => 200, 'fen' => $res_kami['amount'], 'time' => time(), 'ip' => getip(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(200, '充值成功', $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_logon['id'], 'type' => $act, 'status' => 201, 'fen' => $res_kami['amount'], 'time' => time(), 'ip' => getip(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '充值失败', $app_res);
|
||||
}
|
||||
}
|
||||
} elseif (!empty($mainkm)) {
|
||||
$res_mainkm = Db::table('kami')->where('appid', $appid)->where('kami', $mainkm)->find(); //false
|
||||
if (!$res_mainkm) out(149, '主卡密不存在', $app_res); //卡密不存在
|
||||
if ($res_mainkm['state'] == 'n') out(151, '主卡密被禁用', $app_res); //卡密被禁用
|
||||
if ($res_kami['type'] != $res_mainkm['type']) out(152, '主卡密和充值卡密类型不一样', $app_res); //主卡密和充值卡密类型不一样
|
||||
if ($res_kami['type'] == 'vip') {
|
||||
if ($res_mainkm['end_time'] == '999999999') out(199, $app_res); //已经是永久会员了
|
||||
if ($res_mainkm['end_time'] > time()) { //没有过期
|
||||
$vip = $res_mainkm['end_time'] + 86400 * $res_kami['amount'];
|
||||
} else { //已过期
|
||||
$vip = time() + 86400 * $res_kami['amount'];
|
||||
}
|
||||
$res = Db::table('kami')->where('id', $res_mainkm['id'])->update(['end_time' => $vip]); //更新卡密信息
|
||||
if (!$res) out(201, '充值失败', $app_res);
|
||||
Db::table('kami')->where('id', $res_kami['id'])->update(['use_time' => time(), 'user' => $mainkm]); //更新卡密信息
|
||||
out(200, '充值成功', $app_res);
|
||||
} elseif ($res_kami['type'] == 'fen') {
|
||||
$fen = $res_mainkm['amount'] + $res_kami['amount'];
|
||||
$res = Db::table('kami')->where('id', $res_mainkm['id'])->update(['amount' => $fen]); //更新卡密信息
|
||||
if (!$res) out(201, '充值失败', $app_res);
|
||||
Db::table('kami')->where('id', $res_kami['id'])->update(['use_time' => time(), 'user' => $mainkm]); //更新卡密信息
|
||||
out(200, '充值成功', $app_res);
|
||||
}
|
||||
} else {
|
||||
out(201, '未知充值对象', $app_res);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/*
|
||||
Name:打卡签到
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['logon_way'] == 1) out(164, $app_res); //不是账号登录模式不允许使用当前操作
|
||||
$token = isset($data_arr['token']) && !empty($data_arr['token']) ? purge($data_arr['token']) : out(125, $app_res); //请输TOKEN
|
||||
$res_logon = Db::table('user_logon', 'as logon')->field('U.*')->JOIN('user', 'as U', 'logon.uid=U.id')->where('logon.appid', $appid)->where('U.appid', $appid)->where('logon.token', $token)->find(); //false
|
||||
if (!$res_logon) out(127, $app_res); //TOKEN不存在或已失效
|
||||
if ($res_logon['ban'] > time() || $res_logon['ban'] == 999999999) out(114, $res_logon['ban_notice'], $app_res); //账号被禁用
|
||||
Db::table('user_logon')->where('token', $token)->update(['last_t' => time()]); //记录活动时间
|
||||
if ($app_res['diary_award_num'] == 0) out(146, $app_res); //签到功能未启用
|
||||
$res = Db::table('log')->where(['uid' => $res_logon['id'], 'type' => $act])->where('time', 'between', [timeRange('t_a'), timeRange('t_b')])->find();
|
||||
if ($res) out(147, $app_res); //今天已经签到过了
|
||||
if ($app_res['diary_award'] == 'vip') {
|
||||
if ($res_logon['vip'] == '999999999') out(199, $app_res); //账号不存在
|
||||
if ($res_logon['vip'] > time()) {
|
||||
$vip = $res_logon['vip'] + 3600 * $res_fen['vip_num'];
|
||||
} else {
|
||||
$vip = time() + 3600 * $res_fen['vip_num'];
|
||||
}
|
||||
$res = Db::table('user')->where('id', $res_logon['id'])->update(['vip' => $vip]); //更新用户资料
|
||||
if (!$res) out(201, '签到失败', $app_res);
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_logon['id'], 'type' => $act, 'status' => 200, 'vip' => $app_res['diary_award_num'], 'time' => time(), 'ip' => getip(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(200, '签到成功', $app_res);
|
||||
} elseif ($app_res['diary_award'] == 'fen') {
|
||||
$fen = $res_logon['fen'] + $app_res['diary_award_num'];
|
||||
$res = Db::table('user')->where('id', $res_logon['id'])->update(['fen' => $fen]); //更新用户资料
|
||||
if (!$res) out(201, '签到失败', $app_res);
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_logon['id'], 'type' => $act, 'status' => 200, 'fen' => $app_res['diary_award_num'], 'time' => time(), 'ip' => getip(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(200, '签到成功', $app_res);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/*
|
||||
Name:邮箱绑定接口文件
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['reg_state'] == 'n') out(103, $app_res['reg_notice'], $app_res); //判断是否可注册
|
||||
if ($app_res['logon_way'] == 1) out(164, $app_res); //不是账号登录方式不允许使用当前操作
|
||||
$token = isset($data_arr['token']) && !empty($data_arr['token']) ? purge($data_arr['token']) : out(125, $app_res); //请输TOKEN
|
||||
$email = isset($data_arr['email']) && !empty($data_arr['email']) ? purge($data_arr['email']) : out(110, $app_res); //请输入账号
|
||||
$crc = isset($data_arr['crc']) && !empty($data_arr['crc']) ? intval($data_arr['crc']) : out(120, $app_res); //验证码为空
|
||||
$res_logon = Db::table('user_logon', 'as logon')->field('U.*')->JOIN('user', 'as U', 'logon.uid=U.id')->where('logon.appid', $appid)->where('U.appid', $appid)->where('logon.token', $token)->find(); //false
|
||||
if (!$res_logon) out(127, $app_res); //TOKEN不存在或已失效
|
||||
if ($res_logon['ban'] > time() || $res_logon['ban'] == 999999999) out(114, $res_logon['ban_notice'], $app_res); //账号被禁用
|
||||
Db::table('user_logon')->where('token', $token)->update(['last_t' => time()]); //记录活动时间
|
||||
if (!empty($res_logon['email'])) out(115, '当前账号已绑定邮箱,请解绑当前邮箱后绑定', $app_res); //已绑定邮箱
|
||||
if (!check_email($email)) out(116, '邮箱不合法', $app_res); //账号长度5~11位,不支持中文和特殊字符
|
||||
$res_user = Db::table('user')->where(['email' => $email, 'appid' => $appid])->find(); //false
|
||||
if ($res_user) out(115, '该邮箱已绑定其他账号', $app_res); //邮箱已绑定
|
||||
$res_code = Db::table('captcha')->where(['email' => $email, 'code' => $crc, 'new' => 'y', 'appid' => $appid])->order('id DESC')->find(); //false
|
||||
if (!$res_code) out(124, $app_res); //验证码不正确
|
||||
Db::table('captcha')->where('id', $res_code['id'])->update(['new' => 'n']);
|
||||
$res = Db::table('user')->where('id', $res_logon['id'])->update(['email' => $email]);
|
||||
if ($res) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_logon['id'], 'type' => $act, 'status' => 200, 'time' => time(), 'ip' => getip(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(200, '绑定成功', $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_logon['id'], 'type' => $act, 'status' => 201, 'time' => time(), 'ip' => getip(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '绑定失败', $app_res);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/*
|
||||
Name:邮箱注册接口文件
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['reg_state'] == 'n') out(103, $app_res['reg_notice'], $app_res); //判断是否可注册
|
||||
if ($app_res['logon_way'] == 1) out(164, $app_res); //不是账号登录方式不允许使用当前操作
|
||||
$name = isset($data_arr['name']) && !empty($data_arr['name']) ? purge($data_arr['name']) : '这个人没有名字!'; //昵称
|
||||
$email = isset($data_arr['email']) && !empty($data_arr['email']) ? purge($data_arr['email']) : out(110, $app_res); //请输入账号
|
||||
$crc = isset($data_arr['crc']) && !empty($data_arr['crc']) ? intval($data_arr['crc']) : out(120, $app_res); //验证码为空
|
||||
$pwd = isset($data_arr['password']) && !empty($data_arr['password']) ? purge($data_arr['password']) : out(111, $app_res); //请输入密码
|
||||
$inv = isset($data_arr['inv']) ? intval($data_arr['inv']) : 0; //邀请人
|
||||
$reg_in = isset($data_arr['markcode']) ? purge($data_arr['markcode']) : ''; //机器码
|
||||
if ($app_res['reg_inon'] > 0 && $reg_in == '') out(112, $app_res); //判断是否验证机器码
|
||||
$reg_ip = getIp(); //注册IP
|
||||
$reg_time = time(); //注册时间
|
||||
if (!check_email($email)) out(116, '邮箱不合法', $app_res); //账号长度5~11位,不支持中文和特殊字符
|
||||
if (preg_match("/^[a-zA-Z\d.*_-]{6,18}$/", $pwd) == 0) out(119, '密码长度需要满足6-18位数,不支持中文以及.-*_以外特殊字符', $app_res); //密码长度6~18位
|
||||
$res_user = Db::table('user')->where(['email' => $email, 'appid' => $appid])->find(); //false
|
||||
if ($res_user) out(115, $app_res); //账号已存在
|
||||
$res_code = Db::table('captcha')->where(['email' => $email, 'code' => $crc, 'new' => 'y', 'appid' => $appid])->order('id DESC')->find(); //false
|
||||
if (!$res_code) out(124, $app_res); //验证码不正确
|
||||
$reg_ipon = $app_res['reg_ipon']; //获取IP重复注册间隔
|
||||
if ($reg_ipon > 0) {
|
||||
$ip_time = $reg_time - $reg_ipon * 3600;
|
||||
$res = Db::table('user')->where(['appid' => $appid, 'reg_ip' => $reg_ip])->where('reg_time', '>', $ip_time)->find(); //寻找相同IP
|
||||
if ($res) out(117, $app_res); //该IP已注册
|
||||
}
|
||||
$reg_inon = $app_res['reg_inon']; //获取机器码重复注册间隔
|
||||
if ($reg_inon > 0) {
|
||||
$in_time = $reg_time - $reg_inon * 3600;
|
||||
$res = Db::table('user')->where(['appid' => $appid, 'reg_in' => $reg_in])->where('reg_time', '>', $in_time)->find(); //寻找相同机器码
|
||||
if ($res) out(117, $app_res); //该机器码已注册
|
||||
}
|
||||
if ($inv > 0) { //邀请人事件
|
||||
$res = Db::table('user')->where('id', $inv)->where('appid', $appid)->find(); //查询邀请者ID
|
||||
if (!$res) out(118, $app_res); //邀请人已存在
|
||||
$inv_award = $app_res['inv_award']; //奖励类型
|
||||
$inv_award_num = $app_res['inv_award_num']; //邀请奖励数
|
||||
if ($inv_award_num > 0) {
|
||||
if ($inv_award == 'vip' && $res['vip'] != 999999999) { //奖励类型是VIP
|
||||
if ($res['vip'] > $reg_time) { //VIP没有过期
|
||||
$vip = $res['vip'] + 3600 * $inv_award_num;
|
||||
} else { //VIP已过期
|
||||
$vip = $reg_time + 3600 * $inv_award_num;
|
||||
}
|
||||
$inv_res = Db::table('user')->where('id', $inv)->update(['vip' => $vip]); //更新邀请人VIP数据
|
||||
if ($inv_res) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $inv, 'status' => 200, 'type' => 'inv', 'time' => $reg_time, 'ip' => $reg_ip, 'vip' => $inv_award_num, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $inv, 'status' => 201, 'type' => 'inv', 'time' => $reg_time, 'ip' => $reg_ip, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
}
|
||||
} else if ($inv_award == 'fen') {
|
||||
$fen = $res['fen'] + $inv_award_num;
|
||||
$inv_res = Db::table('user')->where('id', $inv)->update(['fen' => $fen]); //更新邀请人积分数据
|
||||
if ($inv_res) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $inv, 'status' => 200, 'type' => 'inv', 'time' => $reg_time, 'ip' => $reg_ip, 'fen' => $inv_award_num, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $inv, 'status' => 201, 'type' => 'inv', 'time' => $reg_time, 'ip' => $reg_ip, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$reg_award = $app_res['reg_award']; //奖励类型
|
||||
$reg_award_num = $app_res['reg_award_num']; //注册奖励
|
||||
if ($reg_award_num > 0) {
|
||||
if ($reg_award == 'vip') {
|
||||
$vip = $reg_time + 60 * $reg_award_num;
|
||||
$add_res = Db::table('user')->add(['name' => $name, 'email' => $email, 'pwd' => md5($pwd), 'vip' => $vip, 'inv' => $inv, 'reg_in' => $reg_in, 'reg_ip' => $reg_ip, 'reg_time' => $reg_time, 'appid' => $appid]);
|
||||
} else {
|
||||
$add_res = Db::table('user')->add(['name' => $name, 'email' => $email, 'pwd' => md5($pwd), 'fen' => $reg_award_num, 'inv' => $inv, 'reg_in' => $reg_in, 'reg_ip' => $reg_ip, 'reg_time' => $reg_time, 'appid' => $appid]);
|
||||
}
|
||||
} else {
|
||||
$add_res = Db::table('user')->add(['name' => $name, 'email' => $email, 'pwd' => md5($pwd), 'inv' => $inv, 'reg_in' => $reg_in, 'reg_ip' => $reg_ip, 'reg_time' => $reg_time, 'appid' => $appid]);
|
||||
}
|
||||
Db::table('captcha')->where('id', $res_code['id'])->update(['new' => 'n']);
|
||||
if ($add_res) {
|
||||
out(200, '注册成功', $app_res);
|
||||
}
|
||||
out(201, '注册失败', $app_res);
|
||||
?>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
Name:邮箱解绑
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['reg_state'] == 'n') out(103, $app_res['reg_notice'], $app_res); //判断是否可注册
|
||||
if ($app_res['logon_way'] == 1) out(164, $app_res); //不是账号登录方式不允许使用当前操作
|
||||
$token = isset($data_arr['token']) && !empty($data_arr['token']) ? purge($data_arr['token']) : out(125, $app_res); //请输TOKEN
|
||||
$crc = isset($data_arr['crc']) && !empty($data_arr['crc']) ? intval($data_arr['crc']) : out(120, $app_res); //验证码为空
|
||||
$res_logon = Db::table('user_logon', 'as logon')->field('U.*')->JOIN('user', 'as U', 'logon.uid=U.id')->where('logon.appid', $appid)->where('U.appid', $appid)->where('logon.token', $token)->find(); //false
|
||||
if (!$res_logon) out(127, $app_res); //TOKEN不存在或已失效
|
||||
if ($res_logon['ban'] > time() || $res_logon['ban'] == 999999999) out(114, $res_logon['ban_notice'], $app_res); //账号被禁用
|
||||
Db::table('user_logon')->where('token', $token)->update(['last_t' => time()]); //记录活动时间
|
||||
if (empty($res_logon['user']) && empty($res_logon['phone'])) out(110, '没有账号不可以解绑邮箱', $app_res); //没有账号不可以解绑
|
||||
if (empty($res_logon['email'])) out(165, $app_res); //没有绑定
|
||||
$res_code = Db::table('captcha')->where(['email' => $res_logon['email'], 'code' => $crc, 'new' => 'y', 'appid' => $appid])->order('id DESC')->find(); //false
|
||||
if (!$res_code) out(124, $app_res); //验证码不正确
|
||||
Db::table('captcha')->where('id', $res_code['id'])->update(['new' => 'n']);
|
||||
$res = Db::table('user')->where('id', $res_logon['id'])->update(['email' => '']);
|
||||
if ($res) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_logon['id'], 'type' => $act, 'status' => 200, 'time' => time(), 'ip' => getip(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(200, '解绑成功', $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_logon['id'], 'type' => $act, 'status' => 201, 'time' => time(), 'ip' => getip(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '解绑失败', $app_res);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/*
|
||||
Name:获取启动配置
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
$ret = [];
|
||||
$app_exten_res = Db::table('app_exten')->where(['appid' => $appid, 'state' => 'y'])->order('id desc')->select(); //获取扩展配置
|
||||
if (is_array($app_exten_res)) {
|
||||
foreach ($app_exten_res as $k => $v) {
|
||||
$rows = $app_exten_res[$k];
|
||||
if ($rows['data'] != null && $rows['data'] != "") {
|
||||
if (strpos($rows['data'], ",")) {
|
||||
$data = explode(",", $rows['data']);
|
||||
$flags["flag"] = $data;
|
||||
} else {
|
||||
$flags["flag"] = $rows['data'];
|
||||
}
|
||||
}
|
||||
if ($rows['header'] != null && $rows['header'] != "") {
|
||||
$flags["header"] = [
|
||||
"User-Agent" => $rows['header']
|
||||
];
|
||||
}
|
||||
$ret[] = [
|
||||
'name' => $rows['name'],
|
||||
'type' => $rows['type'],
|
||||
'url' => $rows['api'],
|
||||
'ext' => json_encode($flags, 320),
|
||||
];
|
||||
}
|
||||
encryptionout(200, $ret, $app_res);
|
||||
}
|
||||
out(201, '自定义接口失败', $app_res);
|
||||
?>
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/*
|
||||
Name:积分验证
|
||||
Version:1.1
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['logon_way'] == 1) out(164, $app_res); //不是账号登录方式不允许使用当前操作
|
||||
$token = isset($data_arr['token']) && !empty($data_arr['token']) ? purge($data_arr['token']) : out(125, $app_res); //请输TOKEN
|
||||
$fid = isset($data_arr['fid']) && !empty($data_arr['fid']) ? intval($data_arr['fid']) : out(143, $app_res); //请输填写积分事件ID
|
||||
$mark = isset($data_arr['mark']) ? purge($data_arr['mark']) : ''; //积分事件标记
|
||||
$res_logon = Db::table('user_logon', 'as logon')->field('U.*')->JOIN('user', 'as U', 'logon.uid=U.id')->where('logon.appid', $appid)->where('U.appid', $appid)->where('logon.token', $token)->find(); //false
|
||||
if (!$res_logon) out(127, $app_res); //TOKEN不存在或已失效
|
||||
if ($res_logon['ban'] > time() || $res_logon['ban'] == 999999999) out(114, $res_logon['ban_notice'], $app_res); //账号被禁用
|
||||
Db::table('user_logon')->where('token', $token)->update(['last_t' => time()]); //记录活动时间
|
||||
$res_fen = Db::table('fen')->where('id', $fid)->find(); //false
|
||||
if (!$res_fen) out(144, $app_res); //积分事件不存在
|
||||
if ($res_fen['state'] == 'n') out(145, $app_res); //积分事件已关闭
|
||||
if ($app_res['mode'] == 'y') { //判断当前收费模式
|
||||
if ($res_fen['vip_num'] > 0) { //兑换会员
|
||||
if ($res_logon['vip'] == '999999999') out(199, $app_res); //已经是永久会员了
|
||||
$surplus = $res_logon['fen'] + $res_fen['fen_num'];
|
||||
if ($surplus >= 0) { //积分正常
|
||||
if ($res_logon['vip'] > time()) {
|
||||
$vip = $res_logon['vip'] + 3600 * $res_fen['vip_num'];
|
||||
} else {
|
||||
$vip = time() + 3600 * $res_fen['vip_num'];
|
||||
}
|
||||
$res = Db::table('user')->where('id', $res_logon['id'])->update(['fen' => $surplus, 'vip' => $vip]); //更新用户资料
|
||||
if (!$res) out(201, '扣除积分失败', $app_res);
|
||||
Db::table('fen_order')->add(['fid' => $fid, 'uid' => $res_logon['id'], 'time' => time()]); //添加积分订单
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_logon['id'], 'type' => $act, 'fen' => $res_fen['fen_num'], 'vip' => $res_logon['vip'], 'status' => 200, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]); //记录日志
|
||||
}
|
||||
out(200, '验证成功', $app_res);
|
||||
} else {
|
||||
out(201, '积分不足', $app_res);
|
||||
}
|
||||
} else {
|
||||
if (empty($mark)) { //为空每次扣分
|
||||
$surplus = $res_logon['fen'] + $res_fen['fen_num'];
|
||||
if ($surplus >= 0) { //积分正常
|
||||
$res = Db::table('user')->where('id', $res_logon['id'])->update(['fen' => $surplus]); //更新用户资料
|
||||
if (!$res) out(201, '扣除积分失败', $app_res);
|
||||
Db::table('fen_order')->add(['fid' => $fid, 'uid' => $res_logon['id'], 'time' => time()]); //添加积分订单
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_logon['id'], 'type' => $act, 'fen' => $res_fen['fen_num'], 'status' => 200, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(200, '验证成功', $app_res);
|
||||
} else {
|
||||
out(201, '积分不足', $app_res);
|
||||
}
|
||||
} else {
|
||||
$res = Db::table('fen_order')->where(['fid' => $fid, 'uid' => $res_logon['id'], 'mark' => $mark])->find(); //false
|
||||
if ($res) out(200, '验证成功1', $app_res);
|
||||
$surplus = $res_logon['fen'] + $res_fen['fen_num'];
|
||||
if ($surplus >= 0) { //积分正常
|
||||
$res = Db::table('user')->where('id', $res_logon['id'])->update(['fen' => $surplus]); //更新用户资料
|
||||
if (!$res) out(201, '扣除积分失败', $app_res);
|
||||
$res = Db::table('fen_order')->add(['fid' => $fid, 'uid' => $res_logon['id'], 'mark' => $mark, 'time' => time()]); //添加积分订单
|
||||
if (!$res) out(201, '验证失败', $app_res);
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_logon['id'], 'type' => $act, 'fen' => $res_fen['fen_num'], 'status' => 200, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(200, '验证成功', $app_res);
|
||||
} else {
|
||||
out(201, '积分不足', $app_res);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($res_fen['vip_num'] > 0) {
|
||||
out(201, '免费模式无需兑换VIP', $app_res);
|
||||
} else {
|
||||
out(200, '验证成功', $app_res);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/*
|
||||
Name:获取全部积分事件
|
||||
Version:1.1
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
$ret = [];
|
||||
$fen_res = Db::table('fen')->where(['appid' => $appid, 'state' => 'y'])->select(); //获取积分事件
|
||||
if (is_array($fen_res)) {
|
||||
foreach ($fen_res as $k => $v) {
|
||||
$rows = $fen_res[$k];
|
||||
if ($rows['name'] != "签到") {
|
||||
$ret[] = [
|
||||
'id' => $rows['id'],
|
||||
'appid' => $rows['appid'],
|
||||
'name' => $rows['name'],
|
||||
'fen_num' => $rows['fen_num'],
|
||||
'vip_num' => $rows['vip_num'],
|
||||
'state' => $rows['state']
|
||||
];
|
||||
}
|
||||
}
|
||||
out(200, $ret, $app_res);
|
||||
}
|
||||
out(201, '商品读取失败', $app_res);
|
||||
?>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/*
|
||||
Name:获取用户信息
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['logon_way'] == 1) out(164, $app_res); //不是账号登录方式不允许使用当前操作
|
||||
$token = isset($data_arr['token']) && !empty($data_arr['token']) ? purge($data_arr['token']) : out(125, $app_res); //请输TOKEN
|
||||
$res_logon = Db::table('user_logon', 'as logon')->field('U.*')->JOIN('user', 'as U', 'logon.uid=U.id')->where('U.appid', $appid)->where('logon.token', $token)->find(); //false
|
||||
if (!$res_logon) out(127, $app_res); //TOKEN不存在或已失效
|
||||
if ($res_logon['ban'] > time() || $res_logon['ban'] == 999999999) out(114, $res_logon['ban_notice'], $app_res); //账号被禁用
|
||||
Db::table('user_logon')->where('token', $token)->update(['last_t' => time()]); //记录活动时间
|
||||
if ($app_res['mode'] == 'y') {
|
||||
$vip = $res_logon['vip'];
|
||||
} else {
|
||||
$vip = '999999999';
|
||||
} //判断当前收费模式
|
||||
if ($app_res['diary_award_num'] > 0) {
|
||||
$res = Db::table('log')->where(['uid' => $res_logon['id'], 'type' => 'clock'])->where('time', 'between', [timeRange('t_a'), timeRange('t_b')])->find();
|
||||
$diary = ($res) ? 'n' : 'y';
|
||||
} else {
|
||||
$diary = 'y';
|
||||
}
|
||||
$user_info = [
|
||||
'id' => $res_logon['id'],
|
||||
'pic' => get_pic($res_logon['pic']),
|
||||
'user' => $res_logon['user'],
|
||||
'email' => $res_logon['email'],
|
||||
'phone' => $res_logon['phone'],
|
||||
'name' => $res_logon['name'],
|
||||
'vip' => $vip,
|
||||
'fen' => $res_logon['fen'],
|
||||
'kam' => $res_logon['kam'],
|
||||
'inv' => $res_logon['inv'],
|
||||
'diary' => $diary,
|
||||
'openid_wx' => $res_logon['openid_wx'],
|
||||
'openid_qq' => $res_logon['openid_qq']
|
||||
];
|
||||
out(200, $user_info, $app_res);
|
||||
?>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/*
|
||||
Name:验证会员
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['logon_way'] == 1) out(164, $app_res); //不是账号登录方式不允许使用当前操作
|
||||
$token = isset($data_arr['token']) && !empty($data_arr['token']) ? purge($data_arr['token']) : out(125, $app_res); //请输TOKEN
|
||||
$res_logon = Db::table('user_logon', 'as logon')->field('U.*')->JOIN('user', 'as U', 'logon.uid=U.id')->where('logon.appid', $appid)->where('U.appid', $appid)->where('logon.token', $token)->find(); //false
|
||||
if (!$res_logon) out(127, $app_res); //TOKEN不存在或已失效
|
||||
if ($res_logon['ban'] > time() || $res_logon['ban'] == 999999999) out(114, $res_logon['ban_notice'], $app_res); //账号被禁用
|
||||
Db::table('user_logon')->where('token', $token)->update(['last_t' => time()]); //记录活动时间
|
||||
if ($app_res['mode'] == 'y') { //判断当前收费模式
|
||||
if ($res_logon['vip'] == '999999999' or $res_logon['vip'] > time()) {
|
||||
out(200, '验证成功', $app_res);
|
||||
} else {
|
||||
out(201, '验证失败', $app_res);
|
||||
}
|
||||
} else {
|
||||
out(200, '验证成功', $app_res);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/*
|
||||
Name:获取商品
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['logon_way'] == 1) out(164, $app_res); //不是账号登录方式不允许使用当前操作
|
||||
$ret = [];
|
||||
$site_res = Db::table('goods')->where(['appid' => $appid, 'state' => 'y'])->select(); //获取商品列表
|
||||
if (is_array($site_res)) {
|
||||
foreach ($site_res as $k => $v) {
|
||||
$rows = $site_res[$k];
|
||||
$ret[] = [
|
||||
'gid' => $rows['id'],
|
||||
'gname' => $rows['name'],
|
||||
'gmoney' => $rows['money'],
|
||||
'gtype' => $rows['type'],
|
||||
'obtain' => $rows['amount'],
|
||||
'cv' => $rows['jie']
|
||||
];
|
||||
}
|
||||
out(200, $ret, $app_res);
|
||||
}
|
||||
out(201, '商品读取失败', $app_res);
|
||||
?>
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/*
|
||||
Name:获取首页广告配置
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
$app_homead = [];
|
||||
$app_homead_res = Db::table('app_homead')->where('appid', $appid)->order('id desc')->select(); //获取首页广告配置
|
||||
if (is_array($app_homead_res)) {
|
||||
foreach ($app_homead_res as $k => $v) {
|
||||
$rows = $app_homead_res[$k];
|
||||
$app_homead[] = [
|
||||
'name' => $rows['name'],
|
||||
'extend' => $rows['data'],
|
||||
'searchable' => $rows['searchable']
|
||||
];
|
||||
}
|
||||
encryptionout(200, $app_homead, $app_res);
|
||||
}
|
||||
out(201, '自定义接口获取失败', $app_res);
|
||||
?>
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/*
|
||||
Name:获取配置
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['app_json'] == null || $app_res['app_json'] == "") {
|
||||
$app_res['app_json'] = "http://" . $_SERVER['SERVER_NAME'] . "/app/api.json";
|
||||
}
|
||||
$ini_data = [ //基本配置
|
||||
'app_bb' => $app_res['app_bb'],
|
||||
'app_nshow' => $app_res['app_nshow'],
|
||||
'app_nurl' => $app_res['app_nurl'],
|
||||
'mode' => $app_res['mode'],
|
||||
'ui_state' => $app_res['ui_state'],
|
||||
'ui_logo' => $app_res['ui_logo'],
|
||||
'ui_startad' => $app_res['ui_startad'],
|
||||
'kami_url' => $app_res['kami_url'],
|
||||
'app_json' => $app_res['app_json'],
|
||||
'app_jsonb' => $app_res['app_jsonb'],
|
||||
'app_huodong' => $app_res['app_huodong'],
|
||||
'logon_way' => $app_res['logon_way'],
|
||||
'ui_paybackg' => $app_res['ui_paybackg'],
|
||||
'ui_kefu' => $app_res['ui_kefu'],
|
||||
'ui_group' => $app_res['ui_group'],
|
||||
'ui_button3backg' => $app_res['ui_button3backg'],
|
||||
'ui_buttonadimg' => $app_res['ui_buttonadimg'],
|
||||
'ui_community' => $app_res['ui_community'],
|
||||
'ui_removersc' => $app_res['ui_removersc'],
|
||||
'ui_remove_parses' => $app_res['ui_remove_parses'],
|
||||
'ui_remove_class' => $app_res['ui_remove_class'],
|
||||
'ui_parse_name' => $app_res['ui_parse_name'],
|
||||
'app_about' => $app_res['app_about']
|
||||
];
|
||||
if (isset($_GET['pay'])) {
|
||||
$pay_ini = [
|
||||
'state' => $app_res['pay_state'],
|
||||
'url' => $app_res['pay_url'],
|
||||
'appid' => $app_res['pay_id'],
|
||||
'appkey' => $app_res['pay_key'],
|
||||
'ali' => $app_res['pay_ali_state'],
|
||||
'wx' => $app_res['pay_wx_state'],
|
||||
'qq' => $app_res['pay_qq_state']
|
||||
];
|
||||
}
|
||||
if (isset($pay_ini) && is_array($pay_ini)) {
|
||||
$ini_data = array_merge($ini_data, ['pay' => $pay_ini]);
|
||||
}
|
||||
encryptionout(200, $ini_data);
|
||||
?>
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/*
|
||||
Name:卡密登录
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['logon_state'] == 'n') out(103, $app_res['logon_notice'], $app_res); //判断是否可登录
|
||||
if ($app_res['logon_way'] != 1) out(163, $app_res); //不是设置卡密登录的话不允许卡密登录
|
||||
$kami = isset($data_arr['kami']) && !empty($data_arr['kami']) ? purge($data_arr['kami']) : out(148, $app_res); //卡密为空
|
||||
$res_kami = Db::table('kami')->where('appid', $appid)->where('kami', $kami)->find(); //false
|
||||
if (!$res_kami) out(149, $app_res); //卡密不存在
|
||||
if (!empty($res_kami['user'])) out(150, $app_res); //卡密已使用
|
||||
if ($res_kami['state'] == 'n') out(151, $app_res); //卡密禁用
|
||||
if ($res_kami['type'] == 'vip') {
|
||||
if (empty($res_kami['use_time'])) { //全新的卡密
|
||||
if ($res_kami['amount'] == 999999999) {
|
||||
$vip = $res_kami['amount'];
|
||||
} else {
|
||||
$vip = time() + 86400 * $res_kami['amount'];
|
||||
}
|
||||
$res = Db::table('kami')->where('id', $res_kami['id'])->update(['use_time' => time(), 'end_time' => $vip]); //更新卡密信息
|
||||
if (!$res) out(201, '登录失败,请重试', $app_res);
|
||||
$kami_info = [
|
||||
'kami' => $kami,
|
||||
'vip' => $vip
|
||||
];
|
||||
} elseif ($res_kami['end_time'] == '999999999' or $res_kami['end_time'] > time()) {
|
||||
$kami_info = [
|
||||
'kami' => $kami,
|
||||
'vip' => $res_kami['end_time']
|
||||
];
|
||||
} else {
|
||||
out(201, '卡密已到期', $app_res);
|
||||
}
|
||||
out(200, $kami_info, $app_res);
|
||||
} else {
|
||||
out(167, $app_res); //不支持积分卡登录
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/*
|
||||
Name:卡密登录
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
$kami = isset($data_arr['kami']) && !empty($data_arr['kami']) ? purge($data_arr['kami']) : out(148, $app_res); //卡密为空
|
||||
$res_kami = Db::table('kami')->where('appid', $appid)->where('kami', $kami)->find(); //false
|
||||
if (!$res_kami) out(149, $app_res); //卡密不存在
|
||||
out(200, $res_kami, $app_res);
|
||||
?>
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/*
|
||||
Name:获取屏保配置
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
$app_level = [];
|
||||
$app_level_res = Db::table('app_level')->where('appid', $appid)->order('id desc')->select(); //获取屏保配置
|
||||
if (is_array($app_level_res)) {
|
||||
foreach ($app_level_res as $k => $v) {
|
||||
$rows = $app_level_res[$k];
|
||||
$app_level[] = [
|
||||
'name' => $rows['name'],
|
||||
'extend' => $rows['data'],
|
||||
'searchable' => $rows['searchable']
|
||||
];
|
||||
}
|
||||
encryptionout(200, $app_level, $app_res);
|
||||
}
|
||||
out(201, '自定义接口获取失败', $app_res);
|
||||
?>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/*
|
||||
Name:删除系统日志
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
$log_key = isset($_GET['key']) && !empty($_GET['key']) ? purge($_GET['key']) : json(201, '秘钥为空'); //没有秘钥不允许访问
|
||||
if (defined('LOG_DEL') && LOG_DEL > 0) {
|
||||
if ($log_key != LOG_KEY) json(200, 'KEY有误');
|
||||
$res = Db::table('log')->where('time', '<', time() - (LOG_DEL * 86400))->del(); //false
|
||||
if ($res == 0 || $res == true) {
|
||||
json(200, '执行成功');
|
||||
}
|
||||
json(201, '执行失败');
|
||||
}
|
||||
json(201, '未开启日志清除功能');
|
||||
?>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/*
|
||||
Name:运动/心跳
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['logon_way'] == 1) out(164, $app_res); //不是账号登录方式不允许使用当前操作
|
||||
$token = isset($data_arr['token']) && !empty($data_arr['token']) ? purge($data_arr['token']) : out(125, $app_res); //请输TOKEN
|
||||
$res_logon = Db::table('user_logon', 'as logon')->field('U.*')->JOIN('user', 'as U', 'logon.uid=U.id')->where('logon.appid', $appid)->where('U.appid', $appid)->where('logon.token', $token)->find(); //false
|
||||
if (!$res_logon) out(127, $app_res); //TOKEN不存在或已失效
|
||||
if ($res_logon['ban'] > time() || $res_logon['ban'] == 999999999) out(114, $res_logon['ban_notice'], $app_res); //账号被禁用
|
||||
$res = Db::table('user_logon')->where('token', $token)->update(['last_t' => time()]); //记录活动时间
|
||||
if ($res) {
|
||||
out(200, $app_res);
|
||||
} else {
|
||||
out(201, $app_res);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/*
|
||||
Name:获取通知
|
||||
Version:1.1
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
$pg = isset($data_arr['pg']) ? intval($data_arr['pg']) : 1;
|
||||
$bnums = ($pg - 1) * $ENUMS;
|
||||
$ret = [];
|
||||
$notice_res = Db::table('app_notice')->where('appid', $appid)->order('id desc')->limit($bnums, $ENUMS)->select(); //获取通知列表
|
||||
if (is_array($notice_res)) {
|
||||
foreach ($notice_res as $k => $v) {
|
||||
$rows = $notice_res[$k];
|
||||
$ret[] = [
|
||||
'content' => $rows['content'],
|
||||
'date' => date("Y-m-d H:i:s", $rows['time']),
|
||||
'name' => $rows['adm']
|
||||
];
|
||||
}
|
||||
out(200, $ret, $app_res);
|
||||
}
|
||||
out(201, '通知列表加载失败', $app_res);
|
||||
?>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/*
|
||||
Name:订单调查
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['logon_way'] == 1) out(164, $app_res); //不是账号登录方式不允许使用当前操作
|
||||
$oin = isset($data_arr['oin']) && !empty($data_arr['oin']) ? purge($data_arr['oin']) : out(140, $app_res); //订单信息,可以是订单号也可以是用户账号
|
||||
$order = Db::table('goods_order', 'as O')->field('O.*,U.user,U.email,U.phone,G.appid,G.type,G.amount')->JOIN("goods", "as G", 'O.gid=G.id')->JOIN("user", 'as U', 'O.Uid=U.id');
|
||||
$order_res = $order->where(['G.appid' => $appid], '(', ')')->where('(O.order', $oin)->whereOr(['U.user' => $oin, 'U.email' => $oin, 'U.phone' => $oin], ')')->order('id desc')->select(); //false
|
||||
$ret = [];
|
||||
if (is_array($order_res)) {
|
||||
foreach ($order_res as $k => $v) {
|
||||
$rows = $order_res[$k];
|
||||
$ret[] = [
|
||||
'order' => $rows['order'],
|
||||
'gname' => $rows['name'],
|
||||
'gmoney' => $rows['money'],
|
||||
'gtype' => $rows['type'],
|
||||
'obtain' => $rows['amount'],
|
||||
'otime' => $rows['o_time'],
|
||||
'ptime' => $rows['p_time'],
|
||||
'ptype' => $rows['p_type'],
|
||||
'state' => $rows['state']
|
||||
];
|
||||
}
|
||||
out(200, $ret, $app_res);
|
||||
}
|
||||
out(201, '订单查询失败', $app_res);
|
||||
?>
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/*
|
||||
Name:支付
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['logon_way'] == 1) out(164, $app_res); //不是账号登录方式不允许使用当前操作
|
||||
$ua = isset($data_arr['ua']) && !empty($data_arr['ua']) ? intval($data_arr['ua']) : 0; //0=pc(电脑扫码),1=H5(手机唤起),2=如意支付
|
||||
$order = isset($data_arr['order']) && !empty($data_arr['order']) ? purge($data_arr['order']) : return_code(130, $app_res, $ua); //订单号为空
|
||||
$user = isset($data_arr['account']) ? purge($data_arr['account']) : ''; //请输入账号
|
||||
$token = isset($data_arr['token']) ? purge($data_arr['token']) : ''; //请输TOKEN
|
||||
$way = isset($data_arr['way']) && !empty($data_arr['way']) ? purge($data_arr['way']) : return_code(131, $app_res, $ua); //支付方式
|
||||
$gid = isset($data_arr['gid']) && !empty($data_arr['gid']) ? purge($data_arr['gid']) : return_code(132, $app_res, $ua); //商品ID
|
||||
$res_goods_order = Db::table('goods_order')->where(['`order`' => $order])->find(); //false
|
||||
if ($res_goods_order) return_code(168, $app_res, $ua); //订单已存在
|
||||
if ($app_res['pay_state'] == 'n' or empty($app_res['pay_url']) or empty($app_res['pay_id']) or empty($app_res['pay_key'])) return_code(133, $app_res, $ua); //判断是否可支付
|
||||
if (empty($app_res['pay_notify'])) return_code(134, $app_res, $ua); //没有设置异步通知地址
|
||||
if ($way == 'ali' && $app_res['pay_ali_state'] == 'n') return_code(135, $app_res, $ua); //不支持该支付方式
|
||||
if ($way == 'wx' && $app_res['pay_wx_state'] == 'n') return_code(135, $app_res, $ua); //不支持该支付方式
|
||||
if ($way == 'qq' && $app_res['pay_qq_state'] == 'n') return_code(135, $app_res, $ua); //不支持该支付方式
|
||||
$res_goods = Db::table('goods')->where(['id' => $gid, 'appid' => $appid])->find(); //false
|
||||
if (!$res_goods) return_code(136, $app_res, $ua); //商品不存在
|
||||
if (!empty($user)) {
|
||||
$res_user = Db::table('user')->where(['appid' => $appid], "(", ")")->where('(user', $user)->whereOr(['email' => $user, 'phone' => $user], ")")->find(); //false
|
||||
if (!$res_user) return_code(122, $app_res, $ua); //账号不存在
|
||||
if ($res_user['ban'] > time() || $res_user['ban'] == 999999999) return_code(114, $app_res, $ua, $res_user['ban_notice']); //账号被禁用
|
||||
} elseif (!empty($token)) {
|
||||
$res_logon = Db::table('user_logon', 'as logon')->field('U.*')->JOIN('user', 'as U', 'logon.uid=U.id')->where('U.appid', $appid)->where('logon.token', $token)->find(); //false
|
||||
if (!$res_logon) out(127, $app_res); //TOKEN不存在或已失效
|
||||
if ($res_logon['ban'] > time() || $res_logon['ban'] == 999999999) return_code(114, $app_res, $ua, $res_logon['ban_notice']); //账号被禁用
|
||||
$res_user['id'] = $res_logon['id'];
|
||||
} else {
|
||||
return_code(110, $app_res, $ua);
|
||||
}
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 200, 'time' => time(), 'ip' => getip(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
$o_info = 'money=' . $res_goods['money'] . '&name=' . $res_goods['name'] . '¬ify_url=' . $app_res['pay_notify'] . '&out_trade_no=' . $order . '&pid=' . $app_res['pay_id'] . '&return_url=' . WEB_URL . '/order.php&sitename=' . $app_res['name'] . '&type=' . $way . 'pay';
|
||||
$sign = md5Sign($o_info, $app_res['pay_key']);
|
||||
$add_res = Db::table('goods_order')->add(['order' => $order, 'uid' => $res_user['id'], 'gid' => $gid, 'name' => $res_goods['name'], 'money' => $res_goods['money'], 'o_time' => time(), 'p_type' => $way]); //订单入库
|
||||
if (!$add_res) return_code(137, $app_res, $ua); //订单入库失败
|
||||
$data = $o_info . '&sign=' . $sign . '&sign_type=MD5';
|
||||
if ($app_res['pay_url'])
|
||||
if (strstr($app_res['pay_url'], 'submit.php')) {
|
||||
$pay_url = $app_res['pay_url'];
|
||||
} else {
|
||||
$pay_url = $app_res['pay_url'] . '/submit.php';
|
||||
}
|
||||
if ($ua == 1 or $ua == 2) {
|
||||
$retdata = http_post($pay_url, $data, 'User-Agent: Mozilla/5.0 (Linux; U; Android 8.1.0; zh-cn; BLA-AL00 Build/HUAWEIBLA-AL00) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 MQQBrowser/8.9 Mobile Safari/537.36');
|
||||
} else {
|
||||
$retdata = http_post($pay_url, $data);
|
||||
}
|
||||
if (strstr($retdata, '站点提示信息')) {
|
||||
if (preg_match("/<h3>站点提示信息<\/h3>.*?<\/body>/", $retdata, $ts)) {
|
||||
$erro_ts = txt_zhong($ts[0], "</h3>", '</body>');
|
||||
return_code(138, $app_res, $ua, $erro_ts);
|
||||
} else {
|
||||
return_code(139, $app_res, $ua);
|
||||
}
|
||||
}
|
||||
echo $retdata;
|
||||
return;
|
||||
function return_code($code, $app, $ua, $msg = '')
|
||||
{
|
||||
if ($ua == 2) {
|
||||
echo "<script>location.href='?code=" . $code . "';</script>";
|
||||
return;
|
||||
} else {
|
||||
out($code, $msg, $app);
|
||||
}
|
||||
}
|
||||
function md5Sign($prestr, $key)
|
||||
{
|
||||
$prestr = $prestr . $key;
|
||||
return md5($prestr);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/*
|
||||
Name:支付结果
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['logon_way'] == 1) out(164, $app_res); //不是账号登录方式不允许使用当前操作
|
||||
$oid = isset($data_arr['oid']) && !empty($data_arr['oid']) ? purge($data_arr['oid']) : out(130); //订单信息,可以是订单号也可以是用户账号
|
||||
$order_res = Db::table('goods_order', 'as O')->field('O.state')->where('O.order', $oid)->find();
|
||||
if (!$order_res) out(153);
|
||||
if ($order_res['state'] == 0) {
|
||||
out(154); //等待支付
|
||||
} else if ($order_res['state'] == 2) {
|
||||
out(200); //充值成功
|
||||
} else if ($order_res['state'] == 1) {
|
||||
out(201); //充值失败
|
||||
} else {
|
||||
out(155); //未知订单状态
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/*
|
||||
Name:QQ绑定
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['logon_way'] == 1) out(164, $app_res); //不是账号登录方式不允许使用当前操作
|
||||
$token = isset($data_arr['token']) && !empty($data_arr['token']) ? purge($data_arr['token']) : out(125, $app_res); //请输TOKEN
|
||||
$openid = isset($data_arr['openid']) && !empty($data_arr['openid']) ? purge($data_arr['openid']) : out(157, $app_res); //请输入openid
|
||||
$access_token = isset($data_arr['access_token']) && !empty($data_arr['access_token']) ? purge($data_arr['access_token']) : out(157, $app_res); //请输入access_token
|
||||
$qqappid = isset($data_arr['qqappid']) && !empty($data_arr['qqappid']) ? purge($data_arr['qqappid']) : out(161, $app_res); //请输入QQ互联ID
|
||||
$res_logon = Db::table('user_logon', 'as logon')->field('U.*')->JOIN('user', 'as U', 'logon.uid=U.id')->where('logon.appid', $appid)->where('U.appid', $appid)->where('logon.token', $token)->find(); //false
|
||||
if (!$res_logon) out(127, $app_res); //TOKEN不存在或已失效
|
||||
if ($res_logon['ban'] > time() || $res_logon['ban'] == 999999999) out(114, $res_logon['ban_notice'], $app_res); //账号被禁用
|
||||
Db::table('user_logon')->where('token', $token)->update(['last_t' => time()]); //记录活动时间
|
||||
$res_qq = Db::table('user')->where(['openid_qq' => $openid, 'appid' => $appid])->find(); //false
|
||||
if ($res_qq) out(160, $app_res); //已绑定其他账号
|
||||
$get_data = ['access_token' => $access_token, 'openid' => $openid, 'oauth_consumer_key' => $qqappid, 'format' => 'json'];
|
||||
$qq_data = http_gets('https://graph.qq.com/user/get_user_info', $get_data);
|
||||
if (!$qq_data) out(162, $app_res);
|
||||
$json_qq = json_decode($qq_data, true);
|
||||
if (isset($json_qq['errcode'])) out(158, $app_res); //错误的身份信息
|
||||
$res = Db::table('user')->where('id', $res_logon['id'])->update(['openid_qq' => $openid]);
|
||||
if ($res) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_logon['id'], 'type' => $act, 'status' => 200, 'time' => time(), 'ip' => getip(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(200, '绑定成功', $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_logon['id'], 'type' => $act, 'status' => 201, 'time' => time(), 'ip' => getip(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '绑定成功', $app_res);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
/*
|
||||
Name:QQ登录接口
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['logon_state'] == 'n') out(103, $app_res['logon_notice'], $app_res); //判断是否可登录
|
||||
if ($app_res['logon_way'] == 1) out(163, $app_res); //不是账号登录方式不允许使用当前操作
|
||||
$openid = isset($data_arr['openid']) && !empty($data_arr['openid']) ? purge($data_arr['openid']) : out(157, $app_res); //请输入openid
|
||||
$access_token = isset($data_arr['access_token']) && !empty($data_arr['access_token']) ? purge($data_arr['access_token']) : out(157, $app_res); //请输入access_token
|
||||
$qqappid = isset($data_arr['qqappid']) && !empty($data_arr['qqappid']) ? purge($data_arr['qqappid']) : out(161, $app_res); //请输入QQ互联ID
|
||||
$reg_in = isset($data_arr['markcode']) ? purge($data_arr['markcode']) : ''; //机器码
|
||||
$inv = isset($data_arr['inv']) ? intval($data_arr['inv']) : 0; //邀请人
|
||||
$get_data = ['access_token' => $access_token, 'openid' => $openid, 'oauth_consumer_key' => $qqappid, 'format' => 'json'];
|
||||
$qq_data = http_gets('https://graph.qq.com/user/get_user_info', $get_data);
|
||||
if (!$qq_data) out(162, $app_res);
|
||||
$json_qq = json_decode($qq_data, true);
|
||||
if (isset($json_qq['errcode'])) out(158, $app_res); //错误的身份信息
|
||||
$name = $json_qq['nickname'];
|
||||
$pic = $json_qq['figureurl_qq'];
|
||||
$token = md5($openid . getcode(32) . time() . $appid); //生成TOKEN
|
||||
$res_qq = Db::table('user')->where(['openid_qq' => $openid, 'appid' => $appid])->find(); //false
|
||||
if ($res_qq) {
|
||||
if ($app_res['logon_check_in'] == 'y' && $reg_in == '') out(112, $app_res); //判断是否验证机器码
|
||||
if ($res_qq['ban'] > time() || $res_user['ban'] == 999999999) out(114, $res_qq['ban_notice'], $app_res); //账号被禁用
|
||||
if ($app_res['mode'] == 'y') {
|
||||
$vip = $res_qq['vip'];
|
||||
} else {
|
||||
$vip = '999999999';
|
||||
} //判断当前收费模式
|
||||
$user_info = [
|
||||
'id' => $res_qq['id'],
|
||||
'pic' => get_pic($res_qq['pic']),
|
||||
'name' => $res_qq['name'],
|
||||
'vip' => $vip,
|
||||
'fen' => $res_qq['fen']
|
||||
];
|
||||
$res_user['id'] = $res_qq['id'];
|
||||
} else {
|
||||
$reg_ipon = $app_res['reg_ipon']; //获取IP重复注册间隔
|
||||
if ($reg_ipon > 0) {
|
||||
$ip_time = time() - $reg_ipon * 3600;
|
||||
$res = Db::table('user')->where(['appid' => $appid, 'reg_ip', getIp()])->where('reg_time', '>', $ip_time)->find(); //寻找相同IP
|
||||
if ($res) out(117, $app_res); //该IP已注册
|
||||
}
|
||||
$reg_inon = $app_res['reg_inon']; //获取机器码重复注册间隔
|
||||
if ($reg_inon > 0) {
|
||||
$in_time = time() - $reg_inon * 3600;
|
||||
$res = Db::table('user')->where(['appid' => $appid, 'reg_in', $reg_in])->where('reg_time', '>', $in_time)->find(); //寻找相同机器码
|
||||
if ($res) out(117, $app_res); //该机器码已注册
|
||||
}
|
||||
if ($inv > 0) { //邀请人事件
|
||||
$res = Db::table('user')->where('id', $inv)->where('appid', $appid)->find(); //查询邀请者ID
|
||||
if (!$res) out(118, $app_res); //邀请人已存在
|
||||
$inv_award = $app_res['inv_award']; //奖励类型
|
||||
$inv_award_num = $app_res['inv_award_num']; //邀请奖励数
|
||||
if ($inv_award_num > 0) {
|
||||
if ($inv_award == 'vip' && $res['vip'] != 999999999) { //奖励类型是VIP
|
||||
if ($res['vip'] > time()) { //VIP没有过期
|
||||
$vip = $res['vip'] + 3600 * $inv_award_num;
|
||||
} else { //VIP已过期
|
||||
$vip = time() + 3600 * $inv_award_num;
|
||||
}
|
||||
$inv_res = Db::table('user')->where('id', $inv)->update(['vip' => $vip]); //更新邀请人VIP数据
|
||||
if ($inv_res) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $inv, 'type' => 'inv', 'status' => 200, 'time' => time(), 'ip' => getIp(), 'vip' => $inv_award_num, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $inv, 'type' => 'inv', 'status' => 201, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
}
|
||||
} else if ($inv_award == 'fen') {
|
||||
$fen = $res['fen'] + $inv_award_num;
|
||||
$inv_res = Db::table('user')->where('id', $inv)->update(['fen' => $fen]); //更新邀请人积分数据
|
||||
if ($inv_res) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $inv, 'type' => 'inv', 'status' => 200, 'time' => time(), 'ip' => getIp(), 'fen' => $inv_award_num, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $inv, 'type' => 'inv', 'status' => 201, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$reg_award = $app_res['reg_award']; //奖励类型
|
||||
$reg_award_num = $app_res['reg_award_num']; //注册奖励
|
||||
if ($reg_award_num > 0) {
|
||||
if ($reg_award == 'vip') {
|
||||
$vips = time() + 60 * $reg_award_num;
|
||||
$add_res = Db::table('user')->add(['name' => $name, 'pic' => $pic, 'openid_qq' => $openid, 'vip' => $vips, 'inv' => $inv, 'reg_in' => $markcode, 'reg_ip' => getIp(), 'reg_time' => time(), 'appid' => $appid]);
|
||||
} else {
|
||||
$fens = $reg_award_num;
|
||||
$add_res = Db::table('user')->add(['name' => $name, 'pic' => $pic, 'openid_qq' => $openid, 'fen' => $fens, 'inv' => $inv, 'reg_in' => $markcode, 'reg_ip' => getIp(), 'reg_time' => time(), 'appid' => $appid]);
|
||||
}
|
||||
} else {
|
||||
$add_res = Db::table('user')->add(['name' => $name, 'pic' => $pic, 'openid_qq' => $openid, 'inv' => $inv, 'reg_in' => $markcode, 'reg_ip' => getIp(), 'reg_time' => time(), 'appid' => $appid]);
|
||||
}
|
||||
if ($add_res) {
|
||||
$res_user['id'] = (int)$add_res;
|
||||
if ($app_res['mode'] == 'y') {
|
||||
$vip = isset($vips) ? $vips : 0;
|
||||
} else {
|
||||
$vip = '999999999';
|
||||
} //判断当前收费模式
|
||||
$fen = isset($fens) ? $fens : 0;
|
||||
$user_info = [
|
||||
'id' => $res_user['id'],
|
||||
'pic' => $pic,
|
||||
'name' => $name,
|
||||
'vip' => $vip,
|
||||
'fen' => $fen
|
||||
];
|
||||
} else {
|
||||
out(201, '注册失败', $app_res);
|
||||
}
|
||||
}
|
||||
$res_num = Db::table('user_logon')->where(['uid' => $res_user['id']])->count();
|
||||
if ($res_num >= $app_res['logon_num']) { //已超过最大登录数
|
||||
$res = Db::table('user_logon')->where(['uid' => $res_user['id'], 'log_in' => $markcode])->find(); //寻找相同设备
|
||||
if ($res) { //找到相同设备的登录信息
|
||||
$res_update = Db::table('user_logon')->where('id', $res['id'])->update(['token' => $token, 'log_time' => time(), 'log_ip' => getIp(), 'log_in' => $markcode, 'last_t' => time()]);
|
||||
if ($res_update) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
$data = ['token' => $token, 'info' => $user_info];
|
||||
out(200, $data, $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 201, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '登录失败', $app_res);
|
||||
}
|
||||
} else { //没有找到相同登录信息
|
||||
$res_logon = Db::table('user_logon')->where(['uid' => $res_user['id']])->order('last_t asc')->find();
|
||||
if ($app_res['logon_check_in'] == 'y') { //需要验证机器码
|
||||
if ($app_res['logon_check_t'] <= 0) { //不限制换绑次数
|
||||
$res_update = Db::table('user_logon')->where('id', $res_logon['id'])->update(['token' => $token, 'log_time' => time(), 'log_ip' => getIp(), 'log_in' => $markcode, 'last_t' => time()]);
|
||||
if ($res_update) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
$data = ['token' => $token, 'info' => $user_info];
|
||||
out(200, $data, $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 201, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '登录失败', $app_res);
|
||||
}
|
||||
} else { //限制设备换绑次数
|
||||
$end = $res_logon['log_time'] + $app_res['logon_check_t'] * 3600;
|
||||
if ($end > time()) out(201, check_t(time(), $end)); //已超换绑间隔
|
||||
$res_update = Db::table('user_logon')->where('id', $res_logon['id'])->update(['token' => $token, 'log_time' => time(), 'log_ip' => getIp(), 'log_in' => $markcode, 'last_t' => time()]);
|
||||
if ($res_update) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
$data = ['token' => $token, 'info' => $user_info];
|
||||
out(200, $data, $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 201, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '登录失败', $app_res);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$res_update = Db::table('user_logon')->where('id', $res_logon['id'])->update(['token' => $token, 'log_time' => time(), 'log_ip' => getIp(), 'log_in' => $markcode, 'last_t' => time()]);
|
||||
if ($res_update) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
$data = ['token' => $token, 'info' => $user_info];
|
||||
out(200, $data, $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 201, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '登录失败', $app_res);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { //未超贵最大登录数
|
||||
$res = Db::table('user_logon')->where(['uid' => $res_user['id'], 'log_in' => $markcode])->find();
|
||||
if ($res) { //找到相同设备的登录信息
|
||||
$res_update = Db::table('user_logon')->where('id', $res['id'])->update(['token' => $token, 'log_time' => time(), 'log_ip' => getIp(), 'log_in' => $markcode, 'last_t' => time()]);
|
||||
if ($res_update) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
$data = ['token' => $token, 'info' => $user_info];
|
||||
out(200, $data, $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 201, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '登录失败', $app_res);
|
||||
}
|
||||
} else { //没有找到相同登录信息
|
||||
$res_add = Db::table('user_logon')->add(['uid' => $res_user['id'], 'token' => $token, 'log_time' => time(), 'log_ip' => getIp(), 'log_in' => $markcode, 'last_t' => time(), 'appid' => $appid]);
|
||||
if ($res_add) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
$data = ['token' => $token, 'info' => $user_info];
|
||||
out(200, $data, $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 201, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '登录失败', $app_res);
|
||||
}
|
||||
}
|
||||
}
|
||||
function check_t($start, $end)
|
||||
{
|
||||
$second = $end - $start; //结束时间戳减去当前时间戳
|
||||
// echo $second;
|
||||
$day = floor($second / 3600 / 24); //倒计时还有多少天
|
||||
if ($day > 0) {
|
||||
return '当前账号已绑定其他设备,' . $day . '天后可在该设备登录';
|
||||
}
|
||||
$hr = floor($second / 3600 % 24); //倒计时还有多少小时(%取余数)
|
||||
if ($hr > 0) {
|
||||
return '当前账号已绑定其他设备,' . $hr . '小时后可在该设备登录';
|
||||
}
|
||||
$min = floor($second / 60 % 60); //倒计时还有多少分钟
|
||||
if ($min > 0) {
|
||||
return '当前账号已绑定其他设备,' . $min . '分钟后可在该设备登录';
|
||||
}
|
||||
$sec = floor($second % 60); //倒计时还有多少秒
|
||||
if ($sec > 0) {
|
||||
return '当前账号已绑定其他设备,' . $sec . '秒后可在该设备登录';
|
||||
}
|
||||
$str = $day . "天" . $hr . "小时" . $min . "分钟" . $sec . "秒"; //组合成字符串
|
||||
return $str;
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
Name:邮箱找回密码
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['smtp_state'] == 'n') out(121, $app_res); //判断邮箱是否可用
|
||||
if ($app_res['logon_way'] == 1) out(164, $app_res); //不是账号登录方式不允许使用当前操作
|
||||
$email = isset($data_arr['email']) && !empty($data_arr['email']) ? purge($data_arr['email']) : out(110, $app_res); //请输入账号
|
||||
$crc = isset($data_arr['crc']) && !empty($data_arr['crc']) ? intval($data_arr['crc']) : out(120, $app_res); //验证码为空
|
||||
$newpwd = isset($data_arr['newpassword']) && !empty($data_arr['newpassword']) ? purge($data_arr['newpassword']) : out(111, '请输入新密码', $app_res); //请输入密码
|
||||
if (!check_email($email)) out(116, '邮箱不合法', $app_res); //账号长度5~11位,不支持中文和特殊字符
|
||||
if (preg_match("/^[a-zA-Z\d.*_-]{6,18}$/", $newpwd) == 0) out(119, '密码长度需要满足6-18位数,不支持中文以及.-*_以外特殊字符', $app_res); //密码长度6~18位
|
||||
$res_user = Db::table('user')->where(['email' => $email, 'appid' => $appid])->find(); //false
|
||||
if (!$res_user) out(122, $app_res); //账号不存在
|
||||
if ($res_user['ban'] > time() || $res_user['ban'] == 999999999) out(114, $res_user['ban_notice'], $app_res); //账号被禁用
|
||||
$res_code = Db::table('captcha')->where(['email' => $email, 'code' => $crc, 'new' => 'y', 'appid' => $appid])->order('id DESC')->find(); //false
|
||||
if (!$res_code) out(124, $app_res); //验证码不正确
|
||||
Db::table('captcha')->where('id', $res_code['id'])->update(['new' => 'n']);
|
||||
$res = Db::table('user')->where('id', $res_user['id'])->update(['pwd' => md5($newpwd)]);
|
||||
if ($res) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 200, 'time' => time(), 'ip' => getip(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(200, '找回密码成功', $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 201, 'time' => time(), 'ip' => getip(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '找回密码失败', $app_res);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/*
|
||||
Name:设置账号
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['logon_way'] == 1) out(164, $app_res); //不是账号登录方式不允许使用当前操作
|
||||
$token = isset($data_arr['token']) && !empty($data_arr['token']) ? purge($data_arr['token']) : out(125, $app_res); //请输TOKEN
|
||||
$user = isset($data_arr['user']) && !empty($data_arr['user']) ? purge($data_arr['user']) : out(110, $app_res); //请输账号
|
||||
$pwd = isset($data_arr['password']) && !empty($data_arr['password']) ? purge($data_arr['password']) : ''; //请输入密码
|
||||
if (preg_match("/^[\w]{32}$/", $token) == 0) out(126, $app_res); //TOKEN不正确,32位字符串
|
||||
$res_logon = Db::table('user_logon', 'as logon')->field('U.*')->JOIN('user', 'as U', 'logon.uid=U.id')->where('U.appid', $appid)->where('logon.token', $token)->find(); //false
|
||||
if (!$res_logon) out(127, $app_res); //TOKEN不存在或已失效
|
||||
if (!empty($res_logon['user'])) out(128, $app_res); //已设置过账号
|
||||
if ($res_logon['ban'] > time() || $res_logon['ban'] == 999999999) out(114, $res_logon['ban_notice'], $app_res); //账号被禁用
|
||||
Db::table('user_logon')->where('token', $token)->update(['last_t' => time()]); //记录活动时间
|
||||
$res_user = Db::table('user')->where(['user' => $user, 'appid' => $appid])->find(); //false
|
||||
if ($res_user) out(115, $app_res); //账号已存在
|
||||
if ($pwd == '') {
|
||||
if (empty($res_logon['pwd'])) out(111, $app_res); //请输入密码
|
||||
$res = Db::table('user')->where('id', $res_logon['id'])->update(['user' => $user]);
|
||||
} else {
|
||||
if (preg_match("/^[a-zA-Z\d.*_-]{6,18}$/", $pwd) == 0) out(119, '密码长度需要满足6-18位数,不支持中文以及.-*_以外特殊字符', $app_res); //密码长度6~18位
|
||||
$res = Db::table('user')->where('id', $res_logon['id'])->update(['user' => $user, 'pwd' => md5($pwd)]);
|
||||
}
|
||||
//die($res);
|
||||
if ($res) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_logon['id'], 'type' => $act, 'status' => 200, 'time' => time(), 'ip' => getip(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(200, '设置成功', $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_logon['id'], 'type' => $act, 'status' => 201, 'time' => time(), 'ip' => getip(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '设置失败', $app_res);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/*
|
||||
Name:获取启动配置
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
$ret = [];
|
||||
$site_res = Db::table('site')->where(['appid' => $appid, 'state' => 'y'])->select(); //获取商品列表
|
||||
if (is_array($site_res)) {
|
||||
foreach ($site_res as $k => $v) {
|
||||
$rows = $site_res[$k];
|
||||
|
||||
if ($rows['type'] == "XML") {
|
||||
$rows['type'] = "0";
|
||||
} else if ($rows['type'] == "JSON") {
|
||||
$rows['type'] = "1";
|
||||
} else {
|
||||
$rows['type'] = "3";
|
||||
}
|
||||
$ret[] = [
|
||||
'gid' => $rows['id'],
|
||||
'gname' => $rows['name'],
|
||||
'gtype' => $rows['type'],
|
||||
'gapiname' => $rows['api'],
|
||||
'extend' => $rows['extend'],
|
||||
'parse' => $rows['parse'],
|
||||
'searchable' => $rows['searchable'],
|
||||
'quicksearch' => $rows['quicksearch'],
|
||||
'filterable' => $rows['filterable']
|
||||
];
|
||||
}
|
||||
encryptionout(200, $ret, $app_res);
|
||||
}
|
||||
out(201, '自定义接口获取失败', $app_res);
|
||||
?>
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*
|
||||
Name:上传头像
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['logon_way'] == 1) out(164, $app_res); //不是账号登录方式不允许使用当前操作
|
||||
$upt = isset($data_arr['upt']) && !empty($data_arr['upt']) ? purge($data_arr['upt']) : 'e4a'; //上传类型
|
||||
$token = isset($data_arr['token']) && !empty($data_arr['token']) ? purge($data_arr['token']) : out(125, $app_res); //请输TOKEN
|
||||
$res_logon = Db::table('user_logon', 'as logon')->field('U.*')->JOIN('user', 'as U', 'logon.uid=U.id')->where('U.appid', $appid)->where('logon.token', $token)->find(); //false
|
||||
if (!$res_logon) out(127, $app_res); //TOKEN不存在或已失效
|
||||
if ($res_logon['ban'] > time() || $res_logon['ban'] == 999999999) out(114, $res_logon['ban_notice'], $app_res); //账号被禁用
|
||||
Db::table('user_logon')->where('token', $token)->update(['last_t' => time()]); //记录活动时间
|
||||
$local_path = FCPATH . USER_PIC_MULU;
|
||||
if (!file_exists($local_path)) mkdir($local_path);
|
||||
if ($upt == 'bbp') {
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') out(141, $app_res); //提交方式不正确
|
||||
foreach ($_FILES as $name => $file) {
|
||||
$fn = $file['name'];
|
||||
$ft = strrpos($fn, '.', 0);
|
||||
$fe = substr($fn, $ft);
|
||||
$fp = $res_logon['id'] . $fe;
|
||||
$result = move_uploaded_file($file['tmp_name'], $local_path . $fp);
|
||||
$pic = $fp;
|
||||
}
|
||||
} else if ($upt == 'e4a') {
|
||||
$target_path = $res_logon['id'] . ".png";
|
||||
$result = move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $local_path . $target_path);
|
||||
$pic = $target_path;
|
||||
} else {
|
||||
out(142, $app_res); //上传类型不支持
|
||||
}
|
||||
if ($result) {
|
||||
$res = Db::table('user')->where('id', $res_logon['id'])->update(['pic' => $pic]);
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_logon['id'], 'type' => $act, 'status' => 200, 'time' => time(), 'ip' => getip(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(200, '上传成功', $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_logon['id'], 'type' => $act, 'status' => 201, 'time' => time(), 'ip' => getip(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '上传失败', $app_res);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
/*
|
||||
Name:登录接口文件
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['logon_state'] == 'n') out(103, $app_res['logon_notice'], $app_res); //判断是否可登录
|
||||
if ($app_res['logon_way'] == 1) out(163, $app_res); //不允许账号登录方式
|
||||
$user = isset($data_arr['account']) && !empty($data_arr['account']) ? purge($data_arr['account']) : out(110, $app_res); //请输入账号
|
||||
$pwd = isset($data_arr['password']) && !empty($data_arr['password']) ? purge($data_arr['password']) : out(111, $app_res); //请输入密码
|
||||
$log_in = isset($data_arr['markcode']) ? purge($data_arr['markcode']) : ''; //机器码
|
||||
if ($app_res['logon_check_in'] == 'y' && $log_in == '') out(112, $app_res); //判断是否验证机器码
|
||||
$log_ip = getIp(); //登录IP
|
||||
$log_time = time(); //登录时间
|
||||
$token = md5($user . getcode(32) . time() . $appid); //生成TOKEN
|
||||
$res_user = Db::table('user')->where(['pwd' => md5($pwd), 'appid' => $appid], "(", ")")->where('(user', $user)->whereOr(['email' => $user, 'phone' => $user], ")")->find(); //false
|
||||
if (!$res_user) out(113, $app_res); //账号密码不正确
|
||||
if ($res_user['ban'] > $log_time || $res_user['ban'] == 999999999) out(114, $res_user['ban_notice'], $app_res); //账号被禁用
|
||||
if ($app_res['mode'] == 'y') {
|
||||
$vip = $res_user['vip'];
|
||||
} else {
|
||||
$vip = '999999999';
|
||||
} //判断当前收费模式
|
||||
$user_info = [
|
||||
'id' => $res_user['id'],
|
||||
'pic' => get_pic($res_user['pic']),
|
||||
'name' => $res_user['name'],
|
||||
'vip' => $vip,
|
||||
'fen' => $res_user['fen']
|
||||
];
|
||||
$res_num = Db::table('user_logon')->where(['uid' => $res_user['id']])->count();
|
||||
if ($res_num >= $app_res['logon_num']) { //已超过最大登录数
|
||||
$res = Db::table('user_logon')->where(['uid' => $res_user['id'], 'log_in' => $log_in])->find(); //寻找相同设备
|
||||
if ($res) { //找到相同设备的登录信息
|
||||
$res_update = Db::table('user_logon')->where('id', $res['id'])->update(['token' => $token, 'log_time' => $log_time, 'log_ip' => $log_ip, 'log_in' => $log_in, 'last_t' => $log_time]);
|
||||
if ($res_update) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'time' => $log_time, 'ip' => $log_ip, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
$data = ['token' => $token, 'info' => $user_info];
|
||||
out(200, $data, $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 201, 'time' => $log_time, 'ip' => $log_ip, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '登录失败', $app_res);
|
||||
}
|
||||
} else { //没有找到相同登录信息
|
||||
$res_logon = Db::table('user_logon')->where(['uid' => $res_user['id']])->order('last_t asc')->find();
|
||||
if ($app_res['logon_check_in'] == 'y') { //需要验证机器码
|
||||
if ($app_res['logon_check_t'] <= 0) { //不限制换绑次数
|
||||
$res_update = Db::table('user_logon')->where('id', $res_logon['id'])->update(['token' => $token, 'log_time' => $log_time, 'log_ip' => $log_ip, 'log_in' => $log_in, 'last_t' => $log_time]);
|
||||
if ($res_update) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'time' => $log_time, 'ip' => $log_ip, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
$data = ['token' => $token, 'info' => $user_info];
|
||||
out(200, $data, $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 201, 'time' => $log_time, 'ip' => $log_ip, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '登录失败', $app_res);
|
||||
}
|
||||
} else { //限制设备换绑次数
|
||||
$end = $res_logon['log_time'] + $app_res['logon_check_t'] * 3600;
|
||||
if ($end > $log_time) out(201, check_t($log_time, $end), $app_res); //已超换绑间隔
|
||||
$res_update = Db::table('user_logon')->where('id', $res_logon['id'])->update(['token' => $token, 'log_time' => $log_time, 'log_ip' => $log_ip, 'log_in' => $log_in, 'last_t' => $log_time]);
|
||||
if ($res_update) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'time' => $log_time, 'ip' => $log_ip, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
$data = ['token' => $token, 'info' => $user_info];
|
||||
out(200, $data, $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 201, 'time' => $log_time, 'ip' => $log_ip, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '登录失败', $app_res);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$res_update = Db::table('user_logon')->where('id', $res_logon['id'])->update(['token' => $token, 'log_time' => $log_time, 'log_ip' => $log_ip, 'log_in' => $log_in, 'last_t' => $log_time]);
|
||||
if ($res_update) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'time' => $log_time, 'ip' => $log_ip, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
$data = ['token' => $token, 'info' => $user_info];
|
||||
out(200, $data, $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 201, 'time' => $log_time, 'ip' => $log_ip, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '登录失败', $app_res);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { //未超贵最大登录数
|
||||
$res = Db::table('user_logon')->where(['uid' => $res_user['id'], 'log_in' => $log_in])->find();
|
||||
if ($res) { //找到相同设备的登录信息
|
||||
$res_update = Db::table('user_logon')->where('id', $res['id'])->update(['token' => $token, 'log_time' => $log_time, 'log_ip' => $log_ip, 'log_in' => $log_in, 'last_t' => $log_time]);
|
||||
if ($res_update) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'time' => $log_time, 'ip' => $log_ip, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
$data = ['token' => $token, 'info' => $user_info];
|
||||
out(200, $data, $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 201, 'time' => $log_time, 'ip' => $log_ip, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '登录失败', $app_res);
|
||||
}
|
||||
} else { //没有找到相同登录信息
|
||||
$res_add = Db::table('user_logon')->add(['uid' => $res_user['id'], 'token' => $token, 'log_time' => $log_time, 'log_ip' => $log_ip, 'log_in' => $log_in, 'last_t' => $log_time, 'appid' => $appid]);
|
||||
if ($res_add) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'time' => $log_time, 'ip' => $log_ip, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
$data = ['token' => $token, 'info' => $user_info];
|
||||
out(200, $data, $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 201, 'time' => $log_time, 'ip' => $log_ip, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '登录失败', $app_res);
|
||||
}
|
||||
}
|
||||
}
|
||||
function check_t($start, $end)
|
||||
{
|
||||
$second = $end - $start; //结束时间戳减去当前时间戳
|
||||
// echo $second;
|
||||
$day = floor($second / 3600 / 24); //倒计时还有多少天
|
||||
if ($day > 0) {
|
||||
return '当前账号已绑定其他设备,' . $day . '天后可在该设备登录';
|
||||
}
|
||||
$hr = floor($second / 3600 % 24); //倒计时还有多少小时(%取余数)
|
||||
if ($hr > 0) {
|
||||
return '当前账号已绑定其他设备,' . $hr . '小时后可在该设备登录';
|
||||
}
|
||||
$min = floor($second / 60 % 60); //倒计时还有多少分钟
|
||||
if ($min > 0) {
|
||||
return '当前账号已绑定其他设备,' . $min . '分钟后可在该设备登录';
|
||||
}
|
||||
$sec = floor($second % 60); //倒计时还有多少秒
|
||||
if ($sec > 0) {
|
||||
return '当前账号已绑定其他设备,' . $sec . '秒后可在该设备登录';
|
||||
}
|
||||
$str = $day . "天" . $hr . "小时" . $min . "分钟" . $sec . "秒"; //组合成字符串
|
||||
return $str;
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/*
|
||||
Name:普通注册接口文件
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['reg_state'] == 'n') out(103, $app_res['reg_notice'], $app_res); //判断是否可注册
|
||||
if ($app_res['logon_way'] == 1) out(164, $app_res); //不是账号登录方式不允许使用当前操作
|
||||
$name = isset($data_arr['name']) && !empty($data_arr['name']) ? purge($data_arr['name']) : '这个人没有名字!'; //昵称
|
||||
$user = isset($data_arr['user']) && !empty($data_arr['user']) ? purge($data_arr['user']) : out(110, $app_res); //请输入账号
|
||||
$pwd = isset($data_arr['password']) && !empty($data_arr['password']) ? purge($data_arr['password']) : out(111, $app_res); //请输入密码
|
||||
$inv = isset($data_arr['inv']) ? intval($data_arr['inv']) : 0; //邀请人
|
||||
$reg_in = isset($data_arr['markcode']) ? purge($data_arr['markcode']) : ''; //机器码
|
||||
if ($app_res['reg_inon'] > 0 && $reg_in == '') out(112, $app_res); //判断是否验证机器码
|
||||
$reg_ip = getIp(); //注册IP
|
||||
$reg_time = time(); //注册时间
|
||||
if (preg_match("/^[a-zA-Z\d.*_-]{6,18}$/", $pwd) == 0) out(119, '密码长度需要满足6-18位数,不支持中文以及.-*_以外特殊字符', $app_res); //密码长度6~18位
|
||||
$res_user = Db::table('user')->where(['user' => $user, 'appid' => $appid])->find(); //false
|
||||
if ($res_user) out(115, $app_res); //账号已存在
|
||||
$reg_ipon = $app_res['reg_ipon']; //获取IP重复注册间隔
|
||||
if ($reg_ipon > 0) {
|
||||
$ip_time = $reg_time - $reg_ipon * 3600;
|
||||
$res = Db::table('user')->where(['appid' => $appid, 'reg_ip' => $reg_ip])->where('reg_time', '>', $ip_time)->find(); //寻找相同IP
|
||||
if ($res) out(117, $app_res); //该IP已注册
|
||||
}
|
||||
$reg_inon = $app_res['reg_inon']; //获取机器码重复注册间隔
|
||||
if ($reg_inon > 0) {
|
||||
$in_time = $reg_time - $reg_inon * 3600;
|
||||
$res = Db::table('user')->where(['appid' => $appid, 'reg_in' => $reg_in])->where('reg_time', '>', $in_time)->find(); //寻找相同机器码
|
||||
if ($res) out(117, $app_res); //该机器码已注册
|
||||
}
|
||||
if ($inv > 0) { //邀请人事件
|
||||
$res = Db::table('user')->where('id', $inv)->where('appid', $appid)->find(); //查询邀请者ID
|
||||
if (!$res) out(118, $app_res); //邀请人已存在
|
||||
$inv_award = $app_res['inv_award']; //奖励类型
|
||||
$inv_award_num = $app_res['inv_award_num']; //邀请奖励数
|
||||
if ($inv_award_num > 0) {
|
||||
if ($inv_award == 'vip' && $res['vip'] != 999999999) { //奖励类型是VIP
|
||||
if ($res['vip'] > $reg_time) { //VIP没有过期
|
||||
$vip = $res['vip'] + 3600 * $inv_award_num;
|
||||
} else { //VIP已过期
|
||||
$vip = $reg_time + 3600 * $inv_award_num;
|
||||
}
|
||||
$inv_res = Db::table('user')->where('id', $inv)->update(['vip' => $vip]); //更新邀请人VIP数据
|
||||
if ($inv_res) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $inv, 'type' => 'inv', 'status' => 200, 'time' => $reg_time, 'ip' => $reg_ip, 'vip' => $inv_award_num, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $inv, 'type' => 'inv', 'status' => 201, 'time' => $reg_time, 'ip' => $reg_ip, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
}
|
||||
} else if ($inv_award == 'fen') {
|
||||
$fen = $res['fen'] + $inv_award_num;
|
||||
$inv_res = Db::table('user')->where('id', $inv)->update(['fen' => $fen]); //更新邀请人积分数据
|
||||
if ($inv_res) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $inv, 'type' => 'inv', 'status' => 200, 'time' => $reg_time, 'ip' => $reg_ip, 'fen' => $inv_award_num, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $inv, 'type' => 'inv', 'status' => 201, 'time' => $reg_time, 'ip' => $reg_ip, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$reg_award = $app_res['reg_award']; //奖励类型
|
||||
$reg_award_num = $app_res['reg_award_num']; //注册奖励
|
||||
if ($reg_award_num > 0) {
|
||||
if ($reg_award == 'vip') {
|
||||
$vip = $reg_time + 60 * $reg_award_num;
|
||||
$add_res = Db::table('user')->add(['name' => $name, 'user' => $user, 'pwd' => md5($pwd), 'vip' => $vip, 'inv' => $inv, 'reg_in' => $reg_in, 'reg_ip' => $reg_ip, 'reg_time' => $reg_time, 'appid' => $appid]);
|
||||
} else {
|
||||
$add_res = Db::table('user')->add(['name' => $name, 'user' => $user, 'pwd' => md5($pwd), 'fen' => $reg_award_num, 'inv' => $inv, 'reg_in' => $reg_in, 'reg_ip' => $reg_ip, 'reg_time' => $reg_time, 'appid' => $appid]);
|
||||
}
|
||||
} else {
|
||||
$add_res = Db::table('user')->add(['name' => $name, 'user' => $user, 'pwd' => md5($pwd), 'inv' => $inv, 'reg_in' => $reg_in, 'reg_ip' => $reg_ip, 'reg_time' => $reg_time, 'appid' => $appid]);
|
||||
}
|
||||
if ($add_res) {
|
||||
out(200, '注册成功', $app_res);
|
||||
}
|
||||
out(201, '注册失败', $app_res);
|
||||
?>
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/*
|
||||
Name:微信绑定
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['logon_way'] == 1) out(164, $app_res); //不是账号登录方式不允许使用当前操作
|
||||
|
||||
$token = isset($data_arr['token']) && !empty($data_arr['token']) ? purge($data_arr['token']) : out(125, $app_res); //请输TOKEN
|
||||
$openid = isset($data_arr['openid']) && !empty($data_arr['openid']) ? purge($data_arr['openid']) : out(157, $app_res); //请输入openid
|
||||
$access_token = isset($data_arr['access_token']) && !empty($data_arr['access_token']) ? purge($data_arr['access_token']) : out(157, $app_res); //请输入access_token
|
||||
|
||||
|
||||
$res_logon = Db::table('user_logon', 'as logon')->field('U.*')->JOIN('user', 'as U', 'logon.uid=U.id')->where('logon.appid', $appid)->where('U.appid', $appid)->where('logon.token', $token)->find(); //false
|
||||
if (!$res_logon) out(127, $app_res); //TOKEN不存在或已失效
|
||||
if ($res_logon['ban'] > time() || $res_logon['ban'] == 999999999) out(114, $res_logon['ban_notice'], $app_res); //账号被禁用
|
||||
Db::table('user_logon')->where('token', $token)->update(['last_t' => time()]); //记录活动时间
|
||||
|
||||
$res_wx = Db::table('user')->where(['openid_wx' => $openid, 'appid' => $appid])->find(); //false
|
||||
if ($res_wx) out(160, $app_res); //已绑定其他账号
|
||||
|
||||
$get_data = ['access_token' => $access_token, 'openid' => $openid, 'lang' => 'zh_CN'];
|
||||
$wx_data = http_gets('https://api.weixin.qq.com/sns/userinfo', $get_data);
|
||||
$json_wx = json_decode($wx_data, true);
|
||||
if (isset($json_wx['errcode'])) out(158, $app_res); //错误的身份信息
|
||||
|
||||
$res = Db::table('user')->where('id', $res_logon['id'])->update(['openid_wx' => $openid]);
|
||||
if ($res) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_logon['id'], 'type' => $act, 'status' => 200, 'time' => time(), 'ip' => getip(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(200, '绑定成功', $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_logon['id'], 'type' => $act, 'status' => 201, 'time' => time(), 'ip' => getip(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '绑定成功', $app_res);
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
/*
|
||||
Name:微信登录注册接口文件
|
||||
Version:1.0
|
||||
Author:乐酷
|
||||
Author QQ:3178156778
|
||||
Author Url:shouq.sujie520.cn
|
||||
*/
|
||||
if (!isset($app_res) or !is_array($app_res)) out(100); //如果需要调用应用配置请先判断是否加载app配置
|
||||
if ($app_res['logon_state'] == 'n') out(103, $app_res['logon_notice'], $app_res); //判断是否可登录
|
||||
if ($app_res['logon_way'] == 1) out(163, $app_res); //不允许账号登录方式
|
||||
$openid = isset($data_arr['openid']) && !empty($data_arr['openid']) ? purge($data_arr['openid']) : out(157, $app_res); //请输入openid
|
||||
$access_token = isset($data_arr['access_token']) && !empty($data_arr['access_token']) ? purge($data_arr['access_token']) : out(157, $app_res); //请输入access_token
|
||||
$reg_in = isset($data_arr['markcode']) ? purge($data_arr['markcode']) : ''; //机器码
|
||||
$inv = isset($data_arr['inv']) ? intval($data_arr['inv']) : 0; //邀请人
|
||||
$get_data = ['access_token' => $access_token, 'openid' => $openid, 'lang' => 'zh_CN'];
|
||||
$wx_data = http_gets('https://api.weixin.qq.com/sns/userinfo', $get_data);
|
||||
$json_wx = json_decode($wx_data, true);
|
||||
if (isset($json_wx['errcode'])) out(158, $app_res); //错误的身份信息
|
||||
$name = $json_wx['nickname'];
|
||||
$pic = $json_wx['headimgurl'];
|
||||
$token = md5($openid . getcode(32) . time() . $appid); //生成TOKEN
|
||||
$res_wx = Db::table('user')->where(['openid_wx' => $openid, 'appid' => $appid])->find(); //false
|
||||
if ($res_wx) {
|
||||
if ($app_res['logon_check_in'] == 'y' && $reg_in == '') out(112, $app_res); //判断是否验证机器码
|
||||
if ($res_wx['ban'] > time() || $res_user['ban'] == 999999999) out(114, $res_wx['ban_notice'], $app_res); //账号被禁用
|
||||
if ($app_res['mode'] == 'y') {
|
||||
$vip = $res_wx['vip'];
|
||||
} else {
|
||||
$vip = '999999999';
|
||||
} //判断当前收费模式
|
||||
$user_info = [
|
||||
'id' => $res_wx['id'],
|
||||
'pic' => get_pic($res_wx['pic']),
|
||||
'name' => $res_wx['name'],
|
||||
'vip' => $vip,
|
||||
'fen' => $res_wx['fen']
|
||||
];
|
||||
$res_user['id'] = $res_wx['id'];
|
||||
} else {
|
||||
$reg_ipon = $app_res['reg_ipon']; //获取IP重复注册间隔
|
||||
if ($reg_ipon > 0) {
|
||||
$ip_time = time() - $reg_ipon * 3600;
|
||||
$res = Db::table('user')->where(['appid' => $appid, 'reg_ip', getIp()])->where('reg_time', '>', $ip_time)->find(); //寻找相同IP
|
||||
if ($res) out(117, $app_res); //该IP已注册
|
||||
}
|
||||
$reg_inon = $app_res['reg_inon']; //获取机器码重复注册间隔
|
||||
if ($reg_inon > 0) {
|
||||
$in_time = time() - $reg_inon * 3600;
|
||||
$res = Db::table('user')->where(['appid' => $appid, 'reg_in', $reg_in])->where('reg_time', '>', $in_time)->find(); //寻找相同机器码
|
||||
if ($res) out(117, $app_res); //该机器码已注册
|
||||
}
|
||||
if ($inv > 0) { //邀请人事件
|
||||
$res = Db::table('user')->where('id', $inv)->where('appid', $appid)->find(); //查询邀请者ID
|
||||
if (!$res) out(118, $app_res); //邀请人已存在
|
||||
$inv_award = $app_res['inv_award']; //奖励类型
|
||||
$inv_award_num = $app_res['inv_award_num']; //邀请奖励数
|
||||
if ($inv_award_num > 0) {
|
||||
if ($inv_award == 'vip' && $res['vip'] != 999999999) { //奖励类型是VIP
|
||||
if ($res['vip'] > time()) { //VIP没有过期
|
||||
$vip = $res['vip'] + 3600 * $inv_award_num;
|
||||
} else { //VIP已过期
|
||||
$vip = time() + 3600 * $inv_award_num;
|
||||
}
|
||||
$inv_res = Db::table('user')->where('id', $inv)->update(['vip' => $vip]); //更新邀请人VIP数据
|
||||
if ($inv_res) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $inv, 'type' => 'inv', 'status' => 200, 'time' => time(), 'ip' => getIp(), 'vip' => $inv_award_num, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $inv, 'type' => 'inv', 'status' => 201, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
}
|
||||
} else if ($inv_award == 'fen') {
|
||||
$fen = $res['fen'] + $inv_award_num;
|
||||
$inv_res = Db::table('user')->where('id', $inv)->update(['fen' => $fen]); //更新邀请人积分数据
|
||||
if ($inv_res) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $inv, 'type' => 'inv', 'status' => 200, 'time' => time(), 'ip' => getIp(), 'fen' => $inv_award_num, 'appid' => $appid]);
|
||||
} //记录日志
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $inv, 'type' => 'inv', 'status' => 201, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$reg_award = $app_res['reg_award']; //奖励类型
|
||||
$reg_award_num = $app_res['reg_award_num']; //注册奖励
|
||||
if ($reg_award_num > 0) {
|
||||
if ($reg_award == 'vip') {
|
||||
$vips = time() + 60 * $reg_award_num;
|
||||
$add_res = Db::table('user')->add(['name' => $name, 'pic' => $pic, 'openid_wx' => $openid, 'vip' => $vips, 'inv' => $inv, 'reg_in' => $markcode, 'reg_ip' => getIp(), 'reg_time' => time(), 'appid' => $appid]);
|
||||
} else {
|
||||
$fens = $reg_award_num;
|
||||
$add_res = Db::table('user')->add(['name' => $name, 'pic' => $pic, 'openid_wx' => $openid, 'fen' => $fens, 'inv' => $inv, 'reg_in' => $markcode, 'reg_ip' => getIp(), 'reg_time' => time(), 'appid' => $appid]);
|
||||
}
|
||||
} else {
|
||||
$add_res = Db::table('user')->add(['name' => $name, 'pic' => $pic, 'openid_wx' => $openid, 'inv' => $inv, 'reg_in' => $markcode, 'reg_ip' => getIp(), 'reg_time' => time(), 'appid' => $appid]);
|
||||
}
|
||||
if ($add_res) {
|
||||
$res_user['id'] = (int)$add_res;
|
||||
if ($app_res['mode'] == 'y') {
|
||||
$vip = isset($vips) ? $vips : 0;
|
||||
} else {
|
||||
$vip = '999999999';
|
||||
} //判断当前收费模式
|
||||
$fen = isset($fens) ? $fens : 0;
|
||||
$user_info = [
|
||||
'id' => $res_user['id'],
|
||||
'pic' => $pic,
|
||||
'name' => $name,
|
||||
'vip' => $vip,
|
||||
'fen' => $fen
|
||||
];
|
||||
}
|
||||
out(201, '注册失败', $app_res);
|
||||
}
|
||||
$res_num = Db::table('user_logon')->where(['uid' => $res_user['id']])->count();
|
||||
if ($res_num >= $app_res['logon_num']) { //已超过最大登录数
|
||||
$res = Db::table('user_logon')->where(['uid' => $res_user['id'], 'log_in' => $markcode])->find(); //寻找相同设备
|
||||
if ($res) { //找到相同设备的登录信息
|
||||
$res_update = Db::table('user_logon')->where('id', $res['id'])->update(['token' => $token, 'log_time' => time(), 'log_ip' => getIp(), 'log_in' => $markcode, 'last_t' => time()]);
|
||||
if ($res_update) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
$data = ['token' => $token, 'info' => $user_info];
|
||||
out(200, $data, $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 201, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '登录失败', $app_res);
|
||||
}
|
||||
} else { //没有找到相同登录信息
|
||||
$res_logon = Db::table('user_logon')->where(['uid' => $res_user['id']])->order('last_t asc')->find();
|
||||
if ($app_res['logon_check_in'] == 'y') { //需要验证机器码
|
||||
if ($app_res['logon_check_t'] <= 0) { //不限制换绑次数
|
||||
$res_update = Db::table('user_logon')->where('id', $res_logon['id'])->update(['token' => $token, 'log_time' => time(), 'log_ip' => getIp(), 'log_in' => $markcode, 'last_t' => time()]);
|
||||
if ($res_update) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
$data = ['token' => $token, 'info' => $user_info];
|
||||
out(200, $data, $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 201, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '登录失败', $app_res);
|
||||
}
|
||||
} else { //限制设备换绑次数
|
||||
$end = $res_logon['log_time'] + $app_res['logon_check_t'] * 3600;
|
||||
if ($end > time()) out(201, check_t(time(), $end)); //已超换绑间隔
|
||||
$res_update = Db::table('user_logon')->where('id', $res_logon['id'])->update(['token' => $token, 'log_time' => time(), 'log_ip' => getIp(), 'log_in' => $markcode, 'last_t' => time()]);
|
||||
if ($res_update) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
$data = ['token' => $token, 'info' => $user_info];
|
||||
out(200, $data, $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 201, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '登录失败', $app_res);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$res_update = Db::table('user_logon')->where('id', $res_logon['id'])->update(['token' => $token, 'log_time' => time(), 'log_ip' => getIp(), 'log_in' => $markcode, 'last_t' => time()]);
|
||||
if ($res_update) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
$data = ['token' => $token, 'info' => $user_info];
|
||||
out(200, $data, $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 201, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '登录失败', $app_res);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { //未超贵最大登录数
|
||||
$res = Db::table('user_logon')->where(['uid' => $res_user['id'], 'log_in' => $markcode])->find();
|
||||
if ($res) { //找到相同设备的登录信息
|
||||
$res_update = Db::table('user_logon')->where('id', $res['id'])->update(['token' => $token, 'log_time' => time(), 'log_ip' => getIp(), 'log_in' => $markcode, 'last_t' => time()]);
|
||||
if ($res_update) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
$data = ['token' => $token, 'info' => $user_info];
|
||||
out(200, $data, $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 201, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '登录失败', $app_res);
|
||||
}
|
||||
} else { //没有找到相同登录信息
|
||||
$res_add = Db::table('user_logon')->add(['uid' => $res_user['id'], 'token' => $token, 'log_time' => time(), 'log_ip' => getIp(), 'log_in' => $markcode, 'last_t' => time(), 'appid' => $appid]);
|
||||
if ($res_add) {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
$data = ['token' => $token, 'info' => $user_info];
|
||||
out(200, $data, $app_res);
|
||||
} else {
|
||||
if (defined('USER_LOG') && USER_LOG == 1) {
|
||||
Db::table('log')->add(['uid' => $res_user['id'], 'type' => $act, 'status' => 201, 'time' => time(), 'ip' => getIp(), 'appid' => $appid]);
|
||||
} //记录日志
|
||||
out(201, '登录失败', $app_res);
|
||||
}
|
||||
}
|
||||
}
|
||||
function check_t($start, $end)
|
||||
{
|
||||
$second = $end - $start; //结束时间戳减去当前时间戳
|
||||
// echo $second;
|
||||
$day = floor($second / 3600 / 24); //倒计时还有多少天
|
||||
if ($day > 0) {
|
||||
return '当前账号已绑定其他设备,' . $day . '天后可在该设备登录';
|
||||
}
|
||||
$hr = floor($second / 3600 % 24); //倒计时还有多少小时(%取余数)
|
||||
if ($hr > 0) {
|
||||
return '当前账号已绑定其他设备,' . $hr . '小时后可在该设备登录';
|
||||
}
|
||||
$min = floor($second / 60 % 60); //倒计时还有多少分钟
|
||||
if ($min > 0) {
|
||||
return '当前账号已绑定其他设备,' . $min . '分钟后可在该设备登录';
|
||||
}
|
||||
$sec = floor($second % 60); //倒计时还有多少秒
|
||||
if ($sec > 0) {
|
||||
return '当前账号已绑定其他设备,' . $sec . '秒后可在该设备登录';
|
||||
}
|
||||
$str = $day . "天" . $hr . "小时" . $min . "分钟" . $sec . "秒"; //组合成字符串
|
||||
return $str;
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user