找回密码
 立即注册
查看: 1987|回复: 0

discuz启用https后,ucenter通信失败的处理方法

[复制链接]

650

主题

2041

回帖

3346

积分

管理员

积分
3346

社区居民社区明星最爱沙发灌水天才终身成就奖诚信商户

QQ
发表于 2020-3-7 09:03:24 | 显示全部楼层 |阅读模式
论坛启用了https,在后台配置ucenter的时候,总是提示通信失败,多次搜索终于找到一个解决方案,测试了确实可行。
记录在这里,方便后期使用。

打开/uc_server/model/misc.php
DZ3.4R20200818版本大约在68行后增加下面的红色字部分。




        function dfopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE        , $ip = '', $timeout = 15, $block = TRUE, $encodetype  = 'URLENCODE') {
                $return = '';
                $matches = parse_url($url);
                $scheme = $matches['scheme'];
                $host = $matches['host'];
                $path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/';
                $port = !empty($matches['port']) ? $matches['port'] : ($matches['scheme'] == 'https' ? 443 : 80);
        if(substr($url,0,5)=='https'){
                            $ch = curl_init($url);
                            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                            if($post){
                                    curl_setopt($ch, CURLOPT_POST, 1);
                                    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
                            }
                            if($cookie){
                                    curl_setopt($ch, CURLOPT_COOKIE, $cookie);
                            }
                            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
                            return curl_exec($ch);
         }
                if($post) {
                        $out = "POST $path HTTP/1.0\r\n";
                        $header = "Accept: */*\r\n";
                        $header .= "Accept-Language: zh-cn\r\n";
                        $boundary = $encodetype == 'URLENCODE' ? '' : ';'.substr($post, 0, trim(strpos($post, "\n")));

安徽大学七彩梦论坛欢迎您~! www.ahubbs.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|安徽大学论坛 ( 皖ICP备11003929号-3 )

GMT+8, 2024-4-25 12:11 , Processed in 0.045900 second(s), 3 queries , Gzip On, Redis On.

Powered by Discuz! X3.5

Copyright © 2006-2024 安徽大学论坛 All Rights Reserved

快速回复 返回顶部 返回列表