Is there a safe way to do php includes from internal and external websites please? A way where the webhosts wouldn't need to worry?
| SitePoint Sponsor |





Is there a safe way to do php includes from internal and external websites please? A way where the webhosts wouldn't need to worry?


As far as I know, internal includes are quite safe, and external ones are not available.





Thanks Ralph. Anyone know for definite?
include supports remote paths, but I'd be more comfortable if this was some sort of API. Do you have a use-case ?
@AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.
Mmmh.. include allows remote paths, but it should be pointed out this will NOT return PHP-execute script... it will just return the HTML result of the remote script. If it did, every PHP site in the world would be easily hackable.
Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.





As StarLion said, it's possible, but not how you may expect.
A use-case would definitely be helpful. There is very little reason not to use an API nowadays. They are incredibly easy to build (for simple things) and rather reliable.
Xazure.Net - My Blog - About Programming and Web Development
Follow Me on Twitter!
Christian Snodgrass
Meanwhile I'm not even sure I follow the question -- I'm assuming by 'external' you mean 'remote' and by 'internal' you mean 'local'?
NOT that 'remote' (as in off server) includes should even be ALLOWED.





I can see remote includes being allowed, but in the context of an intranet (though even then, I still prefer free-standing APIs to a complex mix of PHP files leaving on several servers).
Xazure.Net - My Blog - About Programming and Web Development
Follow Me on Twitter!
Christian Snodgrass










The -only- way... no.
The way 99% of developers who know what they are talking about would recommend: yes.
Basically an API is meant for exactly that: joining two independent systems.
For example, I have a site which uses the logins from a different system. In order to authenticate, we have a web service (an API) which I call to ask that server for the information I want in order to know if I should let the user log in or not. Afterwards, I can ask it other things like information about that user.
Xazure.Net - My Blog - About Programming and Web Development
Follow Me on Twitter!
Christian Snodgrass


As others have said, a use-case would be good (that is, a description of what you are trying to do here). I recently found out how easy it is to pull in data from an remote RSS feed (from another site) onto a page with PHP.
Bookmarks