Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ListFindNoCase Question

Posted on 2011-09-15
3
Medium Priority
?
442 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 2000 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

972 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