1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to block a specific action fo a java script with PHP

Discussion in 'PHP & Perl' started by ija61, Aug 14, 2012.

Thread Status:
Not open for further replies.
  1. ija61

    ija61 Senior Member

    Joined:
    Mar 2, 2011
    Messages:
    965
    Likes Received:
    635
    Gender:
    Male
    Occupation:
    The first SEO economist:)
    Location:
    Romania
    Home Page:
    Hy.

    So here is what I need, I'm not sure if it is possible.

    I have a java code on my website that each time I load a page it send the host name to a url. Is a code for ads.

    So what I need is only to block the script from sending the host name or better to change the host name that it send.

    The idea is that I need to post this code on a different website and I what that the java code to send a host name that I whant.

    How you thing this can be done?

    Thank you.
     
  2. utuxia

    utuxia BANNED BANNED

    Joined:
    Feb 14, 2011
    Messages:
    673
    Likes Received:
    111
    can you paste the code?
     
  3. ija61

    ija61 Senior Member

    Joined:
    Mar 2, 2011
    Messages:
    965
    Likes Received:
    635
    Gender:
    Male
    Occupation:
    The first SEO economist:)
    Location:
    Romania
    Home Page:
    Code:
    <script type="text/javascript">
        var var_name = <code>;
        var var_name = <code>;
    </script>
    <script type="text/javascript" src="http://resources.domain.com/js/filename.js"></script>
    This is the java code. I removed the var main and the domain for confidential reason.

    Thank you
     
  4. utuxia

    utuxia BANNED BANNED

    Joined:
    Feb 14, 2011
    Messages:
    673
    Likes Received:
    111
    So

    http://resources.domain.com/js/filename.js is trying to read the var_name? and you want to do what now?

    You can't really obfuscate it before you give it to me to understand...that doesn't help me any. Sent it to me in a PM if you want me to take a look.
     
  5. ija61

    ija61 Senior Member

    Joined:
    Mar 2, 2011
    Messages:
    965
    Likes Received:
    635
    Gender:
    Male
    Occupation:
    The first SEO economist:)
    Location:
    Romania
    Home Page:
    This is the code that I'm talking about, the name make no difference and my problem have nothing to do with those variables.

    I just put this code on the website and the ads appear on my website.

    The idea is that when I load the page this code send domain name to the advertising company and I want to block to send it or even better, rewrite it so it will look like this code is on a different website.

    You understand it now:)

    Thank you.
     
  6. utuxia

    utuxia BANNED BANNED

    Joined:
    Feb 14, 2011
    Messages:
    673
    Likes Received:
    111
    oh. yo're not setting the domain in there? You can't modify it. unless you can find a way to change window.location.host but I don't think you can. That'll just redirect the user to that page.
     
  7. ija61

    ija61 Senior Member

    Joined:
    Mar 2, 2011
    Messages:
    965
    Likes Received:
    635
    Gender:
    Male
    Occupation:
    The first SEO economist:)
    Location:
    Romania
    Home Page:
    No, those 2 variable are my identification code to that company. Those was provided by them and they must remain there to get my payments:)

    I can not modify the host.

    I get the idea that this can be done only in java since this is a language that is compiled in the browser but I have no idea how to do that.

    Do have any idea?

    Thank you
     
  8. sirgold

    sirgold Supreme Member

    Joined:
    Jun 25, 2010
    Messages:
    1,260
    Likes Received:
    646
    Occupation:
    Busy proving the Pareto principle right
    Location:
    A hot one
    Injecting javascript (not java) from php is as simple as (add brackets, this editor mangles them...):
    Your problem sounds a little vague from here but from what I can understand if you want to send to your ad company another host name you need to host your code on a different server and iframe it or cloak it somehow. In very specific circumstances you could use ajax too, since there are js libraries that allow cross-domain communication, but generally speaking iframing with appropriate cloaking and blanking/spoofing of the referrer seems your best bet to me.
     
    Last edited: Aug 14, 2012
  9. utuxia

    utuxia BANNED BANNED

    Joined:
    Feb 14, 2011
    Messages:
    673
    Likes Received:
    111
    If I understand correctly, he's trying to get the adcode (not his code) loaded from ad provider's site to not load ads for his domain, but someone else's -- that would be a major security problem if you could do that. The ad code is most likely reading from window.location.host to know what domain it's being loaded from. Like I said earlier, you can't change that.
     
  10. ija61

    ija61 Senior Member

    Joined:
    Mar 2, 2011
    Messages:
    965
    Likes Received:
    635
    Gender:
    Male
    Occupation:
    The first SEO economist:)
    Location:
    Romania
    Home Page:
    Thank you guys for your responses.

    Is you got the idea, I want to display ads on different webpages, and to do that I need to insert the a java script on that webpage. I look over the traffic and as nomarl the java script send the host domain. And yes my intention was to mask that and rewrite a different domain.

    As utuxia said beside this parameters the script also send cookies and referrals and for what I know this is impossible to hide, more then that the changes necessary to mask the host name are very difficult and may take me a few weeks to decode the script.

    All that have been said I will go for the iframe method, and what I can get.

    About that... The idea is that this code must be placed on a second website and I have to mask only that host. Any suggestion or material to read about this?

    Thank you
     
  11. mic22

    mic22 Newbie

    Joined:
    Apr 3, 2010
    Messages:
    37
    Likes Received:
    10
    Is the filename.js store hostname string as a variable?
    Try to predefine it and initialize with desired value then use Object.freeze() to make it read-only.
     
    Last edited: Aug 17, 2012
  12. ija61

    ija61 Senior Member

    Joined:
    Mar 2, 2011
    Messages:
    965
    Likes Received:
    635
    Gender:
    Male
    Occupation:
    The first SEO economist:)
    Location:
    Romania
    Home Page:
    I can not know if this work or not but I was thinking at a php solution not java since java is not my strongest point.

    Thank you any way but as I said I think I will go for a different approach since no matter if I manage to solve this I will get in others problems that I do not thing I can solve.

    Thank you
     
Thread Status:
Not open for further replies.