5

Blog Entry #19

posted in Actionscript

Avoiding AS3 security sandbox

avoiding sandox in actionscript3 While working on SoundRiver in 2007, I just wanted to get the album cover somewhere from other domain of the web as GoogleImage, Amazon, ...
When you publish it in flash IDE, it ok.
But on the web you will fight against the Flash Security Sandbox.
So ?
You need to avoid the security sandbox to succeed. If no crossdomain.xml is located on this server you should try something else.
How does it works ?
Easily, you just need a php script on your server. Rather than load a file located on other domain, just ask the script to load it for you...
Here is a php script to load pictures from the web.

  1. <?php
  2.   $infos=pathinfo($_GET['url']);
  3.   $extension = strtolower($infos['extension']);
  4.   switch($extension){
  5.     case "jpg":
  6.     header("Content-Type: image/jpeg");
  7.     $img_in = imagecreatefromjpeg("http://".$_GET['url']);
  8.     imagejpeg($img_in);
  9.     break;
  10.     case "png":
  11.     header("Content-Type: image/png");
  12.     $img_in = imagecreatefrompng("http://".$_GET['url']);
  13.     imagepng($img_in);
  14.     break;
  15.     case "gif":
  16.     header("Content-Type: image/gif");
  17.     $img_in = imagecreatefromgif("http://".$_GET['url']);
  18.     imagegif($img_in);
  19.     break;
  20.   }
  21. ?>

In this example there only two differents php script. One ask googleimage with our request, then send the result using adequat regex. Then the second will load the pictures

Why you should not use it ?
this way is unsecure, as we load a loader(php) we are not able to preview the progress.
Why you should use it ?
To acces to every data available on the web, that's how it should be.

2 comments about this entry

1

posted by : noj
from : sydney
April 8, 2009, 1:56 am
website : www.om-labs.com

why dont you just do file fpassthru(fopen($_GET['url'],'rb'));//way faster.

2

posted by : Badou
from : Brussels
April 8, 2009, 11:05 pm
website : http://www.blog.badou.biz/

@noj Indeed this benchmark http://be.php.net/manual/fr/function.fpassthru.php#55001 is really amazing.

Write a comment

edit




Insert :


Search Engine

Search blog entries


Search

Recommended Feed

keep your mind opened ...