You are here: set variables based on HTTP_HOST « PHP « IT news, forums, messages
set variables based on HTTP_HOST

Posted by Joe Szilagyi on 10/04/37 11:23

Is this potentially bad, security wise, to do something like this? Can
you guys recommend any way to tighten this up a bit or do this sort of
thing better/more eloquently?


<?

$Host1 = array ('name1.host.com');
if (in_array ($_SERVER['HTTP_HOST'], $Host1))
{
$HeaderImg = "/headers/name1_header.gif"; // define graphic
$SiteCSS = "/css/name1_css.css"; // define css
}
$Host2 = array ('name2.host.com');
if (in_array ($_SERVER['HTTP_HOST'], $Host1))
{
$HeaderImg = "/headers/name2_header.gif"; // define graphic
$SiteCSS = "/css/name2_css.css"; // define css
}
$Host3 = array ('name3.host.com');
if (in_array ($_SERVER['HTTP_HOST'], $Host1))
{
$HeaderImg = "/headers/name3_header.gif"; // define graphic
$SiteCSS = "/css/name3_css.css"; // define css
}
$Host4 = array ('name4.host.com');
if (in_array ($_SERVER['HTTP_HOST'], $Host1))
{
$HeaderImg = "/headers/name4_header.gif"; // define graphic
$SiteCSS = "/css/name4_css.css"; // define css
}
else
{
$HeaderImg = "/headers/main_header.gif"; // define graphic
$SiteCSS = "/css/main_css.css"; // define css
}

?>




<link rel="stylesheet" href="<? echo $SiteCSS ?>" type="text/css" />
<img src="<? echo $HeaderImg ?>">


The idea is to use this in the global header of a site that may be
invoked through up to 20-30 different third level subdomains, for the
same content. Standard stuff, one site, one set of tools to run it,
but each subdomain's slightly unique content pulls based on host.

thanks,
Joe

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация