Created
August 24, 2012 08:30
-
-
Save jubalm/3447495 to your computer and use it in GitHub Desktop.
PHP - check if SSL is enabled
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 | |
function is_ssl() { | |
if ( isset($_SERVER['HTTPS']) ) { | |
if ( 'on' == strtolower($_SERVER['HTTPS']) ) | |
return true; | |
if ( '1' == $_SERVER['HTTPS'] ) | |
return true; | |
} elseif ( isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] ) ) { | |
return true; | |
} | |
return false; | |
} | |
?> |
Why you check 443. Why we check this case?
Why you check 443. Why we check this case?
HTTPS connections utilize the TCP port 443 as a standard
Thanks.
Hi and thanks for the script - good work.
I look after an option so I can send output from the script to the browser. I think about the following:
- If SSL is not activated when the webpage is loaded the script should write "Your connection is not sure"
- If SSL is activated when the webpage is loaded the script should write "Your connection is sure".
I will be glad if someone here please can give me the trick regarding what I should add to the script.
Thanks in advance for your answer, and have a nice day.
Regards,
Anders
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks Jubalm.