A great way to grab a surfer's attention is to mention the exchange they're surfing. Until now, there hasn't really been an easy way for "Average Joe" to do this, so I went ahead and made some code that makes it easy for you.


The code below will determine the exchange a user is surfing, and output the name of the exchange, as well as the logo's color. About 25 of the top exchanges are listed, returning the proper name (ie. thumbvu returns ThumbVu) and color. If they're just viewing the page not in an exchange, it will return nothing (so you would get something like "HEY SURFER").

What you'll need to do first, is when you create your splash page, instead of having the name be something like splash.html, name it splash.php.

Where you want to put the exchanges name, put:
[php]
<?php echo get_exchange(); ?>
[/php]
If you want the name to be all caps, put:
[php]
<?php echo strtoupper(get_exchange()); ?>
[/php]

Here's the function (put this at the end of your .php file). All of the exchanges are on my end, so I can update for new exchanges, and it will automatically add them for you (speaking of which, if you'd like your exchange added, post a comment below).

[php]
<?php
function get_exchange()
{
//Parse the referrer url
$url = parse_url($_SERVER['HTTP_REFERER']);
//Grab the host
$host = $url['host'];
//Grab the domain from that
$domain = explode(".", $host);
$domain = $domain[count($domain)-2];
//Grab the stuff to return
$contents = file_get_contents("http://www.austinhallock.com/exchanges.php?domain=$domain");
return $contents;
}
?>
[/php]

If you want it all on your end so you can customize it a bit more, use the following function instead:
[php collapse="true"]
<?php
function get_exchange()
{
//Parse the referrer url
$url = parse_url($_SERVER['HTTP_REFERER']);
//Grab the host
$host = $url['host'];
//Grab the domain from that
$domain = explode(".", $host);
$domain = $domain[count($domain)-2];
/* Show specific names for hosts
* (doing this for proper capitalization and coloring)
* To add custom ones, if the domain name is www.thumbvu.com
* Do:
* $exchanges['thumbvu']['name'] = "ThumbVu";
* $exchanges['thumbvu']['color'] = "#F7931E";
*/
$exchanges['thumbvu']['name'] = "ThumbVu";
$exchanges['thumbvu']['color'] = "#F7931E";

$exchanges['easyhits4u']['name'] = "EasyHits4U";
$exchanges['easyhits4u']['color'] = "#EB8B00";

$exchanges['startxchange']['name'] = "StartXchange";
$exchanges['startxchange']['color'] = "#FF0000";

$exchanges['traffic-splash']['name'] = "Traffic Splash";
$exchanges['traffic-splash']['color'] = "#52D652";

$exchanges['hit2hit']['name'] = "Hit2Hit";
$exchanges['hit2hit']['color'] = "#FB874C";

$exchanges['hitsboosterpro']['name'] = "HBPro";
$exchanges['hitsboosterpro']['color'] = "#171442";

$exchanges['hitsafari']['name'] = "HitSafari";
$exchanges['hitsafari']['color'] = "#E96827";

$exchanges['tezaktrafficpower']['name'] = "TTP";
$exchanges['tezaktrafficpower']['color'] = "#CB0000";

$exchanges['ilovehits']['name'] = "ILoveHits";
$exchanges['ilovehits']['color'] = "#1668A4";

$exchanges['trafficwitch']['name'] = "Traffic Witch";
$exchanges['trafficwitch']['color'] = "#D87204";

$exchanges['traffictaxis']['name'] = "Traffic Taxis";
$exchanges['traffictaxis']['color'] = "#040404";

$exchanges['soaring4traffic']['name'] = "Soaring4Traffic";
$exchanges['soaring4traffic']['color'] = "#096FB1";

$exchanges['trafficera']['name'] = "Traffic Era";
$exchanges['trafficera']['color'] = "#84ADD9";

$exchanges['high-hits']['name'] = "High Hits";
$exchanges['high-hits']['color'] = "#FC9C21";

$exchanges['blue-surf']['name'] = "Blue-Surf";
$exchanges['blue-surf']['color'] = "#005A9D";

$exchanges['majorleaguehits']['name'] = "MLH";
$exchanges['majorleaguehits']['color'] = "#013B63";

$exchanges['rainbow-traffic']['name'] = "RainbowTraffic";
$exchanges['rainbow-traffic']['color'] = "#0092DF";

$exchanges['dragonsurf']['name'] = "DragonSurf";
$exchanges['dragonsurf']['color'] = "#1F4C23";

$exchanges['trafficgoldrush']['name'] = "Traffic Gold Rush";
$exchanges['trafficgoldrush']['color'] = "#B18B2A";

$exchanges['realhitz4u']['name'] = "RealHitz4u";
$exchanges['realhitz4u']['color'] = "#F69800";

$exchanges['fasteasytraffic']['name'] = "FastEasyTraffic";
$exchanges['fasteasytraffic']['color'] = "#F95307";

$exchanges['swattraffic']['name'] = "S.W.A.T.";
$exchanges['swattraffic']['color'] = "#00319C";

if(!isset($exchanges[$domain]))
{
$exchanges[$domain]['name'] = $domain;
$exchanges[$domain]['color'] = "inherit";
}

return "<span style='color:{$exchanges[$domain]['color']};'>{$exchanges[$domain]['name']}</span>";
}
?>
[/php]

