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 :


Recents Blog Entries

posted in Solving

Flash Player 10 freeze randomly on fullscreen

Ho ho ho

posted 2009-12-281 Commentsread more ...

posted in Solving

AS2 setVolume to zero turn off video volume

How to fix setVolume to zero turns off video volume

posted 2009-12-280 Commentsread more ...

posted in Papervision3D

Christmas book using ViewportLayer

It is an old book made with Papervision ViewportLayer. It shows origami that fold/unfold using Bones. It is a christmas gift for my closest friends and favorites co-workers.

posted 2009-12-240 Commentsread more ...

posted in Papervision3D

Animate parented DisplayObject3D from DAE

This post display how to set up and animate parented DisplayObject3D. Also demonstrate how to localise and fix unwanted behavior.

posted 11-01-20090 Commentsread more ...

posted in Personnal

I am Graduated

Time to work !

posted 15 09 20090 Commentsread more ...

posted in Others

Colors syntaxing AS3 for FlashDevelop

A color file configuration for FlashDevelop

posted 04-08-20090 Commentsread more ...

posted in Papervision3D

Faking solar flare

How I've tried to fake a solar flare with Papervision3D

posted 06-08-20091 Commentsread more ...

posted in Papervision3D

Labyrinth3D Papervision3D and WOWEngine

This game-project called 'WOW that 's a Labyrinth' is still in dev. And unfortunately it should be still for a while.

posted 13-03-092 Commentsread more ...

posted in Works

Coverflow like picture gallery

Absolutely not innovating, but I post my coverflow gallery.

posted 12-03-090 Commentsread more ...