set variables based on HTTP_HOST
| From: | Joe Szilagyi | Date: | Mon, 08 Aug 2005 17:40:37 +0000 |
| Subject: | set variables based on HTTP_HOST | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-220237@lists.php.net to get a copy of this message | ||
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