summaryrefslogtreecommitdiff
path: root/extensions/SimpleAntiSpam/SimpleAntiSpam.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-11-14 23:19:13 +0100
committerPierre Schmitz <pierre@archlinux.de>2013-11-14 23:19:13 +0100
commitaf4da56f1ad4d3ef7b06557bae365da2ea27a897 (patch)
treec018c4033c36be77f9ec699cfd485be82c7542d7 /extensions/SimpleAntiSpam/SimpleAntiSpam.php
parent91e194556c52d2f354344f930419eef2dd6267f0 (diff)
Update to MediaWiki 1.21.3
Diffstat (limited to 'extensions/SimpleAntiSpam/SimpleAntiSpam.php')
-rw-r--r--extensions/SimpleAntiSpam/SimpleAntiSpam.php69
1 files changed, 69 insertions, 0 deletions
diff --git a/extensions/SimpleAntiSpam/SimpleAntiSpam.php b/extensions/SimpleAntiSpam/SimpleAntiSpam.php
new file mode 100644
index 00000000..82fff7bc
--- /dev/null
+++ b/extensions/SimpleAntiSpam/SimpleAntiSpam.php
@@ -0,0 +1,69 @@
+<?php
+/**
+ * SimpleSpam extension by Ryan Schmidt
+ * Adds a simple spam/bot check to forms
+ * Does not affect real users in any way/shape/form
+ */
+
+if ( !defined( 'MEDIAWIKI' ) ) {
+ echo <<<EOM
+ This is an extension to the MediaWiki software and cannot be used standalone.\n
+ To install this on the wiki, add the following line to LocalSettings.php:\n
+ <tt>require_once( "\$IP/extensions/SimpleAntiSpam/SimpleAntiSpam.php" );</tt>\n
+ To verify the installation, browse to the Special:Version page on your wiki.\n
+EOM;
+ die( 1 );
+}
+
+$wgExtensionCredits['antispam'][] = array(
+ 'path' => __FILE__,
+ 'name' => 'SimpleAntiSpam',
+ 'descriptionmsg' => 'simpleantispam-desc',
+ 'author' => 'Ryan Schmidt',
+ 'url' => 'https://www.mediawiki.org/wiki/Extension:SimpleAntiSpam',
+ 'version' => '1.1.0',
+);
+
+$wgExtensionMessagesFiles['SimpleAntiSpam'] = __DIR__ . '/SimpleAntiSpam.i18n.php';
+$wgHooks['EditPage::showEditForm:fields'][] = 'efSimpleAntiSpamField';
+$wgHooks['EditPage::attemptSave'][] = 'efSimpleAntiSpamCheck';
+
+/**
+ * Add the form field
+ * @param $editpage EditPage
+ * @param $out OutputPage
+ * @return bool
+ */
+function efSimpleAntiSpamField( &$editpage, &$out ) {
+ $out->addHTML( "<div id=\"antispam-container\" style=\"display: none;\">
+<label for=\"wpAntispam\">"
+ . wfMessage( 'simpleantispam-label' )->parse()
+ . "</label> <input type=\"text\" name=\"wpAntispam\" id=\"wpAntispam\" value=\"\" />
+</div>\n" );
+ return true;
+}
+
+/**
+ * Check for the field and if it isn't empty, negate the save
+ *
+ * @param $editpage EditPage
+ * @return bool
+ */
+function efSimpleAntiSpamCheck( $editpage ) {
+ global $wgRequest, $wgUser;
+ $spam = $wgRequest->getText( 'wpAntispam' );
+ if ( $spam !== '' ) {
+ wfDebugLog(
+ 'SimpleAntiSpam',
+ $wgUser->getName() .
+ ' editing "' .
+ $editpage->mTitle->getPrefixedText() .
+ '" submitted bogus field "' .
+ $spam .
+ '"'
+ );
+ $editpage->spamPageWithContent();
+ return false;
+ }
+ return true;
+}