Simple Sidebar Sample?

Discussion corner for Developers of Serendipity.
Post Reply
User avatar
Posts: 77
Joined: Fri Mar 16, 2007 9:10 pm
Location: Flensburg / Germany

Simple Sidebar Sample?

Post by rowi » Wed Jul 18, 2012 6:24 pm

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)

User avatar
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany

Re: Simple Sidebar Sample?

Post by garvinhicking » Thu Jul 19, 2012 12:18 pm


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'];
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy:
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby:

Post Reply