'bottrop', 'author'=>'L. Diener - lorenzd<at>gmail.com', 'url'=>'http://halcy.de/pages/bottrop', 'description'=>'Very simple spambot trap.', 'version'=>'1.2' ); # 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( 1, strlen( $chars ) -1 ) }; $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( $user->isLoggedIn() ) { # return( true ); # } # Fields if ( !( $_POST['name'] === "" && $_POST[$bottrop_field_name] === $bottrop_field_value ) ) { return( "You triggered the bot trap, try refreshing the page and then try again... Turn cookies on if you have them off. We're very sorry that we have to do this, spam bots are forcing us to." ); } # Fields, JS-filled if( !( $_POST['breakfast'] === "explodingdonuts") ) { return( "You triggered the bot trap. Sorry. Spammers ruin everything. Turn JS on and try again." ); } # Cookie if ( !( $_COOKIE["post_ok"] === "yes" ) ) { return( "You triggered the bot trap, try refreshing the page and then try again... Turn cookies on if you have them off. We're very sorry that we have to do this, spam bots are forcing us to." ); } 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() . '
do n ot fill pls:' . random_string() . '
' ); setcookie("post_ok", "no", time()+360000); $out->addHTML(''); return( true ); } ?>