chengkun
2025-04-27 cc0f23e36407bd75f9fa45a63b7b68e69cf9c769
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<?php
 
 
 
class index_controller extends common
{
    function actMsg($msgUrl, $msg, $status = 8)
    {
 
        $this->ACT_msg($msgUrl, $msg, $status);
    }
 
    function getMsgUrl()
    {
 
        if (isMobileUser()) {
            if ($this->config['sy_wapdomain'] != "") {
                if ($this->config['sy_wapssl'] == '1') {
 
                    $protocol   =   'https://';
                } else {
 
                    $protocol   =   'http://';
                }
                if (strpos($this->config['sy_wapdomain'], 'http://') === false && strpos($this->config['sy_wapdomain'], 'https://') === false) {
 
                    $msgUrl =   $protocol . $this->config['sy_wapdomain'];
                } else {
 
                    $msgUrl =   $this->config['sy_wapdomain'];
                }
            } else {
 
                $msgUrl =   $this->config['sy_weburl'] . '/wap/';
            }
        } else {
 
            $msgUrl     =   $this->config['sy_weburl'];
        }
 
        return $msgUrl;
    }
 
    function index_action()
    {
 
        $msgUrl     =   $this->getMsgUrl();
 
        $UserinfoM  =   $this->MODEL("userinfo");
 
        if ($this->config['sy_sinalogin'] != "1") {
            if ((int)$_GET['login'] == "1") {
 
                $this->actMsg($msgUrl, "对不起,新浪登录已关闭!");
            }
        }
 
        include_once(APP_PATH . 'api/weibo/saetv2.ex.class.php');
 
        define("WB_AKEY", $this->config['sy_sinaappid']);
        define("WB_SKEY", $this->config['sy_sinaappkey']);
        define("WB_CALLBACK_URL", $this->config['sy_weburl'] . '/index.php?m=sinaconnect');
 
        $o  =   new SaeTOAuthV2(WB_AKEY, WB_SKEY);
 
        if (isset($_GET['code'])) {
 
            $keys   =   array();
 
            $keys['code']           =   $_GET['code'];
            $keys['redirect_uri']   =   WB_CALLBACK_URL;
 
            $token =    $o->getAccessToken('code', $keys);
 
            if ($token['access_token']) {
 
                $tokens     =   $token['access_token'];
                $tokenuid   =   $token['uid'];
 
                if ($tokenuid > 0) {
 
                    if ($this->uid != "" && $this->username != "") {
 
                        //已登录状态下 重新绑定账户
                        $data1  =   array(
                            'sinaid' => ''
                        );
                        $where1['sinaid']   =   $tokenuid;
                        $UserinfoM->upInfo($where1, $data1);
                        $data2  =   array(
                            'sinaid' => $tokenuid
                        );
                        $where2['uid'] = $this->uid;
                        $UserinfoM->upInfo($where2, $data2);
                        $this->actMsg($msgUrl . '/member/index.php?c=binding', "新浪微博登录绑定成功!", 9);
                    }
 
                    $userwhere['sinaid']    =   $tokenuid;
 
                    $userinfo               =   $UserinfoM->getInfo($userwhere);
 
                    if (is_array($userinfo)) {
                        if ($userinfo['usertype'] > 0) {
                            if ($userinfo['status'] == '2' || $userinfo['status'] == '4') {
 
                                // 账号被锁定
                                $this->ACT_msg(Url(), '您的帐号被锁定,请联系客服解除锁定!');
                                exit();
                            }
                            $uwhere['uid']  =   $userinfo['uid'];
 
                            $udata  =   array(
                                'login_date' => time()
                            );
 
                            $UserinfoM->upInfo($uwhere, $udata);
 
                            // 会员日志,记录手动登录
                            $LogM   =   $this->MODEL('log');
                            $LogM->addMemberLog($userinfo['uid'], $userinfo['usertype'], 'PC 微博登录成功');
 
                            $logtime    =   date("Ymd", $userinfo['login_date']);
                            $nowtime    =   date("Ymd", time());
 
                            if ($this->config['resume_sx'] == 1 && $userinfo['usertype'] == 1) {
                                $resumeM    =   $this->MODEL('resume');
                                $resume     =   $resumeM->getResumeInfo(array('uid' => $userinfo['uid']), array('field' => '`def_job`'));
                                if ($resume['def_job']) {
                                    $resumeM->upInfo(array('id' => $resume['def_job']), array('eData' => array('lastupdate' => time())));
                                    $resumeM->upResumeInfo(array('uid' => $userinfo['uid']), array('rData' => array('lastupdate' => time()), 'port' => 1));
                                }
                            }
 
                            if ($logtime != $nowtime) {
 
                                $this->MODEL('integral')->invtalCheck($userinfo['uid'], $userinfo['usertype'], "integral_login", "会员登录", 22);
                                //登录日志
                                $logdata['uid']         =   $userinfo['uid'];
                                $logdata['usertype']    =   $userinfo['usertype'];
                                $logdata['did']         =   $userinfo['did'];
                                $logdata['content']     =   'WAP微信登录';
                                $LogM->addLoginlog($logdata);
                            }
                        }
 
                        if ($this->config['sy_uc_type'] == "uc_center") {
 
                            $this->obj->uc_open();
                            $user = uc_get_user($userinfo['username']);
                            $ucsynlogin = uc_user_synlogin($user[0]);
                            $this->actMsg($msgUrl, "登录成功!", 9);
                        } else {
 
                            $this->cookie->unset_cookie();
                            $this->cookie->add_cookie($userinfo['uid'], $userinfo['username'], $userinfo['salt'], $userinfo['email'], $userinfo['password'], $userinfo['usertype'], $this->config['sy_logintime'], $userinfo['did']);
                            $this->actMsg($msgUrl, "登录成功!", 9);
                        }
 
                    } else {
 
                        session_start();
 
                        $_SESSION['sina']["openid"]     =   $tokenuid;
                        $_SESSION['sina']["tooken"]     =   $token['access_token'];
                        $_SESSION['sina']["logininfo"]  =   "您已登录新浪微博,请绑定您的帐户!";
                        $GetUrl =   "https://api.weibo.com/2/users/show.json?uid=" . $tokenuid . "&access_token=" . $token['access_token'];
 
                        $ch = curl_init();
 
                        curl_setopt($ch, CURLOPT_URL, $GetUrl);
                        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
                        $str = curl_exec($ch);
 
                        curl_close($ch);
 
                        $user = json_decode($str, true);
 
                        if ($user['name']) {
 
                            $_SESSION['sina']['nickname']   =   $user['name'];
                            $_SESSION['sina']['pic']        =   $user['avatar_hd'];
                        } else {
 
                            $this->actMsg($msgUrl, "用户信息获取失败,请重新登录新浪微博!");
                        }
                        if (isMobileUser()) {
 
                            header("location:" . Url('wap', array("c" => "sinabind")));
                        } else {
 
                            header("location:" . Url("sinaconnect", array("c" => "sinabind", "type" => 'ba')));
                        }
                    }
                } else {
 
                    $this->actMsg($msgUrl, "新浪微博授权失败,请重新授权!");
                }
            }
        } else {
 
            $code_url = $o->getAuthorizeURL(WB_CALLBACK_URL);
 
            header("location:" . $code_url);
 
        }
    }
 
    function sinabind_action()
    {
 
 
        $this->yunset('sinalogin');
 
        $this->yun_tpl(array('index'));
    }
}