fixed SSL checks

This commit is contained in:
Sarah Poger Gladstone 2019-05-28 06:37:55 -04:00 committed by GitHub
parent 3422d6b46c
commit 7cb8bff32c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -348,12 +348,30 @@ function fancytokens_civicrm_tokens( &$tokens ){
$civi_url = CRM_Utils_System::url('civicrm/example', NULL, TRUE, NULL, FALSE); $civi_url = CRM_Utils_System::url('civicrm/example', NULL, TRUE, NULL, FALSE);
$website_host_name = parse_url( $civi_url, PHP_URL_HOST ); $website_host_name = parse_url( $civi_url, PHP_URL_HOST );
$ssl_in_use = $_SERVER['HTTPS']; $isSecure = false;
if( strlen($ssl_in_use) > 0){ if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
$protocol = "https://"; $isSecure = true;
}else{ }elseif ( ( !empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https') ||
$protocol = "http://"; (!empty($_SERVER['HTTP_X_FORWARDED_SSL']) && strtolower( $_SERVER['HTTP_X_FORWARDED_SSL']) == 'on') ) {
} $isSecure = true;
}
$protocol = $isSecure ? 'https://' : 'http://';
/*
if ( array_key_exists( 'HTTPS', $_SERVER )){
$ssl_in_use = $_SERVER['HTTPS'];
if( strlen($ssl_in_use) > 0){
$protocol = "https://";
}else{
$protocol = "http://";
}
}else{
$protocol = "http://";
}
*/
while( $cur_token_raw = current( $tokens['communitynews'] )){ while( $cur_token_raw = current( $tokens['communitynews'] )){
$tmp_key = key($tokens['communitynews']); $tmp_key = key($tokens['communitynews']);