'bottrop', 'author'=>'L. Diener - lorenzd<at>gmail.com', 'url'=>'http://halcy.de/pages/bottrop', 'description'=>'Very simple spambot trap.', 'version'=>'1.0' ); # Set up hooks $wgHooks['ArticleSave'][] = array( 'spam_trap' ); $wgHooks['EditPage::showEditForm:fields'][] = 'add_spam_trap'; # Makes random strings. function random_string() { $chars = "abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"; $i = mt_rand( 20, 50 ); $string = ""; while( $i > 0 ) { $string .= $chars{ mt_rand( 0, strlen( $chars ) ) }; $i--; } return $string; } # Spring the trap if something does not feel alright. # This only displays "edit conflict" errors, but meh. function spam_trap( &$article, &$user, &$text, &$summary, $minor, $watch, $sectionanchor, &$flags ) { global $bottrop_field_name, $bottrop_field_value; # Enforce setting changes to ensure effectiveness for at least a little while. if( $bottrop_field_name == "changeme" ) { return( "

ERROR, please change the field name and value in bottrop.php. If you're not the person running this web site, tell whoever _is_ running it of this.

" ); } if ( !( $_POST['name'] === "" && $_POST[$bottrop_field_name] === $bottrop_field_value ) ) { return( "You triggered the bot trap, try refreshing the page and then try again..." ); } return( true ); } # Add the trapping code. function add_spam_trap( &$q, &$out ) { global $bottrop_field_name, $bottrop_field_value; # This should be reasonably complex to parse without a full blown SGML and CSS parser. # Yes, I know this is silly. It might still put off some people. $css_name_1 = random_string(); $css_name_2 = random_string(); $out->addHTML('
' . random_string() . '
' . random_string() . '' . random_string() . '
do n ot fill pls:' . random_string() . '
' ); return( true ); } ?>