Downloads » Resources » Encryption » Encryption | 1.0.1

Encryption 1.0.1

  • Currently 4.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
2 vote(s).

This snippet allows you to specify which pages on your site are encrypted. It supports both shared and dedicated SSL certificates and friendly URLs.

Works with MODx Version(s): 0.9.5
Submitted: Dec 12th 2006 | License: LGPL | Downloads: 1474

Description

This snippet allows you to specify which pages on your site are encrypted. It supports both shared and dedicated SSL certificates and friendly URLs. There are two ways to use it:

  • Turn encryption on based on a template variable
  • Turn encryption on for a template (i.e. all documents using the template will be encrypted)

Instructions

First make sure you can access your site via http and https. For shared SSLs the URL would be something like https://www.hostingco.com/~foo.

Installation

1. Copy the text file into a new snippet called "Encryption".

2. Edit the $secureserver parameter to match the location of your site when it is encrypted. For example https://www.hostingco.com/~foo.

3. Edit the $unsecureserver parameter to match the location of your site when it is not encrypted. For example http://www.foo.com.

Using a Template Variable

1. Create a template variable called "encryption" that is a checkbox. The "input option values" should be "On" (capital O). The default value should be "Off".

2. Add the template variable to templates.

3. At the top of each template add the call to the snippet. For example:


[[Encryption]]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


4. Edit the documents to be encrypted and check the encryption checkbox.

Using a template

1. At the top of the template add the call to the snippet, setting the alwaysencrypt parameter. For example:


[[Encryption?alwaysencrypt=`1`]]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


5. Change documents to be encrypted to use this template.

Friendly URLs

1. First test your site without using friendly URLs. If you have a problem then adding friendly URLs will not fix it.

2. Change your .htaccess file to look something like:


RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{SERVER_PORT} 443
RewriteRule ^(.*)$ ~foo/index.php?q=$1 [L,QSA]


The line below %{SERVER_PORT} 80 must match be suitable for the URL for non encrypted access. The line below %{SERVER_PORT} 443 must be suitable for the URL for encrypted access.

That should be it!

Updates

Added parameter passing contrib.


( back to top )