Ticket #2092: allow_different_port_in_login.patch

File allow_different_port_in_login.patch, 2.3 KB (added by aseques, 2 years ago)
  • gui/include/login.php

     
    212212               } 
    213213       } 
    214214 
    215        // prevent external login / check for referer 
    216        if ($preventExternalLogin) { 
    217                if (isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER'])) { 
     215        // prevent external login / check for referer 
     216        if ($preventExternalLogin) { 
     217                if (isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER'])) { 
    218218 
    219                        $info = parse_url($_SERVER['HTTP_REFERER']); 
    220                        if (isset($info['host']) && !empty($info['host'])) { 
    221                                if ($info['host'] != $_SERVER['HTTP_HOST'] 
    222                                        || $info['host'] != $_SERVER['SERVER_NAME']) { 
    223                                        set_page_message(tr('Request from foreign host was blocked!')); 
    224                                        if (!(substr($_SERVER['SCRIPT_FILENAME'], (int)-strlen($_SERVER['REDIRECT_URL']), strlen($_SERVER['REDIRECT_URL'])) === $_SERVER['REDIRECT_URL'])) { 
    225                                                redirect_to_level_page(); 
    226                                        } 
    227                                } 
    228                        } 
    229                } 
    230        } 
     219                        $info = parse_url($_SERVER['HTTP_REFERER']); 
     220                        if (isset($info['host']) && !empty($info['host'])) { 
     221                                if ($info['host'].':'.$_SERVER['SERVER_PORT'] != $_SERVER['HTTP_HOST'] 
     222                                        || $info['host'].':'.$_SERVER['SERVER_PORT'] != $_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT']) { 
     223                                        set_page_message(tr('Request from foreign host was blocked!')); 
     224                                        if (!(substr($_SERVER['SCRIPT_FILENAME'], (int)-strlen($_SERVER['REDIRECT_URL']), strlen($_SERVER['REDIRECT_URL'])) === $_SERVER['REDIRECT_URL'])) { 
     225                                                redirect_to_level_page(); 
     226                                        } 
     227                                } 
     228                        } 
     229                } 
     230        } 
    231231} 
    232232