SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2005
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What does this script do?

    Hello,

    I own a file upload website, and to prevent users from linking to files directly (skipping the pages with ads), the urls are regulary changed (and when someone tries to go to the file directly on the old url they are referred to a page with ads).
    Recently I've noted something strange, one of the sites referring to my site is using Javascript: If the link goes directly to the file, and is not referred to a page with ads, the visitor gets the file when he clicks on it.
    If, however the file refers to a page with ads, the link seems to disappear after a user clicks on it and the user stays on the same page.
    I hope you understand what I mean. Here is the code:
    Code:
    <script type="text/javascript">
    function getURLParam(level)
    {
       var search = level + "=";
       var searchURL=location.href;
       var searchURL=searchURL.substring(searchURL.indexOf('?')+1, searchURL.length);
       if (searchURL.length > 0) {
            var offset = searchURL.indexOf(search);
            if (offset != -1) {
                offset += search.length;
                var end = searchURL.indexOf("&", offset);
                if (end == -1) end = searchURL.length;
                return unescape(searchURL.substring(offset, end));
            }
        }
        return "";
    }
    </script>
    <script type="text/javascript">
    function fraRefresh () {
    var str = getURLParam("url");
    window.frames['frame1'].location = str.replace(/ABC/,"&")
    
    }
    </script>
    
    </head>
    
    <body leftMargin=0 topMargin=0 >
    <a href="javascript:location.replace(getURLParam('url'))">DOWNLOAD</a> 
    </script>
    </body>
    and they put that as the src of an iframe.
    Now, I was wondering if someone could explain to me what this code does and if there's any way to get around it.(they're stealing bandwidth doing this at the moment)

    Thanks,
    Gert

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)

    js code

    The script uses the location.href property value and checks to see if it has a GET var. If it does it returns "empty". Maybe you could give all the URLs a GET var even if it doesn't do anything? This would make the script's user get "empty" for every page, if that's an option for you.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2005
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much! I found a way to remove the GET variables, and then all I had to do was prevent the page from being displayed in an iFrame and now it works.
    Thanks!


Bookmarks

Posting Permissions

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