登錄微擎後臺直接跳轉到人人商城後臺首頁

登陸微擎直接跳轉安裝模塊的後臺,而不是微擎的管理頁面。

修改路徑 web\source\user\login.ctrl.php line 134

 

function _login($forward = '') {

    global $_GPC, $_W;
    if (empty($_GPC['login_type'])) {
        $_GPC['login_type'] = 'system';
    }

    if (empty($_GPC['handle_type'])) {
        $_GPC['handle_type'] = 'login';
    }

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

    if (!empty($_W['user']) && $_GPC['handle_type'] != ''  && $_GPC['handle_type'] == 'bind') {
        if (is_error($member)) {
            itoast($member['message'], url('user/profile/bind'), '');
        } else {
            itoast('綁定成功', url('user/profile/bind'), '');
        }
    }

    if (is_error($member)) {
        itoast($member['message'], url('user/login'), '');
    }

    $record = user_single($member);
    $failed = pdo_get('users_failed_login', array('username' => trim($_GPC['username'])));
    if (!empty($record)) {
        if ($record['status'] == USER_STATUS_CHECK || $record['status'] == USER_STATUS_BAN) {
            itoast('您的賬號正在審覈或是已經被系統禁止,請聯繫網站管理員解決?', url('user/login'), '');
        }
        $_W['uid'] = $record['uid'];
        $_W['isfounder'] = user_is_founder($record['uid']);
        $_W['user'] = $record;

        $support_login_bind_types = Oauth2CLient::supportThirdLoginBindType();
        if (in_array($_GPC['login_type'], $support_login_bind_types) && !empty($_W['setting']['copyright']['oauth_bind']) && !$record['is_bind'] && empty($_W['isfounder']) && ($record['register_type'] == USER_REGISTER_TYPE_QQ || $record['register_type'] == USER_REGISTER_TYPE_WECHAT)) {
            message('您還沒有註冊賬號,請前往註冊', url('user/third-bind/bind_oauth', array('uid' => $record['uid'], 'openid' => $record['openid'], 'register_type' => $record['register_type'])));
            exit;
        }

        if (!empty($_W['siteclose']) && empty($_W['isfounder'])) {
            itoast('站點已關閉,關閉原因:'. $_W['setting']['copyright']['reason'], '', '');
        }

        $cookie = array();
        $cookie['uid'] = $record['uid'];
        $cookie['lastvisit'] = $record['lastvisit'];
        $cookie['lastip'] = $record['lastip'];
        $cookie['hash'] = !empty($record['hash']) ? $record['hash'] : md5($record['password'] . $record['salt']);
        $session = authcode(json_encode($cookie), 'encode');
        isetcookie('__session', $session, !empty($_GPC['rember']) ? 7 * 86400 : 0, true);
        $status = array();
        $status['uid'] = $record['uid'];
        $status['lastvisit'] = TIMESTAMP;
        $status['lastip'] = CLIENT_IP;
        user_update($status);

        if (empty($forward)) {
            $forward = user_login_forward($_GPC['forward']);
        }
                $forward = safe_gpc_url($forward);

        if ($record['uid'] != $_GPC['__uid']) {
            isetcookie('__uniacid', '', -7 * 86400);
            isetcookie('__uid', '', -7 * 86400);
        }
        if (!empty($failed)) {
            pdo_delete('users_failed_login', array('id' => $failed['id']));
        }

        $user_endtime = $_W['user']['endtime'];
        if (!empty($user_endtime) && !in_array($user_endtime, array(USER_ENDTIME_GROUP_EMPTY_TYPE, USER_ENDTIME_GROUP_UNLIMIT_TYPE)) && $user_endtime < TIMESTAMP) {
            $user_is_expired = true;
        }

        if ((empty($_W['isfounder']) || user_is_vice_founder()) && $user_is_expired) {
            $user_expire = setting_load('user_expire');
            $user_expire = !empty($user_expire['user_expire']) ? $user_expire['user_expire'] : array();
            $notice = !empty($user_expire['notice']) ? $user_expire['notice'] : '您的賬號已到期,請前往商城購買續費';
            $redirect = !empty($user_expire['status_store_redirect']) && $user_expire['status_store_redirect'] == 1 ? url('home/welcome/ext', array('m' => 'store')) : '';
            $extend_buttons = array();
            if (!empty($user_expire['status_store_button']) && $user_expire['status_store_button'] == 1) {
                $extend_buttons['status_store_button'] = array(
                    'url' => url('home/welcome/ext', array('m' => 'store')),
                    'class' => 'btn btn-primary',
                    'title' => '去商城續費',
                );
            }
            $extend_buttons['cancel'] = array(
                'url' => url('user/profile'),
                'class' => 'btn btn-default',
                'title' => '取消',
            );
            message($notice, $redirect, 'expired', '', $extend_buttons);
        }
        cache_build_frame_menu();
       //修改直接登錄項目後臺
        header('location:'.url('site/entry/web',array('m'=>'ewei_shopv2')));
        //itoast("歡迎回來,{$record['username']}", $forward, 'success');
    } else {
        if (empty($failed)) {
            pdo_insert('users_failed_login', array('ip' => CLIENT_IP, 'username' => trim($_GPC['username']), 'count' => '1', 'lastupdate' => TIMESTAMP));
        } else {
            pdo_update('users_failed_login', array('count' => $failed['count'] + 1, 'lastupdate' => TIMESTAMP), array('id' => $failed['id']));
        }
        itoast('登錄失敗,請檢查您輸入的賬號和密碼', '', '');
    }
}

image.png



作者:程序_源
鏈接:https://www.jianshu.com/p/dfeeded64b54
來源:簡書
著作權歸作者所有。商業轉載請聯繫作者獲得授權,非商業轉載請註明出處。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章