I not that good with php but I know a little bit. There maybe another way of doing this so I'm open for suggestions. Basically what I'm trying to achieve is a universal footer to be displayed across several sites on different servers.. So in the footer of each site; include 'http://home_server.com/copyright/copyright.php'; PHP: In copyright.php is a straight forward copyright statement. Also there is another include for web stats; define('SITE_ID', $stats_id); include_once('http://home_server.com/Web-Stats/webstats.php'); PHP: Now, $stats_id is the id of the site, used for logging. if ($_SERVER['HTTP_HOST'] == 'www.SITE_1.com' or $_SERVER['HTTP_HOST'] == 'SITE_1.com') { $stats_id = 1; }; if ($_SERVER['HTTP_HOST'] == 'www.SITE_2.com' or $_SERVER['HTTP_HOST'] == 'SITE_2.com') { $stats_id = 2; }; PHP: Ok, so when I go to SITE_1.com, $stats_id should be 1 and when I go to SITE_2.com $stats_id should be 2. Wrong. So what I did was put this in copyright.php; echo $_SERVER['HTTP_HOST']; PHP: When I call SITE_1.com or SITE_2.com it displays home_server.com. So tried something else. I put this above the include copyright.php code; $URL = $_SERVER['HTTP_HOST']; PHP: Then echo'd $URL in copyright.php and called SITE_1.com...nothing Right, so next I tried putting this at the top of copyright.php and called SITE_1.com again; $URL = $_SERVER['HTTP_HOST']; echo $URL; PHP: This output; home_server.com. How could I fix this? Thanks.
It is possible that you are visiting http://site1.com and not http://www.site1.com The variable $_SERVER['HTTP_HOST'] will include the www. if it is used, and it won't if it's not used. You could try this: $host = ( substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.' ) ? substr(strstr($_SERVER['HTTP_HOST'], '.'), 1) : $_SERVER['HTTP_HOST']; PHP: and then compare it to your websites site1.com and site2.com
Yeah I did try that. I think I have found a solution; footer.php $var = $_SERVER['HTTP_HOST']; include("http://home_server.com/copyright/copyright.php?var=".$var); PHP: And then simply echo $var in copyright.php Still need to test it fully. But thanks for you help! 2 whole days I have spent fiddling with this code. I had tried sessions, cookies, post, in about a billion different combos. Then I look at this code and think...wow!