Solved

ListFindNoCase Question

Posted on 2011-09-15
3
432 Views
Last Modified: 2012-05-12
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;
                        }
0
Comment
Question by:erikTsomik
  • 3
3 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 36545469
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
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 36545504
>> I'd start with using list functions to extract the address after the http:// (if any)

In other words, scrub the db entry and extract the domain. Then compare it to the server name. But all bets are off if the cgi.server_name is an ip address or has been tampered with.

<!--- extract part after http:// etc... --->
<cfset dbDomain = getToken(db.homeDomain, 2, "//")>
<!--- ignore leading "www." --->
<cfset dbDomain = listRest(dbDomain, ".")>

<!--- compare values. may need to scrub further --->
<cfscript>
accessOK = 1;
if (cgi.server_name eq dbDomain ) == 0) {
     AccessOK = 0;
}
</cfscript>
0
 
LVL 52

Expert Comment

by:_agx_
ID: 36546097
oops. typo correction, this line:

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

should just be:

    if (cgi.server_name eq dbDomain) {
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now