有没有办法让 flash-app 仅在我的页面(域)上运行,而不是在本地或其他域上运行?

发布于 2024-12-20 12:02:10 字数 63 浏览 0 评论 0原文

我创建了一些游戏,想让用户只在我的域上玩它,因此禁止离线玩它或放在其他网站上。有办法做到吗?以某种方式检查域等?

I created some game and would like to let the users play it only on my domain, so to forbid to play it offline or put on some other site. Is there a way to do it? Somehow check domain or so?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

单挑你×的.吻 2024-12-27 12:02:10

尽管很难明确控制 Flash 内容的分发,但您可以采用几种不同的途径,至少可以使在其他地方发布内容变得更加困难。

一种方法是检查加载 swf 对象的 url 是从 LoaderInfo 类

var url:String = loaderInfo.loaderURL;

您还可以使用 JavaScript 通过 ExternalInterface 类

var url:String;
if (ExternalInterface.available) {
    url = ExternalInterface.call("window.location.href");
}

然后检查 url 以查看它是否位于您所需的域内,如下所示:

if(!/^https?:\/\/www\.example\.com/.test(url)) {
    //This seems to be outside of your domain
}

您可以在本文中找到有关此方法的一些其他信息:
http://www.ghostwire.com/blog/archives/as3- domain-locking-swfs/


另一种方法是尝试从您控制的域下载文件,如果您已经将外部资源下载到您的 swf,这种方法尤其有效。

通过指定资产的绝对 URL,例如 http://www.example.com/assets/myExternalAsset.xml,而不是相对 URL,例如 /assets/myExternalAsset.xml< /code>,你可以设置一个跨域策略 确定哪些域能够访问内容。

如果从允许的域之外访问内容,将触发安全错误事件并且下载将无法完成。


话虽如此,例如,如果您的内容嵌入到另一个网站的 iframe 元素内,我并不完全确定上述任何方法是否能够充分保护您。

Although it's hard to definitively control the distribution of your Flash content, there are a few different routes you can go down to, at least, make it harder to publish your content somewhere else.

One way is to check what url are loading the swf object is to check loaderInfo.loaderURL from the LoaderInfo class.

var url:String = loaderInfo.loaderURL;

You can also check the loading url by using JavaScript through the ExternalInterface class:

var url:String;
if (ExternalInterface.available) {
    url = ExternalInterface.call("window.location.href");
}

Then check the url to see that it resides within your desired domain, like this:

if(!/^https?:\/\/www\.example\.com/.test(url)) {
    //This seems to be outside of your domain
}

You can find some additional information about this approach in this article:
http://www.ghostwire.com/blog/archives/as3-domain-locking-swfs/


Another approach is to try to download a file from a domain you control, this is especially effective if you are already downloading external assets to your swf.

By specifying an absolute url to the asset, like http://www.example.com/assets/myExternalAsset.xml, instead of a relative one, like /assets/myExternalAsset.xml, you can set up a cross-domain-policy to determine what domains are able to access the content.

If the content is accessed from outside of your allowed domain(s), a security error event will be triggered and the download will not complete.


Having said this, I'm not fully sure if any of the above methods will fully protect you if your content, for example, is embedded inside of an iframe element on another site.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文