Below is the full code for this combined with yesterday's post on creating a sexy splash page. You can see it in action here (though it won't say the exchange name since you aren't surfing).

[php htmlscript="true" collapse="true"]
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml' >
<head>
<!-- TITLE OF YOUR PAGE -->
<title>
YOUR PAGE TITLE
</title>
<!-- END TITLE -->
<style type='text/css'>
body
{
/* The color you want the page background to be */
background-color: #111111;
font-family: 'Helvetica Neue', Helvetica, arial;
font-weight: bold;
padding: 0px;
margin:0px;
}
#main
{
/* The color you want the box border to be */
border: 4px solid #FFFFFF;
/* The color you want the box background to be */
background-color:#16DE1A;
/* The color you want the box font to be */
color: #111111;
font-size: 28px;
-moz-border-radius: 10px;
-o-border-radius: 10px;
-webkit-border-radius: 10px;
-khtml-border-radius: 10px;
border-radius: 10px;
width: 700px;
margin: 15px auto 0px auto;
padding: 10px 20px;
text-align: center;
}
.sub_text
{
font-size: 14px;
font-weight: normal;
width: 450px;
margin: 10px auto 0px auto;
}
h2
{
font-size: 50px;
/* The color you want the page heading font to be */
color: #FFFFFF;
text-shadow:0 2px 0 #111111;
margin: 5px;
text-align: center;
}
input
{
/* The color you want your input boxes to be */
background-color: #FFFFFF;
padding: 5px;
/* The color you want the border of your input boxes to be */
border: 2px solid #111111;
font-weight: bold;
-moz-border-radius: 4px;
-o-border-radius: 4px;
-webkit-border-radius: 4px;
-khtml-border-radius: 4px;
}
input:hover
{
/* The color you want your input boxes to be when hovered */
background-color: #C9F5C9;
}
input:focus
{
/* The color you want your input boxes to be when clicked */
background-color: #93DB94;
}
input[type=submit]
{
cursor: pointer;
}
a
{
/* The color you want your links to be */
color: #111111;
}
</style>
<meta http-equiv='Content-Type' content='text/html;charset=utf-8' />
</head>
<body>
<div id='main'>
<h2>
<!-- PAGE HEADER -->
HEY <?php echo strtoupper(get_exchange()); ?> SURFER
<!-- END PAGE HEADER -->
</h2>
<!-- MAIN CONTENT -->
YOUR PAGE CONTENT HERE
<!-- END MAIN CONTENT -->
<div class='sub_text'>
<div style='float:left; width:50%;'>
<!-- FORM DESCRIPTION -->
You can put a subscription form here.
For this example, I'm using my blog's subscription form, feel free to subscribe!
<!-- END FORM DESCRIPTION -->
</div>
<div style='float:right; margin-left: 2%; width:48%;'>
<!-- FORM -->
<form action='http://austinhallock.com/about/subscribe/' method='post'>
<p style='margin-top: 5px;'><input type='text' name='nn' value='Your name' onclick="if (this.defaultValue==this.value) this.value=''" onblur="if (this.value=='') this.value=this.defaultValue"/></p>
<p><input type='text' name='ne' value='Your email' onclick="if (this.defaultValue==this.value) this.value=''" onblur="if (this.value=='') this.value=this.defaultValue"/></p>
<p><input type='submit' value='Subscribe'/></p>
<input type='hidden' name='na' value='s'/>
</form>
<!-- END FORM -->
</div>
<br clear='all'/>
</div>
</div>
</body>
</html>
<?php
function get_exchange()
{
//Parse the referrer url
$url = parse_url($_SERVER['HTTP_REFERER']);
//Grab the host
$host = $url['host'];
//Grab the domain from that
$domain = explode(".", $host);
$domain = $domain[count($domain)-2];
//Grab the stuff to return
$contents = file_get_contents("http://www.austinhallock.com/exchanges.php?domain=$domain");
return $contents;
}
?>
[/php]

If you have any questions or comments, post them below!