views:

29

answers:

3

Sorry for the long and yet still somehow vague title!

A friend of mine has a Flash Action script running on a LAMP server that currently reads an xml config file. He's asked me if it's possible to remove the xml file, and replace it somehow with a system (lets call it an 'auto xml generator') that intercepts the request to read that file and generates an output, so it appears to all intents and purposes as if the file still exists and contains the contents that has actually been returned from our auto xml generator

Hours of Googling has failed to come up with any promising leads, can anyone offer any advice?

Thanks very much!

Mike

+2  A: 

Sure. Your friend could instead point the download at a PHP script that generates an XML file automatically.

This link from IBM looks promising as a starting point if this is unfamiliar teritory.

spender
+1 (I'm assuming that the app runs in the browser and not as an Air app on the server) The Flash app doesn't care if the URL resolves to a file, a PHP script to execute, a Java Servlet, or even a good, old-fashioned CGI application.
dave
I chose PHP because it's the LAMP weapon of choice. Now where's that +1 gone? Has this got something to do with those pesky unicorns?
spender
+1 PHP is the simplest way to do this, just make sure it outputs a properly formatted XML file. Flash will essentially read it in as a string and try to parse it, so it doesn't matter that the file extension is actually .php - if it's valid XML, Flash's E4X will take care of it just fine.
Myk
A: 

This doesn't work... I tried it with a perl script and perl running mod_perl. The problem is that it isn't requesting the xml file as a URL through Apache, it is reading it as a local file and because of this it just reads the code not the output.

Adam
Is this an answer or a comment to the other answer? With some more answers, it won't be clear. Should be a comment. I won't add comments here.
spender
Sorry, my mistake. Have not used this forum before- my friend Mike posted me this link.
Adam
Well very much welcome. I hope you'll find it as useful as I have!
spender
A: 

This could be implemented via FUSE (Filesystem in Userspace) if the host supports it. When mounted, have it show a single .xml file which would (conceivably) return a unique view of data to every reader.

Its not 'intercepting' system calls, open() works as normal. Its the underlying file system that understands and provides the magic.

The link is to what's needed for a PHP implementation.

Tim Post
Thank you so much! All answers gratefully received, FUSE in particular is exceptionally handy (and apologies for the taking so long to update...)Stack Overflow is incredible!
Mike Atkinson