@@ -263,7 +263,7 @@ function init_session()
263263 'lifetime ' => DOKU_SESSION_LIFETIME ,
264264 'path ' => DOKU_SESSION_PATH ,
265265 'domain ' => DOKU_SESSION_DOMAIN ,
266- 'secure ' => ($ conf ['securecookie ' ] && is_ssl ()),
266+ 'secure ' => ($ conf ['securecookie ' ] && \ dokuwiki \Ip:: isSsl ()),
267267 'httponly ' => true ,
268268 'samesite ' => 'Lax ' ,
269269 ]);
@@ -497,28 +497,12 @@ function getBaseURL($abs = null)
497497 if (!empty ($ conf ['baseurl ' ])) return rtrim ($ conf ['baseurl ' ], '/ ' ) . $ dir ;
498498
499499 //split hostheader into host and port
500- if (isset ($ _SERVER ['HTTP_HOST ' ])) {
501- if (
502- (!empty ($ conf ['trustedproxy ' ])) && isset ($ _SERVER ['HTTP_X_FORWARDED_HOST ' ])
503- && preg_match ('/ ' . $ conf ['trustedproxy ' ] . '/ ' , $ _SERVER ['REMOTE_ADDR ' ])
504- ) {
505- $ cur_host = $ _SERVER ['HTTP_X_FORWARDED_HOST ' ];
506- } else {
507- $ cur_host = $ _SERVER ['HTTP_HOST ' ];
508- }
509- $ parsed_host = parse_url ('http:// ' . $ cur_host );
510- $ host = $ parsed_host ['host ' ] ?? '' ;
511- $ port = $ parsed_host ['port ' ] ?? '' ;
512- } elseif (isset ($ _SERVER ['SERVER_NAME ' ])) {
513- $ parsed_host = parse_url ('http:// ' . $ _SERVER ['SERVER_NAME ' ]);
514- $ host = $ parsed_host ['host ' ] ?? '' ;
515- $ port = $ parsed_host ['port ' ] ?? '' ;
516- } else {
517- $ host = php_uname ('n ' );
518- $ port = '' ;
519- }
500+ $ hostname = \dokuwiki \Ip::hostName ();
501+ $ parsed_host = parse_url ('http:// ' . $ hostname );
502+ $ host = $ parsed_host ['host ' ] ?? '' ;
503+ $ port = $ parsed_host ['port ' ] ?? '' ;
520504
521- if (!is_ssl ()) {
505+ if (!\ dokuwiki \Ip:: isSsl ()) {
522506 $ proto = 'http:// ' ;
523507 if ($ port == '80 ' ) {
524508 $ port = '' ;
@@ -536,31 +520,12 @@ function getBaseURL($abs = null)
536520}
537521
538522/**
539- * Check if accessed via HTTPS
540- *
541- * Apache leaves ,$_SERVER['HTTPS'] empty when not available, IIS sets it to 'off'.
542- * 'false' and 'disabled' are just guessing
543- *
544- * @returns bool true when SSL is active
523+ * @deprecated 2025-06-03
545524 */
546525function is_ssl ()
547526{
548- global $ conf ;
549-
550- // check if we are behind a reverse proxy
551- if (
552- (!empty ($ conf ['trustedproxy ' ])) && isset ($ _SERVER ['HTTP_X_FORWARDED_PROTO ' ])
553- && preg_match ('/ ' . $ conf ['trustedproxy ' ] . '/ ' , $ _SERVER ['REMOTE_ADDR ' ])
554- && ($ _SERVER ['HTTP_X_FORWARDED_PROTO ' ] == 'https ' )
555- ) {
556- return true ;
557- }
558-
559- if (preg_match ('/^(|off|false|disabled)$/i ' , $ _SERVER ['HTTPS ' ] ?? 'off ' )) {
560- return false ;
561- }
562-
563- return true ;
527+ dbg_deprecated ('Ip::isSsl() ' );
528+ return \dokuwiki \Ip::isSsl ();
564529}
565530
566531/**
0 commit comments