Solved

ListFindNoCase Question

Posted on 2011-09-15
3
429 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

743 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

12 Experts available now in Live!

Get 1:1 Help Now