Jump to content

How To Use Php Include() With External File


f1p2

Recommended Posts

Hi there,

 

Whilst attempting to make some of my code easier to read I decided to adopt a modular approach and use the include() function to include portions of code I might reuse in separate files.

 

When I use an include with a local file (ie:relative to the root directory) the code is included into the calling script as expected.When I try to include a file on another server by including the domain, path and filename in the include function all I get is a blank page.

I did read somewhere that in some instances it's necessary to add some configure information to the configure file when you want to include from files on another server. Does anyone know if this is needed on heliohost or whether external includes have been disabled ?

 

Thanks in advance for any help :)

Link to comment
Share on other sites

Thank you for the suggestion. Sorry I didn't reply earlier. I was waiting for Stevie to regain consciousness. Anyway.. I changed the permissions and still get a blank page. As I mentioned before.. it works if I include the file on the same server.

 

I also double checked the file path. I know it's correct because it works if I paste it directly into the address bar.

Finally I also tried using..

 

ini_set('allow_url_include','on');

 

Apparently this needs to be set in some instances and I'm not sure if this is where the problem lays.

I don't know much about ini files but I'm also wondering if heliohost have just disabled allow url include because when I Googled

for help I found another post with another host provider where this feature has been disabled.

 

Thanks in advance to all you kind people for any more suggestions.

Link to comment
Share on other sites

This is NEVER safe to include data from external source.

But if someone need to get the data from external source and use it, then there is another way. Get the data with using cURL or fsockopen() functions for example and then use it. If it's HTML then simply echo the code, if it's PHP code then do the eval() on it. Either way - especially if someone wants to eval() some PHP code - It's highly recommended to do some data verification before, for being sure that there is expected, valid and safe data on that external server.

Link to comment
Share on other sites

  • 4 weeks later...
  • 1 month later...
  • 2 weeks later...

Anush, I don't mean to ignore the original question, but why can't you simply move the file onto your own website? If its something that gets updated frequently, you could write a version-check type thing that can re-download the file from the source (ensuring authorized access at the same time) and then include it. Piotr is probably right, its very dangerous to be including files from another server.

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...