Forum Moderators: coopster

Message Too Old, No Replies

include file for several domain on the same server

include file for several domains

         

samuel_ado

11:08 am on Sep 19, 2003 (gmt 0)

10+ Year Member



hi,

i have several domains on the same server and i want to use include file..
for example ;

abc.php at [abc.com...] and i want to use abc.php file at other domains.. can i? and how?

thanks in advance

coopster

11:51 am on Sep 19, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Yes, possibly. If "URL fopen wrappers" are enabled in PHP (which they are in the default configuration), you can specify the file to be included using an URL via HTTP:

include 'http://www.abc.com/abc.php';

However, Windows versions of PHP prior to PHP 4.3.0 do not support accessing remote files via this function, even if allow_url_fopen is enabled.

jatar_k

4:01 pm on Sep 19, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you can include by absolute path

include "/home/mysite/www/abc.php";

coopster

4:17 pm on Sep 19, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



True. I assumed this was on a shared (hosting) server. In this case, wouldn't there be authorization issues? I've never tried it.

jatar_k

4:24 pm on Sep 19, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



There may be but it is always worth testing out. It also depends if they are all in the same section of the tree. Sometimes multiple sites are all accessible through one master dir and then you can throw the file in the root of that and share it across all of the sites in there.

coopster

4:26 pm on Sep 19, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



It's an interesting thought. I know a place where I can test this. I'll give it a whirl tonight/this weekend and post findings in this thread.

BergtheRed

6:42 pm on Sep 20, 2003 (gmt 0)

10+ Year Member



coopster: True. I assumed this was on a shared (hosting) server. In this case, wouldn't there be authorization issues? I've never tried it.

it should work. on most virtual acounts you "own" everything from your user root on down. and in PHP you can access files through the directory tree itself. in this case you could use something like:

include( $_SERVER["DOCUMENT_ROOT"] . "/script_location/script_name.php" );

and you shouldn't have many problems. i use "about the same" construct for pulling ad material from a central domain.

samuel_ado

9:23 pm on Sep 29, 2003 (gmt 0)

10+ Year Member



hi again,

<?
include ("/home/mysite/public_html/abc.php");
?>

it is working and thanks for your help...

i am wondering ;
can we get out any table or link or some words from include file for example ;

"/home/mysite/public_html/abc.php";

i want to get out a link from abc.php
is it possible? & how?

thank you guyss

coopster

9:37 pm on Sep 29, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



i want to get out a link from abc.php
What do you mean by this?

jatar_k

9:43 pm on Sep 29, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Do you mean opening the page and parsing through it for a particular link?

samuel_ado

9:43 pm on Sep 29, 2003 (gmt 0)

10+ Year Member



abc.php has 30 links and i want to leave 2 of them when i call it by include file
for example..

abc.php is a link page at mymainsite and i want to use it on my other site (my2site) with include file
/home/mymaindomain/public_html/abc.php = [my2site.com...]

and i don't want 2 links from abc.php and need rest ogf tme (28 links) to be places at [my2site.com...]

hope it is okey with my poos english

jatar_k

9:48 pm on Sep 29, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You could have a conditional in the file to be included.

<?
if ($_SERVER['HTTP_HOST'] == "www.abc.com") {
?>
<a href="http://www.whatever.com">link 1</a>
<a href="http://www.whatever.com">link 2</a>
<?
}
?>

samuel_ado

10:01 pm on Sep 29, 2003 (gmt 0)

10+ Year Member



hi jatar_k and thanks..

it is www.samuelaaaaa.com/link/europe.php

europe.php is as follow ;
---0000---
<?
include "inc/up.html";
include "/home/samuel/public_html/data_linksold/europe.html";
include "inc/down.html";
?>
---0000---

and i want to get out a link from europe.html <a href="http://www.123.com">www.123</a> - your choice on the web.<br>

should i do ;

<?
include "inc/up.html";
include "/home/samuel/public_html/data_linksold/europe.html";
include "inc/down.html";
?>
<?
if ($_SERVER['HTTP_HOST'] == "www.samuel.com") {
?>
<a href="http://www.123.com">www.123</a> - your choice on the web.<br>
<?
}
?>

"www.samuel.com" should be domain has europe.html? or?

thanks in advance

[edited by: jatar_k at 11:15 pm (utc) on Sep. 29, 2003]
[edit reason] delinked url [/edit]

coopster

10:39 pm on Sep 29, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I think what you want, and what jatar_k is saying, is to change /home/samuel/public_html/data_linksold/europe.html to a PHP page and include your conditional statement in there.

jatar_k

11:18 pm on Sep 29, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



exactly as coopster said

the absolute easiest way I can think of is to put it right in the file you are including

include "/home/samuel/public_html/data_linksold/europe.html";

maybe rename this file as
europe-content.php

and then have the if statement inside of it.

samuel_ado

4:49 am on Oct 1, 2003 (gmt 0)

10+ Year Member



hi guys...

:o( it is not working....

jatar_k

4:51 am on Oct 1, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you have 30 links in the included file

around the two you dont want did you put the if statement

code?

samuel_ado

5:37 am on Oct 1, 2003 (gmt 0)

10+ Year Member



<?
include "inc/up.html";
include "/home/samuel/public_html/data_linksold/europe.html";
include "inc/down.html";
?>
<?
if ($_SERVER['HTTP_HOST'] == "www.samuel.com") {
?>
<a href="http://www.123.com">www.123</a> - your choice on the web.<br>
<?
}
?>

coopster

12:38 pm on Oct 1, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



  1. Make a copy of /home/samuel/public_html/data_linksold/europe.html
  2. Rename it to europe-content.php
  3. Edit europe-content.php by adding the conditional statement mentioned by jatar_k earlier. Make sure it is surrounding the links you want included.
  4. Save your work
  5. Update your calling program to include the new link:
    <?
    include "inc/up.html";
    include "/home/samuel/public_html/data_linksold/europe-content.php";
    include "inc/down.html";
    ?>

That should do it.