我收到错误消息“在http://steamcommunity.com/openid上找不到OpenID服务器”

时间:2019-04-19 07:51:51

标签: php openid

http://steamcommunity.com/openid上找不到OpenID服务器

steamauth.php

if (isset($_GET['login'])){
    require 'openid.php';
    try {
        require 'SteamConfig.php';
        $openid = new LightOpenID($steamauth['domainname']);

        if(!$openid->mode) {
            $openid->identity = 'http://steamcommunity.com/openid';
            header('Location: ' . $openid->authUrl());
        } elseif ($openid->mode == 'cancel') {
            echo 'User has canceled authentication!';
        } else {
            if($openid->validate()) { 
                $id = $openid->identity;
                $ptn = "/^https:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";
                preg_match($ptn, $id, $matches);
                include $GLOBALS['env_folder'] . "file_download.php";
                var_dump($matches);
                // die();
                $steamhex = dechex($matches[1]);

                $chardata = get_ftpdata($steamhex);

                if ($chardata != false) {
                    $_SESSION['datafile'] = $chardata;
                    $_SESSION['steamid'] = $matches[1];
                    $_SESSION['version'] = $currentversion;
                    $baninfo = is_currently_banned_on_server($matches[1]);
                    if ($baninfo == false) {
                        add_log($steamhex, "logn");
                        if (!headers_sent()) {
                            header('Location: '.$steamauth['loginpage']);
                            exit;
                        } else {
                            ?>
                            <script type="text/javascript">
                                window.location.href="<?=$steamauth['loginpage']?>";
                            </script>
                            <noscript>
                                <meta http-equiv="refresh" content="0;url=<?=$steamauth['loginpage']?>" />
                            </noscript>
                            <?php
                            exit;
                        }
                    } else {
                        require 'userInfo.php';

                        $webhook = new Client($GLOBALS['discord_hook_faillogin']);

                        $embed = new Embed();
                        $embed->thumbnail($GLOBALS['discord_image_faillogin']);
                        $embed->color(16711680);
                        $embed->title("Failed webpanel login", $GLOBALS['env_url'] . 'character.php?steam=' . dechex($_SESSION['steamid']));
                        $embed->description('A user tried to access the webpanel during his ban.');
                        $embed->field('SteamID', dechex($_SESSION['steamid']), true);
                        $embed->field('Username', $steamprofile['personaname'], true);
                        $embed->field('Time Remaining', secondsToTime($baninfo['duration'] - time()), false);
                        $embed->field('Ban reason', $baninfo['reason'], false);

                        $webhook->embed($embed);

                        try {
                            $webhook->send();
                        } catch (Exception $e) {
                            echo 'Caught exception: ',  $e->getMessage(), "<br />";
                        }

                        session_unset();
                        session_destroy();
                        session_start();
                        add_log($steamhex, "logB");
                        header('Location: '. $GLOBALS['env_url'] . $steamauth['loginpage'] . "?b=1&r=" . urlencode($baninfo['reason']) . "&e=" . $baninfo['duration']);
                        exit;
                    }
                } else {
                    exit;
                }
            } else {
                echo "User is not logged in.\n";
            }
        }
    } catch(ErrorException $e) {
        echo $e->getMessage();
    }
}
    function discover($url)
    {
        if (!$url) throw new ErrorException('No identity supplied.');
        # Use xri.net proxy to resolve i-name identities
        if (!preg_match('#^https?:#', $url)) {
            $url = "https://xri.net/$url";
        }

        # We save the original url in case of Yadis discovery failure.
        # It can happen when we'll be lead to an XRDS document
        # which does not have any OpenID2 services.
        $originalUrl = $url;

        # A flag to disable yadis discovery in case of failure in headers.
        $yadis = true;

        # Allows optional regex replacement of the URL, e.g. to use Google Apps
        # as an OpenID provider without setting up XRDS on the domain hosting.
        if (!is_null($this->xrds_override_pattern) && !is_null($this->xrds_override_replacement)) {
            $url = preg_replace($this->xrds_override_pattern, $this->xrds_override_replacement, $url);
        }

        # We'll jump a maximum of 5 times, to avoid endless redirections.
        for ($i = 0; $i < 5; $i ++) {
            if ($yadis) {
                $headers = $this->request($url, 'HEAD', array(), true);

                $next = false;
                if (isset($headers['x-xrds-location'])) {
                    $url = $this->build_url(parse_url($url), parse_url(trim($headers['x-xrds-location'])));
                    $next = true;
                }

                if (isset($headers['content-type']) && $this->is_allowed_type($headers['content-type'])) {
                    # Found an XRDS document, now let's find the server, and optionally delegate.
                    $content = $this->request($url, 'GET');

                    preg_match_all('#<Service.*?>(.*?)</Service>#s', $content, $m);
                    foreach($m[1] as $content) {
                        $content = ' ' . $content; # The space is added, so that strpos doesn't return 0.

                        # OpenID 2
                        $ns = preg_quote('http://specs.openid.net/auth/2.0/', '#');
                        if(preg_match('#<Type>\s*'.$ns.'(server|signon)\s*</Type>#s', $content, $type)) {
                            if ($type[1] == 'server') $this->identifier_select = true;

                            preg_match('#<URI.*?>(.*)</URI>#', $content, $server);
                            preg_match('#<(Local|Canonical)ID>(.*)</\1ID>#', $content, $delegate);
                            if (empty($server)) {
                                return false;
                            }
                            # Does the server advertise support for either AX or SREG?
                            $this->ax   = (bool) strpos($content, '<Type>http://openid.net/srv/ax/1.0</Type>');
                            $this->sreg = strpos($content, '<Type>http://openid.net/sreg/1.0</Type>')
                                       || strpos($content, '<Type>http://openid.net/extensions/sreg/1.1</Type>');

                            $server = $server[1];
                            if (isset($delegate[2])) $this->identity = trim($delegate[2]);
                            $this->version = 2;

                            $this->server = $server;
                            return $server;
                        }

                        # OpenID 1.1
                        $ns = preg_quote('http://openid.net/signon/1.1', '#');
                        if (preg_match('#<Type>\s*'.$ns.'\s*</Type>#s', $content)) {

                            preg_match('#<URI.*?>(.*)</URI>#', $content, $server);
                            preg_match('#<.*?Delegate>(.*)</.*?Delegate>#', $content, $delegate);
                            if (empty($server)) {
                                return false;
                            }
                            # AX can be used only with OpenID 2.0, so checking only SREG
                            $this->sreg = strpos($content, '<Type>http://openid.net/sreg/1.0</Type>')
                                       || strpos($content, '<Type>http://openid.net/extensions/sreg/1.1</Type>');

                            $server = $server[1];
                            if (isset($delegate[1])) $this->identity = $delegate[1];
                            $this->version = 1;

                            $this->server = $server;
                            return $server;
                        }
                    }

                    $next = true;
                    $yadis = false;
                    $url = $originalUrl;
                    $content = null;
                    break;
                }
                if ($next) continue;

                # There are no relevant information in headers, so we search the body.
                $content = $this->request($url, 'GET', array(), true);

                if (isset($this->headers['x-xrds-location'])) {
                    $url = $this->build_url(parse_url($url), parse_url(trim($this->headers['x-xrds-location'])));
                    continue;
                }

                $location = $this->htmlTag($content, 'meta', 'http-equiv', 'X-XRDS-Location', 'content');
                if ($location) {
                    $url = $this->build_url(parse_url($url), parse_url($location));
                    continue;
                }
            }

            if (!$content) $content = $this->request($url, 'GET');

            # At this point, the YADIS Discovery has failed, so we'll switch
            # to openid2 HTML discovery, then fallback to openid 1.1 discovery.
            $server   = $this->htmlTag($content, 'link', 'rel', 'openid2.provider', 'href');
            $delegate = $this->htmlTag($content, 'link', 'rel', 'openid2.local_id', 'href');
            $this->version = 2;

            if (!$server) {
                # The same with openid 1.1
                $server   = $this->htmlTag($content, 'link', 'rel', 'openid.server', 'href');
                $delegate = $this->htmlTag($content, 'link', 'rel', 'openid.delegate', 'href');
                $this->version = 1;
            }

            if ($server) {
                # We found an OpenID2 OP Endpoint
                if ($delegate) {
                    # We have also found an OP-Local ID.
                    $this->identity = $delegate;
                }
                $this->server = $server;
                return $server;
            }

            throw new ErrorException("No OpenID Server found at $url", 404);
        }
        throw new ErrorException('Endless redirection!', 500);
    }

这是我认为正在抛出错误的函数。我已经得到一些报告,要求尝试转到指定的openid链接,如果它下载了文件,应该没问题,并且确实下载了文件,但是我不知道我在寻找什么。

我所做的研究是由网络托管公司引起的,但是,这种设置已经使用了近两年,而现在只是随机停止了工作。除此之外,其他人只是开始为他们随机工作,没有真正的押韵或理由。

提供的一种解决方案是尝试将http更改为https,但没有成功。除此之外,我不确定。

0 个答案:

没有答案