View previous topic :: View next topic |
Author |
Message |
Cyberian75
Joined: 26 Sep 2002 Posts: 1285 Location: Oregon
|
Posted: Wed Oct 13, 2004 1:07 am Post subject: [Hack] Comments Blacklist |
|
|
With this hack, you can easily ban specific IPs that leave junk comments from your administrative page. You can also manage them from a seperate "blacklist" page (like the catagory page).
From 0.6, you can search by words.
Uses a seperate database table to store/retrieve banned IPs.
You can get the code here.
Code: |
//CHANGELOG
//
//0.8.0: Implemented a smarter URL matching (step 4).
//
//0.7.9: Added a "Show ALL Comments" action and an associated button to the default action/form (step 6).
//
//0.7.8: Now blocks one URL per IP
// -- added a new field to the database;
// -- updated steps: 1, 3, 4, 5, and 6
// Replace the entire contents of your "b2blacklist.php" file.
//
//BUGFIX: The "addtolist" option of word search wasn't working properly (step 6).
//
//0.7.5: Fixed a bug with highlighting multiple words (step 6).
// Fixed a bug with the pattern for words filter (step 6).
// Restricted the MySQL version check to be executed only once by passing it to the URI (step 6).
// Other minor changes.
//
//0.7.2: Added a MySQL version check
// -- if it's 4 or higher, "word search" should be a little faster
// and lessen the load on your database (step 6).
// Added direct links to comments for both "word search" and "show comments" (step 6).
// Replace the entire contents of your "b2blacklist.php" file.
//
//0.7.0: Totally re-wrote the "word search" action (step 6)
// -- implemented a "paging system";
// -- invalid characters are now filtered out automatically;
// -- highlights now use b2's CSS;
// -- removed the ">2 characters" restriction;
// -- other minor changes.
// Replace the entire contents of your "b2blacklist.php" file.
//
//0.6.5: Improved the "word search" by using REGRXP operator (step 6);
// other minor changes.
//
//0.6.3: Added a couple of options: condition and sort (step 6).
//
//0.6.1: Added an input validation to the "word search" (step 6).
//
//0.6.r: Major bugs fixed
// -- in "delete comments" action (step 6);
// -- in JavaScript (step 8).
// Replace the entire contents of your "b2blacklist.php" file and JavaScript.
//0.6.1: Added an input validation to the "word search" (step 6).
//
//0.6.r: Major bugs fixed
// -- in "delete comments" action (step 6);
// -- in JavaScript (step 8).
//
//0.6.0: Added a new "search by words" capability (I got the idea from Steve M.)
// -- now you can search using one or more words;
// -- deleting comments from a word search automatically adds its IP to the blacklist;
// -- you can choose the condition (AND/OR) of the query;
// -- other minor changes.
// Replace the entire contents of your "b2blacklist.php" file.
//
//0.5.3: Added step 9 (optional)
// -- ban those blacklisted IPs from viewing your blog.
//
//0.5.2: Slightly improved the "search by IP and name" option by using wildcards [%$name%] (step 6; line 204).
//
//0.5.1: Added a confirmation box for the "Delete" button under the "default" action (step 6)
// -- initial (base) script and troubleshooting by Steve M. (changed the name of the form);
// -- added the "deleteip" block to the JavaScript (step 8).
// -- modified the JavaScript to take "this.form" method (steps 6 & 8).
//
//0.5.r: Took out the "datetime" field as it was not needed; instead,
// IPs are now sorted by their IDs in the "default" action (step 6)
// -- updated steps 1, 3, 4, and 6.
//
//0.5.0: Fixed the JavaScript (step 8)
// -- "check all" box wasn't being checked even when all others were checked.
//
//0.4.9: Combined all the JavaScripts into one "blacklist" function (step 8)
// -- updated the "Show Comments" action accordingly (step 6).
//
//0.4.8: Added a new field "datetime_added" to the database (step 1)
// -- modified the default action so that the most recent entry is shown first (step 6);
// -- modified the "banip" action (step 3);
// -- and modified the "add" action with now() function to let it automatically insert
// the current date and time (step 6).
//
//0.4.5: Added a new "search by IP and name" checkbox option to the default action (step 6).
// Modified the "Show Comment" action to implement the option above (step 6).
// Added a new row of "total # comments" in the "Delete Comments" action (step 6).
// Minor "bugs" fixed
// -- replace the entire contents of your "b2blacklist.php" file.
//
//0.3.8: Changed the type, and the location, of the "(un)check all" link to a checkbox
// within the "Show Comments" action (step 6).
// Modified/fixed both JavaScripts (step 8).
// Added more validation codes to the "Delete Comments" action (step 6).
// More cosmetic changes.
//
//0.3.5: Re-worked the "add" action to validate user input (step 6).
// Also added a validation code to the "Delete Comments" action (step 6).
// Some cosmetic changes.
//
//0.3.1: Added a new "validate" JavaScript (steps 6 & 8).
//
//0.3.0: Added a new "page" where you can select which comments to delete (step 6)
// -- replace the entire contents of your "b2blacklist.php" file.
// Added Step 8: "check all/uncheck all" JavaScript.
//
//0.2.0: Removed the "Ban & Delete ALL" link (step 5)
// Changed the "banip" action to reflect the change above (step 3).
// Added a new action (Delete Comments) and a form button on the "blacklist" page (step 6):
// 1. now comments can be deleted from that page;
// 2. and comments are now displayed in a tabular form before they get deleted.
//
//0.1.6: Added a new "Ban & Delete ALL" link which will delete all comments (global)
// associated with the IP you're banning (step 5).
// Changed the behavior of "Ban & Delete" link which now wlll delete comments per post.
// Changed the "banip" action to reflect the changes above (step 3).
//
//0.1.3: Added a confirmation dialog box to the "Ban & Delete" link (step 5).
// Other minor stuffs.
|
Since 0.3.0:
_________________ Michael P.

