@@ -562,27 +562,34 @@ function refreshToken($accessToken, $sessionHandle) {
562
562
* whether to drop the querystring or not. Default true
563
563
* @return string the current URL
564
564
*/
565
- public static function php_self ($ dropqs = true ) {
566
- $ url = sprintf ( '%s://%s%s ' , empty ( $ _SERVER ['HTTPS ' ] ) ? (@$ _SERVER ['SERVER_PORT ' ] == '443 ' ? 'https ' : 'http ' ) : 'http ' , $ _SERVER ['SERVER_NAME ' ], $ _SERVER ['REQUEST_URI ' ] );
567
-
568
- $ parts = parse_url ( $ url );
569
-
570
- $ port = $ _SERVER ['SERVER_PORT ' ];
571
- $ scheme = $ parts ['scheme ' ];
572
- $ host = $ parts ['host ' ];
573
- $ path = @$ parts ['path ' ];
574
- $ qs = @$ parts ['query ' ];
575
-
576
- $ port or $ port = ($ scheme == 'https ' ) ? '443 ' : '80 ' ;
577
-
578
- if (($ scheme == 'https ' && $ port != '443 ' ) || ($ scheme == 'http ' && $ port != '80 ' )) {
579
- $ host = "$ host: $ port " ;
565
+ public static function php_self ($ dropqs = true )
566
+ {
567
+ $ protocol = 'http ' ;
568
+ if (isset ($ _SERVER ['HTTPS ' ]) && strtolower ($ _SERVER ['HTTPS ' ]) == 'on ' )
569
+ {
570
+ $ protocol = 'https ' ;
580
571
}
581
- $ url = "$ scheme:// $ host$ path " ;
582
- if (! $ dropqs )
583
- return "{$ url }? {$ qs }" ;
584
- else
585
- return $ url ;
572
+ elseif (isset ($ _SERVER ['SERVER_PORT ' ]) && ($ _SERVER ['SERVER_PORT ' ] == '443 ' ))
573
+ {
574
+ $ protocol = 'https ' ;
575
+ }
576
+
577
+ $ url = sprintf ('%s://%s%s ' , $ protocol , $ _SERVER ['SERVER_NAME ' ], $ _SERVER ['REQUEST_URI ' ]);
578
+ $ parts = parse_url ($ url );
579
+ $ port = $ _SERVER ['SERVER_PORT ' ];
580
+ $ scheme = $ parts ['scheme ' ];
581
+ $ host = $ parts ['host ' ];
582
+ $ path = @$ parts ['path ' ];
583
+ $ qs = @$ parts ['query ' ];
584
+ $ port or $ port = ($ scheme == 'https ' ) ? '443 ' : '80 ' ;
585
+ if (($ scheme == 'https ' && $ port != '443 ' ) || ($ scheme == 'http ' && $ port != '80 ' ))
586
+ {
587
+ $ host = "$ host: $ port " ;
588
+ }
589
+
590
+ $ url = "$ scheme:// $ host$ path " ;
591
+ if (!$ dropqs ) return "{$ url }? {$ qs }" ;
592
+ else return $ url ;
586
593
}
587
594
588
595
/*
0 commit comments