Hi,
I have a problem, looked at the manual - but didn't get answers.
If the script that includes second script in on the site:
http://www.somedomain.com/first.php
and I want to include a php script located on another site:
http://www.otherdomain.com/second.php
and those sites are on different machines (not local area but internet connection)
Is this possible in PHP ???
I tried, but something didn't quite work.
Thanks Ahead !
Include from another site
Moderator: General Moderators
- dull1554
- Forum Regular
- Posts: 680
- Joined: Sat Nov 22, 2003 11:26 am
- Location: 42:21:35.359N, 76:02:20.688W
lets think about this, if you could include a file from another webserver on your page you would be able to see their source, passwords......
for security you are not allowed to do what your trying to do
maybe have them copy the source of the file, and put it in a txt file then you would be able to include it
for security you are not allowed to do what your trying to do
maybe have them copy the source of the file, and put it in a txt file then you would be able to include it
if you include http://example/script.php you are including the parsed output of that script
i think you want to include http://example/script.phps
i think you want to include http://example/script.phps
phps is just a common server config that people use
if there exists a file named script.phps on the server, then it will be output the script as plain text, w/out parsing/executing the script.
basically, it will show the source. its just handy.
to simplify things, so you dont need to add config options to your other server,
just save the file as script.txt
then run your
include('http://foo.com/script.txt');
but be warned, this is NOT a good idea. if the other server is unreachable, your website will hang. it will also be very slow.
and, doing remote includes is just generally a very bad idea security wise. and also, now anyone can goto http://foo.com/script.txt
and see your source code, and any passwords etc inside of it.
what is your reason for wanting to do this? there likely exists a much better solution to your problem.
if there exists a file named script.phps on the server, then it will be output the script as plain text, w/out parsing/executing the script.
basically, it will show the source. its just handy.
to simplify things, so you dont need to add config options to your other server,
just save the file as script.txt
then run your
include('http://foo.com/script.txt');
but be warned, this is NOT a good idea. if the other server is unreachable, your website will hang. it will also be very slow.
and, doing remote includes is just generally a very bad idea security wise. and also, now anyone can goto http://foo.com/script.txt
and see your source code, and any passwords etc inside of it.
what is your reason for wanting to do this? there likely exists a much better solution to your problem.
...
This file will contain IF, ELSE, ELSEIF structure - based on the page that includes it - it will output different URL's (that are later used for choosing the advertisement on the page).
So basicaly, I don't need much security (no such data will be in it), but I need it to function because I have several machines for my search engine site, and different types of searches are on different machines - and the scripts are makin localhost queries, and those scripts must call the advertisements.
The idea was to be fast for the user, and easy for me to administer (I didn't wan't to use the DB - for T.S. reasons
)
So... what do you suggest?
So basicaly, I don't need much security (no such data will be in it), but I need it to function because I have several machines for my search engine site, and different types of searches are on different machines - and the scripts are makin localhost queries, and those scripts must call the advertisements.
The idea was to be fast for the user, and easy for me to administer (I didn't wan't to use the DB - for T.S. reasons
So... what do you suggest?
you mean you want to use more than 1 server to do multiple queries at the same time to make it faster?
is your app really that intensive to where it needs to spread the load like this?
theres a lot of very large websites that do not need to spread the load in this mannor, maybe look into refining your sql queries.
sometimes you can make enourmous improvements.
no matter what though. even if you do need this, i dont think include() is the right answer.
theres other ways to do this. some may take more effort, but its your call.
take a look at fsockopen()
and file_get_contents()
using one of those you could retrieve a response from one of the servers, then parse it, and act upon the results. all without actually inclduing it.,
is your app really that intensive to where it needs to spread the load like this?
theres a lot of very large websites that do not need to spread the load in this mannor, maybe look into refining your sql queries.
sometimes you can make enourmous improvements.
no matter what though. even if you do need this, i dont think include() is the right answer.
theres other ways to do this. some may take more effort, but its your call.
take a look at fsockopen()
and file_get_contents()
using one of those you could retrieve a response from one of the servers, then parse it, and act upon the results. all without actually inclduing it.,