Jump to content

[SOLVED] Is this possible


SkyRanger

Recommended Posts

hey SkyRanger,

it is not possible to include a file from another domain.

one could always ask the question why you'd want to do that but, there's usually a reason ;)

 

what you could do is use fopen() for that file and then grab the contents of the file and do what every you may want to

do with it. see here: http://us2.php.net/fopen for a detailed explanation.

 

good luck!

The script I am currently designing is a WHM Hosting Script to manage accounts/billing.  When somebody installs the script on there server I want the script to look back at my server for a version file to read:

 

for example in there admin section it would say:

 

Your Version: 1.0 (Encoded write in script)

Current Version 1.1 (Read from file on my server)

 

www.php.net/file_get_contents

 

include will only work if the url_fopen is installed, which I would not want to take a chance of everyone having that on.

 

Curl is also another great option, but can be confusing for simple tasks.

 

<?php
$contents = file_get_contents('PATH TO FILE HERE');
?>

 

Should do what you want, but again it is not set in stone that anyone has to have anything installed, even CURL is the same way. So you may want to incorperate 3 or 4 different methods and do a check IE:

 

<?php
if (is_function('file_get_contents')) {
   $contents = file_get_contents('PATH TO FILE HERE');
}elseif (extension_loaded('curl')) {
   // do curl operations here
}elseif (ini_get('allow_url_fopen') == 1) {
   // do fopen reading here
}else {
   die('I cannot determine the version due to server configurations');
}
?>

 

This way you have 3 checks and if one works great if not than the user is SOL and no errors are thrown.

thanks for correcting me prozente,

yes. you can config apache to allow you to include the remote url. I try to assume that developers do not have full access to their apache files, I understand that some do get this luxury, but on the whole most, I would venture do not. So this option would not work, nor is it secure if he could enable everyone's machine for his function.

 

here's a good write up about changing that setting:

http://blog.php-security.org/archives/45-PHP-5.2.0-and-allow_url_include.html

 

enjoy

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.