查看: 913|回复: 0

微擎 人人商城登录后直接进到后台管理页面

[复制链接]

748

主题

39

回帖

3907

积分

管理员

总舵主

积分
3907
QQ
发表于 2024-5-25 20:02:33 | 显示全部楼层 |阅读模式
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. define('IN_GW', true);

  8. load()->model('user');
  9. load()->model('message');
  10. load()->classs('oauth2/oauth2client');
  11. load()->model('setting');

  12. if (checksubmit() || $_W['isajax']) {
  13.         _login($_GPC['referer']);
  14. }

  15. $support_login_types = OAuth2Client::supportThirdLoginType();
  16. if (in_array($_GPC['login_type'], $support_login_types)) {
  17.         _login($_GPC['referer']);
  18. }

  19. $setting = $_W['setting'];
  20. $_GPC['login_type'] = !empty($_GPC['login_type']) ? $_GPC['login_type'] : (!empty($_W['setting']['copyright']['login_type']) ? 'mobile': 'system');
  21. $login_urls = user_support_urls();
  22. template('user/login');

  23. function _login($forward = '') {
  24.         global $_GPC, $_W;
  25.         if (empty($_GPC['login_type'])) {
  26.                 $_GPC['login_type'] = 'system';
  27.         }

  28.         if (empty($_GPC['handle_type'])) {
  29.                 $_GPC['handle_type'] = 'login';
  30.         }


  31.         if ($_GPC['handle_type'] == 'login') {
  32.                 $member = OAuth2Client::create($_GPC['login_type'], $_W['setting']['thirdlogin'][$_GPC['login_type']]['appid'], $_W['setting']['thirdlogin'][$_GPC['login_type']]['appsecret'])->login();
  33.         } else {
  34.                 $member = OAuth2Client::create($_GPC['login_type'], $_W['setting']['thirdlogin'][$_GPC['login_type']]['appid'], $_W['setting']['thirdlogin'][$_GPC['login_type']]['appsecret'])->bind();
  35.         }

  36.         if (!empty($_W['user']) && $_GPC['handle_type'] == 'bind') {
  37.                 if (is_error($member)) {
  38.                         itoast($member['message'], url('user/profile/bind'), '');
  39.                 } else {
  40.                         itoast('绑定成功', url('user/profile/bind'), '');
  41.                 }
  42.         }

  43.         if (is_error($member)) {
  44.                 itoast($member['message'], url('user/login'), '');
  45.         }
  46.         $record = user_single($member);
  47.         if (!empty($record)) {
  48.                 if ($record['status'] == USER_STATUS_CHECK || $record['status'] == USER_STATUS_BAN) {
  49.                         itoast('您的账号正在审核或是已经被系统禁止,请联系网站管理员解决?', url('user/login'), '');
  50.                 }
  51.                 $_W['uid'] = $record['uid'];
  52.                 $_W['isfounder'] = user_is_founder($record['uid']);
  53.                 $_W['user'] = $record;

  54.                
  55.                         if (empty($_W['isfounder']) || user_is_vice_founder()) {
  56.                                 if (!empty($record['endtime']) && $record['endtime'] < TIMESTAMP) {
  57.                                         itoast('您的账号有效期限已过,请联系网站管理员解决!', '', '');
  58.                                 }
  59.                         }
  60.                

  61.                
  62.                 if (!empty($_W['siteclose']) && empty($_W['isfounder'])) {
  63.                         itoast('站点已关闭,关闭原因:'. $_W['setting']['copyright']['reason'], '', '');
  64.                 }
  65.                 $cookie = array();
  66.                 $cookie['uid'] = $record['uid'];
  67.                 $cookie['lastvisit'] = $record['lastvisit'];
  68.                 $cookie['lastip'] = $record['lastip'];
  69.                 $cookie['hash'] = md5($record['password'] . $record['salt']);
  70.                 $session = authcode(json_encode($cookie), 'encode');
  71.                 isetcookie('__session', $session, !empty($_GPC['rember']) ? 7 * 86400 : 0, true);
  72.                 $status = array();
  73.                 $status['uid'] = $record['uid'];
  74.                 $status['lastvisit'] = TIMESTAMP;
  75.                 $status['lastip'] = CLIENT_IP;
  76.                 user_update($status);

  77.                 if (empty($forward)) {
  78.                         $forward = user_login_forward($_GPC['forward']);
  79.                 }

  80.                 if ($record['uid'] != $_GPC['__uid']) {
  81.                         isetcookie('__uniacid', '', -7 * 86400);
  82.                         isetcookie('__uid', '', -7 * 86400);
  83.                 }
  84.                 $failed = pdo_get('users_failed_login', array('username' => trim($_GPC['username']), 'ip' => CLIENT_IP));
  85.                 pdo_delete('users_failed_login', array('id' => $failed['id']));
  86.                 //itoast("欢迎回来,{$record['username']}", $forward, 'success');
  87.                 if ($record['username']=='admin') {
  88.                         isetcookie('__uniacid', 1, 7 * 86400);
  89.                         header('location:'.url('site/entry/web',array('m'=>'ewei_shopv2')));
  90.                     // itoast("欢迎回来,{$record['username']}。", $forward, 'success');
  91.                 }else{
  92.                         $uniacid = pdo_getcolumn('uni_account_users', array('uid' => $record['uid']), 'uniacid');
  93.                         isetcookie('__uniacid', $uniacid, 7 * 86400);
  94.             header('location:'.url('site/entry/web',array('m'=>'ewei_shopv2')));
  95.                 }
  96.         } else {
  97.                 if (empty($failed)) {
  98.                         pdo_insert('users_failed_login', array('ip' => CLIENT_IP, 'username' => trim($_GPC['username']), 'count' => '1', 'lastupdate' => TIMESTAMP));
  99.                 } else {
  100.                         pdo_update('users_failed_login', array('count' => $failed['count'] + 1, 'lastupdate' => TIMESTAMP), array('id' => $failed['id']));
  101.                 }
  102.                 itoast('登录失败,请检查您输入的账号和密码', '', '');
  103.         }
  104. }
复制代码


道不同,不相为谋!理想要有,万一实现了呢?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注公众号

相关侵权、举报、投诉及建议等,请发 E-mail:2513533699@qq.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.|鲁ICP备19000917号|鲁公网安备37078302000320号

在本版发帖
关注公众号
QQ客服返回顶部