Index: branches/raymond/ExemptFromAccountCreationThrottle/ExemptFromAccountCreationThrottle.i18n.php |
— | — | @@ -0,0 +1,25 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +$messages = array(); |
| 5 | + |
| 6 | +/** |
| 7 | + * @author Reedy |
| 8 | + */ |
| 9 | +$messages['en'] = array( |
| 10 | + 'exemptfromaccountcreationthrottle-desc' => '[[Special:ExemptFromAccountCreationThrottle|Exempte]] from the account creation throttle', |
| 11 | + 'efact-form' => 'Exempt an IP address from account creation throttle', |
| 12 | + 'efact-form-legend' => 'Input form', |
| 13 | + 'efact-intro' => 'To exempt an IP address from account creation throttle enter the IP address, date/time from/until and a reason.', |
| 14 | + 'efact-ipaddress' => 'IP address:', |
| 15 | + 'efact-time-start' => 'Date/time from:', |
| 16 | + 'efact-time-end' => 'Date/time until:', |
| 17 | + 'efact-reason' => 'Reason:', |
| 18 | + 'efact-reason-dropdown' => '* School |
| 19 | +** Test |
| 20 | +* U', |
| 21 | + 'efact-reasonotherlist' => 'Other reason', |
| 22 | + 'efact-otherreason' => 'Other reason:', |
| 23 | + 'efact-submit' => 'Submit', |
| 24 | + ); |
| 25 | + |
| 26 | + |
Property changes on: branches/raymond/ExemptFromAccountCreationThrottle/ExemptFromAccountCreationThrottle.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 27 | + native |
Index: branches/raymond/ExemptFromAccountCreationThrottle/ExemptFromAccountCreationThrottle.php |
— | — | @@ -0,0 +1,26 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * @copyright Copyright © 2011 Raimond Spekking |
| 5 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
| 6 | + */ |
| 7 | + |
| 8 | +$wgExtensionCredits['specialpage'][] = array( |
| 9 | + 'path' => __FILE__, |
| 10 | + 'name' => 'ExemptFromAccountCreationThrottle', |
| 11 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:ExemptFromAccountCreationThrottle', |
| 12 | + 'author' => 'Raimond Spekking', |
| 13 | + 'descriptionmsg' => 'exemptfromaccountcreationthrottle-desc', |
| 14 | +); |
| 15 | + |
| 16 | +$dir = dirname( __FILE__ ) . '/'; |
| 17 | + |
| 18 | +$wgAutoloadClasses['SpecialExemptFromAccountCreationThrottle'] = $dir . 'SpecialExemptFromAccountCreationThrottle.php'; |
| 19 | +$wgAutoloadClasses['ExemptFromAccountCreationThrottleHooks'] = $dir . 'ExemptFromAccountCreationThrottle.hooks.php'; |
| 20 | + |
| 21 | +$wgSpecialPages['ExemptFromAccountCreationThrottle'] = 'SpecialExemptFromAccountCreationThrottle'; |
| 22 | +$wgSpecialPageGroups['ExemptFromAccountCreationThrottle'] = 'other'; |
| 23 | + |
| 24 | +$wgExtensionMessagesFiles['ExemptFromAccountCreationThrottle'] = $dir . 'ExemptFromAccountCreationThrottle.i18n.php'; |
| 25 | +$wgExtensionAliasesFiles['ExemptFromAccountCreationThrottle'] = $dir . 'ExemptFromAccountCreationThrottle.alias.php'; |
| 26 | + |
| 27 | +$wgHooks['exemptFromAccountCreationThrottle'][] = 'ExemptFromAccountCreationThrottleHooks::checkIP'; |
Property changes on: branches/raymond/ExemptFromAccountCreationThrottle/ExemptFromAccountCreationThrottle.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 28 | + native |
Index: branches/raymond/ExemptFromAccountCreationThrottle/SpecialExemptFromAccountCreationThrottle.php |
— | — | @@ -0,0 +1,189 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * |
| 6 | + */ |
| 7 | +class SpecialExemptFromAccountCreationThrottle extends SpecialPage { |
| 8 | + |
| 9 | + public function __construct() { |
| 10 | + parent::__construct( 'ExemptFromAccountCreationThrottle' ); |
| 11 | + } |
| 12 | + |
| 13 | + public function execute( $par ) { |
| 14 | + global $wgOut, $wgRequest, $wgUser; |
| 15 | + $this->setHeaders(); |
| 16 | + $wgOut->setPageTitle( wfMsg( 'efact-form' ) ); |
| 17 | + |
| 18 | + $this->loadParameters( $par ); |
| 19 | + |
| 20 | + $errors = ''; |
| 21 | + if ( $this->mAction == 'success' ) { |
| 22 | + wfDebug( __METHOD__ . ": success.\n" ); |
| 23 | + $this->showSuccess(); |
| 24 | + } elseif ( $wgRequest->wasPosted() && count( $errors ) == 0 ) { |
| 25 | + |
| 26 | + $tokenOk = $wgUser->matchEditToken( $this->mtoken ); |
| 27 | + |
| 28 | + if ( !$tokenOk ) { |
| 29 | + wfDebug( __METHOD__ . ": bad token (" . ( $wgUser->isAnon() ? 'anon' : 'user' ) . "): $token\n" ); |
| 30 | + $wgOut->addWikiMsg( 'sessionfailure' ); |
| 31 | + $this->showForm(); |
| 32 | + } else { |
| 33 | + wfDebug( __METHOD__ . ": submit\n" ); |
| 34 | + $this->doSubmit(); |
| 35 | + } |
| 36 | + } else { |
| 37 | + wfDebug( __METHOD__ . ": form\n" ); |
| 38 | + var_dump('huhu'); |
| 39 | + $this->form( $errors ); |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | + public function form( $error ) { |
| 44 | + global $wgUser, $wgScript, $wgOut; |
| 45 | + |
| 46 | + $form = ''; |
| 47 | + |
| 48 | + // Introduction |
| 49 | + $wgOut->addWikiMsg( 'efact-intro' ); |
| 50 | + |
| 51 | + // Add errors |
| 52 | + $wgOut->addHTML( $error ); |
| 53 | + |
| 54 | + $form .= Xml::fieldset( wfMsg( 'efact-form-legend' ) ); |
| 55 | + $form .= Xml::openElement( 'form', |
| 56 | + array( 'method' => 'post', |
| 57 | + 'action' => $wgScript, |
| 58 | + 'name' => 'efact-form', |
| 59 | + 'id' => 'mw-efact-form' ) ); |
| 60 | + |
| 61 | + $form .= Html::hidden( 'title', SpecialPage::getTitleFor('ExemptFromAccountCreationThrottle')->getPrefixedText() ); |
| 62 | + |
| 63 | + $fields = array (); |
| 64 | + |
| 65 | + // Who to exempt |
| 66 | + $fields['efact-ipaddress'] = |
| 67 | + Xml::input( 'wpAddress', |
| 68 | + 45, |
| 69 | + $this->mAddress, |
| 70 | + array('id' => 'mw-efact-form-address' ) |
| 71 | + ); |
| 72 | + |
| 73 | + // Timeframe to exempt |
| 74 | + $fields['efact-time-start'] = |
| 75 | + Xml::input( |
| 76 | + 'wpTimeStart', |
| 77 | + 45, |
| 78 | + $this->mTimeStart, |
| 79 | + array( 'id' => 'mw-efact-time-start' ) |
| 80 | + ); |
| 81 | + |
| 82 | + $fields['efact-time-end'] = |
| 83 | + Xml::input( |
| 84 | + 'wpTimeEnd', |
| 85 | + 45, |
| 86 | + $this->mTimeEnd, |
| 87 | + array( 'id' => 'mw-efact-time-end' ) |
| 88 | + ); |
| 89 | + |
| 90 | + // Why to exempt them |
| 91 | + $fields['efact-reason'] = |
| 92 | + Xml::listDropDown( |
| 93 | + 'wpBlockReasonList', |
| 94 | + wfMsgForContent( 'efact-reason-dropdown' ), |
| 95 | + wfMsgForContent( 'efact-reasonotherlist' ), |
| 96 | + $this->mReasonList, |
| 97 | + 'mw-globalblock-reasonlist' |
| 98 | + ); |
| 99 | + |
| 100 | + $fields['efact-otherreason'] = |
| 101 | + Xml::input( |
| 102 | + 'wpReason', |
| 103 | + 45, |
| 104 | + $this->mReason, |
| 105 | + array( 'id' => 'mw-efact-reason' ) |
| 106 | + ); |
| 107 | + |
| 108 | + // Build a form. |
| 109 | + $form .= Xml::buildForm( $fields, 'efact-submit' ); |
| 110 | + |
| 111 | + $form .= Html::hidden( 'wpEditToken', $wgUser->editToken() ); |
| 112 | + |
| 113 | + $form .= Xml::closeElement( 'form' ); |
| 114 | + $form .= Xml::closeElement( 'fieldset' ); |
| 115 | + |
| 116 | + |
| 117 | + $wgOut->addHTML( $form ); |
| 118 | + |
| 119 | + } |
| 120 | + |
| 121 | + public function loadParameters( $par ) { |
| 122 | + global $wgRequest; |
| 123 | + $this->mAddress = trim( $wgRequest->getText( 'wpAddress' ) ); |
| 124 | + if (!$this->mAddress) |
| 125 | + $this->mAddress = $par; |
| 126 | + |
| 127 | + $this->mReason = $wgRequest->getText( 'wpReason' ); |
| 128 | + $this->mReasonList = $wgRequest->getText( 'wpBlockReasonList' ); |
| 129 | + $this->mTimeStart = $wgRequest->getText( 'wpTimeStart' ); |
| 130 | + $this->mTimeEnd = $wgRequest->getText( 'wpTimeEnd' ); |
| 131 | + $this->mtoken = $wgRequest->getVal( 'wpEditToken' ); |
| 132 | + $this->mAction = $wgRequest->getVal( 'action' ); |
| 133 | + |
| 134 | + } |
| 135 | + public function doSubmit() { |
| 136 | + global $wgOut, $wgUser, $wgLang; |
| 137 | + |
| 138 | + wfDebug( __METHOD__ . ": start\n" ); |
| 139 | + |
| 140 | + $dbw = wfGetDB( DB_MASTER ); |
| 141 | + $ok = $dbw->insert( |
| 142 | + 'petition', |
| 143 | + array( |
| 144 | + 'petition_title' => $this->fromtitle, |
| 145 | + 'petition_first_name' => $this->fromfirstname, |
| 146 | + 'petition_last_name' => $this->fromlastname, |
| 147 | + 'petition_street' => $this->fromstreet, |
| 148 | + 'petition_postcode' => $this->frompostcode, |
| 149 | + 'petition_city' => $this->fromcity, |
| 150 | + 'petition_country' => $this->fromcountry, |
| 151 | + 'petition_email' => $this->fromaddress, |
| 152 | + 'petition_authenticated' => null, |
| 153 | + 'petition_token' => $this->hash, |
| 154 | + 'petition_registration' => $dbw->timestamp(), |
| 155 | + 'petition_newsletter' => $this->newsletter, |
| 156 | + 'petition_infoletter' => $this->infoletter, |
| 157 | + 'petition_comment' => $this->comment, |
| 158 | + 'petition_ip' => wfGetIP(), |
| 159 | + 'petition_userlang' => $wgLang->getCode(), |
| 160 | + 'petition_campaign' => $this->campaign, |
| 161 | + ), |
| 162 | + __METHOD__ ); |
| 163 | + |
| 164 | + if ( $ok ) { |
| 165 | + wfDebugLog( 'Petition', |
| 166 | + "saving information OK for '$this->fromaddress'\n" ); |
| 167 | + } else { |
| 168 | + wfDebugLog( 'Petition', |
| 169 | + "saving information failed for '$this->fromaddress'\n" ); |
| 170 | + } |
| 171 | + |
| 172 | + |
| 173 | + wfDebug( __METHOD__ . ": success\n" ); |
| 174 | + |
| 175 | + $titleObj = SpecialPage::getTitleFor( 'ExemptFromAccountCreationThrottle' ); |
| 176 | + $wgOut->redirect( $titleObj->getFullURL( 'action=success' ) ); |
| 177 | + |
| 178 | + wfDebug( __METHOD__ . ": end\n" ); |
| 179 | + } |
| 180 | + |
| 181 | + public function showSuccess() { |
| 182 | + global $wgOut; |
| 183 | + |
| 184 | + $wgOut->setPageTitle( wfMsg( 'efact-success' ) ); |
| 185 | + $wgOut->addWikiMsg( 'efact-success-text' ); |
| 186 | + |
| 187 | + $wgOut->returnToMain( false ); |
| 188 | + } |
| 189 | +} |
| 190 | + |
Property changes on: branches/raymond/ExemptFromAccountCreationThrottle/SpecialExemptFromAccountCreationThrottle.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 191 | + native |
Index: branches/raymond/ExemptFromAccountCreationThrottle/ExemptFromAccountCreationThrottle.hooks.php |
— | — | @@ -0,0 +1,27 @@ |
| 2 | +<?php |
| 3 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 4 | + die(); |
| 5 | +} |
| 6 | + |
| 7 | +class ExemptFromAccountCreationThrottleHooks { |
| 8 | + |
| 9 | + public static function checkIP( $ip ) { |
| 10 | + $testIP = '::2'; |
| 11 | + |
| 12 | + if ( $ip == $testIP ) { |
| 13 | + wfDebugLog( 'CACT', "NOT TRHOTTLED: $ip is my IP address\n" ); |
| 14 | + return false; |
| 15 | + } else { |
| 16 | + wfDebugLog( 'CACT', "throttled: $ip is my IP address\n" ); |
| 17 | + return true; |
| 18 | + } |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + return false; |
| 24 | + } |
| 25 | + |
| 26 | +} |
| 27 | + |
| 28 | + |
Property changes on: branches/raymond/ExemptFromAccountCreationThrottle/ExemptFromAccountCreationThrottle.hooks.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 29 | + native |
Index: branches/raymond/ExemptFromAccountCreationThrottle/ExemptFromAccountCreationThrottle.alias.php |
— | — | @@ -0,0 +1,8 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +$specialPageAliases = array(); |
| 5 | + |
| 6 | +/** English (English) */ |
| 7 | +$specialPageAliases['en'] = array( |
| 8 | + 'ExemptFromAccountCreationThrottle' => array( 'ExemptFromAccountCreationThrottle', ), |
| 9 | +); |
\ No newline at end of file |
Property changes on: branches/raymond/ExemptFromAccountCreationThrottle/ExemptFromAccountCreationThrottle.alias.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 10 | + native |
Index: branches/raymond/ExemptFromAccountCreationThrottle/ExemptFromAccountCreationThrottle.sql |
— | — | @@ -0,0 +1,16 @@ |
| 2 | +CREATE TABLE /*$wgDBprefix*/efact ( |
| 3 | + efact_id int NOT NULL auto_increment, |
| 4 | + efact_address varchar(255) NOT NULL, |
| 5 | + efact_by varchar(255) NOT NULL, |
| 6 | + efact_reason TINYBLOB NOT NULL, |
| 7 | + efact_timestamp binary(14) NOT NULL, |
| 8 | + efact_time_start varbinary(32) NOT NULL, |
| 9 | + efact_time_end varbinary(32) NOT NULL, |
| 10 | + |
| 11 | + PRIMARY KEY efact_id (efact_id), |
| 12 | + |
| 13 | + INDEX efact_address (efact_address), |
| 14 | + |
| 15 | + INDEX efact_end_time (efact_time_start, efact_time_end), |
| 16 | + INDEX efact_timestamp (efact_timestamp) |
| 17 | +) /*$wgDBTableOptions*/; |
Property changes on: branches/raymond/ExemptFromAccountCreationThrottle/ExemptFromAccountCreationThrottle.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 18 | + native |
Property changes on: branches/raymond/ExemptFromAccountCreationThrottle |
___________________________________________________________________ |
Added: bugtraq:number |
2 | 19 | + true |
Property changes on: branches/raymond |
___________________________________________________________________ |
Added: bugtraq:number |
3 | 20 | + true |