Created
September 2, 2016 18:18
-
-
Save neo22s/a6ba1b6c2497cfa5dd8430399c7a983d to your computer and use it in GitHub Desktop.
New is_HTTPS_protocol changed today in cloudflares
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* checks if is https by protocol used in nginx | |
* @return boolean | |
*/ | |
public static function is_HTTPS_protocol() | |
{ | |
//we are sure is a https request , we use first the Nginx forwarded PROTO OR apache | |
if( (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) AND $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') | |
OR (isset($_SERVER['REQUEST_SCHEME']) AND $_SERVER['REQUEST_SCHEME'] == 'https') | |
OR (isset($_SERVER['HTTP_CF_VISITOR']) AND $_SERVER['HTTP_CF_VISITOR'] == '{"scheme":"https"}') | |
) | |
{ | |
//so we can use it later | |
$_SERVER['HTTPS']='on'; | |
return TRUE; | |
} | |
return FALSE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment