HI
This snippet works beautiful with shared SSL too.
But when I’m passing along query string arguments along to the Secure Page it doesn’t pass them along.
If you modify the snippet in two places (where the redirect actually happens)
$modx->sendRedirect($secureserver.$document."?".$_SERVER['QUERY_STRING']);
$modx->sendRedirect($unsecureserver.$document."?".$_SERVER['QUERY_STRING']);
Now I have tested it only to make sure it passes along QueryString arguments.
Still testing to see what it does with the submitted forms.(POST)
This is my first post here . So please correct me if I’m mistaken.
MODIFIED SNIPPET CODE
<?php
/*
::::::::::::::::::::::::::::::::::::::::
Snippet name: Encryption
Short Desc: Encrypts a page if needed using SSL
Version: 1.0.0
Author: Andrew Ayre ([email protected])
License: LGPL
::::::::::::::::::::::::::::::::::::::::
Description:
Checks a template variable to see if a page should be encrypted using SSL or not.
The template variable must be called "encryption" and if the value of the template
variable is "On" for a specific page, then it will be encrypted using SSL.
**Before using configure the values $secureserver and $unsecureserver below.**
::::::::::::::::::::::::::::::::::::::::
Example Usage:
Place the call to the snippet at the very top of any template used for encrypted
pages:
[[Encryption]]
[[Encryption?alwaysencrypt=`1`]]
::::::::::::::::::::::::::::::::::::::::
*/
/***********************
* Modified by Kishore Chintoju
* [email protected]
* To pass along the QueryString arguments if any
***********************/
// CONFIGURATION SECTION
// secure location of modx installation - no trailing slash
$secureserver = "https://yourhostingcompany/~yoursite";
// unsecure location of modx installation - no trailing slash
$unsecureserver = "http://www.yoursite.com.au/";
// END OF CONFIGURATION SECTION
// parameters
// alwaysencrypt - set to 1 to always encrypt the page
$alwaysencrypt = isset($alwaysencrypt)? $alwaysencrypt: 0;
// get encryption setting of current document = must be "On" or "0"
$tv = $modx->getTemplateVar('encryption', "", $modx->documentIdentifer);
$encryption = $tv['value'];
if ($alwaysencrypt) {
$encryption = 'On';
}
// get page name of current document
$url = $modx->makeUrl($modx->documentIdentifier);
$document = strrchr($url, "/");
// if SSL off and we are about to access a secure page then redirect
if(strtolower($_SERVER['HTTPS']) != "on" && $encryption == "On")
{
$modx->sendRedirect($secureserver.$document."?".$_SERVER['QUERY_STRING']); //CHANGE
}
// if SSL is on and we are about to acccess an unsecure page then redirect
else if (strtolower($_SERVER['HTTPS']) == "on" && $encryption != "On")
{
$modx->sendRedirect($unsecureserver.$document."?".$_SERVER['QUERY_STRING']);//CHANGE
}
return "";
?>
Thanks
Kishore