PHP如果正在通过URL获取脚本(PHP If Script is being fetched by URL)
我有一个RSS提要,用户将使用它来翻录内容以显示在那里。 但是,我需要检查网站这样做是否可以访问。
它刚刚发生在我身上,我不知道如何检测服务器是否正在读取脚本以及获取的URL是什么。
可能吗?
I have an RSS feed, users will be using it to rip content to display on there site. However I need todo a check that the site doing so has access.
Its just occurred to me that I have no idea in PHP how to detect if the script is being read by a server and what the URL is of the fetch.
Is it possible?
最满意答案
最好的办法是......
为每个rss阅读器提供自己的密钥(甚至可以是登录密码)。 您可以确定没有密钥就无法读取您的RSS。 您只允许从允许列表中的ips读取rss。 检查referer,但这不是一个好主意,因为referer可以伪造,也可以伪造任何HTTP头。The best approaches for this are...
Give each rss reader it's own key (or maybe even login, password). You'll be sure that nobody can read your RSS without key. You can allow reading rss only from ips from allowed list. Checking referer, but it's not a good idea, because referer could be faked as well as any HTTP header.更多推荐
发布评论