Link to home
Start Free TrialLog in
Avatar of erikTsomik
erikTsomikFlag for United States of America

asked on

ListFindNoCase Question

I need to do the search for the domain name. So user may store in the database
http://test.com or test.com or www.test.com I need to find the domain.

So if the site domain is not equals to whatever they entered in the database set varible.

I have  a piece of code that partially work . if they enter the the name without http it is working ,otherwise does not.

I need to allow the user to do it regardlesss
accessOK = 1;
if (ListFindNoCase(#cgi.server_name#,#db.homeDomain#) == 0) {
                              AccessOK = 0;
                        }
Avatar of _agx_
_agx_
Flag of United States of America image

I'd start with using list functions to extract the address after the http:// (if any)

ie    
<cfset dbDomain = getToken(db.homeDomain, 2, "//")>

If you're not validating the user entry, you'll need to scrub the data further. For example if you needed to remove the www:

<cfset dbDomain = listRest(dbDomain, ".")>

But there are some gotchas with using cgi.server_name. For example, the user could enter an IP instead of a name or this one

http://www.coldfusionjedi.com/index.cfm/2008/6/5/Use-cgiservername-Be-careful
ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
oops. typo correction, this line:

    if (cgi.server_name eq dbDomain) == 0) {

should just be:

    if (cgi.server_name eq dbDomain) {