Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Feb 2003
    Location
    UK
    Posts
    139
    Thanks
    0
    Thanked 1 Time in 1 Post

    trouble with Referrer Checker script

    Have tried this script on a site I have,

    <script>
    <!--
    /*Referrer Checker- By JavaScript Kit
    (www.javascriptkit.com) Over 200+ free JavaScripts here!
    */

    //specify valid referrals for script to accept
    //if you wish an entire domain to be valid, enter that (ie: "javascriptkit.com")
    var validreferrals=new Array()
    validreferrals[0]="http://www.javascriptkit.com/script/cut170.shtml"
    validreferrals[1]="http://javascriptkit.com/script/cut170.shtml"

    var passed=0

    for (r=0;r<validreferrals.length;r++){
    if (document.referrer.indexOf(validreferrals[r])!=-1){
    passed=1
    break
    }
    }

    if (passed==0){
    alert("Access to the page denied!")
    history.go(-1)
    }

    //-->
    </script>


    Problem I am having is that if i want the entire domain to be valid
    ie. http://myname.sharewith.us

    It wont work, could this be anything to do with the webspace i am using? It is a freebie!

    The reason i am using this is that i have a password protected section of a website, i dont want anyone typing a page url into the browser and bypassing it.

    Any help appreciated, thanks,
    PS I am not into scripts at all!

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    349
    Thanks
    2
    Thanked 0 Times in 0 Posts
    hmm,
    not sure what you are trying to accomplish really, as I just used the refferer property and it worked fine...

    where is the link located that goes to your members page?....the referrer is the page you 'just' came from....its where the link resides that got you to the page you're at...does that make sense?

    where is your site, and I"lll check it out.

    ---> actually, I just looked at the script...it uses the "indexOf" property which doesn't use an exact match...it only checks to see if the referrer contains the given string...so, if you had...

    www.somename.com/joe

    and you were testing it against say,
    www.somename.com/joe/index.html

    it would match.....

  • #3
    Regular Coder
    Join Date
    Feb 2003
    Location
    UK
    Posts
    139
    Thanks
    0
    Thanked 1 Time in 1 Post
    Just looking at my pages, Im wondering if its actually the password protection thats confusing the script?
    I am using atompark webpage password protector. It basically seems to change the index.htm file to index.htm.bak, and creates the password page as index.htm

    If i use index.htm or index.htm.bak as the referrer page things dont work, however if a member logs in and i then send them to an index2.htm and use this page as the refferer it works ok.

    The only problem I then have is that someone could bypass the front door by typing the index2.htm addy in the address bar.

    Hope I havent confused you as much as ive confused myself


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •