Playback Protection of Flash works

Source: Internet
Author: User

A certain degree of protection can be achieved if the implementation SWF file cannot be played locally or in an illegal URL. Here is a general idea of the implementation,

The code is as follows:

var this_url = _root._url;
if (substring(this_url,1,4) == 'file'){
//如果在硬盘上播放,作出处理
trace('对不起,禁止在本地播放!');
}else{
//表示在网页中播放,则检查是否是合法的URL地址
urlArray = this_url.split("/"); //对url地址分割
if (urlArray[2]!='yourweb.com'){
getURL("javascript:alert('访问被禁止!')");
}else {
getURL("javascript:alert('欢迎光临YourName!')");
}
}

Note: This code must be written at the beginning, the specific processing control needs to be refined to do.

Because the security of the client is not good, it is recommended that the server side of the protection control, the following method uses the server-side implementation:

//访问保护
application.onAppStart = function (info){
this.domainList = new Array("http://210.64.45.41";,"http://210.64.45.38";,"http://vid
eo.idv.to";);
this.domainLength = this.domainList.length;
};

application.onConnect = function(client_obj) {
//限制访问
trace("user trying to connect from:" + client_obj.referrer);
var theReferrer = client_obj.referrer.toLowerCase();

for(i=0; i
var challenge = theReferrer.indexOf(this.domainList[ i ]);
if (challenge == 0) {
acceptit = 1;
break;
}
}
if (acceptit) {
trace ("correct domain, accepting connection");
application.acceptConnection(client_obj)
} else {
trace ("Sorry wrong domain, rejecting connection");
application.rejectConnection(client_obj)
}
}







Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.