Forum Moderators: coopster
on my website I have a nice calculator (written in php) in which some websites are interested in. I don't want to give them the source code, so I decided to allow them iframing the calculator sitting on a separate unstyled site (first question, is this the best option?).
The main question is how do I control that only certain websites will iframe the calculator and not other websites? Is there a way of checking which URL has iframed my site and serving all other URLs a different content?
Would be great to hear some suggestions.
Many thanks
...and Welcome to WebmasterWorld :)
The other option is to just sell the script to people then offer support as the person who wrote the script. Others will copy the script but then eventually people will break through your security anyway. So it all depends on how much time/money you want to spend protecting the code or just sell it on and offer support for it.
still haven't found a solution but have a couple questions:
1. Referrer: I believe the referrer depends on the client browser, right? So, the user can spoof the referrer but not the website owner who puts my tool in an Iframe. If I check the referrer then the users who correctly show the referrer could get another image served but any users who spoof their referrer or block the referrer would get to see the original. Is my understanding correct so far?
2. IP address: Is this also based on the client browser as above or is this foolproof, i.e. my PHP will always get to see the IP address of the website which uses the Iframe?
Thanks
The clients are putting the tool on their own websites to drive a bit of traffic, so it's freely accessible to anyone. Therefore, the password suggestion is also not an option.
But thanks for the suggestions.
The IP address you are going to get is the IP of the browser, not the framing site.
The referrer, keep in mind, is sometimes blank even for legitimate requests. Why? Either it is privatized intentionally by a browser add-on, or sometimes browsers are just flaky and don't always send it. For this reason, usually when people check the referer they allow blank referrers to get the goods, too--in other words, default toward leniency. Only block access when the referrer comes back showing the wrong site. But you can see, using the referrer is not that great of a solution.
Other ideas are more complicated... publish your calculator as a web service, for example, or utilize AJAX for display rather than an IFrame.
var S=['www.example.com','example.com','dev.null'];function chk(l) {
for (var i=0,s;s=S[i];i++) if (l==s) return 1;
}if (window!=top) {
var l;
if (document.referrer && (l=document.referrer.split('/')[2]) &&!chk(l)) top.location=window.location;
}
[edited by: Achernar at 12:25 am (utc) on Nov. 7, 2007]