Files
bobsleighphotos.com/production/includes/sslSwitch.inc.php
2017-03-02 20:30:40 -06:00

95 lines
3.1 KiB
PHP

<?php
/*
+--------------------------------------------------------------------------
| CubeCart 4
| ========================================
| CubeCart is a registered trade mark of Devellion Limited
| Copyright Devellion Limited 2006. All rights reserved.
| Devellion Limited,
| 5 Bridge Street,
| Bishops Stortford,
| HERTFORDSHIRE.
| CM23 2JU
| UNITED KINGDOM
| http://www.devellion.com
| UK Private Limited Company No. 5323904
| ========================================
| Web: http://www.cubecart.com
| Email: info (at) cubecart (dot) com
| License Type: CubeCart is NOT Open Source Software and Limitations Apply
| Licence Info: http://www.cubecart.com/site/faq/license.php
+--------------------------------------------------------------------------
| switch.inc.php
| ========================================
| Switch between secure and insecure pages
+--------------------------------------------------------------------------
*/
if (!defined('CC_INI_SET')) die('Access Denied');
if ($config['ssl']) {
$currentPage = (isset($_GET['_a'])) ? sanitizeVar($_GET['_a']) : '';
$request_uri = explode('?', $_SERVER['REQUEST_URI']);
$currentPageDir = $request_uri[0];
$storeURL = str_replace('http://', '', $glob['storeURL']);
$storeURL_SSL = str_replace('https://', '', $config['storeURL_SSL']);
if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
$params = explode('&', $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
## Make sure ccUser is not appended more than once
if (stristr($param, CC_SESSION_NAME) == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString = htmlentities(implode('&', $newParams));
}
$currentPageDir .= '?' . $queryString;
if (!empty($GLOBALS[CC_SESSION_NAME])) {
$currentPageDir .= '&'.CC_SESSION_NAME.'='.$GLOBALS[CC_SESSION_NAME];
}
} else {
if (!empty($GLOBALS[CC_SESSION_NAME])) {
$currentPageDir .= '?'.CC_SESSION_NAME.'='.$GLOBALS[CC_SESSION_NAME];
}
}
$enableSSl = ($config['force_ssl'] || (isset($enableSSl) && $enableSSl) || (isset($sslPages[$currentPage]) && $sslPages[$currentPage])) ? true : false;
if (!$enableSSl && detectSSL()) {
## switch into ssl mode
$page = $glob['storeURL'].str_replace($config['rootRel_SSL'], '/', $currentPageDir);
httpredir($page);
} else if ($enableSSl && !detectSSL()) {
## switch out of ssl mode
$page = $config['storeURL_SSL'].str_replace($glob['rootRel'], '/', $currentPageDir);
httpredir($page);
}
}
## get/set paths and directories
if (detectSSL()) {
$GLOBALS['storeURL'] = $config['storeURL_SSL'];
$GLOBALS['rootRel'] = $config['rootRel_SSL'];
} else {
$GLOBALS['storeURL'] = $glob['storeURL'];
$GLOBALS['rootRel'] = $glob['rootRel'];
}
## Make $GLOBALS paths fool proof - until someone makes a better fool...
if (substr($GLOBALS['storeURL'], -1, 1) == '/') {
$urlLength = strlen($GLOBALS['storeURL']);
$GLOBALS['storeURL'] = substr($GLOBALS['storeURL'], 0, $urlLength-1);
}
if (substr($GLOBALS['rootRel'], -1, 1) !== '/') {
$GLOBALS['rootRel'] = $GLOBALS['rootRel'].'/';
}
?>