<?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>Bit Matrix &#187; wordpress</title>
	<atom:link href="http://blog.bit-matrix.com/tag/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bit-matrix.com</link>
	<description>Tech. Code. Linux. MySQL. Ones. Zeroes.</description>
	<lastBuildDate>Tue, 31 Aug 2010 01:10:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Generate your own Wordpress Permalink without GUIDs from database</title>
		<link>http://blog.bit-matrix.com/2010/03/01/generate-your-own-wordpress-permalink-without-guids-from-database/</link>
		<comments>http://blog.bit-matrix.com/2010/03/01/generate-your-own-wordpress-permalink-without-guids-from-database/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 19:25:31 +0000</pubDate>
		<dc:creator>Bit Matrix</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[guid]]></category>

		<guid isPermaLink="false">http://blog.bit-matrix.com/?p=134</guid>
		<description><![CDATA[If you are generating links to your blog articles via some other mechanism than Wordpress itself you usually have to use the guid database field. This is the unique global indentifier of the post. In reality it is not globally unique but only unique to your blog.
Typically, the guid in the database will look something [...]]]></description>
			<content:encoded><![CDATA[<p>If you are generating links to your blog articles via some other mechanism than Wordpress itself you usually have to use the <b>guid</b> database field. This is the unique global indentifier of the post. In reality it is not globally unique but only unique to your blog.<span id="more-134"></span></p>
<p>Typically, the guid in the database will look something like this:</p>
<blockquote><p>http://blog.bit-matrix.com/?p=2411</p></blockquote>
<p>You can use this perfectly fine but it will hurt your SEO since search sites prefer descriptive links such as:</p>
<blockquote><p>http://blog.bit-matrix.com/2010/02/10/google-buzz-a-privacy-disaster</p></blockquote>
<p>As it turns out, you can easily construct this link from the database yourself. Wordpress will recognize the format of the link and display the appropriate post. The query to construct this is quite simple, all we need is a little date formatting:</p>
<blockquote><p>SELECT CONCAT(DATE_FORMAT(post_date,&#8217;%Y/%m/%d/&#8217;),post_name) AS permalink FROM wp_posts WHERE post_status=&#8217;publish&#8217;;</p></blockquote>
<p>This will return all the published post guid&#8217;s in the following format:</p>
<blockquote><p>2010/02/10/google-buzz-a-privacy-disaster</p></blockquote>
<p>That&#8217;s all!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bit-matrix.com/2010/03/01/generate-your-own-wordpress-permalink-without-guids-from-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress spam killing script</title>
		<link>http://blog.bit-matrix.com/2009/01/30/wordpress-spam-killing-script/</link>
		<comments>http://blog.bit-matrix.com/2009/01/30/wordpress-spam-killing-script/#comments</comments>
		<pubDate>Sat, 31 Jan 2009 08:55:35 +0000</pubDate>
		<dc:creator>Bit Matrix</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[spam]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.bit-matrix.com/?p=58</guid>
		<description><![CDATA[Blog comment spam is an unfortunate reality of having a blog. See the chart to get a sense of how much spam comes in on a daily basis to one of my blogs that receives a moderate amount of traffic. The red line shows the 30-day moving average for the number of spam comments daily.



Weeding [...]]]></description>
			<content:encoded><![CDATA[<p>Blog comment spam is an unfortunate reality of having a blog. See the chart to get a sense of how much spam comes in on a daily basis to one of my blogs that receives a moderate amount of traffic. The red line shows the 30-day moving average for the number of spam comments daily.</p>
<div class="mceTemp">
<a href="http://blog.bit-matrix.com/wp-content/uploads/2009/12/spam_comments.jpg"><img class="size-full wp-image-85" title="Number of daily spam comments on the typical blog" src="http://blog.bit-matrix.com/wp-content/uploads/2009/12/spam_comments.jpg" alt="Number of daily spam comments on the typical blog" /></a>
</div>
<p><span id="more-58"></span></p>
<p>Weeding out comments daily can be a real nuisance and, if you&#8217;ve missed a few days, the spam can pile up until it becomes a real time waster. Using the Akismet plugin for Wordpress goes a long way to rid you of spam and I would recommend that everyone use it. If, for some reason, you are looking for a standalone solution, I have hacked up a quick script to mark Wordpress Comments as spam based on the number of links in the comment. It is quite crude but if you have thousands of spam messages pilled up, you will appreciate it.</p>
<p>You will need Perl and the DBI module (if you don&#8217;t know what this is you should probably get the Akismet plugin <img src='http://blog.bit-matrix.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> ).</p>
<pre>#!/usr/bin/perl
#
# wp_spam_kill.pl - brute force spam killing script
#
# Kill spam comments in WordPress based on the number of links in the comment
#
# date   : 2009.01.31
# http://bit-matrix.com
# license: GPL

use strict;
use DBI;

$| = 1;

# Configure your blog database
my $db = "DATABASE_NAME";
my $host = "DATABASE_HOST";
my $username = "DATABASE_USERNAME";
my $password = "DATABASE_PASSWORD";
my $comments_table = 'comments';
my $port = "3306";

# If a comment has more than this many links, mark it as spam
my $spam_level = 4;

sub query($$){
    my $dbh = shift;
    my $pre_bind = shift;

    my $sql = $dbh-&gt;prepare($pre_bind);
    return $sql-&gt;execute() ? $sql : undef;
};

# Connect to database
print "Connecting to $db...\n";
my $dsn = sprintf "DBI:mysql:database=%s;host=%s;port=%s;",$db,$host,$port;
my $dbh = DBI-&gt;connect($dsn,$username,$password);

# Fetch all unapproved comments
print "Getting comments...\n";
my $query = 'SELECT * FROM '.$comments_table.' WHERE comment_approved="0";';
my $c_sql = query($dbh,$query);
printf "%d Comments not approved yet\n",$c_sql-&gt;rows();

# Check each comment for number of links and mark it as spam if it has more links
my $spam_killed = 0;
while(my $c = $c_sql-&gt;fetchrow_hashref()){
    my @links = $c-&gt;{comment_content} =~ /(http:\/\/)/gs;
    if( $#links+1 &gt;= $spam_level ){
        printf "SPAM - %d links in comment\n",$#links+1;
        query($dbh,'UPDATE '.$comments_table.' SET comment_approved="spam" WHERE comment_ID="'.$c-&gt;{comment_ID}.'" LIMIT 1;');
        $spam_killed++;
    };
};

printf "Marked %d messages as spam\n",$spam_killed;

0;

__END__</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.bit-matrix.com/2009/01/30/wordpress-spam-killing-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
