Page 1 of 1

Simple Sidebar Sample?

Posted: Wed Jul 18, 2012 6:24 pm
by rowi
I want to create a simple sidebar plugin which displays the number of blocked spam within the last 24 hours / 7 days.

So that's just 8 Numbers and I don't want to dive too deep into S9y for this. Is there a simple Sample/Framework I can modify for this?

Code: Select all

// Bee Honeypot
SELECT count(*) FROM `serendipity_spamblocklog` WHERE reason like 'BEE Ho%' AND timestamp > (UNIX_TIMESTAMP(NOW()) - (7 * 24*60*60) ) ;

// Bee Hidden CAPTCHA
SELECT count(*) FROM `serendipity_spamblocklog` WHERE reason like 'BEE Hi%' AND timestamp > (UNIX_TIMESTAMP(NOW()) - (7 * 24*60*60) ) ;

// caught by Bayes
SELECT count(*) FROM `serendipity_spamblocklog` WHERE reason like '%Bayes%' AND timestamp > (UNIX_TIMESTAMP(NOW()) - (7 * 24*60*60) ) ;

// Blocked IPs via htaccess
SELECT count(*) FROM `serendipity_spamblock_htaccess` WHERE timestamp > (UNIX_TIMESTAMP(NOW()) - (7 * 24*60*60) )  ;
(had some strange wrong results with INTERVAL so this was faster)

Re: Simple Sidebar Sample?

Posted: Thu Jul 19, 2012 12:18 pm
by garvinhicking

Sure. Just take your pick of any sidebar plugin (i.e. serendipity_plugin_templatedropdown). Create a new dir like serendipity_plugin_spamstat, rename the file, change the classname within the PHP file, adjust the introspect() variables for something meaningful. Then everything you need goes into the generate_content() method:

Code: Select all

echo 'Statistik1:';
$rows = serendipity_db_query("SELECT count(*) AS counter FROM ... ....");
echo $rows['counter'];