Hi,
Can anyone tell me if it's possible to include a php file (a load of functions) from another domain? e.g:
include_me.php is on domain1.com
index.php on domain2.com:
<?php include ("http://domain1.com/include_me.php");
?>
I have tried this code but all I get is a failed to open stream error.
Thanks in advance,
Chrisno, because all you would get anyways is what is outputted by the php, not the php itself. it would be an incredibly huge security flaw if you could.if they are on the same server with the same permissions. if so just use the machine path.
include("/home/foo.com/htdocs/something.php");
being called from bar.com
just make sure it's being called after any sessions.
never tried it, but if the other server is in your hosts file, you might be able to include it. Probably not though.
that's an interesting test!You can do this...
<?php
@include("http://www.domain.com/file.php");
?>that just suppresses any error, it still wouldnt work. he said it had php functions in it. when you access it through http, that means it only includes what is echoed by the actual script. if the php file is just functions, he would get nothing since nothing is echoed.I think you'll find it does...
<!-- m --><a class="postlink" href="http://uk.php.net/manual/en/function.include.php">http://uk.php.net/manual/en/function.include.php</a><!-- m -->
PHP Manual - Include Function
<?php
/* This example assumes that <!-- w --><a class="postlink" href="http://www.example.com">www.example.com</a><!-- w --> is configured to parse .php
* files and not .txt files. Also, 'Works' here means that the variables
* $foo and $bar are available within the included file. */
// Won't work; file.txt wasn't handled by <!-- w --><a class="postlink" href="http://www.example.com">www.example.com</a><!-- w --> as PHP
include 'http://www.example.com/file.txt?foo=1&bar=2';
// Won't work; looks for a file named 'file.php?foo=1&bar=2' on the
// local filesystem.
include 'file.php?foo=1&bar=2';
// Works.
include 'http://www.example.com/file.php?foo=1&bar=2';
$foo = 1;
$bar = 2;
include 'file.txt'; // Works.
include 'file.php'; // Works.
?>unless the php script you are including outputs the functions, it will just get what is echoed. i never said you couldnt include files. sure you can include txt files and stuff, but you cannot include php source that is within <?php ?> tags in a .php file (which is what this person is wanting). you can say you can all you want, its not going to happen. it would be a huge security hole since i could just go around including people's source codes and getting all sorts of passwords and stuff.Thanks for the info. It seems I'll have to forget including files from a central server, as it's functions that I need to include.
Regards,
Chris
Can anyone tell me if it's possible to include a php file (a load of functions) from another domain? e.g:
include_me.php is on domain1.com
index.php on domain2.com:
<?php include ("http://domain1.com/include_me.php");
?>
I have tried this code but all I get is a failed to open stream error.
Thanks in advance,
Chrisno, because all you would get anyways is what is outputted by the php, not the php itself. it would be an incredibly huge security flaw if you could.if they are on the same server with the same permissions. if so just use the machine path.
include("/home/foo.com/htdocs/something.php");
being called from bar.com
just make sure it's being called after any sessions.
never tried it, but if the other server is in your hosts file, you might be able to include it. Probably not though.
that's an interesting test!You can do this...
<?php
@include("http://www.domain.com/file.php");
?>that just suppresses any error, it still wouldnt work. he said it had php functions in it. when you access it through http, that means it only includes what is echoed by the actual script. if the php file is just functions, he would get nothing since nothing is echoed.I think you'll find it does...
<!-- m --><a class="postlink" href="http://uk.php.net/manual/en/function.include.php">http://uk.php.net/manual/en/function.include.php</a><!-- m -->
PHP Manual - Include Function
<?php
/* This example assumes that <!-- w --><a class="postlink" href="http://www.example.com">www.example.com</a><!-- w --> is configured to parse .php
* files and not .txt files. Also, 'Works' here means that the variables
* $foo and $bar are available within the included file. */
// Won't work; file.txt wasn't handled by <!-- w --><a class="postlink" href="http://www.example.com">www.example.com</a><!-- w --> as PHP
include 'http://www.example.com/file.txt?foo=1&bar=2';
// Won't work; looks for a file named 'file.php?foo=1&bar=2' on the
// local filesystem.
include 'file.php?foo=1&bar=2';
// Works.
include 'http://www.example.com/file.php?foo=1&bar=2';
$foo = 1;
$bar = 2;
include 'file.txt'; // Works.
include 'file.php'; // Works.
?>unless the php script you are including outputs the functions, it will just get what is echoed. i never said you couldnt include files. sure you can include txt files and stuff, but you cannot include php source that is within <?php ?> tags in a .php file (which is what this person is wanting). you can say you can all you want, its not going to happen. it would be a huge security hole since i could just go around including people's source codes and getting all sorts of passwords and stuff.Thanks for the info. It seems I'll have to forget including files from a central server, as it's functions that I need to include.
Regards,
Chris