| 1 |
<?php |
| 2 |
// @codingStandardsIgnoreFile |
| 3 |
/** |
| 4 |
* SSL routines. |
| 5 |
* |
| 6 |
* Copyright: © 2009-2011 |
| 7 |
* {@link http://websharks-inc.com/ WebSharks, Inc.} |
| 8 |
* (coded in the USA) |
| 9 |
* |
| 10 |
* Released under the terms of the GNU General Public License. |
| 11 |
* You should have received a copy of the GNU General Public License, |
| 12 |
* along with this software. In the main directory, see: /licensing/ |
| 13 |
* If not, see: {@link http://www.gnu.org/licenses/}. |
| 14 |
* |
| 15 |
* @package s2Member\SSL |
| 16 |
* @since 3.5 |
| 17 |
*/ |
| 18 |
if(!defined('WPINC')) // MUST have WordPress. |
| 19 |
exit('Do not access this file directly.'); |
| 20 |
|
| 21 |
if(!class_exists('c_ws_plugin__s2member_ssl')) |
| 22 |
{ |
| 23 |
/** |
| 24 |
* SSL routines. |
| 25 |
* |
| 26 |
* @package s2Member\SSL |
| 27 |
* @since 3.5 |
| 28 |
*/ |
| 29 |
class c_ws_plugin__s2member_ssl |
| 30 |
{ |
| 31 |
/** |
| 32 |
* Forces SSL on specific Posts/Pages, or any page for that matter. |
| 33 |
* |
| 34 |
* Triggered by Custom Field: `s2member_force_ssl = yes|port#` |
| 35 |
* |
| 36 |
* Triggered by: `?s2-ssl` or `?s2-ssl=yes|port#`. |
| 37 |
* |
| 38 |
* @package s2Member\SSL |
| 39 |
* @since 3.5 |
| 40 |
* |
| 41 |
* @attaches-to ``add_action('init');`` |
| 42 |
* @also-attaches-to ``add_action('wp');`` |
| 43 |
* |
| 44 |
* @return null Possibly exiting script execution after redirection to SSL variation. |
| 45 |
*/ |
| 46 |
public static function check_force_ssl() |
| 47 |
{ |
| 48 |
static $forced = FALSE; // Only force SSL once. |
| 49 |
global $post; // We need this global reference to ``$post``. |
| 50 |
|
| 51 |
do_action('ws_plugin__s2member_before_check_force_ssl', get_defined_vars()); |
| 52 |
|
| 53 |
if(!$forced && !c_ws_plugin__s2member_systematics::is_wp_systematic_use_page()) |
| 54 |
{ |
| 55 |
$s2_ssl_gv = apply_filters('ws_plugin__s2member_check_force_ssl_get_var_name', 's2-ssl', get_defined_vars()); |
| 56 |
$_g_s2_ssl = isset($_GET[$s2_ssl_gv]) && (!strlen($_GET[$s2_ssl_gv]) || !preg_match('/^(0|no|off|false)$/i', $_GET[$s2_ssl_gv])) |
| 57 |
? (!strlen($_GET[$s2_ssl_gv]) ? TRUE : $_GET[$s2_ssl_gv]) : FALSE; |
| 58 |
$force_ssl = apply_filters('ws_plugin__s2member_check_force_ssl', $_g_s2_ssl, get_defined_vars()); |
| 59 |
|
| 60 |
if($force_ssl || (did_action('wp') && is_singular() && is_object($post) && ($force_ssl = get_post_meta($post->ID, 's2member_force_ssl', TRUE)))) |
| 61 |
if(!preg_match('/^(0|no|off|false)$/i', (string)$force_ssl) && ($forced = TRUE)) // Make sure it's NOT a negative variation. |
| 62 |
c_ws_plugin__s2member_ssl_in::force_ssl(get_defined_vars()); // Call inner routine now. |
| 63 |
} |
| 64 |
do_action('ws_plugin__s2member_after_check_force_ssl', get_defined_vars()); |
| 65 |
} |
| 66 |
} |
| 67 |
} |
| 68 |
|