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)
}
}