CFLib.org – Common Function Library Project

URLCheckHash()

Last updated January 7, 2002

Version: 1 | Requires: ColdFusion 5 | Library: SecurityLib

 
Rated 0 time(s). Average Rating: 0

Description:
After securing a URL by using the URLHash UDF, you can verify that the URL's integrity remains unchanged by verifying the security Hash vale with URLCheckHash.

Return Values:

Example:

view plain print about
Example code will always fail since it checks the CGI variable which will not be correct for this template.

<cfif NOT URLCheckHash()>
  Here you would CFLOCATE, or throw some kind of error.
</cfif>

Parameters:

No arguments.

Full UDF Source:

view plain print about
<cfscript>
/**
 * Used along with URLHash to verify the URL integrity.
 * 
 * @author John Bartlett (jbartlett@strangejourney.com) 
 * @version 1, January 7, 2002 
 */

function URLCheckHash()
{
  var tmp=CGI.Query_String;
  var listL=0;
  var loop=0;
  var URLVar="";
  var HashData="";

  if (IsDefined("URL.Hash"))
  {
    if (URL.Hash NEQ "")
    {
      listL=ListLen(tmp,"&");
      URLVar=ListGetAt(tmp,ListL,"&");
      if (Left(UCase(URLVar),5) EQ "HASH=")
      {
        tmp=ListDeleteAt(tmp,ListL,"&");
      }
      HashData=cgi.Server_Name & cgi.Remote_Addr & cgi.Script_Name & tmp;
      if (URL.Hash EQ Hash(HashData)) return 1;
      else return 0;
    } else return 0;
  } else return 0;
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
11 day(s) ago

Will Belden Will Belden added
longTime
17 day(s) ago

James Sleeman James Sleeman added
quickSort
27 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
29 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson