Jump to content


How To Use Php Include() With External File


13 replies to this topic

#1 f1p2

    Newbie

  • Members
  • 7 posts

Posted 01 February 2012 - 10:28 AM

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 :)

#2 anush

    Rank IV Member

  • Members
  • PipPipPipPip
  • 279 posts
  • Gender:Male
  • Location:ASIA
  • Interests:I am intrested in computer programming, web designing ,electronics, gaming, networking.

Posted 01 February 2012 - 11:13 AM

You can change the permission of the file to 777.
so it give execute right to user .

i have not tried this before,
please tell if this worked
find more about web designing and programming in c++ , php. and tips and tricks for linux and mac at Techstream.org
Find techstream on » facebook ¸ @twitter¸Google plus


find more about salt analysis (chemistry) at saltanalysis.tk
Find salt analysis on » facebook

#3 f1p2

    Newbie

  • Members
  • 7 posts

Posted 02 February 2012 - 08:49 AM

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.

#4 anush

    Rank IV Member

  • Members
  • PipPipPipPip
  • 279 posts
  • Gender:Male
  • Location:ASIA
  • Interests:I am intrested in computer programming, web designing ,electronics, gaming, networking.

Posted 03 February 2012 - 03:43 PM

that is Ok ,if it does not works then i think you must wait for heliohost admin to answer this,because i don't know whether it is disabled on the server.
find more about web designing and programming in c++ , php. and tips and tricks for linux and mac at Techstream.org
Find techstream on » facebook ¸ @twitter¸Google plus


find more about salt analysis (chemistry) at saltanalysis.tk
Find salt analysis on » facebook

#5 Ice IT Support

    Rank IV Member

  • Members
  • PipPipPipPip
  • 258 posts
  • Gender:Not Telling

Posted 03 February 2012 - 10:26 PM

HelioHost does not allow the including of external scripts (from other servers) for security reasons.
username: iceitsup
domain: iceitsupport.net
server: Stevie

#6 f1p2

    Newbie

  • Members
  • 7 posts

Posted 04 February 2012 - 11:39 AM

Thank you for the info.

#7 byron

    Rank X Member

  • Support Admin
  • 3,939 posts
  • Gender:Male
  • Location:USA

Posted 04 February 2012 - 12:48 PM

You could use an iframe. Not quite the same as include, but maybe what you need.



#8 anush

    Rank IV Member

  • Members
  • PipPipPipPip
  • 279 posts
  • Gender:Male
  • Location:ASIA
  • Interests:I am intrested in computer programming, web designing ,electronics, gaming, networking.

Posted 04 February 2012 - 02:54 PM

Can we use include for a file on a sub domain in a web site hosted on same server of heliohost

i mean can i use

<?php
include('http://head.websitename.org/page.php');
?>

the web site is in Stevie
find more about web designing and programming in c++ , php. and tips and tricks for linux and mac at Techstream.org
Find techstream on » facebook ¸ @twitter¸Google plus


find more about salt analysis (chemistry) at saltanalysis.tk
Find salt analysis on » facebook

#9 byron

    Rank X Member

  • Support Admin
  • 3,939 posts
  • Gender:Male
  • Location:USA

Posted 04 February 2012 - 03:04 PM

It would need to be something like this:

<?php 
include("/home/username/public_html/folder/page.php");
?>


#10 Piotr GRD

    Rank III Member

  • Contributors
  • 157 posts
  • Location:Stettin, Poland (Szczecin, Polska)

Posted 04 February 2012 - 03:31 PM

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.

#11 anush

    Rank IV Member

  • Members
  • PipPipPipPip
  • 279 posts
  • Gender:Male
  • Location:ASIA
  • Interests:I am intrested in computer programming, web designing ,electronics, gaming, networking.

Posted 07 February 2012 - 09:19 AM

Piotr GRD thank you
find more about web designing and programming in c++ , php. and tips and tricks for linux and mac at Techstream.org
Find techstream on » facebook ¸ @twitter¸Google plus


find more about salt analysis (chemistry) at saltanalysis.tk
Find salt analysis on » facebook

#12 alemaopb

    Rank I Member

  • Members
  • Pip
  • 30 posts

Posted 07 March 2012 - 04:52 AM

thank you !

#13 kgb

    Newbie

  • Members
  • 1 posts

Posted 11 April 2012 - 10:37 AM

Piotr GRD... good advice!
- gabriella

#14 mindstorm8191

    Rank I Member

  • Members
  • Pip
  • 12 posts

Posted 19 April 2012 - 12:15 PM

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users