A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 34

Thread: Work around Load Variables from other Server/host

  1. #1
    Junior Member
    Join Date
    May 2001
    Posts
    4
    I know that it is impossible for flash to do a loadvariables from a textfile/cgi/asp or whatsoever which resides on a external server/host. Flash says confirms this. They give as a reason "security".
    They advice you to do one of the 3 things.
    1.get the external files to the same server as the swf's who call the variables. (possible but rather not since all different site make use of the same datbase files/routines)

    2. use localserverscript who do a proxy to the external files on a other server (Good idea, but does somebody know how to do a proxy in Perl)

    3. make a agreement with the server administrator to arrange something with the DNS, in order to make your .swf "feel at home" at the other servers location.(also good idea, but my relation with the webadminister is not so good, need my own server, than it wouldn't be a problem.)

    I was thinking of a 4th direction: would it be possible to fool Flash temporarly and let it think it is in another environment. With Perl I would be able to change the environment with the %ENV hash.

    MY QUESTION: Does anybody know where Flash gets its environmental variables from, based on which it decides that a loadvariables is done on another server? And how I can write the fake ones from Perl to Flash?

    Or if somebody knows another workaround, please let me know.

    I would like to use the same subroutines for all the different sites, since they are all practical the same and it gives me far less work updating the different sites.


  2. #2
    Senior Member
    Join Date
    Aug 2000
    Posts
    1,317
    with xml you can pass over servers and with asp/xml, you can even fool browsers that aren't xml friendly.

  3. #3
    What do you mean by "pass over servers" with XML? I just wrote a movie that uses XMLL newsfeeds, but to retrieve the feeds, I had to write a php proxy that would do the fetching for me.

    I can see if you mean ASP and XML would work, but that would mean that ASP is probably working as the proxy.... or are you talking about something else?

  4. #4
    Junior Member
    Join Date
    May 2001
    Posts
    4
    Hee mikebrittain, could you send me a copy of your PHP file to see if I could copy/translate it into Perl. Or at least give me a clue of how it is done. Maybe you could supply me with a link.

    Sorry, edeveloper XML in Flash does the same thing. Refer to the usermanual which comes with Perl (5). In the Actionscript reference or dictionary, it gives some clues.
    Since CGI didn't work I have to admit I didn't even try XML.

    Thanx!!

  5. #5
    Originally posted by sjako
    could you send me a copy of your PHP file to see if I could copy/translate it into Perl.
    Here's how I did it in PHP. I know a bit of perl as well, so if you get a start and can't get it going just let me know and I'll try to lend a hand. It shouldn't be much though....

    Code:
    <?php
    // Fetch XML files from Moreover.com's XML newsfeeds
    
    // Take the query string from the request for this script and 
    // append it to a new request that will retrieve an XML file
    // from moreover.com.
    $XMLurl = "http://www.moreover.com/cgi-local/page?" . $QUERY_STRING;
    
    // load the XML file into array ($file)
    $file = file ($XMLurl) or die ("Could not open XML file.");
    
    // join each line of the array into one scalar value
    $XMLContents = join ('', $file);
    
    // print the contents of the XML file 
    // (which returns it to the flash movie)
    echo $XMLContents;
    
    ?>

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

    doing the http proxy you suggested before is not a big deal. It does not solve all problems, though: you need cgi service on the host where your flash content resides, and you must be allowed to make outgoing connections. Since this might interfere with the server's firewall policy, it will depend on whether you can convince the server admin.
    Rather than real proxying, it might be possible to have the intermediate server send redirects. Does anyone know whether flash allows that?

    Musicman

  7. #7
    You're correct on the statements about CGI. I'm taking my server for granted. I don't have to worry about admin policies.

    As for the redirects, you are suggesting that the server be configured to redirect the request for a CGI or other file off to another server? Sounds like a good idea -- I wonder if it's possible.

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

    give it a try:

    #!/usr/bin/perl

    print "Location: http://www.real.server/realscript.cg...NG&#39;}\n\n";

    should work for GET and pass entire request. Tell me whether flash permits that.

    Musicman

  9. #9
    Junior Member
    Join Date
    May 2001
    Posts
    4
    I do have full cgi-access on both sites, two virtual servers on 2 different machines. I am also able to redirect, That I'll try first. If that works it would be the key to everything.

    Changing the environmental variable with Perl doesn't work, because it applies to child proceses. Since Flash isn't a child of that CGI-script, It wouldn't work with the new environment. If I'll manage to execute a script, which writes back a swf file directly, after changing the environment, (let's say to use in a loadmovie command) then it will be able to fool Flash...I guess.

    Does anyone know more about this kind of matters. Maybe I am completely wrong!

  10. #10
    Junior Member
    Join Date
    May 2001
    Posts
    4
    By the Way! Iam completely forgeting to tell you a odd thing. When I put the complete site, execpt for the cgi-scripts on my local PC, it makes a perfect call to the outside scripts. Also from the browser....So, it is possible!

    Thanx Musicman and mikebrittain, Let you know when I manage.

  11. #11
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835
    hmmm. this is all really interesting.

    but this thing always work on local machines, just not when you access the swf through http protocol - we ran into the same problems here - caused all sorts of headaches because no one could work out what the problem was

    this php script looks very simple - but aren't there any security restrictions that will prevent the php script simply reading in files from another server?

    will follow this one with interest

    good luck - n.

  12. #12
    Originally posted by enemem
    but aren't there any security restrictions that will prevent the php script simply reading in files from another server?
    The only restriction I can think of would be if you were to configure PHP not to be allowed to open remote files (on different servers). I think you can fix that in the PHP.ini file on your installation.


  13. #13
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835
    cool.
    have been trying to get our 'PHP guy' (or one of them) to try this out but no luck so far

    thanks for the answer...

    see ya - n.

  14. #14
    enemem -- is your server restricting you from loading outside files?

  15. #15
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835
    hey mike,

    nope - no problems there. I don't know how to code in PHP [I'm just the designer round here], so I had to get someone else to try it. Worked fine - no problems what so ever.

    thanks for your interest + help offers!

    cheers - n.

  16. #16
    Senior Member
    Join Date
    Aug 2000
    Posts
    1,317
    mikebrittain:
    in flash:
    objXml = new Xml;
    objXml.onLoad = writePage;

    objXml.load("http://p.moreover.com/cgi-local/page?c=Developer%20news&o=xml")

    function writePage(){

    strXML = new Xml;

    strXML = objXml.firstChild.nextSibling;
    trace(strXML);

    }

    this is very basic. just to show that you can import xml from a external source. you can add some "for" loops and get all the info without ever putting this file in a html page without any other code. now maybe i'm misunderstanding you but isn't this what the problem is?

  17. #17
    Originally posted by edeveloper
    objXml = new Xml;
    objXml.load("http://p.moreover.com/cgi-local/page?c=Developer%20news&o=xml")
    Looks like what I was trying to do, but when I tried it, I got nothing back from the server. The action script manual says that you shouldn't be able to load XML files from outside your own server/subdomain. There is similar reference to loadVariables, XMLsocket, and getURL but I don't understand when this is possible and when it is not.

    Perhaps it wouldn't let me load from another subdomain if I was testing the file on my own computer and not from a server?


  18. #18
    Senior Member
    Join Date
    Aug 2000
    Posts
    1,317
    Hey Mike,
    make a text area (type="dynamic",name="screen").
    put this in the (only) frame:
    Code:
    screen = "loading newsfeed"
    
    objXml = new Xml;
    objXml.onLoad = writePage;
    objXml.load("http://p.moreover.com/cgi-local/page?c=Developer%20news&o=xml")
    
    function writePage(){
    
    mainTag = new Xml;
    
    content = new Array;
    ChildTag = new Array;
    ParentTag = objXml.firstChild.nextSibling
    content = ParentTag.childNodes
    
    	for (i=1;i<=content.length;i++){  // you can also use a Integer like 6 or 10
    									  // instead of content.length which will return
    									  // all the records
    		 
    		ChildTag = content[i];
    		
    		urlValue = ChildTag.firstChild.nextSibling
    		headlineValue = ChildTag.firstChild.nextSibling.nextSibling.nextSibling
    		
    		if(urlValue.nodeName == "url"){
    			url = urlValue.childNodes
    		} 
    
    		if(headlineValue.nodeName == "headline_text"){
    			headline = headlineValue.childNodes
    			
    		}
    		
    		i = i + 1
    		
     		newsItem +=  "<a href=" add chr(34) add url add chr(34) add ">" add headline add "</a><br>"
    		
    		screen = newsItem
    	}
    		
    }
    works for me at home on my pc and at work on a network.
    also, running xml 3.0
    good luck.
    [Edited by edeveloper on 05-09-2001 at 12:25 AM]

  19. #19
    Brandon -- I don't doubt what you've said about it working. I do want to try it out, but I have another project I have to spend some time on tonight. I'll let you know what I find out when I get a chance.

    Speaking of XML, though, I was wondering if you saw my posting from last week about extending the built-in XML object. Do you know anything about it, or have you done any work in that direction that you could share?

    This is the project that I was doing with the moreover stuff, if you didn't see it. I think I posted it on one of the boards. I wrote a getElementListByName method for XML(node), and I was hoping that some other people had made some similar DOM-type methods available but didn't manage to come up with much.... you sound like you're on the XML kick, so I thought I might ask you.

    http://www.embimedia.com/mike/school/3502/moreover_xml/

    If you have a chance to look at the FLA file, maybe you could let me know your opinion.

    Like I said, I'll get back about the external network connections from Flash when I get a chance.

    One last question -- what were you referring to when you mentioned you were "running xml 3.0"?

    Thanks.

  20. #20
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835
    don't want to start a fight or anything but this is a bit weird.

    edeveloper, when you say 'works at home and at work on a network', are you requesting the actual swf using http? Stick it on a server somewhere and see whether it still works - because I don't think it will.

    not trying to be clever or anything, just to clear whether this does work or not.

    see ya - n.

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