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

Status
Not open for further replies.

ija61

Senior Member
Joined
Mar 2, 2011
Messages
976
Reaction score
644
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.
 
can you paste the code?

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
 
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.
 
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.

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.
 
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.
 
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
 
Injecting javascript (not java) from php is as simple as (add brackets, this editor mangles them...):
echo "script javascript code /script";
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:
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.
 
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.

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.

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
 
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:
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.

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
 
Status
Not open for further replies.
Back
Top