RSS Feed

Displaying an exchange’s name

February 7, 2010 by Austin Hallock

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 echo get_exchange(); ?>

If you want the name to be all caps, put:

<?php echo strtoupper(get_exchange()); ?>

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
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;
}
?>

If you want it all on your end so you can customize it a bit more, use the following function instead:

<?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>";
}
?>

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).

<!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;
}
?>

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


24 Comments »

  1. paul brown says:

    wow why to go Austin
    been trying to find this code for a long time
    can you add Astrology-surf.com to the list off traffic exchanges please

  2. Marc Eglon says:

    Shit man – that's slick. Great job bro'
    Would love you to add Jetstreamtraffic.

    Thanks again,
    Marc

  3. Austin says:

    Thanks Marc, added!

  4. Toni says:

    Good Day Austin .. I would love to have my traffic exchange added please.. looking forward to giving this a try.. thank you kindly for allowing us to have these teriffic codes

  5. Hey Austin, You are providing some massive value here. Keep up the Great Work!

    Jason Dandridge
    Networking Zoo

  6. Joe Parazoo says:

    My name is Joe… I would like to introduce Shaman-Traffic.com which is a Native American themed manual traffic exchange based on the LFMTE script.

  7. AM Bank says:

    Welcome First time jumped here on your site, founde on Google. It is so good to know that there are people as generous as you with their time to answer personally questions that others ponder on alone for so long. I didn’t know you replied to each email. You’ve made me consider my options and I’m really grateful for your time and original thoughts. Sometimes people are blinded at consequence to themselves and however hard it is they have to look facts in the eye. Thanks.

  8. Charlee says:

    Could I get the code to exchanges.php so I could just link to it on my own server? I like that you put a way to do it on our own servers but I don't want all the names and colors to have to be on the splash page because I would want it to load asap.

    • Austin says:

      Charlee, either way your server will have to process the same amount of data, and honestly the quickest solution is to take that second to last block of code (with all the names and colors in it) and put it in your splash page. Otherwise you have to do the file_get_contents (or cURL) both of which are much slower than a straight function call.

      Basically what exchanges.php does is run that block of code and output the name. What the function does is runs the block of code and returns the name. Another option you have is to put <?php include('functions.php'); ?> at the top of your file, put that second to last block of code in functions.php then call the function with: <?php echo get_exchange(); ?>

      Hope that makes sense

      • Charlee says:

        sure does, thanks. Please add my traffic exchange too by the way. I posted it once but it seems to have went away. Anyway, it is in the website option field. Also, how does easyhits4u do it on all their splash pages without a database? They had my name the day my site went up.

        • Austin says:

          My script with more or less get the name if it's not stored on my end, it just doesn't look as good. For example, your site would show up as "Hey Onestoptrafficshop Surfer!" in black. I'd imagine there's does the same (haven't looked at it).

          Added your exchange.

  9. Miles says:

    Hey, Austin!

    I saw your new pics on ILoveHits!

  10. Sooooooo awesome post, i love some words so much and can i quote a few of those on my blog? I also have emailed you regarding could it be possible for us to exchange our links, hope hearing from you soon.

  11. Robert says:

    Hey Austin how about adding my site http://lazertargetedtraffic.com it can really help if you are looking for traffic.

  12. Robert says:

    Austin you can add your site just go to the URL and generate the link

  13. Hi Austin,

    It would be great if it was possible to get a list of all the exchanges that are currently listed, it would also make it easier for people to suggest additions without dusplicating ones that are already there.

    Thanks,
    Darren

  14. James says:

    Austin,
    I would love to see ablaze with traffic in there we are little but getting bigger every day.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>