<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Zaki.Asia &#187; Tech</title>
	<atom:link href="http://zaki.asia/category/blog/tech/feed/" rel="self" type="application/rss+xml" />
	<link>http://zaki.asia</link>
	<description>Virtual Worlds - Real Experience</description>
	<lastBuildDate>Fri, 16 Jul 2010 05:29:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Referrer spam in statpress</title>
		<link>http://zaki.asia/2010/07/14/referrer-spam-in-statpress/</link>
		<comments>http://zaki.asia/2010/07/14/referrer-spam-in-statpress/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 07:50:40 +0000</pubDate>
		<dc:creator>Zaki</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[referrer spam]]></category>
		<category><![CDATA[statpress]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://zaki.asia/?p=339</guid>
		<description><![CDATA[Today I got really fed up with statpress referrer spam, so I decided to implement a dead simple referrer check function into statpress. The function works very similar to the current IP banning, so it wasn&#8217;t very difficult to get it to work. If I get angry again, I might create a new statpress Option/Page ...]]></description>
			<content:encoded><![CDATA[<p>Today I got really fed up with statpress referrer spam, so I decided to implement a dead simple referrer check function into statpress. The function works very similar to the current IP banning, so it wasn&#8217;t very difficult to get it to work. If I get angry again, I might create a new statpress Option/Page to make the word banning easier or even make it non-destructive by only marking the referrer as spam. Of course other than the proactive banning, one might want to sanitize the referrrers in the statpress table as well. For me, I just cleared all the referrers with bad words in them, but didn&#8217;t bother to entirely remove the entries as I wanted to keep count of the actual access count.</p>
<p>Here are my simple changes to statpress.php:</p>
<pre class="brush: php;">
// A function to check whether a referrer should be
// omitted due to a manual ban
// To add/remove referrer bans, edit
// wp-content/plugins/statpress/def/banreferrers.dat
function iriCheckBanReferrer($arg)
{
    $lines = file(ABSPATH.'wp-content/plugins/'.
                  dirname(plugin_basename(__FILE__)).
                  '/def/banreferrers.dat');
    foreach($lines as $line_num =&gt; $banref)
    {
        if(strpos($arg,rtrim($banref,&quot;\n&quot;))===FALSE) continue;
        return true; // banned
    }
    return false;
}

// In function iriStatAppend()
$referrer = (isset($_SERVER['HTTP_REFERER']) ?
             htmlentities($_SERVER['HTTP_REFERER']) :
             '');
// BANNED REFERRERS
if (iriCheckBanReferrer($referrer)) $referrer = '';
// END BANNED REFERRERS
</pre>
<p>Then all I needed to do is create a banreferrers.dat file in the plugins/statpress/def directory containing one bad word/domain per line and now hopefully a lot less referrer spam will appear in the statpress overview. For now this will suffice for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://zaki.asia/2010/07/14/referrer-spam-in-statpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
