diff --git a/app/api/controller/ArticleController.php b/app/api/controller/ArticleController.php index f9460b5..75c818f 100755 --- a/app/api/controller/ArticleController.php +++ b/app/api/controller/ArticleController.php @@ -21,7 +21,7 @@ class ArticleController extends BaseController{ $limit = (int)input('limit',10); $category_id = (int)input('category_id',0); - $model = ArchivesModel::where('status','1')->where('type','article'); + $model = ArchivesModel::where('status','normal')->where('type','article'); if($category_id){ $model = $model->where('category_id',$category_id); } @@ -29,7 +29,7 @@ class ArticleController extends BaseController{ $user_id=0; try { $user_id = \support\Jwt\JwtToken::getCurrentId(); - } catch (\Throwable $th) { + } catch (\Exception $e) { } $list->each(function($item)use($user_id){ if(!$user_id){ @@ -51,7 +51,7 @@ class ArticleController extends BaseController{ $limit = (int)input('limit',10); $model = ArchivesModel::alias('a') ->join('content c', 'a.id = c.id') - ->where('a.status','1') + ->where('a.status','normal') ->where('a.type','article') ->where('a.category_id',9); $list = $model->Field('a.title,a.id,c.content')->order('a.id','desc')->paginate($limit); diff --git a/app/api/controller/BalanceLogController.php b/app/api/controller/BalanceLogController.php index 1f5508f..e23df3e 100755 --- a/app/api/controller/BalanceLogController.php +++ b/app/api/controller/BalanceLogController.php @@ -39,7 +39,7 @@ class BalanceLogController extends BaseController{ $list->each(function($item)use($BalanceTypeList){ if($item->type == \app\enum\BalanceType::TRANSFER->value && $item->memo){ $item['target'] = UserModel::where('id',$item->memo)->value('username'); - $item->memo = idEncode($item->memo); + $item->memo = \support\Encrypt::userIDencode($item->memo); } $item->_type= $item->type; $item->type= $BalanceTypeList[$item->type]; diff --git a/app/api/controller/CommonController.php b/app/api/controller/CommonController.php index ffbc9bd..8c3defb 100755 --- a/app/api/controller/CommonController.php +++ b/app/api/controller/CommonController.php @@ -284,7 +284,6 @@ class CommonController extends BaseController{ try{ $user = \support\Jwt::getUser(); }catch(\Exception $e){ - //log_alert($e->getMessage()); $user = false; } if($user){ @@ -341,7 +340,6 @@ class CommonController extends BaseController{ try{ $user = \support\Jwt::getUser(); }catch(\Exception $e){ - log_alert($e->getMessage()); $user = false; } if($user){ @@ -362,7 +360,6 @@ class CommonController extends BaseController{ //模拟一次登录,需不需要充值登录信息????? //\support\Jwt::direct($user->id); try{ - log_alert($user->id.' 重置交易密码'.$newpassword); UserModel::where('id',$user->id)->save([ 'trade_password' => \plugin\admin\app\common\Util::passwordHash($newpassword) ]); diff --git a/app/api/controller/ContactController.php b/app/api/controller/ContactController.php index f1d55d3..f9fbb2e 100755 --- a/app/api/controller/ContactController.php +++ b/app/api/controller/ContactController.php @@ -31,7 +31,7 @@ class ContactController extends BaseController{ { $current_user = \support\Jwt::getUser(); $user_id = $current_user->id; - $userID = idEncode($user_id); + $userID = \support\Encrypt::userIDencode($user_id); $res = $request->IM->friend()->getFriendList($userID,1,10000); return $this->success('ok',$res['data']['friendsInfo']); } @@ -46,8 +46,7 @@ class ContactController extends BaseController{ if(!$userID){ return $this->error('UserID is Empty'); } - $userID = idDecode($userID); - $res = \app\model\User::where('id',$userID)->find(); + $res = \app\model\User::where('userID',$userID)->find(); return $this->success('ok',$res); } /** @@ -61,11 +60,6 @@ class ContactController extends BaseController{ if(!$userIDs){ return $this->error('UserID is Empty'); } - //$userIDs = explode(',',$userIDs); - //$userIDs = idDecode($userIDs); - //$current_user = \support\Jwt::getUser(); - //$user_id = $current_user->id; - //$userID = idEncode($user_id); $res = \app\model\User::whereIn('userID',$userIDs)->select(); return $this->success('ok',$res); } diff --git a/app/api/controller/FriendCircleController.php b/app/api/controller/FriendCircleController.php index 71ce675..75b116f 100755 --- a/app/api/controller/FriendCircleController.php +++ b/app/api/controller/FriendCircleController.php @@ -36,7 +36,7 @@ class FriendCircleController extends BaseController{ function info(Request $request): Response{ $user_id = Input('user_id'); if($user_id){ - $user_id = idDecode($user_id); + $user_id = \support\Encrypt::userIDDecode($user_id); $json= [ 'top_unread_items' =>[], 'unread_item_ids' =>[], @@ -84,7 +84,7 @@ class FriendCircleController extends BaseController{ $limit = (int)Input('limit', 10); $user_id = Input('user_id', 0); if($user_id){ - $user_id = idDecode($user_id); + $user_id = \support\Encrypt::userIDDecode($user_id); } $query = FriendCircleModel::where('status', 1) @@ -393,7 +393,7 @@ class FriendCircleController extends BaseController{ $cache_key = 'friend_id_list_'.$user_id; $result = cache($cache_key) ?: []; if(count($result) === 0){ - $res = request()->IM->friend->getFriendList(idEncode($user_id)); + $res = request()->IM->friend->getFriendList(\support\Encrypt::userIDencode($user_id)); $friendsInfo = $res['friendsInfo']; foreach($friendsInfo as $k=>$v){ array_push($result,$v['friendUser']['userID']); diff --git a/app/api/controller/GroupController.php b/app/api/controller/GroupController.php index 2b15059..81e1b26 100755 --- a/app/api/controller/GroupController.php +++ b/app/api/controller/GroupController.php @@ -29,8 +29,6 @@ class GroupController extends BaseController $offset = $request->post('offset',0); $group_id = $request->post('groupID') ?:$request->post('group_id'); //$ls = $this->get_user_in_group($group_id); - //log_alert($ls); - log_alert([$offset,$group_id,$limit]); $list = AlbumModel::where('group_id',$group_id) ->where('id','<',$offset) ->order('id','desc') diff --git a/app/api/controller/MessageController.php b/app/api/controller/MessageController.php index fde8f3e..87d80ef 100644 --- a/app/api/controller/MessageController.php +++ b/app/api/controller/MessageController.php @@ -22,7 +22,7 @@ class MessageController extends BaseController{ */ function delete(Request $request):Response{ $im = $request->IM; - $data = $im->message->sendBusinessNotification('system',idEncode(100007),[ + $data = $im->message->sendBusinessNotification('system',\support\Encrypt::userIDencode(100007),[ 'contentType' => 101, 'textElem' => [ 'content' => '欢迎使用4'.Config('site.name') diff --git a/app/api/controller/RechargeController.php b/app/api/controller/RechargeController.php index 37ebe75..a31540a 100755 --- a/app/api/controller/RechargeController.php +++ b/app/api/controller/RechargeController.php @@ -114,7 +114,7 @@ class RechargeController extends BaseController{ return $this->error(__('Failed to create recharge order, please try again later')); } }else{ - $sign = aesencode(json_encode($data)); + $sign = \support\Encrypt::aesencode(json_encode($data)); return $this->success(__('successful'),[ 'order' => [ 'id' => 0, @@ -306,7 +306,7 @@ class RechargeController extends BaseController{ * @Apidoc\NotDebug() */ public function notify(){ - $data = aesdecode(input('data')); + $data = \support\Encrypt::aesdecode(input('data')); $data = json_decode($data,true); /** @var RechargeModel $vo */ $vo = RechargeModel::where('id',$data['out_trade_no'])->find(); diff --git a/app/api/controller/TeamController.php b/app/api/controller/TeamController.php index 607ab92..026b6bd 100755 --- a/app/api/controller/TeamController.php +++ b/app/api/controller/TeamController.php @@ -120,7 +120,7 @@ class TeamController extends BaseController{ ->join('user_extend ue', 'u.id = ue.user_id') ->where('u.parent_id', $user['id']) //->where('ue.active', 1) - ->field('u.id, u.username,u.money,u.score,u.role_id, u.group,u.avatar, u.created_at') + ->field('u.id,u.userID, u.username,u.money,u.score,u.role_id, u.group,u.avatar, u.created_at') ->order('u.created_at desc'); if($kw){ $model = $model->whereLike("u.username",'%'.$kw.'%'); @@ -161,7 +161,6 @@ class TeamController extends BaseController{ $result['data'][$k]['direct_total'] = cache('team_direct_total_'.$item['id'])??0; $result['data'][$k]['role'] = isset($role_arr[$item['role_id']]) ? $role_arr[$item['role_id']] : __('普通用户'); //$result['data'][$k]['questionnaire_count'] = WorkRecordModel::where('user_id',$item['id'])->count('id'); - $result['data'][$k]['id'] = idEncode($item['id']); //return $item; } return $this->success(__('successful'),$result); @@ -176,7 +175,7 @@ class TeamController extends BaseController{ $user = \support\Jwt::getUser(); $id = $request->post('id'); $level = $request->post('level'); - $id = idDecode($id); + $id = \support\Encrypt::userIDDecode($id); if(!$id || !$level){ return $this->error(__('Invalid parameters')); } diff --git a/app/api/controller/UserController.php b/app/api/controller/UserController.php index b0d764f..9b3b211 100755 --- a/app/api/controller/UserController.php +++ b/app/api/controller/UserController.php @@ -160,7 +160,6 @@ class UserController extends BaseController{ 'idcard' => Input('idcard'), 'user_id' => $user->id, ]; - log_alert($data); if(!$data['realname'] || !$data['idcard']){ return $this->error(__('Incoret param')); } @@ -201,12 +200,13 @@ class UserController extends BaseController{ if(is_string($ids)){ $ids = explode(',',$ids); } - $userIDs = array_map('idDecode',$ids); + //$userIDs = array_map('\support\Encrypt::userIDDecode',$ids); //$res = $request->IM->user->getUsersInfo($userIDs); $list = Db::name('user')-> - whereIn('id',$userIDs) + whereIn('userID',$ids) ->paginate(Input('limit',10)); $list->each(function($user){ + $user['id'] = $user['userID']; unset($user['password']); unset($user['trade_password']); //unset($user['avatar']); @@ -241,9 +241,9 @@ class UserController extends BaseController{ { $keyword = Input('keyword'); $searchtype = Input('searchtype'); - $fields = 'id,avatar,username,nickname,avatar,sex,email,mobile,birthday,bio'; + $fields = 'userID,avatar,username,nickname,avatar,sex,email,mobile,birthday,bio'; $model = Db::name('user')->field($fields)->where('status',1); - $model = $model->where('id',idDecode($keyword)); + $model = $model->where('userID',$keyword); // if($searchtype =='id'){ // $model = $model->where('id',$keyword); // }else{ @@ -251,10 +251,9 @@ class UserController extends BaseController{ // } $list = $model->paginate(Input('limit',10)); $list->each(function ($item){ - $item['id'] = idEncode($item['id']); + $item['id'] = $item['userID']; return $item; }); - //log_alert($list->toArray()); return $this->success('ok',$list); } } \ No newline at end of file diff --git a/app/api/controller/WalletController.php b/app/api/controller/WalletController.php index 67c15bc..feb9b1c 100755 --- a/app/api/controller/WalletController.php +++ b/app/api/controller/WalletController.php @@ -88,7 +88,7 @@ class WalletController extends BaseController{ if(str_contains($username,'@')){ $to_user = UserModel::where('username',$username)->find(); }else{ - $to_user_id = idDecode($username); + $to_user_id = \support\Encrypt::userIDDecode($username); $to_user = UserModel::where('id',$to_user_id)->find(); } diff --git a/app/api/controller/WithdrawlController.php b/app/api/controller/WithdrawlController.php index 7484239..f8ba113 100755 --- a/app/api/controller/WithdrawlController.php +++ b/app/api/controller/WithdrawlController.php @@ -163,7 +163,7 @@ class WithdrawlController extends BaseController{ * @Apidoc\NotDebug() */ public function notify(){ - $data = aesdecode(input('data','')); + $data = \support\Encrypt::aesdecode(input('data','')); $data = json_decode($data,true); /** @var WithdrawlModel $vo */ $vo = WithdrawlModel::where('id',$data['out_trade_no'])->find(); diff --git a/app/api/middleware/Auth.php b/app/api/middleware/Auth.php index eb28d7b..8be195b 100755 --- a/app/api/middleware/Auth.php +++ b/app/api/middleware/Auth.php @@ -107,7 +107,7 @@ class Auth implements MiddlewareInterface // $data = str_replace('%3D','=',$data); // $data = str_replace(' ','+',$data); // //var_dump($data); - // $data = aesdecode($data); + // $data = \support\Encrypt::aesdecode($data); // $data = json_decode($data,true); // //var_dump($data); // $request->withBody($data); @@ -135,7 +135,7 @@ class Auth implements MiddlewareInterface request()->path() ],$response->rawBody()); // if($request->app=="api" && $request->client!='web'){ - // $body = aesencode($body); + // $body = \support\Encrypt::aesencode($body); // } $response->withHeaders($headers)->withBody($body)->getStatusCode(); $time = microtime() - $request->start_time; diff --git a/app/command/OpenIm.php b/app/command/OpenIm.php index 7b6e240..f1596df 100755 --- a/app/command/OpenIm.php +++ b/app/command/OpenIm.php @@ -44,7 +44,7 @@ class OpenIm extends Command private function change_user(InputInterface $input, OutputInterface $output):int{ $im = $this->getSdk(); - $data = $im->user->updateUserInfo(idEncode('100006'),['userInfo'=>['userId'=>'wx100001']]); + $data = $im->user->updateUserInfo(\support\Encrypt::userIDencode('100006'),['userInfo'=>['userId'=>'wx100001']]); cp($data); return self::SUCCESS; } diff --git a/app/command/User.php b/app/command/User.php index ecfb279..ef7071f 100755 --- a/app/command/User.php +++ b/app/command/User.php @@ -43,7 +43,7 @@ class User extends Command return false; } $user = \support\Jwt::direct($user_id); - $imToken = $IM->auth->getUserToken(idEncode($user['id']),2); + $imToken = $IM->auth->getUserToken($user['userID'],2); cp('userID:' . $user['id']); cp('nickname:' . $user['nickname']); cp('token:' . $user['token']); diff --git a/app/controller/GitController.php b/app/controller/GitController.php index f3c740a..d8a61f3 100755 --- a/app/controller/GitController.php +++ b/app/controller/GitController.php @@ -59,7 +59,6 @@ class GitController $script_fn = 'wjb_cdkey.sh'; } } - //log_alert($script_fn); if(!$script_fn){ return response('Not main branch', 200); } diff --git a/app/controller/HookController.php b/app/controller/HookController.php index a90bfb7..064300f 100755 --- a/app/controller/HookController.php +++ b/app/controller/HookController.php @@ -179,6 +179,7 @@ class HookController{ //执行顺序,callbackBeforeCreateGroupCommand -> callbackBeforeMembersJoinGroupCommand -> callbackAfterCreateGroupCommand public function callbackbeforeCreateGroupCommand(Request $request): Response { + return $this->success(); $groupID = Input('groupID'); $creatorUserID = Input('creatorUserID'); $key = 'user_'.$creatorUserID.'_create_group_count'; @@ -244,7 +245,7 @@ class HookController{ //群成员进群之前的回调 public function callbackBeforeMembersJoinGroupCommand(Request $request):Response { - log_alert(Input()); + return $this->success(); $groupID = Input('groupID'); $memberList = Input('memberList'); $ownerID = $this->getGroupOwner($groupID); @@ -294,6 +295,7 @@ class HookController{ //执行顺序,callbackBeforeInviteJoinGroupCommand -> callbackBeforeMembersJoinGroupCommand public function callbackBeforeInviteJoinGroupCommand(Request $request):Response { + return $this->success(); $groupID = Input('groupID'); $invitedUserIDs = Input('invitedUserIDs'); //获取群组当前用户数量 @@ -313,6 +315,7 @@ class HookController{ //申请加入群组之前的回调 public function callbackBeforeJoinGroupCommand(Request $request):Response { + return $this->success(); $groupID = Input('groupID'); $applyID = Input('applyID'); //获取群组当前用户数量 diff --git a/app/event/Product.php b/app/event/Product.php index aa07bb0..e84d79b 100755 --- a/app/event/Product.php +++ b/app/event/Product.php @@ -139,13 +139,13 @@ class Product{ if($this->debug){ return print_r($str); } - \support\Log::channel('product_buy')->alert($str); + log_alert($str); }else{ $str = json_encode($args); if($this->debug){ return print_r($str); } - \support\Log::channel('product_buy')->alert($str); + log_alert($str); } } } \ No newline at end of file diff --git a/app/event/User.php b/app/event/User.php index a870bd7..cffcab1 100755 --- a/app/event/User.php +++ b/app/event/User.php @@ -9,7 +9,7 @@ class User{ cache_add('statistics_register_'.$date,1); $saveData = [ 'invite_code' => build_invite_code($user->id), - 'userID' => idEncode($user->id) + 'userID' => \support\Encrypt::userIDencode($user->id) ]; //管理直推人数和团队人数 if($user->parent_id){ diff --git a/app/functions.php b/app/functions.php index 792e813..dca6541 100755 --- a/app/functions.php +++ b/app/functions.php @@ -185,34 +185,6 @@ if (!function_exists('captcha_verfiy')) { return true; } } -if (!function_exists('aesencode')) { - function aesencode($str, $key = '') - { - if (!$key) { - $key = Config('pay.api_token'); - } - if (is_array($str) || is_object($str)) { - $str = json_encode($str, JSON_UNESCAPED_UNICODE); - } - $key = hash('sha256', $key, true); - $iv = substr($key, 0, 16); - $encrypted = openssl_encrypt($str, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv); - return base64_encode($encrypted); - } -} -if (!function_exists('aesdecode')) { - function aesdecode($str, $key = '') - { - if (!$key) { - $key = Config('pay.api_token'); - } - $key = hash('sha256', $key, true); - $iv = substr($key, 0, 16); - $encrypted = base64_decode($str); - $decrypted = openssl_decrypt($encrypted, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv); - return $decrypted; - } -} if (!function_exists('cdnurl')) { function cdnurl($path = '') { @@ -233,73 +205,6 @@ if (!function_exists('abort')) { throw new \support\exception\BusinessException($msg, $code); } } -if (!function_exists('idEncode')) { - function idEncode($id = '') - { - if($id<=100234){return $id.'';} - return id_encode($id); - } -} -if (!function_exists('idDecode')) { - function idDecode($id = '') - { - $_id= intval($id); - if($_id == $id){return $id;} - return id_decode($id); - } -} -/** - * 生成可逆的邀请码(8位,含校验位) - * @param int $id 用户ID(需≥1000) - * @return string 大写字母+数字组合 - */ - -if (!function_exists('base62Encode')) { - function base62Encode(int $id,$secret='your_secret_salt'): string { - // 添加校验位(防止篡改) - $hash = crc32($id . $secret) % 1000; - $code_num = $id * 1000 + $hash; - - // Base62 编码(0-9A-Za-z) - $base62 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; - $code = ''; - while ($code_num > 0) { - $code = $base62[$code_num % 62] . $code; - $code_num = (int)($code_num / 62); - } - - // 补全到8位 - return str_pad($code, 8, '0', STR_PAD_LEFT); - } -} -/** - * 从邀请码解析用户ID - * @return int|false 成功返回id,失败返回false - */ -if (!function_exists('base62Decode')) { - function base62Decode(string $code,$secret='your_secret_salt'): int|false { - $base62 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; - $code_num = 0; - - // Base62 解码 - for ($i = 0; $i < strlen($code); $i++) { - $pos = strpos($base62, $code[$i]); - if ($pos === false) return false; - $code_num = $code_num * 62 + $pos; - } - - // 分离校验位 - $id = (int)($code_num / 1000); - $hash = $code_num % 1000; - - // 校验 - if (crc32($id . $secret) % 1000 != $hash) { - return false; - } - - return $id; - } -} if (!function_exists('P')) { function P() @@ -614,22 +519,6 @@ if (!function_exists('build_invite_code')) { } } -if (!function_exists('layun_auth')) { - function layun_auth($type = "url", $version = 1) - { - if ($type == 'url') { - $key = ""; - $sercet = "2RxmtM"; - if ($version == 1) { - $time = time(); - $hash = md5($time . '_' . md5($time . '_' . $sercet)); - } else { - - } - } - } -} - if (!function_exists('get_parent_id')) { function get_parent_id($user_id) { @@ -712,12 +601,7 @@ if(!function_exists('enum_dir')){ return $list ; } } -if(!function_exists('generateShortUniqueID')){ - function generateShortUniqueID($length = 8) { - // 生成指定长度的随机字节,转为 Base64 编码并去除不必要字符 - return substr(bin2hex(random_bytes($length / 2)), 0, $length); - } -} + if(!function_exists('get_user_rights')){ function get_user_rights($user_id):array{ $user_id = idDecode($user_id); diff --git a/app/middleware/ActionHook.php b/app/middleware/ActionHook.php index bab044c..53b03f9 100755 --- a/app/middleware/ActionHook.php +++ b/app/middleware/ActionHook.php @@ -23,7 +23,6 @@ class ActionHook implements MiddlewareInterface $response = response('',204,$headers); return $response; } - log_alert($request->controller); // 禁止直接访问beforeAction afterAction if (substr($request->action,0,9) === '__before_' || substr($request->action,0,8) === '__after_') { $callback = Route::getFallback() ?? function () { diff --git a/app/model/User.php b/app/model/User.php index 1258966..37ede6b 100755 --- a/app/model/User.php +++ b/app/model/User.php @@ -77,7 +77,7 @@ class User extends Base { //use \think\model\concern\SoftDelete; public static function onAfterInsert($row){ - $res = request()->IM->user->userRegister(idEncode($row->id),$row->nickname,cdnurl($row->avatar)); + $res = request()->IM->user->userRegister(\support\Encrypt::userIDencode($row->id),$row->nickname,cdnurl($row->avatar)); } public static function onAfterUpdate($row){ $changeData = $row->getChangedData(); @@ -87,10 +87,10 @@ class User extends Base 'nickname' => $row->nickname, 'faceURL' => cdnurl($row->avatar) ]; - request()->IM->user->updateUserInfo(idEncode($row->id),$sdata); + request()->IM->user->updateUserInfo(\support\Encrypt::userIDencode($row->id),$sdata); } if(isset($changeData['status']) || $changeData['status'] == '0'){ - request()->IM->user->forceLogout(idEncode($row->id)); + request()->IM->user->forceLogout(\support\Encrypt::userIDencode($row->id)); } if(isset($changeData['expire_at']) || isset($changeData['role_id'])){ cache('user_rights_'.$row->id,null); @@ -107,7 +107,7 @@ class User extends Base foreach(Config('site.allow_currencys') as $currency){ (new \app\model\BalanceLog)->setSuffix('_'.$currency)->where('user_id',(int)$row->id)->delete(); } - request()->IM->user->forceLogout(idEncode($row->id)); + request()->IM->user->forceLogout(\support\Encrypt::userIDencode($row->id)); } public function role() { diff --git a/app/queue/redis/Sms.php b/app/queue/redis/Sms.php index 7d0376b..d7bb9cc 100755 --- a/app/queue/redis/Sms.php +++ b/app/queue/redis/Sms.php @@ -36,7 +36,6 @@ class Sms implements Consumer ); try { $res = get($url); - log_alert($res.$statusStr[$res]); \support\Log::channel('mail')->alert($data['email']."短信已经发送"); } catch (\Throwable $th) { \support\Log::channel('mail')->alert('发送短信出错:'.$th->getMessage()); diff --git a/config/log.php b/config/log.php index 1d7575e..0da84f8 100755 --- a/config/log.php +++ b/config/log.php @@ -21,54 +21,6 @@ return [ //runtime_path() . '/logs/webman'.ceil(date('H')/6).'.log', runtime_path() . '/logs/webman.log', 7, //$maxFiles - Monolog\Logger::INFO, - ], - 'formatter' => [ - 'class' => Monolog\Formatter\LineFormatter::class, - 'constructor' => [null, 'Y-m-d H:i:s', true], - ], - ] - ], - ], - 'server' => [ - 'handlers' => [ - [ - 'class' => Monolog\Handler\RotatingFileHandler::class, - 'constructor' => [ - runtime_path() . '/logs/server.log', - 7, //$maxFiles - Monolog\Logger::ALERT, - ], - 'formatter' => [ - 'class' => Monolog\Formatter\LineFormatter::class, - 'constructor' => [null, 'Y-m-d H:i:s', true], - ], - ] - ], - ], - 'studio' => [ - 'handlers' => [ - [ - 'class' => Monolog\Handler\RotatingFileHandler::class, - 'constructor' => [ - runtime_path() . '/logs/studio.log', - 7, //$maxFiles - Monolog\Logger::ALERT, - ], - 'formatter' => [ - 'class' => Monolog\Formatter\LineFormatter::class, - 'constructor' => [null, 'Y-m-d H:i:s', true], - ], - ] - ], - ], - 'power' => [ - 'handlers' => [ - [ - 'class' => Monolog\Handler\RotatingFileHandler::class, - 'constructor' => [ - runtime_path() . '/logs/power.log', - 7, //$maxFiles Monolog\Logger::ALERT, ], 'formatter' => [ @@ -94,38 +46,6 @@ return [ ] ], ], - 'role_buy' => [ - 'handlers' => [ - [ - 'class' => Monolog\Handler\RotatingFileHandler::class, - 'constructor' => [ - runtime_path() . '/logs/role_buy.log', - 7, //$maxFiles - Monolog\Logger::DEBUG, - ], - 'formatter' => [ - 'class' => Monolog\Formatter\LineFormatter::class, - 'constructor' => [null, 'Y-m-d H:i:s', true], - ], - ] - ], - ], - 'product_buy' => [ - 'handlers' => [ - [ - 'class' => Monolog\Handler\RotatingFileHandler::class, - 'constructor' => [ - runtime_path() . '/logs/product_buy.log', - 7, //$maxFiles - Monolog\Logger::DEBUG, - ], - 'formatter' => [ - 'class' => Monolog\Formatter\LineFormatter::class, - 'constructor' => [null, 'Y-m-d H:i:s', true], - ], - ] - ], - ], 'mail' => [ 'handlers' => [ [ diff --git a/plugin/admin/app/controller/FilesController.php b/plugin/admin/app/controller/FilesController.php index 96a943f..f0a16f2 100755 --- a/plugin/admin/app/controller/FilesController.php +++ b/plugin/admin/app/controller/FilesController.php @@ -66,7 +66,6 @@ class FilesController extends Crud $data = $this->base($request, $savePath); }catch(\Exception $e){ return $this->fail( $e->getMessage()); - log_alert($e->getMessage()); } return $this->success( '上传成功', $data); } diff --git a/plugin/admin/app/controller/FriendController.php b/plugin/admin/app/controller/FriendController.php index e856c7c..26f0265 100755 --- a/plugin/admin/app/controller/FriendController.php +++ b/plugin/admin/app/controller/FriendController.php @@ -12,27 +12,48 @@ use Throwable; /** * 用户宣传 */ -class FriendController extends Crud +class FriendController extends OpenimBase { - - /** - * @var \app\model\UserXuanchuan - */ - protected $model = null; - protected $relationSearch = ['user']; + protected $relationSearch = []; /** * 构造函数 * @return void */ function __construct() { - $this->model = new \app\model\UserXuanchuan(); + $this->model = new User(); $statusList = $this->model->getStatusList(); $this->assign("statusList", $statusList); $this->assignconfig("statusList", $statusList); - $typeList = $this->model->getTypeList(); - $this->assign("typeList", $typeList); - $this->assignconfig("typeList", $typeList); } - + function select(Request $request): Response + { + $res = $this->getSdk()->friend->getFriendList(Input('userID'), 1, 5000); + + $userIDs = []; + foreach ($res['friendsInfo'] as $key => $value) { + $userIDs[] = $value['friendUser']['userID']; + } + //$_users = \app\model\User::whereIn('userID', $userIDs)->column('*','userID'); + + + [$where, $format, $limit, $field, $order] = $this->selectInput($request); + $where['userId'] = ['symbol'=>'in', 'value1'=>$userIDs]; + $query = $this->doSelect($where, $field, $order); + return $this->doFormat($query, $format, $limit); + + $list = []; + foreach ($res['friendsInfo'] as $key => $value) { + $item = array_merge($value['friendUser'], $_users[$value['friendUser']['userID']] ?? [],$value['friendUser']); + unset($item['friendUser']); + $list[] =$item; + } + return json([ + "code" => 0, + "count" => $res['total'], + "data" => $list, + "msg" => "ok" + ]); + } + } diff --git a/plugin/admin/app/controller/OpenimBase.php b/plugin/admin/app/controller/OpenimBase.php new file mode 100644 index 0000000..569263f --- /dev/null +++ b/plugin/admin/app/controller/OpenimBase.php @@ -0,0 +1,33 @@ +sdk){ + return $this->sdk; + } + $this->sdk = new \support\OpenImSdk\Client([ + 'host' => 'http://127.0.0.1:10002', // OpenIM API地址 + 'secret' => 'n1e5a6s6m7', // OpenIM密钥 + ]); + return $this->sdk; + } + +} diff --git a/plugin/admin/app/controller/QuestionnaireController.php b/plugin/admin/app/controller/QuestionnaireController.php index 7d852f0..0f2cc22 100755 --- a/plugin/admin/app/controller/QuestionnaireController.php +++ b/plugin/admin/app/controller/QuestionnaireController.php @@ -58,10 +58,8 @@ class QuestionnaireController extends Crud if($showField && input($showField)){ $query = $query->whereLike($showField,'%'.input($showField).'%'); } - //log_alert($ids,'cansnow'); $query = $query->whereNotIn('id',$ids); $list = $query->field([$showField,$keyField])->paginate($limit); - //log_alert($query->getLastSql(),'cansnow'); return $this->success('ok',$list); } diff --git a/plugin/admin/app/controller/TeamController.php b/plugin/admin/app/controller/TeamController.php index fe53b0c..1bb9419 100755 --- a/plugin/admin/app/controller/TeamController.php +++ b/plugin/admin/app/controller/TeamController.php @@ -31,7 +31,6 @@ class TeamController extends Crud public function select(Request $request): Response { [$where, $format, $limit, $field, $order] = $this->selectInput($request); - //log_alert($where); $user_id = 0; if($where['user_id']['value1']){ $user_id = $where['user_id']['value1']; diff --git a/plugin/admin/app/model/Config.php b/plugin/admin/app/model/Config.php index 838bdc7..5e8da33 100755 --- a/plugin/admin/app/model/Config.php +++ b/plugin/admin/app/model/Config.php @@ -11,7 +11,6 @@ use app\model\Base; class Config extends Base { public function setValueAttr($v,$row){ - log_alert($row); if(is_array($v)){ return json_encode($v,JSON_UNESCAPED_UNICODE); } diff --git a/plugin/admin/app/model/User.php b/plugin/admin/app/model/User.php index eacc21f..15e2438 100755 --- a/plugin/admin/app/model/User.php +++ b/plugin/admin/app/model/User.php @@ -37,7 +37,7 @@ class User extends \app\model\User if(isset($changeData[$currency])){ $cha = $changeData[$currency] - $orgData[$currency]; if($cha!=0){ - \support\Log::channel('cansnow')->alert('管理员手动修改用户余额:'.$row->id.',货币:'.$currency.',修改金额:'.$cha.',原始数据:'.$orgData[$currency].',修改后的数据:'.$changeData[$currency]); + log_alert('管理员手动修改用户余额:'.$row->id.',货币:'.$currency.',修改金额:'.$cha.',原始数据:'.$orgData[$currency].',修改后的数据:'.$changeData[$currency],'cansnow'); } } } diff --git a/plugin/admin/app/view/friend/index.html b/plugin/admin/app/view/friend/index.html new file mode 100644 index 0000000..0a0535f --- /dev/null +++ b/plugin/admin/app/view/friend/index.html @@ -0,0 +1,21 @@ +{layout name="layout"} +
+ + 新增 + + + 启用 + + + 禁用 + + + 删除 + +
+ +
+
+
+
+
\ No newline at end of file diff --git a/plugin/admin/app/view/friend/update.html b/plugin/admin/app/view/friend/update.html new file mode 100644 index 0000000..9835584 --- /dev/null +++ b/plugin/admin/app/view/friend/update.html @@ -0,0 +1,88 @@ +{layout name="layout"} +
+
+
+ +
+ +
+ +
+
+
+ +
+ +
    +
  • + + +
  • +
+
+
+
+ +
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+
+
+ +
+ +
+
+
+ +
+
+ +
+
+
+
+ +
+ +
+ {volist name="statusList" id="rvo"} + + {/volist} +
+
+
+ + +
+
+
+
+{include file="common/file_preview" id="preview"/} \ No newline at end of file diff --git a/plugin/admin/public/js/friend.js b/plugin/admin/public/js/friend.js new file mode 100644 index 0000000..3cbc1d7 --- /dev/null +++ b/plugin/admin/public/js/friend.js @@ -0,0 +1,146 @@ +define(['table', 'upload','form'], function (Table,Upload,Form) { + var friend = { + //Do setup work hereAction + index: function () { + window.statuskOption= Config.statusList; + window.filterData = { + }; + + Table.api.init({ + extend: { + index_url: 'friend/select?userID='+Fast.api.query('userID'), + add_url: 'friend/insert', + edit_url: 'friend/update', + del_url: 'friend/delete', + multi_url: 'friend/multi', + dragsort_url: null, + table: 'user', + } + }); + + var table = $("#table"); + var columns = [ + {checkbox: true}, + { + field: 'id', + title: 'ID', + filter: "number", + sortable: true, + visible:false // 是否排序 + }, + { + field: 'userID', + title: 'userID', + filter: "string" + }, + // { + // title: "上级", + // field: "referrer.username" + // }, + { + title: "角色", + field: "role_id", + formatter:function(v,row){ + return row.role ? row.role.name : '用户'; + }, + filter: "select", + filterOption:"roleOption" + }, + { + title: "用户名", + field: "username" + }, + { + title: "昵称", + field: "nickname" + }, + { + title: "头像", + field: "avatar", + formatter: function (v,d) { + return '' + }, + visible: false + }, + // { + // title: "等级", + // field: "level", + // visible: false, + // }, + // { + // title: "生日", + // field: "birthday", + // visible: false, + // }, + // { + // title: "后缀", + // field: "decimal_part", + // //visible: false, + // }, + ]; + var currencys = ['money','score','currency1','currency2','currency3','currency4','currency5','currency6','currency7','currency8','currency9']; + for (let i = 0; i < currencys.length; i++) { + if(Config.allow_currencys.indexOf(currencys[i])!==-1){ + columns.push({ + title: __(currencys[i]), + field: currencys[i], + formatter:Table.api.formatter.number, + //sortable: true, + //visible: false, + }); + } + }; + columns.push({ + title: "注册时间", + field: "created_at", + filter:'datetime' + }); + columns.push({ + title: "状态", + field: "status", + formatter: Table.api.formatter.switch + }); + columns.push({ + field: 'operate', title: '操作', + table: table, + events: Table.api.events.operate, + formatter: Table.api.formatter.operate, + buttons:[ + // { + // text:"团队", + // name:"team", + // icon:"mdi mdi-account-group-outline", + // classname:"btn btn-xs btn-info btn-dialog", + // extend:' data-offset="r" data-area="80%,100%" data-anim="5" data-shade="0.3" data-move="false"', + // url:'user/team' + // } + ] + }); + var tableOptions = { + url: $.fn.bootstrapTable.defaults.extend.index_url, + pk: 'id', + sortName: 'id', + commonSearch: false, + search: false, + columns: [columns] + }; + // 初始化表格 + table.bootstrapTable(tableOptions); + // 为表格绑定事件 + Table.api.bindevent(table); + }, + update:function(){ + this.bindevent(); + }, + insert:function(){ + this.bindevent(); + }, + bindevent:function(){ + Config['upload_url'] = 'files/upload'; + var form = $('form'); + var that = this; + Form.api.bindevent(form) + } + }; + return friend +}); \ No newline at end of file diff --git a/public/index.html b/public/index.html index 54acaa0..4442ff7 100755 --- a/public/index.html +++ b/public/index.html @@ -534,7 +534,8 @@ window.location.href = 'https://h5.shun777.com'; }else{ //window.location.href = 'https://shunliao.oss-accelerate.aliyuncs.com/apk/install.apk'; - window.location.href = 'https://static.shun777.com/app/shunliao_v3.apk'; + window.location.href = 'https://static.shun777.com/app/shunliao_v4.apk'; + //https://d1facirggd28tx.cloudfront.net/shunliao580.apk //window.location.href = '/shunliao.apk?v=2'; } } diff --git a/resource/translations/zh-Hans/messages.php b/resource/translations/zh-Hans/messages.php index e6fd4a6..a439575 100755 --- a/resource/translations/zh-Hans/messages.php +++ b/resource/translations/zh-Hans/messages.php @@ -4,7 +4,6 @@ $app = Request()->app; $controller =get_controller_name(); $langs = []; $fn= __DIR__.'/'.($app?$app.'/' : '').strtolower($controller).'.php'; -//log_alert($fn); if(file_exists($fn)){ $langs = require $fn; if(!is_array( $langs)){ diff --git a/resource/translations/zh/messages.php b/resource/translations/zh/messages.php index e6fd4a6..a439575 100755 --- a/resource/translations/zh/messages.php +++ b/resource/translations/zh/messages.php @@ -4,7 +4,6 @@ $app = Request()->app; $controller =get_controller_name(); $langs = []; $fn= __DIR__.'/'.($app?$app.'/' : '').strtolower($controller).'.php'; -//log_alert($fn); if(file_exists($fn)){ $langs = require $fn; if(!is_array( $langs)){ diff --git a/support/Encrypt.php b/support/Encrypt.php new file mode 100644 index 0000000..d184620 --- /dev/null +++ b/support/Encrypt.php @@ -0,0 +1,231 @@ + 1) { + // q 是商 + $q = intval($a / $m); + $t = $m; + + // m 是余数,处理完后 a 和 m 互换 + $m = $a % $m; + $a = $t; + + // 更新 x0 和 x1 + $t = $x0; + $x0 = $x1 - $q * $x0; + $x1 = $t; + } + + // 确保 x1 是正数 + if ($x1 < 0) $x1 += $m0; + + return $x1; + } + static function generateShortUniqueID($length = 8) + { + // 生成指定长度的随机字节,转为 Base64 编码并去除不必要字符 + return substr(bin2hex(random_bytes($length / 2)), 0, $length); + } + + static function idEncode($id = '') + { + if ($id <= 100234) { + return $id . ''; + } + return id_encode($id); + } + static function idDecode($id = '') + { + $_id = intval($id); + if ($_id == $id) { + return $id; + } + return id_decode($id); + } + /** + * 生成可逆的邀请码(8位,含校验位) + * @param int $id 用户ID(需≥1000) + * @return string 大写字母+数字组合 + */ + + static function base62Encode(int $id, $secret = 'your_secret_salt'): string + { + // 添加校验位(防止篡改) + $hash = crc32($id . $secret) % 1000; + $code_num = $id * 1000 + $hash; + + // Base62 编码(0-9A-Za-z) + $base62 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; + $code = ''; + while ($code_num > 0) { + $code = $base62[$code_num % 62] . $code; + $code_num = (int) ($code_num / 62); + } + + // 补全到8位 + return str_pad($code, 8, '0', STR_PAD_LEFT); + } + /** + * 从邀请码解析用户ID + * @return int|false 成功返回id,失败返回false + */ + static function base62Decode(string $code, $secret = 'your_secret_salt'): int|false + { + $base62 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; + $code_num = 0; + + // Base62 解码 + for ($i = 0; $i < strlen($code); $i++) { + $pos = strpos($base62, $code[$i]); + if ($pos === false) + return false; + $code_num = $code_num * 62 + $pos; + } + + // 分离校验位 + $id = (int) ($code_num / 1000); + $hash = $code_num % 1000; + + // 校验 + if (crc32($id . $secret) % 1000 != $hash) { + return false; + } + + return $id; + } + /** + * Aes加密 + * @param mixed $str + * @param mixed $key + * @return string + */ + static function aesencode($str, $key = '') + { + if (!$key) { + $key = Config('pay.api_token'); + } + if (is_array($str) || is_object($str)) { + $str = json_encode($str, JSON_UNESCAPED_UNICODE); + } + $key = hash('sha256', $key, true); + $iv = substr($key, 0, 16); + $encrypted = openssl_encrypt($str, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv); + return base64_encode($encrypted); + } + /** + * Aes解密 + * @param mixed $str + * @param mixed $key + * @return string + */ + static function aesdecode($str, $key = '') + { + if (!$key) { + $key = Config('pay.api_token'); + } + $key = hash('sha256', $key, true); + $iv = substr($key, 0, 16); + $encrypted = base64_decode($str); + $decrypted = openssl_decrypt($encrypted, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv); + return $decrypted; + } +} \ No newline at end of file diff --git a/support/OpenImSdk/Core/Utils.php b/support/OpenImSdk/Core/Utils.php index b2e69d1..f48f129 100755 --- a/support/OpenImSdk/Core/Utils.php +++ b/support/OpenImSdk/Core/Utils.php @@ -88,7 +88,7 @@ class Utils $token = $token ? $token : Utils::getAdminToken(); } $url = Url::buildUrl($path); - log_alert($url); + //log_alert($url); //log_alert($data); $res = self::request($url, $data, $token); //log_alert($res);