Dotclear

Changeset 3349:92af373753e4 for inc


Ignore:
Timestamp:
09/20/16 16:42:44 (9 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Try HTTP if HTTPS url fails to be reached for version info and update download, fixes #2209

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/core/class.dc.update.php

    r2566 r3349  
    109109                    $client->setUserAgent($_SERVER['HTTP_USER_AGENT']); 
    110110                    $client->get($path); 
    111  
     111                    $status = (int) $client->getStatus(); 
     112 
     113                    if ($status >= 400) { 
     114                         // If original URL uses HTTPS, try with HTTP 
     115                         $url_parts = parse_url($client->getRequestURL()); 
     116                         if (isset($url_parts['scheme']) && $url_parts['scheme'] == 'https') { 
     117 
     118                              // Replace https by http in url 
     119                              $this->url = preg_replace('/^https(?=:\/\/)/i','http',$this->url); 
     120 
     121                              $client = netHttp::initClient($this->url,$path); 
     122                              if ($client !== false) { 
     123                                   $client->setTimeout(4); 
     124                                   $client->setUserAgent($_SERVER['HTTP_USER_AGENT']); 
     125                                   $client->get($path); 
     126                                   $status = (int) $client->getStatus(); 
     127                              } 
     128                         } 
     129                    } 
     130 
     131                    if (!$status || $status >= 400) { 
     132                         return; 
     133                    } 
    112134                    $this->readVersion($client->getContent()); 
    113135               } 
     
    209231               $client->setOutput($dest); 
    210232               $client->get($path); 
    211  
    212                if ($client->getStatus() != 200) { 
     233               $status = (int) $client->getStatus(); 
     234 
     235               if ($status >= 400) { 
     236                    // If original URL uses HTTPS, try with HTTP 
     237                    $url_parts = parse_url($client->getRequestURL()); 
     238                    if (isset($url_parts['scheme']) && $url_parts['scheme'] == 'https') { 
     239 
     240                         // Replace https by http in url 
     241                         $url = preg_replace('/^https(?=:\/\/)/i','http',$url); 
     242 
     243                         $client = netHttp::initClient($url,$path); 
     244                         $client->setTimeout(4); 
     245                         $client->setUserAgent($_SERVER['HTTP_USER_AGENT']); 
     246                         $client->useGzip(false); 
     247                         $client->setPersistReferers(false); 
     248                         $client->setOutput($dest); 
     249                         $client->get($path); 
     250                         $status = (int) $client->getStatus(); 
     251                    } 
     252               } 
     253 
     254               if ($status != 200) { 
    213255                    @unlink($dest); 
    214256                    throw new Exception(); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map