Forum Topic: Strip Function

(2,124 views • 10 replies)

This topic is 1 page long.

<< < > >>
None

Famicom-Kid

Reply To Post Reply & Quote

Posted at: 6/14/05 01:50 PM

Famicom-Kid LIGHT LEVEL 09

Sign-Up: 05/26/04

Posts: 258

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...


None

Pilot-Doofy

Reply To Post Reply & Quote

Posted at: 6/14/05 03:22 PM

Pilot-Doofy NEUTRAL LEVEL 37

Sign-Up: 09/13/03

Posts: 12,274

So in other words you want to proceed with hotlinking NG flash's which they strictly dislike?


None

Famicom-Kid

Reply To Post Reply & Quote

Posted at: 6/14/05 03:51 PM

Famicom-Kid LIGHT LEVEL 09

Sign-Up: 05/26/04

Posts: 258

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!");}


None

Deja-Vu

Reply To Post Reply & Quote

Posted at: 6/14/05 05:11 PM

Deja-Vu NEUTRAL LEVEL 25

Sign-Up: 05/03/02

Posts: 556

You have to test _root._url against your array of allowed sites.

BBS Signature

None

Famicom-Kid

Reply To Post Reply & Quote

Posted at: 6/14/05 05:12 PM

Famicom-Kid LIGHT LEVEL 09

Sign-Up: 05/26/04

Posts: 258

I know im just not doing that because im to lazy to reupload everytime i test it


None

Taylor

Reply To Post Reply & Quote

Posted at: 6/14/05 05:46 PM

Taylor LIGHT LEVEL 09

Sign-Up: 08/19/03

Posts: 8,508

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.


None

Famicom-Kid

Reply To Post Reply & Quote

Posted at: 6/14/05 05:51 PM

Famicom-Kid LIGHT LEVEL 09

Sign-Up: 05/26/04

Posts: 258

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...


None

MainThink

Reply To Post Reply & Quote

Posted at: 6/15/05 09:23 AM

MainThink NEUTRAL LEVEL 11

Sign-Up: 04/05/05

Posts: 11

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!


None

Famicom-Kid

Reply To Post Reply & Quote

Posted at: 6/15/05 10:36 AM

Famicom-Kid LIGHT LEVEL 09

Sign-Up: 05/26/04

Posts: 258

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


None

henke37

Reply To Post Reply & Quote

Posted at: 6/16/05 07:00 AM

henke37 NEUTRAL LEVEL 23

Sign-Up: 09/10/04

Posts: 3,646

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.


None

liljim

Reply To Post Reply & Quote

Posted at: 6/16/05 08:50 AM

liljim NEUTRAL LEVEL 27

Sign-Up: 12/16/99

Posts: 8,903

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

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 02:05 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!