Simple Sidebar Sample?

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

Simple Sidebar Sample?

Post 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)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Simple Sidebar Sample?

Post by garvinhicking »

Hi!

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