GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

WxProxy::run()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 12
nc 3
nop 0
dl 0
loc 15
rs 9.8666
c 1
b 0
f 0
1
<?php
2
3
class WxProxy
4
{
5
    protected $AuthorizeURL = 'https://open.weixin.qq.com/connect/oauth2/authorize';
6
7
    public function run()
8
    {
9
        if (isset($_GET['code'])) {
10
            header('Location: ' . $_COOKIE['return_uri'] . '?code=' . $_GET['code'] . '&state=' . $_GET['state']);
11
        } else {
12
            $protocol = $this->is_HTTPS() ? 'https://' : 'http://';
13
            $params   = array(
14
                'appid'         => $_GET['appid'],
15
                'redirect_uri'  => $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['DOCUMENT_URI'],
16
                'response_type' => $_GET['response_type'],
17
                'scope'         => $_GET['scope'],
18
                'state'         => $_GET['state'],
19
            );
20
            setcookie('return_uri', urldecode($_GET['return_uri']), $_SERVER['REQUEST_TIME'] + 60, '/');
21
            header('Location: ' . $this->AuthorizeURL . '?' . http_build_query($params) . '#wechat_redirect');
22
        }
23
    }
24
25
    /**
26
     * 是否https
27
     */
28
    protected function is_HTTPS()
29
    {
30
        if (!isset($_SERVER['HTTPS'])) {
31
            return false;
32
        }
33
        if ($_SERVER['HTTPS'] === 1) { //Apache
34
            return true;
35
        } elseif ($_SERVER['HTTPS'] === 'on') { //IIS
36
            return true;
37
        } elseif ($_SERVER['SERVER_PORT'] == 443) { //其他
38
            return true;
39
        }
40
        return false;
41
    }
42
}
43
44
$app = new WxProxy();
45
$app->run();
46