Changeset 623


Ignore:
Timestamp:
Feb 17, 2018 10:59:13 AM (6 years ago)
Author:
anonymous
Message:

Simplify HTTPS detection

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/App.inc.php

    r610 r623  
    468468        // Not available on CLI scripts obviously.
    469469        if (isset($_SERVER['HTTP_HOST']) && '' != $_SERVER['HTTP_HOST'] && '' == $this->getParam('site_url')) {
    470             $this->setParam(array('site_url' => sprintf('%s://%s', ('on' == getenv('HTTPS') ? 'https' : 'http'), getenv('HTTP_HOST'))));
     470            $this->setParam(array('site_url' => sprintf('%s://%s', (getenv('HTTPS') ? 'https' : 'http'), getenv('HTTP_HOST'))));
    471471        }
    472472
     
    474474        // Also not available on CLI scripts obviously.
    475475        if (isset($_SERVER['HTTP_HOST']) && '' != $_SERVER['HTTP_HOST']) {
    476             $this->setParam(array('page_url' => sprintf('%s://%s%s', ('on' == getenv('HTTPS') ? 'https' : 'http'), getenv('HTTP_HOST'), getenv('REQUEST_URI'))));
     476            $this->setParam(array('page_url' => sprintf('%s://%s%s', (getenv('HTTPS') ? 'https' : 'http'), getenv('HTTP_HOST'), getenv('REQUEST_URI'))));
    477477        }
    478478
     
    13681368        if (preg_match('!^/!', $url)) {
    13691369            // If relative URL is given, prepend correct local hostname.
    1370             $scheme = 'on' == getenv('HTTPS') ? 'https' : 'http';
     1370            $scheme = getenv('HTTPS') ? 'https' : 'http';
    13711371            $host = getenv('HTTP_HOST');
    13721372            $url = sprintf('%s://%s%s', $scheme, $host, $url);
     
    16121612        }
    16131613
    1614         if ('' == getenv('HTTPS') && $this->getParam('ssl_enabled') && in_array('mod_ssl', $modules)) {
     1614        if (!getenv('HTTPS') && $this->getParam('ssl_enabled') && in_array('mod_ssl', $modules)) {
    16151615            $this->raiseMsg(sprintf(_("Secure SSL connection made to %s"), $this->getParam('ssl_domain')), MSG_NOTICE, __FILE__, __LINE__);
    16161616            // Always append session because some browsers do not send cookie when crossing to SSL URL.
     
    16571657        // Defaults.
    16581658        $expire = (is_numeric($expire) ? $expire : (is_string($expire) ? strtotime($expire) : $expire));
    1659         $secure = $secure ?: ('' != getenv('HTTPS') && $this->getParam('ssl_enabled'));
     1659        $secure = $secure ?: (getenv('HTTPS') && $this->getParam('ssl_enabled'));
    16601660        $httponly = $httponly ?: true;
    16611661
  • trunk/lib/Utilities.inc.php

    r613 r623  
    14261426function absoluteMe()
    14271427{
    1428     $protocol = ('on' == getenv('HTTPS')) ? 'https://' : 'http://';
    1429     return $protocol . getenv('HTTP_HOST') . getenv('REQUEST_URI');
     1428    return sprintf('%s://%s%s', (getenv('HTTPS') ? 'https' : 'http'), getenv('HTTP_HOST'), getenv('REQUEST_URI'));
    14301429}
    14311430
Note: See TracChangeset for help on using the changeset viewer.