first commit
This commit is contained in:
@@ -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