AS3 URLRequest XSS? - actionscript-3

Im basically working on an image analyser that downloads images from another server. I have no control over the server but I only want to scan images not html pages.
would something like this work?
new URLRequest('http://otherserver.com/someimage.jpg');
Or would I have to use a PHP script to act as a proxy for my script and have the swf look up that php script with parameters instead?
new URLRequest('http://myserver.com/proxy.php?image=someimage.jpg');
I only ask because I remembered AJAX requests wont work cross domain so I wondered if the same thing affects AS3 aswell.

You need a cross-domain-policy:
http://help.adobe.com/de_DE/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7e08.html

Related

How to get change in HTML DOM in LabVIEW?

I am doing IOT related project in Labview using Arudino as hardware.
I was able switch off/on an led on Arudino by Pressing OFF/ON on website by using datasocket vi. Now what i want is to control the intensity of led from Website.
I have a range slider in my website and its real time value can be viewed in textarea,div,input type.
Is there any way i can get that real time value that is being changed in HTML DOM in Labview.
I know that datasocket vi returns the html source code but not the HTML DOM.
I dont want to use the Web Publishing Services as they dont work in my Laptop.
This is the link im referring for datasocket.
Datasocket Labview
You can do something like creating a web socket, but I expect the easiest thing is to use a web service. You can create one in LV and add a setLEDIntensity method to it and call it from your JS code. You can find a simple example here and in other documents in that community.
Use WebSocket API for LabVIEW to send and receive data from the web. This is the best option for you.
https://decibel.ni.com/content/docs/DOC-40572

ActionScript3 Error Handling URLRequest

(ActionScript3) Hi, I'm trying to work out why a URLRequest is failing when viewed via a third party website. Ideally any error could be pointed out in the below code, however, I think it's fine as similar things we do work fine.
Next to ideal would be URLRequest error handling, how can I find out WHY the URLRequest is not pulling the information from time.php? Even if it's just output to a textbox on the timeline (everything works fine when done from the testing environment)
Many thanks
Craig
Scenario:
domain.com (Server 1): file.swf uses a URLRequest to load domain.com/time.php?a=b (so the PHP and the SWF are both hosted on the same domain and server)
example.com (Server 2): PHP page embedding file.swf (which in turn URLRequests time.php)
Outcomes:
When you access file.swf directly via browser, it loads the data from time.php just fine
When you view the page file.swf is embedded on, on Server 2 the loading fails
file.swf
var loaderNameHolder;
var loaderNameHolderLoader:URLLoader = new URLLoader();
var loaderNameHolderURLRqst:URLRequest = new URLRequest('http://domain.com/time.php?a=b');
loaderNameHolderLoader.addEventListener(Event.COMPLETE, loaderNameHolderURLFunc);
loaderNameHolderLoader.load(loaderNameHolderURLRqst);
function loaderNameHolderURLFunc(e:Event):void{
loaderNameHolder = loaderNameHolderLoader.data
gotoAndStop(loaderNameHolder);
}
Security
There is a crossdomain XML in place on the domain's root folder, it seems to make no difference (or is not being referenced/used correctly) however as mentioned similar things I do work fine without modifying this XML
It sounds like a security issue, although you say that you have the crossdomain file in place.
Have you checked the http calls with a tool like Charles (http://www.charlesproxy.com/)? This is definitely the best way to debug such a problem.
Thanks for the tips above, they'll be great resources to keep.
The actual issue was that the Requested URL didn't include "www" (I think because the SWF is embedded with the WWW so it was coming from an "outside" domain. I think I need www.domain.com in my own security XML).
Craig
try adding this code
Security.allowDomain("*");
Security.loadPolicyFile("http://domain.com/crossdomain.xml");
and read about crossdomain.xml using links given here: https://stackoverflow.com/a/9728845/2234089

bringing in an API (xml)/URL into php for Joomla

what I need is a way to bring in this: 184.173.18.228/api/profile/1000/0/Adam.Adams (which is an xml file) into php ( Im assuming) to be used in Joomla ( I can use Sourcerer for the code in Joomla) - the problem I have been running into is that there is a cross domain proxy problem - over last weekend I was able to render that xml when it was locally on my machine using ajax/jquery:
// jQuery script
$(function() {
// Load data from proxy.php using GET request
$.get('test.xml', function(data)
{
// Search for the XML element you want, perform an action on each occurrence of found element
$(data).find("XMLElement").each(function()
{
$('#output').append($(this).attr('XMLAttribute')); // Display desired attribute of element -OR-
$('#output').append($(this).children("Phone").text());
I'm not even sure if Im asking the question correctly - what I would like to happen is: a php script to bring in that xml/url to echo/populate html on a page. I have tried a million things and just can't get it
That really looks like Javascript, not php. In php you wouldn't have the cross domain limitation anyway since it's running on the server, not the browser.
All browsers will block cross domain ajax calls.
Your solution is to write a script in php that does a wget or curl to the remote site, so you invoke a local script and the script on your server loads the remote url. You should be able to find some ready-made.

How do I "install" specific web files on a proxy server?

This is for a in house system, that is required to be set-up this way.
I need specific web files, for example, all images to be manually pre-installed on a proxy server and never downloaded from the web server.
When the browser request the page, the only thing sent from the web server to the proxy should be the plain html page.
I would then like the images the html page uses, to be grabbed from the the proxy every time, for the complete render to the browser.
Is there a name for this set up? I have seen about caching but I do not even want the images downladed once. In addition, how would the html page know to use the images from the proxy?
How would I set up such a thing? I do not have a proxy server set-up yet so I do not know what platform I will be using, but suggestions are appreciated.
Thank You.
Well, I think that you could, for example, use Privoxy and tell it to redirect some queries for images to a local server or even let it replace the img src=" attribute inline using regexes.

Partial updates to an SWF

WHat is the standard method for say a server to update an already loaded SWF on the client browser, i.e. something analogous to how an html page is partially updated via ajax (though I don't know a lot about ajax yet either.) Would the mechanism be the same if user-initiated.
I assume the .SWF should have public functions that can be invoked, then you'll use javascript to access the swf from the html page its in, then invoke a public function of that swf.
Just the specific terms or functions I need to search for to get a primer on this would be great.
ALso, How would one go about testing the public functions of an swf that is already loaded in a browser (wihtout having a full Adobe devleopment suite for example).
This is quite a vast subject actually. This is the whole RIA concept. Flash can look after itself in terms of communicating with a server , you don't necessarily need Javascript. You only need a server side language to communicate with.
Since it all can happen within the swf , public functions don't really come into it. A User initiates an action in the movie that triggers a call to a remoting service which in turn sends a response which consequently updates the movie.
A few areas you can look into, in no particular order:
Flash PHP communication
Zend Amf Server ( Zend Framework )
http://framework.zend.com/
For testing purposes , try MonsterDebugger
http://gotoandlearn.com/play.php?id=109
Edit:
Flash can use PHP to retrieve a XML , then parse the XML & change the data inside the SWF according to the data retrieved in the XML
http://gotoandlearn.com/play.php?id=90
In case of a link, the concept is a bit different, because depending on the type of link this may cause a page refresh. The approach in the above tutorial could be user initiated by clicking on a swf element, entering text in a text input box etc... this is what I meant by the RIA concept. It's quite standard now in Flash that user interaction will introduce changes in your SWF by making calls to the server.