Shaun Mccran

My digital playground

07
S
E
P
2010

Forcing an SSL redirect using Coldfusion

I've never really coded much around individual Secure templates, but this afternoon I found myself working in a framework where certain templates were required to be called with the 'https' URL instead of standard non secure URLs.

This turns out to be incredibly easy. There is a variable in the cgi scope that tells you if the request is served under a secure port or not, cgi.server_port_secure returns true or false (1/0), so you can use it to redirect people to where they should be.

view plain print about
1<cfif NOT cgi.server_port_secure>
2
3    <cflocation url="https://#cgi.server_name##cgi.script_name#"
4    addtoken="false">

5
6</cfif>

I've used other cgi values above as I've put this in a 'prefuseaction' function in a fusebox CFC controller file. That way all requests to any actions in that file are routed to the SSL equivalent.

19
J
U
L
2010

Cross site AJAX HttpRequest problems and how to create a Proxy handler

Most of us are familiar with the AJAX post() and getJSON() methods of remotely calling and passing around data, I use them with abundance when building applications. One thing I had not considered until recently is that all my AJAX Http requests are usually internal to that application, which also means they are on the same server and domain.

I recently jumped into a project where the application spanned 24 domains, and had been developed to use a core component library to help code re use. The problem with this arose when you are on one domain (www.domain1.com) and you want to make a request to a different domain (www.domain2.com). You encounter something called the 'same-Origin' policy.

This article deals with how to create a proxy to handle cross site AJAX http Requests.

[ More ]

28
J
U
N
2010

My handy custom font header building function

I've been putting together a personal site for a little while now, and one of the more common pieces of work I've had to do is creating the page headers from a custom font library in Photoshop. The site is 'comic' themed, and as such has an appropriate font (not comic sans!) .

Rather than having to create a new image for each page, I thought I'd cut up the alphabet, and create a function to turn a string into a set of graphics.

[ More ]

04
J
U
N
2010

Simple Coldfusion script to detect if a user is on a Mobile platform

After all the 'mobile talk' at the recent Scotch on the Rocks conference my interest was piqued into looking at mobile versions of sites, and how we as developers can try and seamlessly integrate mobile platforms into our web applications.

The article deals with the first step of that, which is detecting if your user is hitting your site on a mobile platform.

There is a full example of this here: http://www.mccran.co.uk/examples/detect/, hitting this URL with an iPhone or Android device will serve up a different response.

[ More ]

_UNKNOWNTRANSLATION_ /