Search code examples
phpflashactionscript-3.htaccessprotected

ActionScript - Loading Assets From Password Protected Directory (.htaccess) Using PHP?


without having to hardcode a username / password in my .swf file (very easy to decompile!), is it possible to send a URLRequest for some file (perhaps .php?) to a loader object which can load assets that reside in password protected directories?

my PHP skills are weak at best, so if calling a .php script is the solution to this problem some sample code would be greatly appreciated.


Solution

  • This syntax may be a little off, so please forgive me if it doesn't work without a little tweak.

    Outside the protected dir, you can have a file, say "secret.php". In it:

    <?php
    
      header('Content-type: image/png'); //Change to whatever filetype
      echo file_get_contents('/path/to/file/image.png');
    
    ?>
    

    This works because it's reading the file on the file system instead of through the server which invokes auth.

    You can set up parameters to input a filename (be super careful!!!! people could access stuff you dont want) and to handle the content-type.