Stop Global Grind from framing your content

by rafi on April 28, 2010

I have been comfortably ignoring Russell Simmons’ lame urban aggregator Global Grind for years but it’s just been brought to all of our attention that they’ve gone and crossed the line from parasitic to Evil.

No longer happy to merely index, excerpt and link to your content, Global Grind is now duplicating it – putting your entire page in an iframe on a globalgrind.com url under their toolbar. So when you write a post at your site, the whole damn thing will become material for Global Grind traffic and you’ll actually have to compete with your own work at their url for Google search engine ranking.

Blogger Patrick O’Keefe has a very in-depth article describing the Global Grind violations and deserves credit for calling foul on this issue. O’Keefe also astutely draws a parallel to the recently shut down and very maligned DiggBar which was Digg’s attempt to frame user content. But Digg wasn’t as flagrant as Global Grind is being; one huge difference is Digg defined canonical url’s in their page’s metadata to let search engines know that the original source was the one to be considered the real url.

O’Keefe asks why hip-hop bloggers put up with this when tech bloggers were quick to speak out against Digg, suggesting it may be just a lack of savvy to blame. I’d like to posit an alternate theory that Digg matters a great deal to tech bloggers, and meant even more when they first launched the DiggBar last year. Digg can generate a great deal of traffic for the bloggers whose content it aggregates. Global Grind on the other hand is not really a factor for anyone. So I think the reason you didn’t hear any outrage about this previously could be as simple as web-savvy hip-hop bloggers (and there are many) weren’t aware that this was going on.

We could go on about how framing other people’s content was decried evil by everyone back in the late 90s when it first became a trend. Or how the very fact that Global Grind is doing this most likely speaks to their own state of desperation to get some sort of numbers up.

But instead, let’s talk about how you can stop Global Grind from stuffing your website under their villainous cape.

The fix is crazy simple and I more or less lifted it from John Gruber’s post on how to block the DiggBar. If Global Grind is going to be so unoriginal as to steal Digg’s questionable moves then we should just match them tit for tat with an unoriginal fix.

Click to see what this code looks like in action.

UPDATE Programmer Tiffany Brown rightfully pointed out in the comments that the code is better off using strpos instead of regular expression matching for performance reasons. Her suggestion has been tested here and updated in the posts. Thanks Tiffany.

The Code - Generic version


<?php
if(strpos($_SERVER['HTTP_REFERER'],'http://globalgrind.com') !== false) {
echo "<p>A message for Global Grind visitors goes here.</p>";
exit;
}
?>

Explanation

When a web page is linked to, the page that did the linking is considered the referrer. When Global Grind puts your site in an iframe, your web server considers globalgrind.com to be the referrer. So this code uses a regular expression pattern match to check if GlobalGrind.com is the referring site and if it is, it will output a different message and then because of the “exit” line will show nothing else on your page but that message.

Gruber’s regular expression looked different because he wanted to allow for regular inbound links from Digg to still work normally. So even while blocking the Digg toolbar he could still have a an article giving him that juicy Digg traffic.

We don’t have to worry about that with Global Grind because they don’t actually pass any kind of significant traffic. And more importantly, they don’t currently link out to any blogger’s site – a painfully lame attempt to build Google juice instead of being part of ¬†the reader-blogger ecosystem they feed from.

The Code – Sassier version (feel free to use)


<?php

if(strpos($_SERVER['HTTP_REFERER'],'http://globalgrind.com') !== false) {

echo "<p>Because of Global Grind's <a href='http://www.patrickokeefe.com/2010/04/26/global-grind-copies-content-submits-it-to-google-news/' target='_parent'>evil policy of content scraping</a>, I am blocking all traffic from Global Grind. Please support those who create instead of those who steal.<br /><br />You can still <a href='http://www.ohword.com" . $_SERVER['REQUEST_URI'] . "' target='_parent'>read this post on my site.</a></p>";

exit;

}

?>

Sassier Version Explanation

This is probably the one you want to grab. It includes some words letting the reader know that Global Grind is stealing content with a link to Patrick O’Keefe’s explanatory post.

Then it includes a link for the reader to view the post they wanted to see on your site instead of inside the Global Grind frame. Important: You will need to change the base of the url in the html from www.ohword.com to whatever your site is. But leave the http:// or the link will break.

Both links use target=_parent to break out of the frame.

How to Implement

Copy either chunk of PHP code and drop it in near the top of your page template. If you’re running a basic WordPress theme you may want to go to the theme editor under appearance in the left sidebar. Choose to edit the header.php file and paste this code right before the <body> tag. That would give you your paragraph on a plain white background.

Gruber also mentions in his post that there is javascript code out there for busting pages out of frames but that his preference is to fix the problem with PHP. An important positive about using PHP in this case that wasn’t a concern with the DiggBar (because of canonical urls) is keeping Global Grind’s content scrape out of Google. Google’s spider isn’t going to be running any javascript code but PHP code runs before the spider sees your page. So if you use this PHP code, your words will stop showing up in Google under a Global Grind url.

A smarter way to insert custom code into WordPress

Adding this fix was different for me than what I just described above. I use the Thesis theme for WordPress which has a strong ideological stance against modifying theme files, with good reason. Because Thesis is constantly improving, you don’t want to put changes in your core theme files which you’ll have to worry about maintaining later when you upgrade to a future version of Thesis.

Instead, Thesis uses separate files to allow you to add custom styling and custom programming. The programming is handled using something called hooks which are basically commands that you can add and remove at various points throughout your template. There’s a plugin for Thesis called OpenHook which makes these hooks extremely easy to work with. So instead of editing any of my actual theme files, I simply went into OpenHook and added the PHP code to the Thesis template just before the logo and nav were to appear.

You can see from this screenshot how OpenHook made adding this code totally idiot-proof. I didn’t have to worry at all about whether it would show up in the spot I wanted it in and didn’t have to worry about stepping on other code. That’s time-saving, worry-saving stuff that has made Thesis well worth the money for me.

Previous post:

Next post: