Page 1 of 1

Include from another site

Posted: Mon Nov 22, 2004 6:12 am
by Calimero
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 !

Posted: Mon Nov 22, 2004 6:21 am
by dull1554
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

Posted: Mon Nov 22, 2004 6:24 am
by timvw
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

Posted: Mon Nov 22, 2004 6:25 am
by dull1554
wow i forgot about the phpsource file...... handy to have around

maybe you could have a script that everyonce in a while will automatically update the foo.phps file you want to include so that you have updated info

...

Posted: Mon Nov 22, 2004 12:17 pm
by Calimero
What's the difference between script.php and script.phps

Will this way work for my idea ?!?!

Posted: Mon Nov 22, 2004 12:56 pm
by rehfeld
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.

...

Posted: Tue Nov 23, 2004 3:48 pm
by Calimero
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?

Posted: Tue Nov 23, 2004 4:09 pm
by rehfeld
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.,