File tree 5 files changed +26
-22
lines changed
5 files changed +26
-22
lines changed Original file line number Diff line number Diff line change 84
84
$ t_protocol = 'http ' ;
85
85
if ( isset ( $ _SERVER ['HTTP_X_FORWARDED_PROTO ' ] ) ) {
86
86
$ t_protocol = $ _SERVER ['HTTP_X_FORWARDED_PROTO ' ];
87
- } else if ( isset ( $ _SERVER ['HTTPS ' ] ) && ( strtolower ( $ _SERVER ['HTTPS ' ] ) != 'off ' ) ) {
87
+ } else if ( ! empty ( $ _SERVER ['HTTPS ' ] ) && ( strtolower ( $ _SERVER ['HTTPS ' ] ) != 'off ' ) ) {
88
88
$ t_protocol = 'https ' ;
89
89
}
90
90
Original file line number Diff line number Diff line change 20
20
* @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
21
21
* @copyright Copyright (C) 2002 - 2012 MantisBT Team - mantisbt-dev@lists.sourceforge.net
22
22
* @link http://www.mantisbt.org
23
+ *
24
+ * @uses http_api.php
23
25
*/
24
26
27
+ require_once ( 'http_api.php ' );
28
+
25
29
/**
26
30
* Determines (once-off) whether the client is accessing this script via a
27
31
* secure connection. If they are, we want to use the Secure cookie flag to
28
32
* prevent the cookie from being transmitted to other domains.
29
33
* @global bool $g_cookie_secure_flag_enabled
30
34
*/
31
- $ g_cookie_secure_flag_enabled = isset ( $ _SERVER [ ' HTTPS ' ] ) && ( utf8_strtolower ( $ _SERVER [ ' HTTPS ' ] ) != ' off ' );
35
+ $ g_cookie_secure_flag_enabled = http_is_protocol_https ( );
32
36
33
37
/**
34
38
* Determines (once-off) whether the version of PHP executing this script has
Original file line number Diff line number Diff line change 22
22
* @link http://www.mantisbt.org
23
23
*/
24
24
25
+ /**
26
+ * Checks to see if script was queried through the HTTPS protocol
27
+ * @return boolean True if protocol is HTTPS
28
+ */
29
+ function http_is_protocol_https () {
30
+ return !empty ( $ _SERVER ['HTTPS ' ] ) && ( utf8_strtolower ( $ _SERVER ['HTTPS ' ] ) != 'off ' );
31
+ }
32
+
25
33
/**
26
34
* Check to see if the client is using Microsoft Internet Explorer so we can
27
35
* enable quirks and hacky non-standards-compliant workarounds.
@@ -128,7 +136,7 @@ function http_security_headers() {
128
136
header ( 'X-Frame-Options: DENY ' );
129
137
$ t_avatar_img_allow = '' ;
130
138
if ( config_get_global ( 'show_avatar ' ) ) {
131
- if ( isset ( $ _SERVER [ ' HTTPS ' ] ) && ( utf8_strtolower ( $ _SERVER [ ' HTTPS ' ] ) != ' off ' ) ) {
139
+ if ( http_is_protocol_https ( ) ) {
132
140
$ t_avatar_img_allow = "; img-src 'self' https://secure.gravatar.com:443 " ;
133
141
} else {
134
142
$ t_avatar_img_allow = "; img-src 'self' http://www.gravatar.com:80 " ;
Original file line number Diff line number Diff line change 20
20
* @subpackage UserAPI
21
21
* @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
22
22
* @copyright Copyright (C) 2002 - 2012 MantisBT Team - mantisbt-dev@lists.sourceforge.net
23
+ *
24
+ * @uses email_api.php
25
+ * @uses ldap_api.php
23
26
*/
24
27
25
- /**
26
- * requires email_api
27
- */
28
28
require_once ( 'email_api.php ' );
29
- /**
30
- * requires ldap_api
31
- */
32
29
require_once ( 'ldap_api.php ' );
33
30
34
31
# ===================================
@@ -803,15 +800,10 @@ function user_get_avatar( $p_user_id, $p_size = 80 ) {
803
800
} else {
804
801
$ t_size = $ p_size ;
805
802
806
- $ t_use_ssl = false ;
807
- if ( isset ( $ _SERVER ['HTTPS ' ] ) && ( utf8_strtolower ( $ _SERVER ['HTTPS ' ] ) != 'off ' ) ) {
808
- $ t_use_ssl = true ;
809
- }
810
-
811
- if ( !$ t_use_ssl ) {
812
- $ t_gravatar_domain = 'http://www.gravatar.com/ ' ;
813
- } else {
803
+ if ( http_is_protocol_https () ) {
814
804
$ t_gravatar_domain = 'https://secure.gravatar.com/ ' ;
805
+ } else {
806
+ $ t_gravatar_domain = 'http://www.gravatar.com/ ' ;
815
807
}
816
808
817
809
$ t_avatar_url = $ t_gravatar_domain . 'avatar/ ' . md5 ( $ t_email ) . '?d=identicon&r=G&s= ' . $ t_size ;
Original file line number Diff line number Diff line change 119
119
# attached files via HTTPS, we disable the "Pragma: no-cache"
120
120
# command when IE is used over HTTPS.
121
121
global $ g_allow_file_cache ;
122
- if ( ( isset ( $ _SERVER [ " HTTPS " ] ) && ( " on " == utf8_strtolower ( $ _SERVER [ " HTTPS " ] ) ) ) && is_browser_internet_explorer () ) {
122
+ if ( http_is_protocol_https ( ) && is_browser_internet_explorer () ) {
123
123
# Suppress "Pragma: no-cache" header.
124
124
} else {
125
125
if ( !isset ( $ g_allow_file_cache ) ) {
143
143
$ finfo = finfo_get_if_available ();
144
144
145
145
$ t_content_type = $ v_file_type ;
146
-
146
+
147
147
$ t_content_type_override = file_get_content_type_override ( $ t_filename );
148
148
149
149
# dump file content to the connection.
159
159
$ t_content_type = $ t_file_info_type ;
160
160
}
161
161
}
162
-
162
+
163
163
if ( $ t_content_type_override ) {
164
164
$ t_content_type = $ t_content_type_override ;
165
165
}
184
184
$ t_content_type = $ t_file_info_type ;
185
185
}
186
186
}
187
-
187
+
188
188
if ( $ t_content_type_override ) {
189
189
$ t_content_type = $ t_content_type_override ;
190
190
}
200
200
$ t_content_type = $ t_file_info_type ;
201
201
}
202
202
}
203
-
203
+
204
204
if ( $ t_content_type_override ) {
205
205
$ t_content_type = $ t_content_type_override ;
206
206
}
You can’t perform that action at this time.
0 commit comments