MediaWiki
1.30.2
|
A class to check request restrictions expressed as a JSON object. More...
Public Member Functions | |
__toString () | |
check (WebRequest $request) | |
Test against the passed WebRequest. More... | |
checkIP ( $ip) | |
Test an IP address. More... | |
toArray () | |
Return the restrictions as an array. More... | |
toJson ( $pretty=false) | |
Return the restrictions as a JSON string. More... | |
Static Public Member Functions | |
static | newDefault () |
static | newFromArray (array $restrictions) |
static | newFromJson ( $json) |
Protected Member Functions | |
__construct (array $restrictions=null) | |
Private Member Functions | |
loadFromArray (array $restrictions) | |
Private Attributes | |
$ipAddresses = [ '0.0.0.0/0', '::/0' ] | |
A class to check request restrictions expressed as a JSON object.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. http://www.gnu.org/copyleft/gpl.html A class to check request restrictions expressed as a JSON object
Definition at line 24 of file MWRestrictions.php.
|
protected |
array | $restrictions |
InvalidArgumentException |
Definition at line 32 of file MWRestrictions.php.
References loadFromArray().
MWRestrictions::__toString | ( | ) |
Definition at line 115 of file MWRestrictions.php.
References toJson().
MWRestrictions::check | ( | WebRequest | $request | ) |
Test against the passed WebRequest.
WebRequest | $request |
Definition at line 124 of file MWRestrictions.php.
References checkIP(), WebRequest\getIP(), and StatusValue\newGood().
MWRestrictions::checkIP | ( | $ip | ) |
Test an IP address.
string | $ip |
Definition at line 138 of file MWRestrictions.php.
References as, and IP\isInRange().
Referenced by check().
|
private |
Definition at line 67 of file MWRestrictions.php.
References $keys, as, and IP\isIPAddress().
Referenced by __construct().
|
static |
Definition at line 41 of file MWRestrictions.php.
Referenced by HTMLRestrictionsField\getDefault(), BotPassword\newUnsaved(), ApiLoginTest\testBotPassword(), HTMLRestrictionsFieldTest\testConstruct(), MWRestrictionsTest\testNewDefault(), and BotPasswordTest\testUnsaved().
|
static |
array | $restrictions |
InvalidArgumentException |
Definition at line 50 of file MWRestrictions.php.
Referenced by HTMLRestrictionsField\loadDataFromRequest(), MWRestrictionsTest\setUpBeforeClass(), and MWRestrictionsTest\testArray().
|
static |
string | $json | JSON representation of the restrictions |
InvalidArgumentException |
Definition at line 59 of file MWRestrictions.php.
References FormatJson\decode().
Referenced by BotPassword\__construct(), MWRestrictionsTest\testJson(), BotPasswordTest\testSave(), and BotPasswordTest\testUnsaved().
MWRestrictions::toArray | ( | ) |
Return the restrictions as an array.
Definition at line 100 of file MWRestrictions.php.
References $ipAddresses.
Referenced by toJson().
MWRestrictions::toJson | ( | $pretty = false | ) |
Return the restrictions as a JSON string.
bool | string | $pretty | Pretty-print the JSON output, see FormatJson::encode |
Definition at line 111 of file MWRestrictions.php.
References FormatJson\ALL_OK, FormatJson\encode(), and toArray().
Referenced by __toString().
|
private |
Definition at line 26 of file MWRestrictions.php.
Referenced by toArray().