Solved

ListFindNoCase Question

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

Suggested Solutions

Title # Comments Views Activity
Open dialog with server side controls in it 3 46
Opening a new tab in IE using Powershell / HTML 2 45
HTML <font style="color:red"> 9 51
Html split(text) 2 28
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

756 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