A Flash Developer Resource Site

Page 1 of 5 12345 LastLast
Results 1 to 20 of 93

Thread: Load a movie into flash using a PHP file

  1. #1
    Senior Member ninjakannon's Avatar
    Join Date
    Sep 2004
    Posts
    393

    Load a movie into flash using a PHP file

    Hi,

    I have no idea whether this is possible or not but I'll ask to be sure...

    For security reasons I am using a Flash file which loads in other swf files, I was just wondering if I could load an swf file into the flash movie from a PHP file.

    Thanks for any help, even if your gonna tell me it can't be done =)

    ------------------------------------------------------------------------

    For anyone reading this now, Keyone.it has managed to find a way of loading swf files into flash from php files, the main aim of this is for security.

    To Keyone.it's 'masterpiece' click this link: http://www.flashkit.com/board/showth...54#post3590754
    Last edited by ninjakannon; 04-07-2006 at 07:57 AM.
    ninjakannon

    - My Website -

  2. #2
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    Sure it can be done.
    There are two quick solutions:

    OPTION "A":
    The main Flash movie DOES NOT contain the URL's of the other Flash movies.
    A database, or text file, contains the URL's of the other Flash movies, with an ID for each URL.
    The main Flash movie requests an URL, sending the ID of the desired movie (at this point a PHP file processes the request and sends back the URL of the desired movie, IF the user is authorized, user authentication must have already been done, you use the $_SESSION functions to manage login).
    The main Flash movie loads the desired Flash movie.

    OPTION "B":
    The main Flash movie only contains the filenames of the other Flash movies.
    The main Flash movie sends a request with the filename and loads the desired Flash movie.
    The PHP script processes the request, and IF user is authorized, it loads the Flash movie and outputs it (the other Flash movies can be placed outside of the PUBLIC_HTML root, so that they can NOT be accessed from the web).


    You should go have a look at http://www.php.net/. There is plenty of documentation there.
    You should type "session", "header" and "image" in the search box (looking for functions).

    If you want to load Flash movies THROUGH php, you need to use the GD graphic library (most likely, but maybe not, you will have to check it).


    With option "B", Flash would just do this:
    Code:
    function safeLoadMovie(filename, myTarget) {
        myTarget.loadMovie("path_to/script.php?movie=" + filename);
    }
    Hope this helps..
    Altruism does not exist. Sustainability must be made profitable.

  3. #3
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    the other Flash movies can be placed outside of the PUBLIC_HTML root, so that they can NOT be accessed from the web
    Ya know, I've seen this line at least 10 times while learning sql. What does it mean? Where is outside the public html root on a server?

  4. #4
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    Don't worry, it's the simplest thing:

    A website is delivered by a server, basically a personal computer with optimized resources and the necessary software (like a Unix workstation with an Apache web server software).

    The web server software handles the website(s) giving a set of privileges for the internet clients on the computer it's running on. Obviously you don't want anonymous users to be able to access the whole filesystem of the computer, so this is where the "public_html" comes into place.
    The "public_html" folder (that can have another name, it's just defined as the "public_html"), is the one that anonymous clients coming in from the web can access freely.

    It is also called the root of the website, because it is the mother folder of the public documents of the website.

    With CGI, ASP, PHP etc.. you can work directly on the filesystem (PHP has a very limited set of privileges though.. due to file owner issues and SAFE_MODE), which means that you can load files that are outside of the public_html area.

    That is good if you want to keep content private: this way, the only way to reach the content is through your script, and if your script requires authentication, you need it!
    In other cases, placing your content in folders with complex names without direct links, somebody might eventually spot the URL and access the content without limitations. (yes you can always use directory access restrictions, but it's very ugly to use it...).

    Cheers
    Altruism does not exist. Sustainability must be made profitable.

  5. #5
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    I'm still missing something here. Assume your using a hosting company and not your own server. I have seen hosts where there are other than the public-html folders available, but not often. When you log in, that's it. How are you supposed to make a folder outside that?

  6. #6
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    in that case you should check for password protected folders. Just put the files into protected area - your serverside script can access them but direct access from a browser will be blocked

    Musicman

  7. #7
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    Now that, I can understand. Thanks.

  8. #8
    if($<0){WelcomeToMyWorld} joshchernoff's Avatar
    Join Date
    Jul 2005
    Location
    Portland
    Posts
    321
    yeah but dont it get saved to the cache any how? you could just get the swf from there if you really want it.

  9. #9
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    server scripts can - and should - tell the browser that the swf is not cachable.
    Besides, usually the plan is not to prevent somebody from viewing again but rather to prevent somebody else from viewing stuff where they can guess the url. Also, it is somewhat unlikely that movies which were extracted from cache really work ... they will be unable to communicate with their home server

    Musicman

  10. #10
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    it is somewhat unlikely that movies which were extracted from cache really work
    Oh yeah, they work, and worse, they can be ripped for any actionscript inside. It's simply too easy.

  11. #11
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    make the movie talk to the server - when someone tries to run the file extracted from cache, it would try to talk to localhost and perhaps not get the responses it expects

    Musicman

  12. #12
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    Yes, SWF movies launched locally don't have domain restrictions. They can communicate with the original home server with no limitation.


    Geezer, when you FTP to your shared server, you should try going "up" folders, to the root of the resources that have been made available to you.

    A good hosting service will give you a "virtual server", which means that when you FTP your account, you will see all the usual folders of a whole machine, even though you don't have the ability to actually configure it (most of the configuration files are there just because it's a "virtual server", but actually are not read by the system, as the system has it's own parent configuration).

    In such cases, your "public_html" folder will most likely be found at the address "/var/www/html/".

    From Dreamweaver, you can define "/" as the initial folder, this should get you to the root of the available resources.

    If you need a better hosting service, go look at http://www.mediatemple.net/. They have the optimum quality/price/guarantee ratio. Been with them for years, few problems and quick service!

    Cheers
    Altruism does not exist. Sustainability must be made profitable.

  13. #13
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    while local swf can connect to any server, I believe that a swf calling its home server via relative path can be quite an obstacle ... one would need to duplicate the functionality of the remote script or decompile and then rebuild the movie

    Musicman

  14. #14
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    Musicman, I was totally overseeing what you pointed.
    It's relaxing to think how sometimes the simplest solution is also the best one

    Cheers
    Altruism does not exist. Sustainability must be made profitable.

  15. #15
    Senior Member ninjakannon's Avatar
    Join Date
    Sep 2004
    Posts
    393
    While you can do all these things to make your swf files ungetable (storing in the root folder, making the swf connect to a file on the server and the load - so that it cannot run past frame 1 without recieving a variable from this file etc...) there always seems to be a way of getting in.

    The best solution would to somehow stop the file from being cashed, which is probably impossible - or very hard =(. So any ideas....?

    There is a way, although I'm not sure how, to make sure no one can download or open files on your website directly. If you could combine this with allowing no cache then it would be pretty hard to actually get the file.
    ninjakannon

    - My Website -

  16. #16
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    This does seem to work;

    myClip.loadMovie("filename.swf?nocache=" + new Date().getTime());

    make the movie talk to the server
    Heyden Porter has a nice script that will make the movie unable to play on localhost or any server but the one you specify. But again, if the swf is ripped, anyone can get the code. I'll attach an example. The best protection I have found is Amayeta's SWFEncrypt 3. It works. If someone snags the swf and tries to rip it, they get a bunch of worthless code loops, the images are smeared and there are no sounds in the library.

    Geezer, when you FTP to your shared server, you should try going "up" folders,
    Yeah, tried that, but I'm with godaddy, and they don't let you do that either. But the deal is too good to leave.
    Attached Files Attached Files
    Last edited by Ask The Geezer; 03-27-2006 at 02:25 PM.

  17. #17
    Senior Member ninjakannon's Avatar
    Join Date
    Sep 2004
    Posts
    393
    Nice one! I've tried out that swf file on my computer and two of mywebsites and it's, well... emence!

    I have two further questions:
    1) I have some PHP files, that do not cache, which load data from txt files (and soon a database). Could I make these not cache by using the same principle as:
    myClip.loadMovie("filename.swf?nocache=" + new Date().getTime());
    or is there some other way?

    and 2, could you give me a link to somwhere where I can download Amayeta's SWFEncrypt 3, thanks.

    Regards,
    ninjakannon

    - My Website -

  18. #18
    Senior Member ninjakannon's Avatar
    Join Date
    Sep 2004
    Posts
    393
    Opps, this was a duplicate... sorry.
    ninjakannon

    - My Website -

  19. #19
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    from PHP you just use headers...

    PHP Code:
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); //passed date
    header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT"); //always modified
    header("Cache-Control: no-store, no-cache, must-revalidate");  // HTTP/1.1
    header("Cache-Control: post-check=0, pre-check=0"false);
    header("Pragma: no-cache"); //HTTP/1.0 
    Cheers
    Altruism does not exist. Sustainability must be made profitable.

  20. #20
    Senior Member ninjakannon's Avatar
    Join Date
    Sep 2004
    Posts
    393
    OK,

    And is there a way to get the files that are loaded in not to cache as well?
    ninjakannon

    - My Website -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center