Skip to content

Instantly share code, notes, and snippets.

@neo22s
Created September 2, 2016 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neo22s/a6ba1b6c2497cfa5dd8430399c7a983d to your computer and use it in GitHub Desktop.
Save neo22s/a6ba1b6c2497cfa5dd8430399c7a983d to your computer and use it in GitHub Desktop.
New is_HTTPS_protocol changed today in cloudflares
<?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