WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: HTTPS for WordPress] Incomplete checking of https (2 posts)

  1. allanctan
    Member
    Posted 5 years ago #

    I believe the condition to check for https is incomplete.
    Here's a more complete checking

    <?php
    function isSSL(){

    if($_SERVER['https'] == 1) /* Apache */ {
    return TRUE;
    } elseif ($_SERVER['https'] == 'on') /* IIS */ {
    return TRUE;
    } elseif ($_SERVER['SERVER_PORT'] == 443) /* others */ {
    return TRUE;
    } else {
    return FALSE; /* just using http */
    }

    }
    ?>

    Copied from
    http://www.php.net/manual/en/reserved.variables.server.php

    Allan
    http://www.ideyatech.com

    http://wordpress.org/extend/plugins/https-for-wordpress/

  2. jeremysawesome
    Member
    Posted 4 years ago #

    how about this:

    function isSSL()
    {
       if(!empty($_SERVER['HTTPS']){ return true; }
       else{ return false; }
    }

    I suppose if you really wanted to you could check the server port.

    function isSSL()
    {
       if(!empty($_SERVER['HTTPS'])||$_SERVER['SERVER_PORT']==443)
       { return true; }
       else{ return false; }
    }

    I always check if $_SERVER['HTTPS'] is not empty. The PHP Documentation says that $_SERVER['HTTPS'] is, "Set to a non-empty value if the script was queried through the HTTPS protocol."

Topic Closed

This topic has been closed to new replies.

About this Topic