Nobots.php

From Organic Design wiki
Revision as of 00:10, 4 March 2006 by Nad (talk | contribs) (Upgrading to new Human detector)

<?

  1. Add an "I am a human" checkbox to stop spambots for a while

global $xwUserName; $comment = ;

if ( $event == 'view' ) { # Called after rendering login form $article = preg_replace( "/(Your email\\*:.+?)<\\/tr>/is",

"$1<input type='checkbox' name='xwSpecies' value='Human'>

Tick this if you're Human

", $article ); $article = str_replace( '(new users only)', '(for new users - no robots please!)

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="155" height="50" id="nobots.swf" align="" type="application/x-shockwave-flash" data="nobots.swf"> <param name="flashvars" value="'.$code.'"> <param name="movie" value="nobots.swf"> <param name="quality" value="low"> <param name="bgcolor" value="cccccc"> <embed src="nobots.swf" quality="high" bgcolor="cccccc" width="155" height="50" align="" flashvars="'.$code.'" name="nobots.swf" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />

</object> Human detector: <input type='text' name='xwSpecies' size='20'> (Enter the characters displayed above)',

$article ); } elseif ( $event == 'init' ) { # Called before processing posted login form xwSetProperty( $properties, 'xpath:/properties:view', $tTitle ); if ( $_REQUEST['wpCreateaccount'] ) { $xwBot = $_REQUEST['wpName']; if ( $_REQUEST['xwSpecies'] != 'Human' ) { $url = $_SERVER['HTTP_HOST']."/wiki/index.php?title=No+Bots!&xwBot=$xwBot"; header( "Location: http://$url" ); exit; } $comment = "User:$xwBot successfully created from IP $xwUserName"; } } elseif ( $event == 'data' && ( $xwBot = $_REQUEST['xwBot'] ) ) { # This is called from the "No Bots!" page $comment = "Attempt from IP $xwUserName to create user \"$xwBot\" denied ;-)"; }

  1. Append the XmlWiki log article if there's a comment

if ( $comment ) { global $wgLang; $ts = $wgLang->timeanddate( wfTimestampNow(), true ); $log = xwArticleContent( 'XmlWiki Log' )."\n*$ts : $comment"; $a = new Article( Title::makeTitle( 0, 'XmlWiki Log' ) ); $a->quickEdit( $log ); } ?>