nutballs

i just discovered that

php

  can do remote file includes...

aside from the obvious willies this gives me, I might want to use this for something.

the question is, how do I make it fail gracefully if the file is not found? ie, the interwebs decide to poop on the connection.
will it just timeout on its own, and I can then test for something to see if it got it?

also, what is the scope of that included code? Is it actually as if it is local to the scope you called it from? If so, i guess thats how I can test, check for a known variable that I would set.

thedarkness

http://

php

 

.net

 /include/

?

nutballs

yea I read it, but its confusing how they word it and the example they give. But i get it now.

include('http://www.somesite.com/remote.txt');

is valid. they make it seem like it isn't in the example, unless you read it a few more times.

thanks

DangerMouse

I was under the impression that many hosts disable remote file includes? So it may not be a practical solution.

DM

nutballs

oh ok. thanks for the heads up. i probably wont do it, and instead do a different method for code updating.

perkiset

If you're going where I think you are, then you might consider just

apache

 -ing a file from a primary location and then writing the file locally, then including it. You could check the LUPDATE or mtime on the remote file against yours, and if it's later than the local, get it and store before you include.

Have you read up on eval() as well?

nutballs

yea i read up on eval, and i cant stop reading it as evil...

But i decided to got the "push" route. My remote files will have a way to receive updates. a little better that way anyway i think, though the security is a bit, um... dicey.

perkiset

Well, if you're pushing then someone else *could* figger it out and push something else... a callback ping and pull would be cleaner IMO (ping the remote, it calls home for instructions and pulls new code) if the phone home is over https then it'll be REALLY hard for someone to get in the middle of all of that...


Perkiset's Place Home   Politics @ Perkiset's