http://www.mediawiki.org/wiki/Special:Code/MediaWiki/74153
Revision: 74153
Author: platonides
Date: 2010-10-02 21:17:29 +0000 (Sat, 02 Oct 2010)
Log Message:
-----------
Stylize
Modified Paths:
--------------
trunk/extensions/ArticleComments/ArticleComments.php
Modified: trunk/extensions/ArticleComments/ArticleComments.php
===================================================================
--- trunk/extensions/ArticleComments/ArticleComments.php 2010-10-02
21:13:32 UTC (rev 74152)
+++ trunk/extensions/ArticleComments/ArticleComments.php 2010-10-02
21:17:29 UTC (rev 74153)
@@ -5,7 +5,7 @@
* @author Platonides
* @version 0.5
* @copyright Copyright (C) 2007 Jim R. Wilson
- * @license The MIT License -
http://www.opensource.org/licenses/mit-license.php
+ * @license The MIT License -
http://www.opensource.org/licenses/mit-license.php
* -----------------------------------------------------------------------
* Description:
* This is a MediaWiki (http://www.mediawiki.org/) extension which adds
support
@@ -49,38 +49,38 @@
* Initial release.
* -----------------------------------------------------------------------
* Copyright (c) 2007 Jim R. Wilson
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
copy
- * of this software and associated documentation files (the "Software"), to
deal
- * in the Software without restriction, including without limitation the
rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of
- * the Software, and to permit persons to whom the Software is furnished to do
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
deal
+ * in the Software without restriction, including without limitation the
rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of
+ * the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
all
+ *
+ * The above copyright notice and this permission notice shall be included in
all
* copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
* -----------------------------------------------------------------------
*/
-
+
# Confirm MW environment
-if (!defined('MEDIAWIKI')) die();
+if ( !defined( 'MEDIAWIKI' ) ) die();
# Credits
$wgExtensionCredits['other'][] = array(
- 'name'=>'ArticleComments',
- 'author'=>'Jim R. Wilson - wilson.jim.r <at> gmail.com',
- 'url'=>'http://jimbojw.com/wiki/index.php?title=ArticleComments',
- 'description'=>'Enables comment sections on article pages.',
- 'version'=>'0.5'
+ 'name' => 'ArticleComments',
+ 'author' => 'Jim R. Wilson - wilson.jim.r <at> gmail.com',
+ 'url' => 'http://jimbojw.com/wiki/index.php?title=ArticleComments',
+ 'description' => 'Enables comment sections on article pages.',
+ 'version' => '0.5'
);
# Add Extension Functions
@@ -128,7 +128,7 @@
# Hide content from the Parser using base64 to avoid mangling.
# Note: Content will be decoded after Tidy has finished its processing of
the page.
- return '<pre>@ENCODED@'.base64_encode($commentForm).'@ENCODED@</pre>';
+ return '<pre>@ENCODED@' . base64_encode( $commentForm ) .
'@ENCODED@</pre>';
}
/**
@@ -139,15 +139,15 @@
function wfArticleCommentsAfterContent( $data, $skin ) {
global $wgRequest, $wgArticleCommentsNSDisplayList;
-
+
# Short circuit for anything other than action=view or action=purge
- if ($wgRequest->getVal('action') &&
- $wgRequest->getVal('action')!='view' &&
- $wgRequest->getVal('action')!='purge'
+ if ( $wgRequest->getVal( 'action' ) &&
+ $wgRequest->getVal( 'action' ) != 'view' &&
+ $wgRequest->getVal( 'action' ) != 'purge'
) return true;
-
+
# Short-circuit if displaylist is undefined, empty or null
- if ($wgArticleCommentsNSDisplayList == null)
+ if ( $wgArticleCommentsNSDisplayList == null )
return true;
$title = $skin->getTitle();
@@ -157,13 +157,13 @@
# Ensure that the namespace list is an actual list
$nsList = $wgArticleCommentsNSDisplayList;
- if (!is_array($nsList)) $nsList = array($nsList);
-
+ if ( !is_array( $nsList ) ) $nsList = array( $nsList );
+
# Display the form
- if (in_array($title->getNamespace(), $nsList)) {
+ if ( in_array( $title->getNamespace(), $nsList ) ) {
$data .= wfArticleCommentForm( $title );
}
-
+
return true;
}
@@ -175,10 +175,10 @@
function wfArticleCommentForm( $title, $params = array() ) {
global $wgArticleCommentDefaults;
- # Merge in global defaults if specified
+ # Merge in global defaults if specified
$tmp = $wgArticleCommentDefaults;
foreach ( $params as $k => $v ) {
- $tmp[strtolower($k)] = (bool)strcasecmp( $v, "false" );
+ $tmp[strtolower( $k )] = (bool)strcasecmp( $v, "false" );
}
$params = $tmp;
$ac = 'article-comments-';
@@ -190,21 +190,21 @@
$content .= '<p>';
$content .= Html::hidden( 'commentArticle', $title->getPrefixedDBkey()
);
- $content .= '<label for="commenterName">' . wfMsgExt($ac.'name-field',
array( 'parseinline', 'content' ) ) . Html::element('br') . '</label>';
- $content .= Html::input( 'commenterName', '', 'text', array(
'id'=>'commenterName' ) );
+ $content .= '<label for="commenterName">' . wfMsgExt( $ac .
'name-field', array( 'parseinline', 'content' ) ) . Html::element( 'br' ) .
'</label>';
+ $content .= Html::input( 'commenterName', '', 'text', array( 'id' =>
'commenterName' ) );
$content .= '</p>';
if ( $params['showurlfield'] ) {
- $content .= '<p><label for="commenterURL">' .
wfMsgExt($ac.'url-field', array( 'parseinline', 'content' ) ) .
Html::element('br') . '</label>';
- $content .= Html::input( 'commenterURL', 'http://', 'text',
array( 'id'=>'commenterURL' ) );
+ $content .= '<p><label for="commenterURL">' . wfMsgExt( $ac .
'url-field', array( 'parseinline', 'content' ) ) . Html::element( 'br' ) .
'</label>';
+ $content .= Html::input( 'commenterURL', 'http://', 'text',
array( 'id' => 'commenterURL' ) );
$content .= '</p>';
}
-
- $content .= '<p><label for="comment">'.wfMsgExt($ac.'comment-field',
array( 'parseinline', 'content' ) ) . Html::element('br') . '</label>';
-
+
+ $content .= '<p><label for="comment">' . wfMsgExt( $ac .
'comment-field', array( 'parseinline', 'content' ) ) . Html::element( 'br' ) .
'</label>';
+
$content .= '<textarea id="comment" name="comment" style="width:30em"
rows="5">' . '</textarea></p>';
- $content .= '<p>' . Html::input( 'comment-submit', wfMsgForContent(
$ac.'submit-button' ), 'submit' ) . '</p>';
+ $content .= '<p>' . Html::input( 'comment-submit', wfMsgForContent( $ac
. 'submit-button' ), 'submit' ) . '</p>';
$content .= '</form></div>';
# Short-circuit if noScript has been set to anything other than false
@@ -216,51 +216,51 @@
$content .= "<script type='text/javascript'>//<![CDATA[\n(function(){\n";
# Prefill the name field if the user is logged in.
- $content .=
- 'var prefillUserName = function(){'."\n".
- 'var ptu=document.getElementById("pt-userpage");'."\n".
- 'if (ptu) document.getElementById("commenterName").value='.
- 'ptu.getElementsByTagName("a")[0].innerHTML;};'."\n".
- 'if (window.addEventListener) window.addEventListener'.
- '("load",prefillUserName,false);'."\n".
- 'else if (window.attachEvent) window.attachEvent'.
- '("onload",prefillUserName);'."\n";
+ $content .=
+ 'var prefillUserName = function(){' . "\n" .
+ 'var ptu=document.getElementById("pt-userpage");' . "\n" .
+ 'if (ptu) document.getElementById("commenterName").value=' .
+ 'ptu.getElementsByTagName("a")[0].innerHTML;};' . "\n" .
+ 'if (window.addEventListener) window.addEventListener' .
+ '("load",prefillUserName,false);' . "\n" .
+ 'else if (window.attachEvent) window.attachEvent' .
+ '("onload",prefillUserName);' . "\n";
# Prefill comment text if it has been specified by a system message
# Note: This is done dynamically with JavaScript since it would be annoying
# for JS-disabled browsers to have the prefilled text (since they'd have
# to manually delete it) and would break parser output caching
- $pretext = wfMsgForContent($ac.'prefilled-comment-text');
- if ($pretext) {
+ $pretext = wfMsgForContent( $ac . 'prefilled-comment-text' );
+ if ( $pretext ) {
$content .=
- 'var comment = document.getElementById("comment");'."\n".
- 'comment._everFocused=false;'."\n".
- 'comment.innerHTML="'.htmlspecialchars($pretext).'";'."\n".
- 'var clearCommentOnFirstFocus = function() {'."\n".
- 'var c=document.getElementById("comment");'."\n".
- 'if (!c._everFocused) {'."\n".
- 'c._everFocused=true;'."\n".
- 'c.value="";}}'."\n".
- 'if (comment.addEventListener) comment.addEventListener'.
- '("focus",clearCommentOnFirstFocus,false);'."\n".
- 'else if (comment.attachEvent) comment.attachEvent'.
- '("onfocus",clearCommentOnFirstFocus);'."\n";
+ 'var comment = document.getElementById("comment");' . "\n" .
+ 'comment._everFocused=false;' . "\n" .
+ 'comment.innerHTML="' . htmlspecialchars( $pretext ) . '";' . "\n"
.
+ 'var clearCommentOnFirstFocus = function() {' . "\n" .
+ 'var c=document.getElementById("comment");' . "\n" .
+ 'if (!c._everFocused) {' . "\n" .
+ 'c._everFocused=true;' . "\n" .
+ 'c.value="";}}' . "\n" .
+ 'if (comment.addEventListener) comment.addEventListener' .
+ '("focus",clearCommentOnFirstFocus,false);' . "\n" .
+ 'else if (comment.attachEvent) comment.attachEvent' .
+ '("onfocus",clearCommentOnFirstFocus);' . "\n";
}
# Hides the commentForm until the "Make a comment" link is clicked
# Note: To disable, set $wgArticleCommentDefaults['hideForm']=false in
LocalSettings.php
- if (!isset($params['hideform']) ||
- ($params['hideform']!='false' &&
- !$params['hideform']===false)) {
- $content .=
- 'var cf=document.getElementById("commentForm");'."\n".
- 'cf.style.display="none";'."\n".
- 'var p=document.createElement("p");'."\n".
- 'p.innerHTML="<a href=\'javascript:void(0)\' onclick=\''.
-
'document.getElementById(\\"commentForm\\").style.display=\\"block\\";'.
- 'this.style.display=\\"none\\";false'.
- '\'>'.wfMsgForContent($ac.'leave-comment-link').'</a>";'."\n".
- 'cf.parentNode.insertBefore(p,cf);'."\n";
+ if ( !isset( $params['hideform'] ) ||
+ ( $params['hideform'] != 'false' &&
+ !$params['hideform'] === false ) ) {
+ $content .=
+ 'var cf=document.getElementById("commentForm");' . "\n" .
+ 'cf.style.display="none";' . "\n" .
+ 'var p=document.createElement("p");' . "\n" .
+ 'p.innerHTML="<a href=\'javascript:void(0)\' onclick=\'' .
+
'document.getElementById(\\"commentForm\\").style.display=\\"block\\";' .
+ 'this.style.display=\\"none\\";false' .
+ '\'>' . wfMsgForContent( $ac . 'leave-comment-link' ) . '</a>";' .
"\n" .
+ 'cf.parentNode.insertBefore(p,cf);' . "\n";
}
$content .= "})();\n//]]></script>";
@@ -274,7 +274,7 @@
* @param String $text Article/Output text (passed by reference)
* @return Boolean Always tru to give other hooking methods a chance to run.
*/
-function wfProcessEncodedContent($out, $text) {
+function wfProcessEncodedContent( $out, $text ) {
$text = preg_replace(
'/<pre>\...@encoded@([0-9a-zA-Z\\+\\/]+=*)@enco...@\n<\\/pre>/e',
'base64_decode("$1")',
@@ -295,7 +295,7 @@
$commenterName = $wgRequest->getVal( 'commenterName' );
$commenterURL = trim( $wgRequest->getVal( 'commenterURL' ) );
$comment = $wgRequest->getVal( 'comment' );
-
+
// The default value is the same as not providing a URL
if ( $commenterURL == 'http://' ) {
$commenterURL = '';
@@ -308,30 +308,30 @@
$messages = array();
if ( !$wgRequest->wasPosted() )
- $messages[] = wfMsgForContent( $ac.'not-posted' );
+ $messages[] = wfMsgForContent( $ac . 'not-posted' );
- if ( $titleText === '' || !$title) {
+ if ( $titleText === '' || !$title ) {
$messages[] = wfMsgForContent(
- $ac.'invalid-field', wfMsgForContent($ac.'title-string'), $titleText );
+ $ac . 'invalid-field', wfMsgForContent( $ac . 'title-string' ),
$titleText );
}
-
- if (!$commenterName) $messages[] = wfMsgForContent(
- $ac.'required-field', wfMsgForContent($ac.'name-string'));
+ if ( !$commenterName ) $messages[] = wfMsgForContent(
+ $ac . 'required-field', wfMsgForContent( $ac . 'name-string' ) );
+
if ( !preg_match( "/^(" . wfUrlProtocols() . ')' .
Parser::EXT_LINK_URL_CLASS . '+$/', $commenterURL ) )
$messages[] = wfMsgForContent(
- $ac.'invalid-field', wfMsgForContent($ac.'url-string'), $commenterURL
);
+ $ac . 'invalid-field', wfMsgForContent( $ac . 'url-string' ),
$commenterURL );
- if (!$comment) $messages[] = wfMsgForContent(
- $ac.'required-field', wfMsgForContent($ac.'comment-string'));
- if (!empty($messages)) {
- $wgOut->setPageTitle(wfMsgForContent($ac.'submission-failed'));
+ if ( !$comment ) $messages[] = wfMsgForContent(
+ $ac . 'required-field', wfMsgForContent( $ac . 'comment-string' ) );
+ if ( !empty( $messages ) ) {
+ $wgOut->setPageTitle( wfMsgForContent( $ac . 'submission-failed' ) );
$wikiText = "<div class='errorbox'>";
- $wikiText .= wfMsgForContent($ac.'failure-reasons')."\n\n";
- foreach ($messages as $message) {
+ $wikiText .= wfMsgForContent( $ac . 'failure-reasons' ) . "\n\n";
+ foreach ( $messages as $message ) {
$wikiText .= "* $message\n";
}
- $wgOut->addWikiText($wikiText . "</div>");
+ $wgOut->addWikiText( $wikiText . "</div>" );
return;
}
@@ -342,12 +342,12 @@
$talkArticle = new Article( $talkTitle );
# Check whether user is blocked from editing the talk page
- if ($wgUser->isBlockedFrom($talkTitle)) {
- $wgOut->setPageTitle(wfMsgForContent($ac.'submission-failed'));
+ if ( $wgUser->isBlockedFrom( $talkTitle ) ) {
+ $wgOut->setPageTitle( wfMsgForContent( $ac . 'submission-failed' ) );
$wikiText = "<div class='errorbox'>";
- $wikiText .= wfMsgForContent($ac.'failure-reasons')."\n\n";
- $wikiText .= '* '.wfMsgForContent($ac.'user-is-blocked',
$talkTitle->getPrefixedText())."\n";
- $wgOut->addWikiText($wikiText . "</div>");
+ $wikiText .= wfMsgForContent( $ac . 'failure-reasons' ) . "\n\n";
+ $wikiText .= '* ' . wfMsgForContent( $ac . 'user-is-blocked',
$talkTitle->getPrefixedText() ) . "\n";
+ $wgOut->addWikiText( $wikiText . "</div>" );
return;
}
@@ -362,26 +362,26 @@
if ( $talkTitle->exists() ) {
$talkContent = $talkArticle->getContent();
}
-
-
+
+
# Check if talk NS is in the Namespace display list
# Note: if so, then there's no need to confirm that <comments /> appears
in the article or talk page.
global $wgArticleCommentsNSDisplayList;
$skipCheck = (
- is_array($wgArticleCommentsNSDisplayList) ?
- in_array($talkTitle->getNamespace(),$wgArticleCommentsNSDisplayList):
+ is_array( $wgArticleCommentsNSDisplayList ) ?
+ in_array( $talkTitle->getNamespace(), $wgArticleCommentsNSDisplayList
):
false
);
# Check whether the article or its talk page contains a <comments /> flag
- if (!$skipCheck &&
- preg_match('/<comments( +[^>]*)?\\/>/', $articleContent)===0 &&
- preg_match('/<comments( +[^>]*)?\\/>/', $talkContent)===0
+ if ( !$skipCheck &&
+ preg_match( '/<comments( +[^>]*)?\\/>/', $articleContent ) === 0 &&
+ preg_match( '/<comments( +[^>]*)?\\/>/', $talkContent ) === 0
) {
- $wgOut->setPageTitle(wfMsgForContent($ac.'submission-failed'));
+ $wgOut->setPageTitle( wfMsgForContent( $ac . 'submission-failed' ) );
$wgOut->addWikiText(
- "<div class='errorbox'>".
- wfMsgForContent($ac.'no-comments', $title->getPrefixedText()).
+ "<div class='errorbox'>" .
+ wfMsgForContent( $ac . 'no-comments', $title->getPrefixedText() ) .
"</div>"
);
return;
@@ -392,55 +392,55 @@
wfRunHooks( 'ArticleCommentsSpamCheck', array( $comment ,
$commenterName, $commenterURL, &$isspam ) );
# If it's spam - it's gone!
- if ($isspam) {
- $wgOut->setPageTitle(wfMsgForContent($ac.'submission-failed'));
+ if ( $isspam ) {
+ $wgOut->setPageTitle( wfMsgForContent( $ac . 'submission-failed' ) );
$wgOut->addWikiText(
- "<div class='errorbox'>".
- wfMsgForContent($ac.'no-spam').
+ "<div class='errorbox'>" .
+ wfMsgForContent( $ac . 'no-spam' ) .
"</div>"
);
return;
}
-
+
# Initialize the talk page's content.
if ( $talkContent == '' ) {
- $talkContent = wfMsgForContent($ac.'talk-page-starter',
$title->getPrefixedText() );
+ $talkContent = wfMsgForContent( $ac . 'talk-page-starter',
$title->getPrefixedText() );
}
-
+
# Determine signature components
- if ($commenterURL != '') $sigText = "[$commenterURL $commenterName]";
- else if ($wgUser->isLoggedIn()) $sigText = $wgParser->getUserSig( $wgUser
);
+ if ( $commenterURL != '' ) $sigText = "[$commenterURL $commenterName]";
+ else if ( $wgUser->isLoggedIn() ) $sigText = $wgParser->getUserSig(
$wgUser );
else $sigText = $commenterName;
-
+
# Search for insertion point, or append most recent comment.
$commentText = wfMsgForContent(
- $ac.'new-comment',
- wfMsgForContent($ac.'commenter-said', $commenterName),
+ $ac . 'new-comment',
+ wfMsgForContent( $ac . 'commenter-said', $commenterName ),
$comment,
$sigText,
'~~~~~'
);
-
+
$posAbove = stripos( $talkContent, '<!--COMMENTS_ABOVE-->' );
- if ($posAbove===false) $posBelow = stripos( $talkContent,
'<!--COMMENTS_BELOW-->' );
- if ($posAbove!==false) {
+ if ( $posAbove === false ) $posBelow = stripos( $talkContent,
'<!--COMMENTS_BELOW-->' );
+ if ( $posAbove !== false ) {
# Insert comments above HTML marker
$talkContent = substr( $talkContent, 0, $posAbove ) . $commentText .
substr( $talkContent, $posAbove );
- } else if ($posBelow!==false) {
+ } else if ( $posBelow !== false ) {
# Insert comments below HTML marker
$talkContent = substr( $talkContent, 0, $posBelow + 21 ) .
$commentText . substr( $talkContent, $posBelow + 21 );
} else {
# No marker found, append to bottom (default)
$talkContent .= $commentText;
}
-
+
# Update the talkArticle with the new comment
- $summary = wfMsgForContent($ac.'summary', $commenterName);
- $talkArticle->doEdit($talkContent, $summary);
+ $summary = wfMsgForContent( $ac . 'summary', $commenterName );
+ $talkArticle->doEdit( $talkContent, $summary );
- $wgOut->setPageTitle(wfMsgForContent($ac.'submission-succeeded'));
- $wgOut->addWikiText(wfMsgForContent($ac.'submission-success',
$title->getPrefixedText()));
- $wgOut->addWikiText(wfMsgForContent($ac.'submission-view-all',
$talkTitle->getPrefixedText()));
+ $wgOut->setPageTitle( wfMsgForContent( $ac . 'submission-succeeded' ) );
+ $wgOut->addWikiText( wfMsgForContent( $ac . 'submission-success',
$title->getPrefixedText() ) );
+ $wgOut->addWikiText( wfMsgForContent( $ac . 'submission-view-all',
$talkTitle->getPrefixedText() ) );
}
/**
@@ -452,16 +452,16 @@
* @param Boolean $isspam Whether the comment is spam (passed by reference)
* @return Boolean Always true to indicate other hooking methods may continue
to check for spam.
*/
-function defaultArticleCommentSpamCheck($comment, $commenterName,
$commenterURL, $isspam) {
+function defaultArticleCommentSpamCheck( $comment, $commenterName,
$commenterURL, $isspam ) {
# Short-circuit if spam has already been determined
- if ($isspam) return true;
- $fields = array($comment, $commenterName, $commenterURL);
-
+ if ( $isspam ) return true;
+ $fields = array( $comment, $commenterName, $commenterURL );
+
# Run everything through $wgSpamRegex if it has been specified
global $wgSpamRegex;
- if ($wgSpamRegex) {
- foreach ($fields as $field) {
+ if ( $wgSpamRegex ) {
+ foreach ( $fields as $field ) {
if ( preg_match( $wgSpamRegex, $field ) ) return $isspam = true;
}
}
@@ -471,23 +471,23 @@
'%\\[url=(https?|ftp)://%smi',
'%<a\\s+[^>]*href\\s*=\\s*[\'"]?\\s*(https?|ftp)://%smi'
);
- foreach ($spampatterns as $sp) {
- foreach (array($comment, $commenterName, $commenterURL) as $field) {
- if ( preg_match($sp, $field) ) return $isspam = true;
+ foreach ( $spampatterns as $sp ) {
+ foreach ( array( $comment, $commenterName, $commenterURL ) as $field )
{
+ if ( preg_match( $sp, $field ) ) return $isspam = true;
}
}
-
+
# Check for bad input for commenterName (seems to be a popular spam
location)
$spampatterns = array(
'%<a\\s+%smi',
'%(https?|ftp)://%smi',
'%(\\n|\\r)%smi'
);
- foreach ($spampatterns as $sp) if ( preg_match($sp, $commenterName) )
return $isspam = true;
-
+ foreach ( $spampatterns as $sp ) if ( preg_match( $sp, $commenterName ) )
return $isspam = true;
+
# Fail for length violations
- if ( strlen($commenterName)>255 || strlen($commenterURL)>300 ) return
$isspam = true;
-
+ if ( strlen( $commenterName ) > 255 || strlen( $commenterURL ) > 300 )
return $isspam = true;
+
# We made it this far, leave $isspam alone and give other implementors a
chance.
return true;
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs