diff options
author | Wojciech Polak <polak@gnu.org> | 2015-07-29 18:07:10 +0200 |
---|---|---|
committer | Wojciech Polak <polak@gnu.org> | 2015-07-29 18:07:10 +0200 |
commit | 016cd65ae72870349b2342d0226cac7294771f50 (patch) | |
tree | 464da39284a1c6c43409e0d7cc5aff3a2d7c86ae | |
parent | c01f3a965cc116a7a4aad3c06a802bce49ecf6d9 (diff) | |
download | cheetah-016cd65ae72870349b2342d0226cac7294771f50.tar.gz cheetah-016cd65ae72870349b2342d0226cac7294771f50.tar.bz2 |
-rw-r--r-- | frontend/lib/http.class.php | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/frontend/lib/http.class.php b/frontend/lib/http.class.php index 6fda479..25e74fb 100644 --- a/frontend/lib/http.class.php +++ b/frontend/lib/http.class.php @@ -1,11 +1,11 @@ <?php /* Cheetah News lib/http.class.php - Copyright (C) 2005, 2006 Wojciech Polak. + Copyright (C) 2005, 2006, 2015 Wojciech Polak. Copyright (C) 2006 The Cheetah News Team. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. @@ -66,16 +66,22 @@ class Http if ($url_parts['scheme'] == 'feed') $url_parts['scheme'] = 'http'; switch ($url_parts['scheme']) { case 'http': + case 'https': $this->host = $url_parts['host']; if (!empty ($url_parts['port'])) $this->port = $url_parts['port']; + if ($url_parts['scheme'] == 'https') { + $this->host = 'ssl://'.$this->host; + $this->port = 443; + } + if ($this->_connect ($fp)) { $path = (!empty ($url_parts['path']) ? $url_parts['path'] : '') .($url_parts['query'] ? '?'.$url_parts['query'] : ''); $this->_httprequest ($path, $fp, $url); @@ -84,13 +90,13 @@ class Http if ($this->_redirectaddr) { /* URL was redirected, check if we've hit the max depth */ if ($this->maxredirs > $this->_redirectdepth) { // only follow redirect if it's on this site, or offsiteok is true - if (preg_match ("|^http://".preg_quote ($this->host)."|i", + if (preg_match ("|^https?://".preg_quote ($this->host)."|i", $this->_redirectaddr) || $this->offsiteok) { /* follow the redirect */ $this->_redirectdepth++; $this->lastredirectaddr = $this->_redirectaddr; $this->fetch ($this->_redirectaddr); @@ -111,12 +117,14 @@ class Http } return true; } function _httprequest ($path, $fp, $url) { + $this->host = str_replace ('ssl://', '', $this->host); + $url_parts = parse_url ($url); if (empty ($path)) $path = '/'; if (empty ($url)) $url = '/'; $headers = 'GET '.$path." HTTP/1.0\r\n"; if (!empty ($this->agent)) |