Home | Projects | Downloads | Contact Me | SQL Injection Attacks

Mobile pages for BlogCFC Part Deaux revisited

The original blog entry I posted neglected to take into account SES url's.  This is an attempt to right that.  The code should read:

<cfif findNoCase("Windows CE",CGI.HTTP_USER_AGENT) or
      findNoCase("iPhone",CGI.HTTP_USER_AGENT) or
      findNoCase("iPod",CGI.HTTP_USER_AGENT) or   
      findNoCase("BlackBerry",CGI.HTTP_USER_AGENT) >
    <cfset mobilePath = rereplace(cgi.path_info, "(.*?)/index.cfm", "")> 
    <cfif not len(CGI.QUERY_STRING)>
        <cflocation url="/mobile.cfm#mobilePath#" addtoken="false">
    <cfelse>
        <cflocation url="/mobile.cfm#mobilePath#?#CGI.QUERY_STRING#" addtoken="false">
    </cfif>
</cfif>

This will automatically redirect a mobile browser to the mobile.cfm page and bring over the path variables correctly instead of ignoring them, as it was doing. 

Comments
Layout: Shane Zehnder ::: BlogCFC was created by Raymond Camden. ::: This blog is running version 5.9.