Created
July 30, 2018 12:54
-
-
Save marcocesarato/eec0b5c2ebead9cc006688b842e0a81c to your computer and use it in GitHub Desktop.
Check if site run over https
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 | |
/** | |
* Check if site run over https | |
* | |
* @author Marco Cesarato <cesarato.developer@gmail.com> | |
* @return boolean | |
*/ | |
if (!function_exists('is_https')){ | |
function is_https(){ | |
if (isset($_SERVER['HTTP_HOST'])){ | |
if(((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443) | |
|| !empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on'){ | |
return true; | |
} | |
return false; | |
} | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment