Archive for December, 2006

New Theme is Live

Friday, December 29th, 2006

I’ve finally launched my new theme.

Thumbnail of the new blog.joshuaeichorn.com

Let me know what you think, I expect to make some more refinements and to clean up some content yet but the majority of the work is done.

The big new featues are the magic help bubbles you saw on page load. The dock containing secondary navigation, and the new comment styling.

Let me know what you think, and if you see any bugs.

Oh and I only tested things on ie7 and ff so if your running something else and things are totally broken let me know.

New Look

Thursday, December 21st, 2006

I’ve slowly been working on a new theme for this site.

I think i made some good progress tonight.

Take a look and tell me what you think: http://new.joshuaeichorn.com/

Oh and thats not a link for a good reason, its a week old copy of my wordpress DB and I don’t want it too get indexed.

Update
Also check out a page with a lot of comments, I did a neat layout trick that puts my comments in there own column and things line up so each of my comments is next to the comment its replying too.

I’m not done formatting the content in the comment boxes yet, I want to switch too a x days|months|years ago date formatting style

More Spam Fun

Thursday, December 21st, 2006

I hacked akismet a couple days ago to give me hourly spam statistics and then threw together a graph.

Spam in the last 24

Looks like the evil spammers were at it again this morning.

The Code

Create a new table to hold the stats:


CREATE TABLE `spam_count` (
  `day` date NOT NULL default ‘0000-00-00′,
  `hour` tinyint(4) NOT NULL default ‘0′,
  `count` int(11) NOT NULL default ‘0′,
  PRIMARY KEY  (`day`,`hour`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Find your akismet plugin [blog root]/wp-content/plugins/akismet/akistmet.php

Find the line in akismet that updates the global spam count

<?php

update_option( ‘akismet_spam_count’, get_option(‘akismet_spam_count’) + 1 );

?>

On my version of akismet thats line 139, in the ksd_auto_check_comment function

below that line add:

<?php

                /* Hourly Spam Counting Start */
                $today = date(‘Y-m-d’);
                $hour = date(‘H’);
                global $wpdb;
                $wpdb->query(“insert into spam_count (`day`,`hour`,`count`) values(’$today’,$hour,1) on duplicate key update `count`=`count`+1″);
                /* Hourly Spam Counting End */

?>

Then post some comments to test things, make sure your logged out and post something spammy. Then check the spam_count table and make sure its got a new row in it. If so then things are working right.

Now you have the data so the next step is too add some graphs. I use PEAR’s Image_Graph so install it.

Something like the command below might work:

pear install –alldeps Image_Graph-beta

Then make a graph the code for mine is:

<?php

// uses PEAR Image_Graph http://pear.php.net/Image_Graph
require_once ‘Image/Graph.php’;

require_once( dirname(__FILE__) . ‘/wp-config.php’);

$day = date(‘Y-m-d’,strtotime(‘-24 hours’));
$today = date(‘Y-m-d’);
$hour = date(‘H’,strtotime(‘-24 hours’));

$sql = “select `hour`, count from spam_count where day = ‘$today’ or (day = ‘$day’ and hour > $hour)”;
$data = $wpdb->get_results($sql ,ARRAY_A);

$month = date(‘F’);

// create the graph
$Graph =& Image_Graph::factory(‘graph’, array(300, 300));
// add a TrueType font
//$Font =& $Graph->addNew(’font’, ‘Verdana’);
$Font =& $Graph->addNew(‘font’, ‘/usr/share/fonts/dejavu/DejaVuSans.ttf’);
// set the font size to 11 pixels
$Font->setSize(8);

$Graph->setFont($Font);

$Graph->add(
    Image_Graph::vertical(
        Image_Graph::factory(‘title’, array(“Blog Spams in the Last 24 Hours”, 12)),
        $Plotarea = Image_Graph::factory(‘plotarea’),
            //$Plotarea = Image_Graph::factory(’plotarea’,array(’axis’, ‘axis’)),
        7
    )
);

$colors = array(‘red’,‘green’,‘blue’,‘orange’,‘gray’,‘purple’);

// create the dataset
$Dataset_all =& Image_Graph::factory(‘dataset’);
foreach($data as $row) {
        $Dataset_all->addPoint($row['hour'],$row['count']);
}

$Dataset_all =& Image_Graph::factory(‘dataset’);
foreach($data as $row) {
        $Dataset_all->addPoint($row['hour'],$row['count']);
}

// create the 1st plot as smoothed area chart using the 1st dataset
$Plot_all =& $Plotarea->addNew(‘Image_Graph_Plot_Smoothed_Area’, array(&$Dataset_all));

$Plot_all->setLineColor($colors[5]);
$Plot_all->setFillColor(“$colors[2]@0.2″);
$Plot_all->setTitle(‘24 Spam’);

// format the axis

$Processor =& Image_Graph::factory(‘Image_Graph_DataPreprocessor_Function’, ‘formatTime’);
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
$AxisX->setDataPreprocessor($Processor);
$AxisX->setLabelInterval(3);

// output the Graph
$Graph->done();

function formatTime($hour) {
        $hour = (int)$hour;
        $m = ‘AM’;
        if ($hour > 12) {
                $hour = $hour-12;
                $m = ‘PM’;
        }
        return “$hour$m”;
}

?>

The code for the graph is a little more complicated then needed since its just a hacked up version of the graphs i make for WebThumb. Anyhow then its just a matter of putting your graph script in the src of an image.


<img src="/graph-spam-last24.php"/>

Oh and you might want to add some caching if your showing the graph all the time since generating pngs is a bit more expensive then generating html.

When Blog Spammers Attack

Friday, December 15th, 2006

You may have noticed that my blog has been running a bit slower these days. I’ve been getting huge load spikes a couple times a day.

Load Graph of Bluga.net for Dec 14-15

Looking at that and my Akismet counter, its seems im getting 3-4000 spam comment submissions a day. And while the server could handle the load if the spammers were polite about it, its much harder to handle spams coming in 500-1000 spam bursts (less then 1 minute).

I’ve added mod_evasive support to apache but it doesn’t look like things will help since so many different ip’s are being used in the spam attacks. There is nothing like being dos’d by spammers.

I may end up having to rewrite wordpress’s comment submission code in order to get enough performance out of it too handle the attacks. Any suggestions would be much appreciated.

Update
I moved my comments page and since serving up 404’s is cheap my load is no longer spiking. Now i just need a script that finds 404’s to the old comments page and add them to my firewall.

This circle expands additional navigation
You should really buy my AJAX book.
You'll learn not only the technology you need for implementation but also an understanding that will help you get the most from AJAX.
You'll also have my eternal thanks :-)