The Serendipity Handbook

You can now read the (german) handbook here: PDF - https://github.com/s9y/Book (LaTeX source).

Forum-Information

Before posting about errors, make sure that the answer cannot already be found in our FAQ or by searching this forum!
Posting is restricted to registered users (registering is free and simple!) due to recent spam attacks. When having trouble with this board, contact garvin(-at)s9y(-dot)org.

Board index Development Simple Sidebar Sample?

Discussion corner for Developers of Serendipity.
User avatar
rowi
Regular
 
Posts: 56
Joined: Fri Mar 16, 2007 10:10 pm
Location: Flensburg / Germany

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

Postby garvinhicking » Thu Jul 19, 2012 12:18 pm

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/



Return to Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron