Are you using the Bad Behavior plugin to help prevent spam on your wordpress blog? But what about your webpages that lie outside your blog… it would be nice to protect them as well!!
Well I figured out how to do this… you can now protect your other webpages using the bad behavior files in the WordPress plugins directory, which is great because whenever you upgrade the plugin, your external webpages will automatically benefit from the upgrade!
NOTE: They need to be php files, so if you want to protect html files you will need to change the extension from html to php. This may require you set up an html file with the old name that auto-refers to the new php file if you are worried about links no longer working.
So assuming you already have the plugin installed and activated, do the following on any webpage you want to protect from spam that is outside your wordpress blog:
Copy and paste the code below into a file called:
Change the settings by entering your email, your wp db-name, your wp db-username and your wp db-user-password. You will also need to enter the table name you want to use. You can use the existing bad behavior table if you want to, or you can specify a different table and it will automatically be created for you. Don’t forget to specify your wp prefix in the table name as well.
Now save this file in the /wordpress/wp-content/plugins/bad-behavior folder (/wordpress/wp-content/plugins/bad-behavior/bad-behavior-generic-outside-wp.php).
For any php webpages you want to protect, add the following code at the VERY top of the page… it MUST be the first thing in your file, even before the HTML and HEAD and DOCTYPE tags. Don’t forget to change the path name so it points to the proper direcotry.
<?php //Bad Behavior - This include_once statement MUST be the very first item at the //top of your page, or it will generate an WARNING and the following functions //may not work: bb2_insert_head(), bb2_insert_stats() // NOTE: It MUST be the very first item on the page or you will get an error. // It needs to be BEFORE all tags (before <html>, <head>, <!DOCTYPE>, etc). include_once('/home/path-to/wordpress/wp-content/plugins/bad-behavior/bad-behavior-generic-outside-wp.php'); ?>
Now ad the following code to the same file, somwhere in the HEAD section of the file:
In the bad-behavior-generic-outside-wp.php file, you can change the ‘verbose’ setting to TRUE. This will log ALL activity to your webpage, including valid permitted access, so you can make sure the logging is working correctly… once it’s set to true visit the webpage a few times then go check the db to make sure there are some entries in it. You probably want to set ‘verbose’ back to FALSE when you are done.
That’s it… hope this helpful to somebody!!
- The topic ‘Bad Behavior spam protection outside your blog’ is closed to new replies.