Strip Function
- Famicom-Kid
-
Famicom-Kid
- Member since: May. 26, 2004
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
I was making a security script for my sites flash movies and I forgot that when its uploaded to ng I wont know the exact location of the flash. So I wont know what to put for the location its looking for, making the movie not able to be played.
I remember seeing a tutorial that would strip the location and use an array for allowed sites. I got the array crap down but I dont remember how to strip the url. I think the tutorial was psychogoldfish's protection, but its not up anymore...
- Pilot-Doofy
-
Pilot-Doofy
- Member since: Sep. 13, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (12,142)
- Block
-
- Forum Stats
- Member
- Level 37
- Musician
So in other words you want to proceed with hotlinking NG flash's which they strictly dislike?
- Famicom-Kid
-
Famicom-Kid
- Member since: May. 26, 2004
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
No no no no, lol. Well I finally made the script but it doesn't seem to work, but wut it is supposed to do is provent anyone else besides sites i put on an allow list to from putting the flash on their site.
Here is the script I came up with, it should work but I dont know why. I have been trying at it for almost 2 hours and it looks like it should work but it doesn't.
var my_str = String = "http://www.frostbite-studios.com/security.swf";
var my_array = Array = my_str.split(".com", 1);
var reallocation = my_array;
var allowlocation = "http://www.frostbite-studios";
if (reallocation == allowlocation) {
trace("IT WORKS!");
} else {trace("YOU FAILED!");}
- Deja-Vu
-
Deja-Vu
- Member since: May. 3, 2002
- Offline.
-
- Forum Stats
- Member
- Level 32
- Programmer
You have to test _root._url against your array of allowed sites.
- Famicom-Kid
-
Famicom-Kid
- Member since: May. 26, 2004
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
I know im just not doing that because im to lazy to reupload everytime i test it
- Taylor
-
Taylor
- Member since: Aug. 19, 2003
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
You made that way too difficult on yourself
allowedsite = "http://www.frostbite-studios.com/security.swf";
if (_root._url == allowedsite) {
trace ('correct site');
} else {
trace ('wrong site');
}
Or something like that
I gave up on Flash as a programming enviroment long, long ago... but this is the right concept.
- Famicom-Kid
-
Famicom-Kid
- Member since: May. 26, 2004
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
Yes I had that, but now lets say I submit a flash with that to newgrounds. I wouldn't know its exact location. Thats why I strip the _root._url down to only the domain and if the domains match it lets the movie play. But no flash has to be gay and make the script not work when it looks like it should...
- MainThink
-
MainThink
- Member since: Apr. 5, 2005
- Offline.
-
- Forum Stats
- Member
- Level 12
- Blank Slate
Well, just looking at the code it should actually work.
The thing is, you are comparing a string with an array.
I don't know a thing about ActionScript, but even if it's an array of string with just one element as you specified in the .split call, shouldn't you refer to the first element with my_array[0]?
I don't really understand why you define another variable and you assign the array to it. Is this a tecnique to put the first element in the variable?
Remember that if arrays are considered "by reference" it looks to me like your function is trying to compare a string (char by char) with the first element's memory address.
But again, I'm not thinking like an ActionScript compiler, so...
Have you already tried this:
if (my_array[0] == allowlocation)
{ trace("IT WORKS!"); }
else
{ trace("YOU FAILED!"); }
Of course if you get it to work, you have to insert everything in a loop and modify it if you have an array of allowlocations.
Let us know what happens!
- Famicom-Kid
-
Famicom-Kid
- Member since: May. 26, 2004
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
Yes yes I know, I went to the macromedia forums asking for help cause no one else here seems to know AS and they gave me the same answer. Thnx anyway, im just glad its all freaking over I spent almost all trying to find the function and then to find out that it wasn't working made me feel mad.
Thnx
- henke37
-
henke37
- Member since: Sep. 10, 2004
- Offline.
-
- Forum Stats
- Member
- Level 30
- Blank Slate
I don't do as but here's my try(php syntax):
$arr[0]='www.ungrounded.com';//Remember ng uses this domain for the flashfiles
$arr[1]='www.yourdomain.com';
$rurl=lower($_root->_url);
foreach($arr as $url) {
if($url==$rurl) {
$ok=true;
break;
}
}
if(!$ok) {
echo 'Watch this movie at http://www.yoursite.com and f the site you found this on';
}
Each time someone abuses hittest, God kills a kitten. Please, learn real collision testing.
- liljim
-
liljim
- Member since: Dec. 16, 1999
- Offline.
-
- Send Private Message
- Browse All Posts (11,644)
- Block
-
- Forum Stats
- Staff
- Level 28
- Blank Slate
This won't work on your local filesystem. Also make sure you change the "goodurl" and "badurl" jumps to something appropriate in your file:
_____________________________________________
this_url = _root._url;
// list of allowed urls.
allowed_urls = new Array("uploads.ungrounded.net", "uploads.newgrounds.com", "www.yoursite.com", "yoursite.com", "yoursite.mirror.com");
// Take out the http://, and get the domain
// Life would be so much easier if Flash supported regular expressions
// as a standard.
this_url = this_url.substr(7, this_url.length);
this_url = this_url.substr(0, this_url.indexOf("/"));
var found_good_url = 0;
for(var i=0; i<allowed_urls.length; i++)
{
if(this_url == allowed_urls[i])
{
found_good_url = 1;
break;
}
}
if(found_good_url == 1)
{
gotoAndStop("goodurl");
} else
{
gotoAndStop("badurl");
}


