Difference between revisions of "Nobots.php"

From Organic Design wiki
(newline at start not end)
(Also log successful logins)
Line 1: Line 1:
 
<?
 
<?
 
# Add an "I am a human" checkbox to stop spambots for a while
 
# Add an "I am a human" checkbox to stop spambots for a while
 +
global $xwUserName;
 +
$comment = '';
 +
 
if ( $event == 'view' ) {
 
if ( $event == 'view' ) {
 +
# Called from login-page
 
$article = preg_replace(
 
$article = preg_replace(
 
"/(Your email\\*:.+?)<\\/tr>/is",
 
"/(Your email\\*:.+?)<\\/tr>/is",
Line 10: Line 14:
 
}
 
}
 
elseif ( $event == 'init' ) {
 
elseif ( $event == 'init' ) {
 +
# Called from login-page
 
xwSetProperty( $properties, 'xpath:/properties:view', $tTitle );
 
xwSetProperty( $properties, 'xpath:/properties:view', $tTitle );
 
if ( $_REQUEST['wpCreateaccount'] ) {
 
if ( $_REQUEST['wpCreateaccount'] ) {
Line 16: Line 21:
 
exit;
 
exit;
 
}
 
}
 +
$comment = "New user \"$xwBot\" successfully created from $xwUserName!";
 
}
 
}
 
}
 
}
 
elseif ( $event == 'data' && ( $xwBot = $_REQUEST['xwBot'] ) ) {
 
elseif ( $event == 'data' && ( $xwBot = $_REQUEST['xwBot'] ) ) {
 
# This is called from the "No Bots!" page
 
# This is called from the "No Bots!" page
 +
$comment = "Attempt from $xwUserName to create user \"$xwBot\" denied ;-)";
 +
}
 +
 +
if ( $comment ) {
 
global $wgLang;
 
global $wgLang;
 
$ts = $wgLang->timeanddate( wfTimestampNow(), true );
 
$ts = $wgLang->timeanddate( wfTimestampNow(), true );
$log = xwArticleContent( 'XmlWiki Log' );
+
$log = xwArticleContent( 'XmlWiki Log' )."\n$ts : $comment";
$log .= "\n*$ts : Attempt to create user \"$xwBot\" denied ;-)";
 
 
$a = new Article( Title::makeTitle( 0, 'XmlWiki Log' ) );
 
$a = new Article( Title::makeTitle( 0, 'XmlWiki Log' ) );
 
$a->quickEdit( $log );
 
$a->quickEdit( $log );

Revision as of 07:22, 3 March 2006

<?

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

global $xwUserName; $comment = ;

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

"$1<input type='checkbox' name='xwSpecies' value='meat'>Yes I'm a meat creature",

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

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 ); }

?>