r181 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r180‎ | r181 | r182 >
Date:21:22, 20 February 2002
Author:magnus_manske
Status:old
Tags:
Comment:
blocking IPs, finished
Modified paths:
  • /trunk/phpwiki/fpw/basicFunctions.php (modified) (history)
  • /trunk/phpwiki/fpw/wikiTextEn.php (modified) (history)

Diff [purge]

Index: trunk/phpwiki/fpw/basicFunctions.php
@@ -60,10 +60,17 @@
6161 return strtr ( $str , $wikiUpperChars , $wikiLowerChars );
6262 }
6363
 64+function isBlockedIP () {
 65+ $ip = getenv ( REMOTE_ADDR ) ;
 66+ $list = getMySQL ( "cur" , "cur_text" , "cur_title=\"Wikipedia:Blocked_IPs\"" ) ;
 67+ $list = explode ( "*$ip (" , $list ) ; # The most memory-wasting substring search ever!
 68+ if ( count ( $list ) > 1 ) return true ;
 69+ return false ;
 70+ }
6471
6572 # Called when editing/saving a page
6673 function edit ( $title ) {
67 - global $EditBox , $SaveButton , $PreviewButton , $MinorEdit , $FromEditForm ;
 74+ global $EditBox , $SaveButton , $PreviewButton , $MinorEdit , $FromEditForm , $wikiIPblocked ;
6875 global $user , $CommentBox , $vpage , $EditTime , $wikiDescribePage , $wikiUser ;
6976 global $wikiCannotEditPage , $wikiEditConflictMessage , $wikiPreviewAppend , $wikiEditHelp , $wikiRecodeInput ;
7077 global $wikiSummary , $wikiMinorEdit , $wikiCopyrightNotice , $wikiSave , $wikiPreview , $wikiDontSaveChanges ;
@@ -101,12 +108,10 @@
102109 $editConflict = true ;
103110 }
104111 }
105 - if ( $doSave ) {
 112+ if ( $doSave ) { # Actually saving the article!
106113 $text = $EditBox ;
107114 $text = str_replace ( "\\'" , "'" , $text ) ;
108115 $text = str_replace ( "\\\"" , "\"" , $text ) ;
109 -# $text = urldecode ( $text ) ;
110 -# $text = str_replace ( "&" , "&" , $text ) ;
111116 if ( $user->isLoggedIn ) $text = str_replace ( "~~~" , "[[$wikiUser:$user->name|$user->name]]" , $text ) ;
112117 else $text = str_replace ( "~~~" , $user->getLink() , $text ) ;
113118 $title = str_replace ( "\\'" , "'" , $title ) ;
@@ -116,6 +121,10 @@
117122 $npage->makeAll () ;
118123 if ( $npage->doesTopicExist() ) $npage->backup() ;
119124 else { $MinorEdit = 2 ; $npage->ensureExistence () ; }
 125+
 126+ # Checking for blocked IP
 127+ if ( isBlockedIP() ) return $wikiIPblocked ;
 128+
120129 if ( !$user->isLoggedIn ) $npage->setEntry ( $text , $CommentBox , 0 , $user->getLink() , $MinorEdit*1 ) ;
121130 else $npage->setEntry ( $text , $CommentBox , $user->id , $user->name , $MinorEdit*1 ) ;
122131 global $wasSaved ;
Index: trunk/phpwiki/fpw/wikiTextEn.php
@@ -95,6 +95,7 @@
9696 $wikiCounter = "This page has been accessed $1 times." ;
9797 $wikiBlockIPTitle = "Block an IP (sysops only)" ;
9898 $wikiBlockIPText = "IP $1 was blocked by $2" ;
 99+$wikiIPblocked = "<font color=red size='+1'>Your IP has been blocked! Your edits will not be saved. Please contact a sysop to have the block removed, or try again later.</font>" ;
99100
100101 # Interwiki links
101102 $wikiInterwiki = array ( "w"=>"http://www.wikipedia.com/wiki/$1" , "m"=>"http://meta.wikipedia.com/wiki.phtml?title=$1" ) ;

Status & tagging log