rickrack
rickrack

Reputation: 23

Get top-frame (address bar in browser) URL in PHP?

I'm sorry for my English, it isn't so good... I need help with a simple PHP program: if the page's URL contain a specific word, the content is showed. If there isn't it, the entire page redirects. I would use this to prevent me from frames that other webmasters make to "steal" my website contents. For this is ok.. But a friend of mine need to make a black list of specific words, not a white list. So if the URL contain a word, the entire page redirects. I tried using *$_SERVER['HTTP_REFERER']* but if the "thief" put the frame on an external website that is not in the black list and after he make a frame of the frame, the content is showed and the page doesn't redirect.. So I think it's like that: *$_SERVER['HTTP_REFERER']* could read just 1st level frame and not the main page (top frame). I really need help with this, I can't make it with Javascript because we want to keep the code not visible.

If it is not possible, is there a method to pass a JS variable value to a PHP variable for my case?

Thank you in advance!

Upvotes: 1

Views: 1757

Answers (1)

lbstr
lbstr

Reputation: 2832

This is only possible by javascript if and only if the top level domain is the same as yours. If that is the case, you could make an ajax call to the server, passing along the url and then the server could determine whether or not to redirect.

Instead of showing what the code would look like, I'm much more inclined to persuade you against this approach. If you have content that you don't want people to steal, you should make your site non-public (i.e. users must login). If that is not possible, the content that you are worried about sounds like it shouldn't be on the internet.

Upvotes: 1

Related Questions