Last edited by Cyberian75 on Thu Dec 30, 2004 8:45 pm; edited 49 times in total |
|
Back to top |
|
 |
Sigg3
Joined: 03 Jul 2003 Posts: 906 Location: Oslo, Norway
|
|
Back to top |
|
 |
Cyberian75
Joined: 26 Sep 2002 Posts: 1285 Location: Oregon
|
Posted: Wed Oct 13, 2004 8:34 pm Post subject: |
|
|
Sure.  _________________ Michael P.
 |
|
Back to top |
|
 |
Cyberian75
Joined: 26 Sep 2002 Posts: 1285 Location: Oregon
|
Posted: Wed Oct 13, 2004 8:55 pm Post subject: |
|
|
Sigg3 wrote: | You don't think Big-Corporated-Spammers use spoofing, thus blacklisting innocent victims? (or infected, yet innocent, clients?) |
If you know a little of PHP, that can be resolved quite easily; i.e., make it mandatory to comment ONLY IF the user is coming from the comments page. I do this by passing a variable containing the user's IP along with the comment and then do a comparison check on the "posting" page. This method will stop most bots. _________________ Michael P.
 |
|
Back to top |
|
 |
stevem
Joined: 15 Mar 2003 Posts: 369
|
Posted: Wed Oct 13, 2004 9:41 pm Post subject: |
|
|
This is a very welcome hack which works well. There's just one tiny error in the naming of a new banned IP address, which gives it a name of 'name'.
In line 51 of b2blacklist.php it says:
Code: | $query="INSERT INTO $tableblacklist (IP,name) VALUES ('$IP','name')"; |
That 'name' at the end of the line should read '$name' so that you get
Code: | $query="INSERT INTO $tableblacklist (IP,name) VALUES ('$IP','$name')"; |
Editing the IP address though works fine with name. |
|
Back to top |
|
 |
Cyberian75
Joined: 26 Sep 2002 Posts: 1285 Location: Oregon
|
Posted: Wed Oct 13, 2004 10:02 pm Post subject: |
|
|
It's been corrected. Thanks!  _________________ Michael P.
 |
|
Back to top |
|
 |
Cyberian75
Joined: 26 Sep 2002 Posts: 1285 Location: Oregon
|
Posted: Wed Oct 13, 2004 11:05 pm Post subject: |
|
|
Sigg,
You might want to put up my "close commens" and "private" hacks as well. They can be found here.
I've changed the name of the directory from "hacks" to "b2hacks" and enabled graphical indexing. _________________ Michael P.
 |
|
Back to top |
|
 |
Sigg3
Joined: 03 Jul 2003 Posts: 906 Location: Oslo, Norway
|
|
Back to top |
|
 |
Cyberian75
Joined: 26 Sep 2002 Posts: 1285 Location: Oregon
|
Posted: Thu Oct 14, 2004 7:17 pm Post subject: |
|
|
[Deleted] _________________ Michael P.

Last edited by Cyberian75 on Wed Oct 27, 2004 7:18 pm; edited 1 time in total |
|
Back to top |
|
 |
Sigg3
Joined: 03 Jul 2003 Posts: 906 Location: Oslo, Norway
|
|
Back to top |
|
 |
Cyberian75
Joined: 26 Sep 2002 Posts: 1285 Location: Oregon
|
|
Back to top |
|
 |
Sigg3
Joined: 03 Jul 2003 Posts: 906 Location: Oslo, Norway
|
|
Back to top |
|
 |
Cyberian75
Joined: 26 Sep 2002 Posts: 1285 Location: Oregon
|
Posted: Sun Oct 17, 2004 12:06 am Post subject: |
|
|
Major updates!  _________________ Michael P.
 |
|
Back to top |
|
 |
Sigg3
Joined: 03 Jul 2003 Posts: 906 Location: Oslo, Norway
|
|
Back to top |
|
 |
Cyberian75
Joined: 26 Sep 2002 Posts: 1285 Location: Oregon
|
Posted: Mon Oct 18, 2004 3:07 am Post subject: |
|
|
I'm just challenging myself on how far I can take it, that's all.  _________________ Michael P.
 |
|
Back to top |
|
 |
|