Changeset 2313

Show
Ignore:
Timestamp:
03/17/2008 07:48:11 PM (8 months ago)
Author:
Shadowhand
Message:

Fixing a bug in HTTPS detection on IIS. Thanks PugFish?!

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/helpers/url.php

    r2178 r2313  
    1515         * Base URL, with or without the index page. 
    1616         * 
    17          * If protocol (and core.site_protocol) and core.site_domain are both empty,  
    18          * then  
     17         * If protocol (and core.site_protocol) and core.site_domain are both empty, 
     18         * then 
    1919         * 
    2020         * @param   boolean  include the index page 
     
    2525        { 
    2626                $protocol = ($protocol == FALSE) ? Config::item('core.site_protocol') : strtolower($protocol); 
    27                  
     27 
    2828                $site_domain = Config::item('core.site_domain', TRUE); 
    29                  
     29 
    3030                if (empty($protocol)) 
    3131                { 
    32                         if (strlen($site_domain) > 0 AND $site_domain[0] != '/')  
     32                        if (strlen($site_domain) > 0 AND $site_domain[0] != '/') 
    3333                        { 
    3434                                // try to guess protocol, provide full http://domain/path... 
    35                                 $base_url = (!empty($_SERVER['HTTPS']) ? 'https' : 'http').'://'.$site_domain; 
     35                                $base_url = (empty($_SERVER['HTTPS']) OR $_SERVER['HTTPS'] === 'off') ? 'http' : 'https').'://'.$site_domain; 
    3636                        } 
    3737                        else 
    3838                        { 
    3939                                // provide only path, eg /path... 
    40                                 $base_url = !empty($site_domain) ? $site_domain : ''; 
     40                                $base_url = empty($site_domain) ? '' : $site_domain; 
    4141                        } 
    4242                } 
    4343                else 
    4444                { 
    45                         // return a full url 
    46                          
    4745                        // Add current servername if site_domain starts with a / 
    4846                        if (empty($site_domain) OR $site_domain[0] == '/') 
    4947                        { 
    50                                 $base_url = $protocol.'://'.$_SERVER['HTTP_HOST'].(!empty($site_domain) ? $site_domain : ''); 
     48                                $base_url = $protocol.'://'.$_SERVER['HTTP_HOST'].(empty($site_domain) ? '' : $site_domain); 
    5149                        } 
    52                         else  
     50                        else 
    5351                        { 
    54                                 $base_url = $protocol.'://'.(!empty($site_domain) ? $site_domain : ''); 
     52                                $base_url = $protocol.'://'.(empty($site_domain) ? '' : $site_domain); 
    5553                        } 
    5654                } 
    57                  
     55 
    5856                // make sure base_url ends in a slash 
    59                 (!empty($base_url) AND ($base_url[strlen($base_url)-1] != '/')) AND $base_url .= '/'; 
    60                  
     57                $base_url = rtrim($base_url, '/').'/'; 
     58 
    6159                // add index.php if needed 
    62                 if ($index == TRUE AND $index = Config::item('core.index_page')) 
     60                if ($index === TRUE AND $index = Config::item('core.index_page')) 
    6361                { 
    6462                        $base_url = $base_url.$index.'/';