SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question What's a safe way to code for external php includes ?

    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?

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,111
    Mentioned
    448 Post(s)
    Tagged
    8 Thread(s)
    As far as I know, internal includes are quite safe, and external ones are not available.
    Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form

    Forum Usage: Tips on posting code samples, images and more

    Forrest Gump: "IE is like a box of chocolates: you never know what you're gonna get."

  3. #3
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Ralph. Anyone know for definite?

  4. #4
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    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.

  5. #5
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    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.

  6. #6
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    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.

  7. #7
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    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.

  8. #8
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    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).

  9. #9
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by samanime View Post
    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).
    Thanks to all for the help and ideas on this it's really appreciated. So, retrieving contents from an external website, is possible, but the only way to do it, is by API's - is that about right please? Or are there other ways? Use case?

  10. #10
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    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.

  11. #11
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,111
    Mentioned
    448 Post(s)
    Tagged
    8 Thread(s)
    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.
    Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form

    Forum Usage: Tips on posting code samples, images and more

    Forrest Gump: "IE is like a box of chocolates: you never know what you're gonna get."


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •