Anti-spam update recheck prompter
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    b2evolution Forum Index -> Plugins & Extensions -> Fighting spam!
View previous topic :: View next topic  
Author Message
EdB
/bb|[^b]{2}/

Joined: 05 Jan 2004
Posts: 7123
Reputation: 140.9 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 90

PostPosted: Sat Jan 29, 2005 17:39    Post subject: Anti-spam update recheck prompter Reply with quote

This comes from a request in the Feature request forum about antispam checking what it updates. It would be really cool if updating antispam included a re-check of everything it added, or at the very least asked you "do you want to re-check the new things?". The latter is a step above what I hacked in. This hack involves a new field in the antispam table and modifications to admin/b2antispam.php and b2evocore/_functions_antispam.php. The end result is that any banned keywords I haven't actually clicked "re-check" on tell me "NOT rechecked!" in the back office. It also sorts with the not rechecked keywords on the top so I can easily see which words got added with the latest update. I wrote up all the hackage in detail on my blog, and for those who don't need the details here's the quickie:

New field:
Code:
ALTER TABLE `evo_antispam` ADD `aspm_checked` ENUM( 'needs', 'gotit' ) DEFAULT 'needs' NOT NULL

Change _functions_antispam:
Code:
$sql = "SELECT aspm_ID, aspm_string, aspm_source, aspm_checked
FROM $tableantispam
ORDER BY aspm_checked ASC, aspm_string ASC";
$res_stats = $DB->get_results( $sql, ARRAY_A );

Change b2antispam:
Code:
if( $recheck > 0 ) {
$sql = "UPDATE $tableantispam SET aspm_checked='gotit' WHERE aspm_ID = $recheck";
$result = $DB->query( $sql );
}

if( $delhits && $deluxe_ban )
and
Code:
[blahblahblah T_('Check hit-logs and comments for this keyword!') blahblahblah]
</td>
<td>
<?php $been_rechecked = $row_stats['aspm_checked'];
if( $been_rechecked == 'needs' ) {
echo 'NOT rechecked!';
} else {
echo ' ';
}
?>
</td>


Last edited by EdB on Wed Aug 03, 2005 10:13; edited 1 time in total
Back to top
View user's profile Send private message
EdB
/bb|[^b]{2}/

Joined: 05 Jan 2004
Posts: 7123
Reputation: 140.9 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 90

PostPosted: Sun Jan 30, 2005 13:39    Post subject: Reply with quote

Why show the stuff you've already banned and rechecked?
http://wonderwinds.com/hackblo...tool_part2
Back to top
View user's profile Send private message
EdB
/bb|[^b]{2}/

Joined: 05 Jan 2004
Posts: 7123
Reputation: 140.9 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 90

PostPosted: Mon Feb 07, 2005 13:38    Post subject: Reply with quote

http://wonderwinds.com/hackblo...tool_part3

This version is much cooler. You set the new field in the table then tell antispam to "Recheck 'em all!". It stops each time it finds a nasty and asks you if you want to delete the offenders or not, and it hides hits you've already rechecked.
Back to top
View user's profile Send private message
majort
New Poster
New Poster

Joined: 13 Aug 2004
Posts: 3
Reputation: 21.1Reputation: 21.1 add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Mon Feb 07, 2005 16:54    Post subject: Great stuff - but i still like the comment "checked or Reply with quote

EdB, please keep the code pieces

Code:
<td>
   <?php $been_rechecked = $row_stats['aspm_checked'];
   if( $been_rechecked == 'no' ) {
   echo 'NOT rechecked!';
   } else {
   echo 'was rechecked! ';
   }
   ?>
        </td>
Back to top
View user's profile Send private message Visit poster's website
EdB
/bb|[^b]{2}/

Joined: 05 Jan 2004
Posts: 7123
Reputation: 140.9 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 90

PostPosted: Mon Feb 07, 2005 17:50    Post subject: Reply with quote

Ya think so? I felt it was redundant because having "re-check" means it's not been re-checked. Oh wait a minute. On the short table it's intuitive because if it shows up then it must be not rechecked. On the full (original) table there's no explanation of what's been done or not, so it makes sense to add a reference to the checked/notrechecked status of each keyword.

Lemme know what you think and I'll work it back in.
Back to top
View user's profile Send private message
EdB
/bb|[^b]{2}/

Joined: 05 Jan 2004
Posts: 7123
Reputation: 140.9 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 90

PostPosted: Mon Feb 07, 2005 18:04    Post subject: Reply with quote

Code:
      <?php } else {
      echo '&nbsp;';
      } ?>
   </td>

   <?php if( $show_full ) { ?>
      <td>
      <?php $been_rechecked = $row_stats['aspm_checked'];
      if( $been_rechecked == 'no' ) {
         echo '<strong>NOT re-checked!</strong>';
         } else {
         echo 're-check done';
         } ?>
      </td>
      <?php } ?>

   </tr>
   <?php
   $count++;
   } // End stat loop ?>
</table>


Add it to the tail end of the new file. You will get the extra column when you decide to view the full list of banned keywords, un-re-checked items will be flagged with bold, and re-checked items will be regular font. I'll update my blog post and associated files too.

Hope this addresses your concern.
Back to top
View user's profile Send private message
BenFranske
Seasoned Poster
Seasoned Poster

Joined: 28 Jun 2004
Posts: 84
Reputation: 54.6Reputation: 54.6Reputation: 54.6Reputation: 54.6Reputation: 54.6 add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Thu Jun 16, 2005 0:12    Post subject: Reply with quote

I've been using EdB's hack for a while now and love it but it broke with 0.9.0.12 so I've updated it to version 4.

You can download the hack and instructions from this location until I setup a more permanent home.

If you run into problems with the installation or fuction of the hack please post and I'll do my best to assist you.

*UPDATED LINK*


Last edited by BenFranske on Thu Jun 16, 2005 0:26; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
John
the uncertain

Joined: 22 Jun 2004
Posts: 2147
Reputation: 4.6Reputation: 4.6Reputation: 4.6Reputation: 4.6 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 27

PostPosted: Thu Jun 16, 2005 0:19    Post subject: Reply with quote

Quote:
Forbidden
You don't have permission to access /ben/recheck4.zip on this server.

_________________
See the Sites in in Venice
Back to top
View user's profile Send private message Visit poster's website
BenFranske
Seasoned Poster
Seasoned Poster

Joined: 28 Jun 2004
Posts: 84
Reputation: 54.6Reputation: 54.6Reputation: 54.6Reputation: 54.6Reputation: 54.6 add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Thu Jun 16, 2005 0:27    Post subject: Reply with quote

Should be fixed now.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mikkyT
Seasoned Poster
Seasoned Poster

Joined: 14 Feb 2005
Posts: 76
Reputation: 21.7Reputation: 21.7 add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Thu Jun 23, 2005 9:30    Post subject: Reply with quote

MySQL error!

Unknown column 'aspm_checked' in 'field list'(Errno=1054)

Your query:
SELECT aspm_ID, aspm_string, aspm_source, aspm_checked FROM evo_antispam WHERE aspm_checked = 'FALSE' ORDER BY aspm_string ASC



Anyone any ideas?

I've added the field into the database,

Field Type Attributes Null Default Extra Action
aspm_ID bigint(11) No auto_increment Change Drop Primary Index Unique Fulltext
aspm_string varchar(80) No Change Drop Primary Index Unique Fulltext
aspm_source enum('local', 'reported', 'central') No reported Change Drop Primary Index Unique Fulltext
aspm_checked tinyint(1) No 0

But no cigar for me! .... executing the SQL command in MyPhpAdmin is successful.

_________________
Smoke me a kipper, skipper
Back to top
View user's profile Send private message Visit poster's website
BenFranske
Seasoned Poster
Seasoned Poster

Joined: 28 Jun 2004
Posts: 84
Reputation: 54.6Reputation: 54.6Reputation: 54.6Reputation: 54.6Reputation: 54.6 add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Thu Jun 23, 2005 17:54    Post subject: Reply with quote

Check your hacks.php file. It should have a line like
Code:
$sql = "SELECT aspm_ID, aspm_string, aspm_source, aspm_checked
FROM $tableantispam
WHERE aspm_checked = '0'
ORDER BY aspm_string ASC";
$res_stats = $DB->get_results( $sql, ARRAY_A );

If the line says WHERE aspm_checked = 'FALSE' change it. You should be using 0 and 1 in the queries, not TRUE and FALSE. I beleive this is the only place that query appears.

Let us know what you find.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mikkyT
Seasoned Poster
Seasoned Poster

Joined: 14 Feb 2005
Posts: 76
Reputation: 21.7Reputation: 21.7 add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Wed Aug 03, 2005 6:53    Post subject: Reply with quote

EDB/Anyone - have you thought about automating the update process so that I could call a cron job that automatically does a recheck & prune every X hours?

Currently, manual intervention is the only way, and you need to recheck for every unchecked entry.
Back to top
View user's profile Send private message Visit poster's website
EdB
/bb|[^b]{2}/

Joined: 05 Jan 2004
Posts: 7123
Reputation: 140.9 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 90

PostPosted: Wed Aug 03, 2005 10:24    Post subject: Reply with quote

Isaac made up a way to automatically get the update and do the recheck using a cron job. Check http://isaacschlueter.com/ for details.

BenFranske: why do you say it didn't work in v12? I have a v12 installation that uses my last version of this hack without issue. The "yes/no" version was problematic for some situations, but that became "needs/gotit" a long time ago. Effectively the same solution as "1/0"?
Back to top
View user's profile Send private message
Pneumatus
New Poster
New Poster

Joined: 22 Aug 2005
Posts: 8
Reputation: 15.6Reputation: 15.6 add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Mon Aug 22, 2005 14:23    Post subject: Reply with quote

Just a small modification:
Code:
if( $show_full ) {

on line 514 of you modifed b2antispam.php should read
Code:
if( $_GET['show_full'] ) {

to be register_globals off compatible - otherwise the user will never be able to see any of the keywords already checked.
Back to top
View user's profile Send private message
William
New Poster
New Poster

Joined: 27 Aug 2005
Posts: 13
Reputation: 11.4 add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Sat Aug 27, 2005 9:30    Post subject: Parse Error when running b2antispam_recheck.php Reply with quote

I posted this in the plugins forum & EdB suggested that I try over here:
Quote:

I'm getting an error when cron runs it (same if I run it manually) - (MySQL 4.0.25-standard / B2Evo 0.9.0.12) / php ver: 4.3.10

Parse error: parse error, unexpected ';' in /home/mysite/public_html/blog/admin/b2antispam_recheck.php on line 24

Here's the code referenced:

Code:
   $report = ( $result->aspm_source != 'central' &amp;&amp; $result->aspm_source != 'reported' ) ? 1 : 0;


I've done EdB's "hacks": added database field, changed "no's" to "needs" & "yes's" to "gotit" in the script.

I'm using Isaac's blacklist update cron technique successfully & would like to get the re-check working, too.

any ideas?

__________________

Comment from: EdB [Visitor] · http://wonderwinds.com
Hi William. I'll try to figure something out on this, but Isaac wrote the 'automatic recheck' hack - all I did was copy it and be happy. What version of PHP are you running? Are you a member of the forums? If not you should sign up because pasting code works a lot better in there than out here.

It'll take me a while. I'm wondering about the syntax of that particular line. How it says "variable = this or that depending on a condition". I'm thinking maybe your PHP doesn't like the way Isaac wrote the code? It'd be odd because Isaac is really good with code, but I don't know what else to look at.

See you in the forums!
_________________

Comment from: EdB [Visitor] · http://wonderwinds.com
Try changing "? 1 : 0;" to "? true : false;. Just a thought based on the reason I had to change yes and no to gotit and needs. I don't understand why - I just remember my hack failed with yes and no for a few people. Something about how their server was setup.

Any additional followup we'll do in the forums. Lotsa smart people in there!


Thanks for your reply, EdB

I Tried true /false, but no joy. (my php ver: 4.3.10)

Thanks for any other thoughts...

_________________
William
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    b2evolution Forum Index -> Fighting spam! All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2


 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
b2evolution Support Forum RSS Feed Forums powered by php Bulletin Board