MediaWiki r4130 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r4129‎ | r4130 (on ViewVC)‎ | r4131 >
Date:07:41, 21 June 2004
Author:timstarling
Status:old
Tags:
Comment:
new anti-bot code
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -99,7 +99,7 @@
100100
101101 /* private */ function getBlockedStatus()
102102 {
103 - global $wgIP, $wgBlockCache;
 103+ global $wgIP, $wgBlockCache, $wgProxyList;
104104
105105 if ( -1 != $this->mBlockedby ) { return; }
106106
@@ -122,12 +122,20 @@
123123 $this->mBlockreason = $block->mReason;
124124 }
125125 }
 126+
 127+ # Proxy blocking
 128+ if ( !$this->mBlockedby ) {
 129+ if ( array_key_exists( $wgIP, $wgProxyList ) ) {
 130+ $this->mBlockreason = wfMsg( 'proxyblockreason' );
 131+ $this->mBlockedby = "Proxy blocker";
 132+ }
 133+ }
126134 }
127135
128136 function isBlocked()
129137 {
130138 $this->getBlockedStatus();
131 - if ( 0 == $this->mBlockedby ) { return false; }
 139+ if ( 0 === $this->mBlockedby ) { return false; }
132140 return true;
133141 }
134142
Index: trunk/phase3/includes/DefaultSettings.php
@@ -181,6 +181,7 @@
182182 $wgProxyScriptPath = "$IP/proxy_check.php";
183183 $wgProxyMemcExpiry = 86400;
184184 $wgProxyKey = 'W1svekXc5u6lZllTZOwnzEk1nbs';
 185+$wgProxyList = array(); # big list of banned IP addresses, in the keys not the values
185186
186187 # Client-side caching:
187188 $wgCachePages = true; # Allow client-side caching of pages
@@ -371,6 +372,8 @@
372373 # Text matching this regular expression will be recognised as spam
373374 # See http://en.wikipedia.org/wiki/Regular_expression
374375 $wgSpamRegex = false;
 376+# Similarly if this function returns true
 377+$wgFilterCallback = false;
375378
376379 # Go button goes straight to the edit screen if the article doesn't exist
377380 $wgGoToEdit = false;
Index: trunk/phase3/includes/EditPage.php
@@ -114,7 +114,7 @@
115115 global $wgLang, $wgParser, $wgTitle;
116116 global $wgAllowAnonymousMinor;
117117 global $wgWhitelistEdit;
118 - global $wgSpamRegex;
 118+ global $wgSpamRegex, $wgFilterCallback;
119119
120120 $sk = $wgUser->getSkin();
121121 $isConflict = false;
@@ -137,14 +137,13 @@
138138 if ( "save" == $formtype ) {
139139 # Check for spam
140140 if ( $wgSpamRegex && preg_match( $wgSpamRegex, $this->textbox1 ) ) {
141 - if ( $wgUser->isSysop() ) {
142 - $this->spamPage();
143 - } else {
144 - sleep(10);
145 - $wgOut->redirect( $this->mTitle->getFullURL() );
146 - }
147 - return;
 141+ $this->spamPage();
 142+ return;
148143 }
 144+ if ( $wgFilterCallback && $wgFilterCallback( $this->mTitle, $this->textbox1, $this->section ) ) {
 145+ # Error messages or other handling should be performed by the filter function
 146+ return;
 147+ }
149148 if ( $wgUser->isBlocked() ) {
150149 $this->blockedIPpage();
151150 return;
@@ -467,7 +466,11 @@
468467 $reason = $wgUser->blockedFor();
469468 $ip = $wgIP;
470469
471 - $name = User::whoIs( $id );
 470+ if ( is_string( $id ) ) {
 471+ $name = $id;
 472+ } else {
 473+ $name = User::whoIs( $id );
 474+ }
472475 $link = "[[" . $wgLang->getNsText( Namespace::getUser() ) .
473476 ":{$name}|{$name}]]";
474477
@@ -491,13 +494,12 @@
492495
493496 function spamPage()
494497 {
495 - global $wgOut, $wgSpamRegex;
 498+ global $wgOut;
496499 $wgOut->setPageTitle( wfMsg( "spamprotectiontitle" ) );
497500 $wgOut->setRobotpolicy( "noindex,nofollow" );
498501 $wgOut->setArticleRelated( false );
499502
500503 $wgOut->addWikiText( wfMsg( "spamprotectiontext" ) );
501 - $wgOut->addWikiText( "<pre>".$wgSpamRegex."</pre>" );
502504 $wgOut->returnToMain( false );
503505 }
504506

Status & tagging log

  • 01:56, 13 October 2010 ^demon (Talk | contribs) changed the status of r4130 [removed: new added: old]
Personal tools
Namespaces

Variants
Views
Actions
Navigation
Support
Download
Development
Communication
Toolbox