Solved

ListFindNoCase Question

Posted on 2011-09-15
3
439 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

615 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