优化HTTPS修复代码,提高兼容性

This commit is contained in:
Ruing 2017-02-03 22:14:43 +08:00
parent def9b78e8c
commit 37befaf4eb
1 changed files with 3 additions and 10 deletions

View File

@ -65,14 +65,7 @@ class miscmodel {
$scheme = $matches['scheme'];
$host = $matches['host'];
$path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/';
$port = !empty($matches['port']) ? $matches['port'] : 80;
if($scheme = 'https'){
$scheme = 'ssl';
if($port == 80){
$port = 443;
}
}
$port = !empty($matches['port']) ? $matches['port'] : ($matches['scheme'] == 'https' ? 443 : 80);
if($post) {
$out = "POST $path HTTP/1.0\r\n";
@ -99,7 +92,7 @@ class miscmodel {
}
$fpflag = 0;
if(!$fp = @fsocketopen($scheme.'://'.($ip ? $ip : $host), $port, $errno, $errstr, $timeout)) {
if(!$fp = @fsocketopen(($scheme == 'https' ? 'ssl' : $scheme).'://'.($scheme == 'https' ? $host : ($ip ? $ip : $host)), $port, $errno, $errstr, $timeout)) {
$context = array(
'http' => array(
'method' => $post ? 'POST' : 'GET',
@ -109,7 +102,7 @@ class miscmodel {
),
);
$context = stream_context_create($context);
$fp = @fopen($scheme.'://'.($ip ? $ip : $host).':'.$port.$path, 'b', false, $context);
$fp = @fopen($scheme.'://'.($scheme == 'https' ? $host : ($ip ? $ip : $host)).':'.$port.$path, 'b', false, $context);
$fpflag = 1;
}