@@ -16,16 +16,16 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | function smarty_modifier_date($input) |
| 18 | 18 | { |
| 19 | - if (gettype($input) === 'object' |
|
| 20 | - && (get_class($input) === DateTime::class || get_class($input) === DateTimeImmutable::class) |
|
| 21 | - ) { |
|
| 22 | - /** @var $date DateTime|DateTimeImmutable */ |
|
| 23 | - $date = $input; |
|
| 24 | - $dateString = $date->format('Y-m-d H:i:s'); |
|
| 19 | + if (gettype($input) === 'object' |
|
| 20 | + && (get_class($input) === DateTime::class || get_class($input) === DateTimeImmutable::class) |
|
| 21 | + ) { |
|
| 22 | + /** @var $date DateTime|DateTimeImmutable */ |
|
| 23 | + $date = $input; |
|
| 24 | + $dateString = $date->format('Y-m-d H:i:s'); |
|
| 25 | 25 | |
| 26 | - return $dateString; |
|
| 27 | - } |
|
| 28 | - else { |
|
| 29 | - return $input; |
|
| 30 | - } |
|
| 26 | + return $dateString; |
|
| 27 | + } |
|
| 28 | + else { |
|
| 29 | + return $input; |
|
| 30 | + } |
|
| 31 | 31 | } |
| 32 | 32 | \ No newline at end of file |
@@ -22,288 +22,288 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class RequestValidationHelper |
| 24 | 24 | { |
| 25 | - /** @var IBanHelper */ |
|
| 26 | - private $banHelper; |
|
| 27 | - /** @var Request */ |
|
| 28 | - private $request; |
|
| 29 | - private $emailConfirmation; |
|
| 30 | - /** @var PdoDatabase */ |
|
| 31 | - private $database; |
|
| 32 | - /** @var IAntiSpoofProvider */ |
|
| 33 | - private $antiSpoofProvider; |
|
| 34 | - /** @var IXffTrustProvider */ |
|
| 35 | - private $xffTrustProvider; |
|
| 36 | - /** @var HttpHelper */ |
|
| 37 | - private $httpHelper; |
|
| 38 | - /** |
|
| 39 | - * @var string |
|
| 40 | - */ |
|
| 41 | - private $mediawikiApiEndpoint; |
|
| 42 | - private $titleBlacklistEnabled; |
|
| 43 | - /** |
|
| 44 | - * @var TorExitProvider |
|
| 45 | - */ |
|
| 46 | - private $torExitProvider; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * Summary of __construct |
|
| 50 | - * |
|
| 51 | - * @param IBanHelper $banHelper |
|
| 52 | - * @param Request $request |
|
| 53 | - * @param string $emailConfirmation |
|
| 54 | - * @param PdoDatabase $database |
|
| 55 | - * @param IAntiSpoofProvider $antiSpoofProvider |
|
| 56 | - * @param IXffTrustProvider $xffTrustProvider |
|
| 57 | - * @param HttpHelper $httpHelper |
|
| 58 | - * @param string $mediawikiApiEndpoint |
|
| 59 | - * @param boolean $titleBlacklistEnabled |
|
| 60 | - * @param TorExitProvider $torExitProvider |
|
| 61 | - */ |
|
| 62 | - public function __construct( |
|
| 63 | - IBanHelper $banHelper, |
|
| 64 | - Request $request, |
|
| 65 | - $emailConfirmation, |
|
| 66 | - PdoDatabase $database, |
|
| 67 | - IAntiSpoofProvider $antiSpoofProvider, |
|
| 68 | - IXffTrustProvider $xffTrustProvider, |
|
| 69 | - HttpHelper $httpHelper, |
|
| 70 | - $mediawikiApiEndpoint, |
|
| 71 | - $titleBlacklistEnabled, |
|
| 72 | - TorExitProvider $torExitProvider |
|
| 73 | - ) { |
|
| 74 | - $this->banHelper = $banHelper; |
|
| 75 | - $this->request = $request; |
|
| 76 | - $this->emailConfirmation = $emailConfirmation; |
|
| 77 | - $this->database = $database; |
|
| 78 | - $this->antiSpoofProvider = $antiSpoofProvider; |
|
| 79 | - $this->xffTrustProvider = $xffTrustProvider; |
|
| 80 | - $this->httpHelper = $httpHelper; |
|
| 81 | - $this->mediawikiApiEndpoint = $mediawikiApiEndpoint; |
|
| 82 | - $this->titleBlacklistEnabled = $titleBlacklistEnabled; |
|
| 83 | - $this->torExitProvider = $torExitProvider; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * Summary of validateName |
|
| 88 | - * @return ValidationError[] |
|
| 89 | - */ |
|
| 90 | - public function validateName() |
|
| 91 | - { |
|
| 92 | - $errorList = array(); |
|
| 93 | - |
|
| 94 | - // ERRORS |
|
| 95 | - // name is empty |
|
| 96 | - if (trim($this->request->getName()) == "") { |
|
| 97 | - $errorList[ValidationError::NAME_EMPTY] = new ValidationError(ValidationError::NAME_EMPTY); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - // name is banned |
|
| 101 | - $ban = $this->banHelper->nameIsBanned($this->request->getName()); |
|
| 102 | - if ($ban != false) { |
|
| 103 | - $errorList[ValidationError::BANNED] = new ValidationError(ValidationError::BANNED); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - // username already exists |
|
| 107 | - if ($this->userExists()) { |
|
| 108 | - $errorList[ValidationError::NAME_EXISTS] = new ValidationError(ValidationError::NAME_EXISTS); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - // username part of SUL account |
|
| 112 | - if ($this->userSulExists()) { |
|
| 113 | - // using same error slot as name exists - it's the same sort of error, and we probably only want to show one. |
|
| 114 | - $errorList[ValidationError::NAME_EXISTS] = new ValidationError(ValidationError::NAME_EXISTS_SUL); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - // username is numbers |
|
| 118 | - if (preg_match("/^[0-9]+$/", $this->request->getName()) === 1) { |
|
| 119 | - $errorList[ValidationError::NAME_NUMONLY] = new ValidationError(ValidationError::NAME_NUMONLY); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - // username can't contain #@/<>[]|{} |
|
| 123 | - if (preg_match("/[" . preg_quote("#@/<>[]|{}", "/") . "]/", $this->request->getName()) === 1) { |
|
| 124 | - $errorList[ValidationError::NAME_INVALIDCHAR] = new ValidationError(ValidationError::NAME_INVALIDCHAR); |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - // existing non-closed request for this name |
|
| 128 | - if ($this->nameRequestExists()) { |
|
| 129 | - $errorList[ValidationError::OPEN_REQUEST_NAME] = new ValidationError(ValidationError::OPEN_REQUEST_NAME); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - return $errorList; |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Summary of validateEmail |
|
| 137 | - * @return ValidationError[] |
|
| 138 | - */ |
|
| 139 | - public function validateEmail() |
|
| 140 | - { |
|
| 141 | - $errorList = array(); |
|
| 142 | - |
|
| 143 | - // ERRORS |
|
| 144 | - |
|
| 145 | - // Email is banned |
|
| 146 | - $ban = $this->banHelper->emailIsBanned($this->request->getEmail()); |
|
| 147 | - if ($ban != false) { |
|
| 148 | - $errorList[ValidationError::BANNED] = new ValidationError(ValidationError::BANNED); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - // email addresses must match |
|
| 152 | - if ($this->request->getEmail() != $this->emailConfirmation) { |
|
| 153 | - $errorList[ValidationError::EMAIL_MISMATCH] = new ValidationError(ValidationError::EMAIL_MISMATCH); |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - // email address must be validly formed |
|
| 157 | - if (trim($this->request->getEmail()) == "") { |
|
| 158 | - $errorList[ValidationError::EMAIL_EMPTY] = new ValidationError(ValidationError::EMAIL_EMPTY); |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - // email address must be validly formed |
|
| 162 | - if (!filter_var($this->request->getEmail(), FILTER_VALIDATE_EMAIL)) { |
|
| 163 | - if (trim($this->request->getEmail()) != "") { |
|
| 164 | - $errorList[ValidationError::EMAIL_INVALID] = new ValidationError(ValidationError::EMAIL_INVALID); |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - // email address can't be wikimedia/wikipedia .com/org |
|
| 169 | - if (preg_match('/.*@.*wiki(m.dia|p.dia)\.(org|com)/i', $this->request->getEmail()) === 1) { |
|
| 170 | - $errorList[ValidationError::EMAIL_WIKIMEDIA] = new ValidationError(ValidationError::EMAIL_WIKIMEDIA); |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - // WARNINGS |
|
| 174 | - |
|
| 175 | - return $errorList; |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * Summary of validateOther |
|
| 180 | - * @return ValidationError[] |
|
| 181 | - */ |
|
| 182 | - public function validateOther() |
|
| 183 | - { |
|
| 184 | - $errorList = array(); |
|
| 185 | - |
|
| 186 | - $trustedIp = $this->xffTrustProvider->getTrustedClientIp($this->request->getIp(), |
|
| 187 | - $this->request->getForwardedIp()); |
|
| 188 | - |
|
| 189 | - // ERRORS |
|
| 190 | - |
|
| 191 | - // TOR nodes |
|
| 192 | - if ($this->torExitProvider->isTorExit($trustedIp)) { |
|
| 193 | - $errorList[ValidationError::BANNED] = new ValidationError(ValidationError::BANNED_TOR); |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - // IP banned |
|
| 197 | - $ban = $this->banHelper->ipIsBanned($trustedIp); |
|
| 198 | - if ($ban != false) { |
|
| 199 | - $errorList[ValidationError::BANNED] = new ValidationError(ValidationError::BANNED); |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - // WARNINGS |
|
| 203 | - |
|
| 204 | - // Antispoof check |
|
| 205 | - $this->checkAntiSpoof(); |
|
| 206 | - |
|
| 207 | - // Blacklist check |
|
| 208 | - $this->checkTitleBlacklist(); |
|
| 209 | - |
|
| 210 | - return $errorList; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - private function checkAntiSpoof() |
|
| 214 | - { |
|
| 215 | - try { |
|
| 216 | - if (count($this->antiSpoofProvider->getSpoofs($this->request->getName())) > 0) { |
|
| 217 | - // If there were spoofs an Admin should handle the request. |
|
| 218 | - $this->request->setStatus("Flagged users"); |
|
| 219 | - } |
|
| 220 | - } |
|
| 221 | - catch (Exception $ex) { |
|
| 222 | - // logme |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - private function checkTitleBlacklist() |
|
| 227 | - { |
|
| 228 | - if ($this->titleBlacklistEnabled == 1) { |
|
| 229 | - $apiResult = $this->httpHelper->get( |
|
| 230 | - $this->mediawikiApiEndpoint, |
|
| 231 | - array( |
|
| 232 | - 'action' => 'titleblacklist', |
|
| 233 | - 'tbtitle' => $this->request->getName(), |
|
| 234 | - 'tbaction' => 'new-account', |
|
| 235 | - 'tbnooverride' => true, |
|
| 236 | - 'format' => 'php', |
|
| 237 | - ) |
|
| 238 | - ); |
|
| 239 | - |
|
| 240 | - $data = unserialize($apiResult); |
|
| 241 | - |
|
| 242 | - $requestIsOk = $data['titleblacklist']['result'] == "ok"; |
|
| 243 | - |
|
| 244 | - if (!$requestIsOk) { |
|
| 245 | - $this->request->setStatus("Flagged users"); |
|
| 246 | - } |
|
| 247 | - } |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - private function userExists() |
|
| 251 | - { |
|
| 252 | - $userExists = $this->httpHelper->get( |
|
| 253 | - $this->mediawikiApiEndpoint, |
|
| 254 | - array( |
|
| 255 | - 'action' => 'query', |
|
| 256 | - 'list' => 'users', |
|
| 257 | - 'ususers' => $this->request->getName(), |
|
| 258 | - 'format' => 'php', |
|
| 259 | - ) |
|
| 260 | - ); |
|
| 261 | - |
|
| 262 | - $ue = unserialize($userExists); |
|
| 263 | - if (!isset ($ue['query']['users']['0']['missing']) && isset ($ue['query']['users']['0']['userid'])) { |
|
| 264 | - return true; |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - return false; |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - private function userSulExists() |
|
| 271 | - { |
|
| 272 | - $requestName = $this->request->getName(); |
|
| 273 | - |
|
| 274 | - $userExists = $this->httpHelper->get( |
|
| 275 | - $this->mediawikiApiEndpoint, |
|
| 276 | - array( |
|
| 277 | - 'action' => 'query', |
|
| 278 | - 'meta' => 'globaluserinfo', |
|
| 279 | - 'guiuser' => $requestName, |
|
| 280 | - 'format' => 'php', |
|
| 281 | - ) |
|
| 282 | - ); |
|
| 283 | - |
|
| 284 | - $ue = unserialize($userExists); |
|
| 285 | - if (isset ($ue['query']['globaluserinfo']['id'])) { |
|
| 286 | - return true; |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - return false; |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - /** |
|
| 293 | - * Checks if a request with this name is currently open |
|
| 294 | - * |
|
| 295 | - * @return bool |
|
| 296 | - */ |
|
| 297 | - private function nameRequestExists() |
|
| 298 | - { |
|
| 299 | - $query = "SELECT COUNT(id) FROM request WHERE status != 'Closed' AND name = :name;"; |
|
| 300 | - $statement = $this->database->prepare($query); |
|
| 301 | - $statement->execute(array(':name' => $this->request->getName())); |
|
| 302 | - |
|
| 303 | - if (!$statement) { |
|
| 304 | - return false; |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - return $statement->fetchColumn() > 0; |
|
| 308 | - } |
|
| 25 | + /** @var IBanHelper */ |
|
| 26 | + private $banHelper; |
|
| 27 | + /** @var Request */ |
|
| 28 | + private $request; |
|
| 29 | + private $emailConfirmation; |
|
| 30 | + /** @var PdoDatabase */ |
|
| 31 | + private $database; |
|
| 32 | + /** @var IAntiSpoofProvider */ |
|
| 33 | + private $antiSpoofProvider; |
|
| 34 | + /** @var IXffTrustProvider */ |
|
| 35 | + private $xffTrustProvider; |
|
| 36 | + /** @var HttpHelper */ |
|
| 37 | + private $httpHelper; |
|
| 38 | + /** |
|
| 39 | + * @var string |
|
| 40 | + */ |
|
| 41 | + private $mediawikiApiEndpoint; |
|
| 42 | + private $titleBlacklistEnabled; |
|
| 43 | + /** |
|
| 44 | + * @var TorExitProvider |
|
| 45 | + */ |
|
| 46 | + private $torExitProvider; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * Summary of __construct |
|
| 50 | + * |
|
| 51 | + * @param IBanHelper $banHelper |
|
| 52 | + * @param Request $request |
|
| 53 | + * @param string $emailConfirmation |
|
| 54 | + * @param PdoDatabase $database |
|
| 55 | + * @param IAntiSpoofProvider $antiSpoofProvider |
|
| 56 | + * @param IXffTrustProvider $xffTrustProvider |
|
| 57 | + * @param HttpHelper $httpHelper |
|
| 58 | + * @param string $mediawikiApiEndpoint |
|
| 59 | + * @param boolean $titleBlacklistEnabled |
|
| 60 | + * @param TorExitProvider $torExitProvider |
|
| 61 | + */ |
|
| 62 | + public function __construct( |
|
| 63 | + IBanHelper $banHelper, |
|
| 64 | + Request $request, |
|
| 65 | + $emailConfirmation, |
|
| 66 | + PdoDatabase $database, |
|
| 67 | + IAntiSpoofProvider $antiSpoofProvider, |
|
| 68 | + IXffTrustProvider $xffTrustProvider, |
|
| 69 | + HttpHelper $httpHelper, |
|
| 70 | + $mediawikiApiEndpoint, |
|
| 71 | + $titleBlacklistEnabled, |
|
| 72 | + TorExitProvider $torExitProvider |
|
| 73 | + ) { |
|
| 74 | + $this->banHelper = $banHelper; |
|
| 75 | + $this->request = $request; |
|
| 76 | + $this->emailConfirmation = $emailConfirmation; |
|
| 77 | + $this->database = $database; |
|
| 78 | + $this->antiSpoofProvider = $antiSpoofProvider; |
|
| 79 | + $this->xffTrustProvider = $xffTrustProvider; |
|
| 80 | + $this->httpHelper = $httpHelper; |
|
| 81 | + $this->mediawikiApiEndpoint = $mediawikiApiEndpoint; |
|
| 82 | + $this->titleBlacklistEnabled = $titleBlacklistEnabled; |
|
| 83 | + $this->torExitProvider = $torExitProvider; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * Summary of validateName |
|
| 88 | + * @return ValidationError[] |
|
| 89 | + */ |
|
| 90 | + public function validateName() |
|
| 91 | + { |
|
| 92 | + $errorList = array(); |
|
| 93 | + |
|
| 94 | + // ERRORS |
|
| 95 | + // name is empty |
|
| 96 | + if (trim($this->request->getName()) == "") { |
|
| 97 | + $errorList[ValidationError::NAME_EMPTY] = new ValidationError(ValidationError::NAME_EMPTY); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + // name is banned |
|
| 101 | + $ban = $this->banHelper->nameIsBanned($this->request->getName()); |
|
| 102 | + if ($ban != false) { |
|
| 103 | + $errorList[ValidationError::BANNED] = new ValidationError(ValidationError::BANNED); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + // username already exists |
|
| 107 | + if ($this->userExists()) { |
|
| 108 | + $errorList[ValidationError::NAME_EXISTS] = new ValidationError(ValidationError::NAME_EXISTS); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + // username part of SUL account |
|
| 112 | + if ($this->userSulExists()) { |
|
| 113 | + // using same error slot as name exists - it's the same sort of error, and we probably only want to show one. |
|
| 114 | + $errorList[ValidationError::NAME_EXISTS] = new ValidationError(ValidationError::NAME_EXISTS_SUL); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + // username is numbers |
|
| 118 | + if (preg_match("/^[0-9]+$/", $this->request->getName()) === 1) { |
|
| 119 | + $errorList[ValidationError::NAME_NUMONLY] = new ValidationError(ValidationError::NAME_NUMONLY); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + // username can't contain #@/<>[]|{} |
|
| 123 | + if (preg_match("/[" . preg_quote("#@/<>[]|{}", "/") . "]/", $this->request->getName()) === 1) { |
|
| 124 | + $errorList[ValidationError::NAME_INVALIDCHAR] = new ValidationError(ValidationError::NAME_INVALIDCHAR); |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + // existing non-closed request for this name |
|
| 128 | + if ($this->nameRequestExists()) { |
|
| 129 | + $errorList[ValidationError::OPEN_REQUEST_NAME] = new ValidationError(ValidationError::OPEN_REQUEST_NAME); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + return $errorList; |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Summary of validateEmail |
|
| 137 | + * @return ValidationError[] |
|
| 138 | + */ |
|
| 139 | + public function validateEmail() |
|
| 140 | + { |
|
| 141 | + $errorList = array(); |
|
| 142 | + |
|
| 143 | + // ERRORS |
|
| 144 | + |
|
| 145 | + // Email is banned |
|
| 146 | + $ban = $this->banHelper->emailIsBanned($this->request->getEmail()); |
|
| 147 | + if ($ban != false) { |
|
| 148 | + $errorList[ValidationError::BANNED] = new ValidationError(ValidationError::BANNED); |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + // email addresses must match |
|
| 152 | + if ($this->request->getEmail() != $this->emailConfirmation) { |
|
| 153 | + $errorList[ValidationError::EMAIL_MISMATCH] = new ValidationError(ValidationError::EMAIL_MISMATCH); |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + // email address must be validly formed |
|
| 157 | + if (trim($this->request->getEmail()) == "") { |
|
| 158 | + $errorList[ValidationError::EMAIL_EMPTY] = new ValidationError(ValidationError::EMAIL_EMPTY); |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + // email address must be validly formed |
|
| 162 | + if (!filter_var($this->request->getEmail(), FILTER_VALIDATE_EMAIL)) { |
|
| 163 | + if (trim($this->request->getEmail()) != "") { |
|
| 164 | + $errorList[ValidationError::EMAIL_INVALID] = new ValidationError(ValidationError::EMAIL_INVALID); |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + // email address can't be wikimedia/wikipedia .com/org |
|
| 169 | + if (preg_match('/.*@.*wiki(m.dia|p.dia)\.(org|com)/i', $this->request->getEmail()) === 1) { |
|
| 170 | + $errorList[ValidationError::EMAIL_WIKIMEDIA] = new ValidationError(ValidationError::EMAIL_WIKIMEDIA); |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + // WARNINGS |
|
| 174 | + |
|
| 175 | + return $errorList; |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * Summary of validateOther |
|
| 180 | + * @return ValidationError[] |
|
| 181 | + */ |
|
| 182 | + public function validateOther() |
|
| 183 | + { |
|
| 184 | + $errorList = array(); |
|
| 185 | + |
|
| 186 | + $trustedIp = $this->xffTrustProvider->getTrustedClientIp($this->request->getIp(), |
|
| 187 | + $this->request->getForwardedIp()); |
|
| 188 | + |
|
| 189 | + // ERRORS |
|
| 190 | + |
|
| 191 | + // TOR nodes |
|
| 192 | + if ($this->torExitProvider->isTorExit($trustedIp)) { |
|
| 193 | + $errorList[ValidationError::BANNED] = new ValidationError(ValidationError::BANNED_TOR); |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + // IP banned |
|
| 197 | + $ban = $this->banHelper->ipIsBanned($trustedIp); |
|
| 198 | + if ($ban != false) { |
|
| 199 | + $errorList[ValidationError::BANNED] = new ValidationError(ValidationError::BANNED); |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + // WARNINGS |
|
| 203 | + |
|
| 204 | + // Antispoof check |
|
| 205 | + $this->checkAntiSpoof(); |
|
| 206 | + |
|
| 207 | + // Blacklist check |
|
| 208 | + $this->checkTitleBlacklist(); |
|
| 209 | + |
|
| 210 | + return $errorList; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + private function checkAntiSpoof() |
|
| 214 | + { |
|
| 215 | + try { |
|
| 216 | + if (count($this->antiSpoofProvider->getSpoofs($this->request->getName())) > 0) { |
|
| 217 | + // If there were spoofs an Admin should handle the request. |
|
| 218 | + $this->request->setStatus("Flagged users"); |
|
| 219 | + } |
|
| 220 | + } |
|
| 221 | + catch (Exception $ex) { |
|
| 222 | + // logme |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + private function checkTitleBlacklist() |
|
| 227 | + { |
|
| 228 | + if ($this->titleBlacklistEnabled == 1) { |
|
| 229 | + $apiResult = $this->httpHelper->get( |
|
| 230 | + $this->mediawikiApiEndpoint, |
|
| 231 | + array( |
|
| 232 | + 'action' => 'titleblacklist', |
|
| 233 | + 'tbtitle' => $this->request->getName(), |
|
| 234 | + 'tbaction' => 'new-account', |
|
| 235 | + 'tbnooverride' => true, |
|
| 236 | + 'format' => 'php', |
|
| 237 | + ) |
|
| 238 | + ); |
|
| 239 | + |
|
| 240 | + $data = unserialize($apiResult); |
|
| 241 | + |
|
| 242 | + $requestIsOk = $data['titleblacklist']['result'] == "ok"; |
|
| 243 | + |
|
| 244 | + if (!$requestIsOk) { |
|
| 245 | + $this->request->setStatus("Flagged users"); |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + private function userExists() |
|
| 251 | + { |
|
| 252 | + $userExists = $this->httpHelper->get( |
|
| 253 | + $this->mediawikiApiEndpoint, |
|
| 254 | + array( |
|
| 255 | + 'action' => 'query', |
|
| 256 | + 'list' => 'users', |
|
| 257 | + 'ususers' => $this->request->getName(), |
|
| 258 | + 'format' => 'php', |
|
| 259 | + ) |
|
| 260 | + ); |
|
| 261 | + |
|
| 262 | + $ue = unserialize($userExists); |
|
| 263 | + if (!isset ($ue['query']['users']['0']['missing']) && isset ($ue['query']['users']['0']['userid'])) { |
|
| 264 | + return true; |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + return false; |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + private function userSulExists() |
|
| 271 | + { |
|
| 272 | + $requestName = $this->request->getName(); |
|
| 273 | + |
|
| 274 | + $userExists = $this->httpHelper->get( |
|
| 275 | + $this->mediawikiApiEndpoint, |
|
| 276 | + array( |
|
| 277 | + 'action' => 'query', |
|
| 278 | + 'meta' => 'globaluserinfo', |
|
| 279 | + 'guiuser' => $requestName, |
|
| 280 | + 'format' => 'php', |
|
| 281 | + ) |
|
| 282 | + ); |
|
| 283 | + |
|
| 284 | + $ue = unserialize($userExists); |
|
| 285 | + if (isset ($ue['query']['globaluserinfo']['id'])) { |
|
| 286 | + return true; |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + return false; |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + /** |
|
| 293 | + * Checks if a request with this name is currently open |
|
| 294 | + * |
|
| 295 | + * @return bool |
|
| 296 | + */ |
|
| 297 | + private function nameRequestExists() |
|
| 298 | + { |
|
| 299 | + $query = "SELECT COUNT(id) FROM request WHERE status != 'Closed' AND name = :name;"; |
|
| 300 | + $statement = $this->database->prepare($query); |
|
| 301 | + $statement->execute(array(':name' => $this->request->getName())); |
|
| 302 | + |
|
| 303 | + if (!$statement) { |
|
| 304 | + return false; |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + return $statement->fetchColumn() > 0; |
|
| 308 | + } |
|
| 309 | 309 | } |
@@ -10,27 +10,27 @@ |
||
| 10 | 10 | |
| 11 | 11 | class IrcColourCode |
| 12 | 12 | { |
| 13 | - const BOLD = "\x02"; |
|
| 14 | - const ITALIC = "\x09"; |
|
| 15 | - const STRIKE = "\x13"; |
|
| 16 | - const UNDERLINE = "\x15"; |
|
| 17 | - const UNDERLINE2 = "\x1f"; |
|
| 18 | - const REVERSE = "\x16"; |
|
| 19 | - const RESET = "\x0f"; |
|
| 20 | - const WHITE = "\x0300"; |
|
| 21 | - const BLACK = "\x0301"; |
|
| 22 | - const DARK_BLUE = "\x0302"; |
|
| 23 | - const DARK_GREEN = "\x0303"; |
|
| 24 | - const RED = "\x0304"; |
|
| 25 | - const DARK_RED = "\x0305"; |
|
| 26 | - const DARK_VIOLET = "\x0306"; |
|
| 27 | - const ORANGE = "\x0307"; |
|
| 28 | - const YELLOW = "\x0308"; |
|
| 29 | - const LIGHT_GREEN = "\x0309"; |
|
| 30 | - const CYAN = "\x0310"; |
|
| 31 | - const LIGHT_CYAN = "\x0311"; |
|
| 32 | - const BLUE = "\x0312"; |
|
| 33 | - const VIOLET = "\x0313"; |
|
| 34 | - const DARK_GREY = "\x0314"; |
|
| 35 | - const LIGHT_GREY = "\x0315"; |
|
| 13 | + const BOLD = "\x02"; |
|
| 14 | + const ITALIC = "\x09"; |
|
| 15 | + const STRIKE = "\x13"; |
|
| 16 | + const UNDERLINE = "\x15"; |
|
| 17 | + const UNDERLINE2 = "\x1f"; |
|
| 18 | + const REVERSE = "\x16"; |
|
| 19 | + const RESET = "\x0f"; |
|
| 20 | + const WHITE = "\x0300"; |
|
| 21 | + const BLACK = "\x0301"; |
|
| 22 | + const DARK_BLUE = "\x0302"; |
|
| 23 | + const DARK_GREEN = "\x0303"; |
|
| 24 | + const RED = "\x0304"; |
|
| 25 | + const DARK_RED = "\x0305"; |
|
| 26 | + const DARK_VIOLET = "\x0306"; |
|
| 27 | + const ORANGE = "\x0307"; |
|
| 28 | + const YELLOW = "\x0308"; |
|
| 29 | + const LIGHT_GREEN = "\x0309"; |
|
| 30 | + const CYAN = "\x0310"; |
|
| 31 | + const LIGHT_CYAN = "\x0311"; |
|
| 32 | + const BLUE = "\x0312"; |
|
| 33 | + const VIOLET = "\x0313"; |
|
| 34 | + const DARK_GREY = "\x0314"; |
|
| 35 | + const LIGHT_GREY = "\x0315"; |
|
| 36 | 36 | } |
@@ -17,25 +17,25 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class Session |
| 19 | 19 | { |
| 20 | - public static function start() |
|
| 21 | - { |
|
| 22 | - ini_set('session.cookie_httponly', 1); |
|
| 20 | + public static function start() |
|
| 21 | + { |
|
| 22 | + ini_set('session.cookie_httponly', 1); |
|
| 23 | 23 | |
| 24 | - if (WebRequest::isHttps()) { |
|
| 25 | - ini_set('session.cookie_secure', 1); |
|
| 26 | - } |
|
| 24 | + if (WebRequest::isHttps()) { |
|
| 25 | + ini_set('session.cookie_secure', 1); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - session_start(); |
|
| 29 | - } |
|
| 28 | + session_start(); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - public static function destroy() |
|
| 32 | - { |
|
| 33 | - session_destroy(); |
|
| 34 | - } |
|
| 31 | + public static function destroy() |
|
| 32 | + { |
|
| 33 | + session_destroy(); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - public static function restart() |
|
| 37 | - { |
|
| 38 | - self::destroy(); |
|
| 39 | - self::start(); |
|
| 40 | - } |
|
| 36 | + public static function restart() |
|
| 37 | + { |
|
| 38 | + self::destroy(); |
|
| 39 | + self::start(); |
|
| 40 | + } |
|
| 41 | 41 | } |
@@ -13,53 +13,53 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class DebugHelper |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * Internal mockable method wrapper for debug_backtrace. |
|
| 18 | - * |
|
| 19 | - * As mocking out debug_backtrace uses debug_backtrace internally, we need this in order to not cause a recursive |
|
| 20 | - * cascade until the runtime explodes. |
|
| 21 | - * |
|
| 22 | - * Instead, we mock this method, which allows debug_backtrace to still be called correctly. |
|
| 23 | - * |
|
| 24 | - * @return array |
|
| 25 | - */ |
|
| 26 | - public function get_debug_backtrace() |
|
| 27 | - { |
|
| 28 | - return debug_backtrace(); |
|
| 29 | - } |
|
| 16 | + /** |
|
| 17 | + * Internal mockable method wrapper for debug_backtrace. |
|
| 18 | + * |
|
| 19 | + * As mocking out debug_backtrace uses debug_backtrace internally, we need this in order to not cause a recursive |
|
| 20 | + * cascade until the runtime explodes. |
|
| 21 | + * |
|
| 22 | + * Instead, we mock this method, which allows debug_backtrace to still be called correctly. |
|
| 23 | + * |
|
| 24 | + * @return array |
|
| 25 | + */ |
|
| 26 | + public function get_debug_backtrace() |
|
| 27 | + { |
|
| 28 | + return debug_backtrace(); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Returns a string representation of the current backtrace for display. |
|
| 33 | - * |
|
| 34 | - * Note that this explicitly excludes the top two frames, which will be methods from this class. |
|
| 35 | - * |
|
| 36 | - * @return string |
|
| 37 | - */ |
|
| 38 | - public function getBacktrace() |
|
| 39 | - { |
|
| 40 | - $backtrace = $this->get_debug_backtrace(); |
|
| 31 | + /** |
|
| 32 | + * Returns a string representation of the current backtrace for display. |
|
| 33 | + * |
|
| 34 | + * Note that this explicitly excludes the top two frames, which will be methods from this class. |
|
| 35 | + * |
|
| 36 | + * @return string |
|
| 37 | + */ |
|
| 38 | + public function getBacktrace() |
|
| 39 | + { |
|
| 40 | + $backtrace = $this->get_debug_backtrace(); |
|
| 41 | 41 | |
| 42 | - $output = ""; |
|
| 42 | + $output = ""; |
|
| 43 | 43 | |
| 44 | - $count = 0; |
|
| 45 | - foreach ($backtrace as $line) { |
|
| 46 | - if ($count <= 1) { |
|
| 47 | - $count++; |
|
| 48 | - continue; |
|
| 49 | - } |
|
| 44 | + $count = 0; |
|
| 45 | + foreach ($backtrace as $line) { |
|
| 46 | + if ($count <= 1) { |
|
| 47 | + $count++; |
|
| 48 | + continue; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - $output .= "#{$count}: "; |
|
| 51 | + $output .= "#{$count}: "; |
|
| 52 | 52 | |
| 53 | - if (isset($line['type']) && $line['type'] != "") { |
|
| 54 | - $output .= $line['class'] . $line['type']; |
|
| 55 | - } |
|
| 53 | + if (isset($line['type']) && $line['type'] != "") { |
|
| 54 | + $output .= $line['class'] . $line['type']; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - $output .= $line['function'] . "(...)"; |
|
| 58 | - $output .= " [{$line['file']}#{$line['line']}\r\n"; |
|
| 57 | + $output .= $line['function'] . "(...)"; |
|
| 58 | + $output .= " [{$line['file']}#{$line['line']}\r\n"; |
|
| 59 | 59 | |
| 60 | - $count++; |
|
| 61 | - } |
|
| 60 | + $count++; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - return $output; |
|
| 64 | - } |
|
| 63 | + return $output; |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -12,16 +12,16 @@ |
||
| 12 | 12 | |
| 13 | 13 | class FakeBlacklistHelper implements IBlacklistHelper |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * Returns a value indicating whether the provided username is blacklisted by the on-wiki title blacklist |
|
| 17 | - * |
|
| 18 | - * @param string $username |
|
| 19 | - * |
|
| 20 | - * @return bool |
|
| 21 | - */ |
|
| 22 | - public function isBlacklisted($username) |
|
| 23 | - { |
|
| 24 | - // Short-circuit |
|
| 25 | - return false; |
|
| 26 | - } |
|
| 15 | + /** |
|
| 16 | + * Returns a value indicating whether the provided username is blacklisted by the on-wiki title blacklist |
|
| 17 | + * |
|
| 18 | + * @param string $username |
|
| 19 | + * |
|
| 20 | + * @return bool |
|
| 21 | + */ |
|
| 22 | + public function isBlacklisted($username) |
|
| 23 | + { |
|
| 24 | + // Short-circuit |
|
| 25 | + return false; |
|
| 26 | + } |
|
| 27 | 27 | } |
| 28 | 28 | \ No newline at end of file |
@@ -14,49 +14,49 @@ |
||
| 14 | 14 | |
| 15 | 15 | class BanHelper implements IBanHelper |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * @var PdoDatabase |
|
| 19 | - */ |
|
| 20 | - private $database; |
|
| 17 | + /** |
|
| 18 | + * @var PdoDatabase |
|
| 19 | + */ |
|
| 20 | + private $database; |
|
| 21 | 21 | |
| 22 | - public function __construct(PdoDatabase $database) |
|
| 23 | - { |
|
| 24 | - $this->database = $database; |
|
| 25 | - } |
|
| 22 | + public function __construct(PdoDatabase $database) |
|
| 23 | + { |
|
| 24 | + $this->database = $database; |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Summary of nameIsBanned |
|
| 29 | - * |
|
| 30 | - * @param string $name The name to test if is banned. |
|
| 31 | - * |
|
| 32 | - * @return Ban |
|
| 33 | - */ |
|
| 34 | - public function nameIsBanned($name) |
|
| 35 | - { |
|
| 36 | - return Ban::getBanByTarget($name, "Name", $this->database); |
|
| 37 | - } |
|
| 27 | + /** |
|
| 28 | + * Summary of nameIsBanned |
|
| 29 | + * |
|
| 30 | + * @param string $name The name to test if is banned. |
|
| 31 | + * |
|
| 32 | + * @return Ban |
|
| 33 | + */ |
|
| 34 | + public function nameIsBanned($name) |
|
| 35 | + { |
|
| 36 | + return Ban::getBanByTarget($name, "Name", $this->database); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Summary of emailIsBanned |
|
| 41 | - * |
|
| 42 | - * @param string $email |
|
| 43 | - * |
|
| 44 | - * @return Ban |
|
| 45 | - */ |
|
| 46 | - public function emailIsBanned($email) |
|
| 47 | - { |
|
| 48 | - return Ban::getBanByTarget($email, "EMail", $this->database); |
|
| 49 | - } |
|
| 39 | + /** |
|
| 40 | + * Summary of emailIsBanned |
|
| 41 | + * |
|
| 42 | + * @param string $email |
|
| 43 | + * |
|
| 44 | + * @return Ban |
|
| 45 | + */ |
|
| 46 | + public function emailIsBanned($email) |
|
| 47 | + { |
|
| 48 | + return Ban::getBanByTarget($email, "EMail", $this->database); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Summary of ipIsBanned |
|
| 53 | - * |
|
| 54 | - * @param string $ip |
|
| 55 | - * |
|
| 56 | - * @return Ban |
|
| 57 | - */ |
|
| 58 | - public function ipIsBanned($ip) |
|
| 59 | - { |
|
| 60 | - return Ban::getBanByTarget($ip, "IP", $this->database); |
|
| 61 | - } |
|
| 51 | + /** |
|
| 52 | + * Summary of ipIsBanned |
|
| 53 | + * |
|
| 54 | + * @param string $ip |
|
| 55 | + * |
|
| 56 | + * @return Ban |
|
| 57 | + */ |
|
| 58 | + public function ipIsBanned($ip) |
|
| 59 | + { |
|
| 60 | + return Ban::getBanByTarget($ip, "IP", $this->database); |
|
| 61 | + } |
|
| 62 | 62 | } |
@@ -13,91 +13,91 @@ |
||
| 13 | 13 | |
| 14 | 14 | class BlacklistHelper implements IBlacklistHelper |
| 15 | 15 | { |
| 16 | - /** @var HttpHelper */ |
|
| 17 | - private $httpHelper; |
|
| 18 | - /** |
|
| 19 | - * Cache of previously requested usernames |
|
| 20 | - * @var array |
|
| 21 | - */ |
|
| 22 | - private $cache = array(); |
|
| 23 | - /** @var string */ |
|
| 24 | - private $mediawikiWebServiceEndpoint; |
|
| 16 | + /** @var HttpHelper */ |
|
| 17 | + private $httpHelper; |
|
| 18 | + /** |
|
| 19 | + * Cache of previously requested usernames |
|
| 20 | + * @var array |
|
| 21 | + */ |
|
| 22 | + private $cache = array(); |
|
| 23 | + /** @var string */ |
|
| 24 | + private $mediawikiWebServiceEndpoint; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * BlacklistHelper constructor. |
|
| 28 | - * |
|
| 29 | - * @param HttpHelper $httpHelper |
|
| 30 | - * @param string $mediawikiWebServiceEndpoint |
|
| 31 | - */ |
|
| 32 | - public function __construct(HttpHelper $httpHelper, $mediawikiWebServiceEndpoint) |
|
| 33 | - { |
|
| 34 | - $this->httpHelper = $httpHelper; |
|
| 35 | - $this->mediawikiWebServiceEndpoint = $mediawikiWebServiceEndpoint; |
|
| 36 | - } |
|
| 26 | + /** |
|
| 27 | + * BlacklistHelper constructor. |
|
| 28 | + * |
|
| 29 | + * @param HttpHelper $httpHelper |
|
| 30 | + * @param string $mediawikiWebServiceEndpoint |
|
| 31 | + */ |
|
| 32 | + public function __construct(HttpHelper $httpHelper, $mediawikiWebServiceEndpoint) |
|
| 33 | + { |
|
| 34 | + $this->httpHelper = $httpHelper; |
|
| 35 | + $this->mediawikiWebServiceEndpoint = $mediawikiWebServiceEndpoint; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Returns a value indicating whether the provided username is blacklisted by the on-wiki title blacklist |
|
| 40 | - * |
|
| 41 | - * @param string $username |
|
| 42 | - * |
|
| 43 | - * @return false|string False if the username is not blacklisted, else the blacklist entry. |
|
| 44 | - */ |
|
| 45 | - public function isBlacklisted($username) |
|
| 46 | - { |
|
| 47 | - if (isset($this->cache[$username])) { |
|
| 48 | - $result = $this->cache[$username]; |
|
| 49 | - if ($result === false) { |
|
| 50 | - return false; |
|
| 51 | - } |
|
| 38 | + /** |
|
| 39 | + * Returns a value indicating whether the provided username is blacklisted by the on-wiki title blacklist |
|
| 40 | + * |
|
| 41 | + * @param string $username |
|
| 42 | + * |
|
| 43 | + * @return false|string False if the username is not blacklisted, else the blacklist entry. |
|
| 44 | + */ |
|
| 45 | + public function isBlacklisted($username) |
|
| 46 | + { |
|
| 47 | + if (isset($this->cache[$username])) { |
|
| 48 | + $result = $this->cache[$username]; |
|
| 49 | + if ($result === false) { |
|
| 50 | + return false; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - return $result['line']; |
|
| 54 | - } |
|
| 53 | + return $result['line']; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - try { |
|
| 57 | - $result = $this->performWikiLookup($username); |
|
| 58 | - } |
|
| 59 | - catch (CurlException $ex) { |
|
| 60 | - // LOGME log this, but fail gracefully. |
|
| 61 | - return false; |
|
| 62 | - } |
|
| 56 | + try { |
|
| 57 | + $result = $this->performWikiLookup($username); |
|
| 58 | + } |
|
| 59 | + catch (CurlException $ex) { |
|
| 60 | + // LOGME log this, but fail gracefully. |
|
| 61 | + return false; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - if ($result['result'] === 'ok') { |
|
| 65 | - // not blacklisted |
|
| 66 | - $this->cache[$username] = false; |
|
| 64 | + if ($result['result'] === 'ok') { |
|
| 65 | + // not blacklisted |
|
| 66 | + $this->cache[$username] = false; |
|
| 67 | 67 | |
| 68 | - return false; |
|
| 69 | - } |
|
| 70 | - else { |
|
| 71 | - $this->cache[$username] = $result; |
|
| 68 | + return false; |
|
| 69 | + } |
|
| 70 | + else { |
|
| 71 | + $this->cache[$username] = $result; |
|
| 72 | 72 | |
| 73 | - return $result['line']; |
|
| 74 | - } |
|
| 75 | - } |
|
| 73 | + return $result['line']; |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Performs a fetch to MediaWiki for the relevant title blacklist entry |
|
| 79 | - * |
|
| 80 | - * @param string $username The username to look up |
|
| 81 | - * |
|
| 82 | - * @return array |
|
| 83 | - * @throws CurlException |
|
| 84 | - */ |
|
| 85 | - private function performWikiLookup($username) |
|
| 86 | - { |
|
| 87 | - $endpoint = $this->mediawikiWebServiceEndpoint; |
|
| 77 | + /** |
|
| 78 | + * Performs a fetch to MediaWiki for the relevant title blacklist entry |
|
| 79 | + * |
|
| 80 | + * @param string $username The username to look up |
|
| 81 | + * |
|
| 82 | + * @return array |
|
| 83 | + * @throws CurlException |
|
| 84 | + */ |
|
| 85 | + private function performWikiLookup($username) |
|
| 86 | + { |
|
| 87 | + $endpoint = $this->mediawikiWebServiceEndpoint; |
|
| 88 | 88 | |
| 89 | - $parameters = array( |
|
| 90 | - 'action' => 'titleblacklist', |
|
| 91 | - 'format' => 'php', |
|
| 92 | - 'tbtitle' => $username, |
|
| 93 | - 'tbaction' => 'new-account', |
|
| 94 | - 'tbnooverride' => true, |
|
| 95 | - ); |
|
| 89 | + $parameters = array( |
|
| 90 | + 'action' => 'titleblacklist', |
|
| 91 | + 'format' => 'php', |
|
| 92 | + 'tbtitle' => $username, |
|
| 93 | + 'tbaction' => 'new-account', |
|
| 94 | + 'tbnooverride' => true, |
|
| 95 | + ); |
|
| 96 | 96 | |
| 97 | - $apiResult = $this->httpHelper->get($endpoint, $parameters); |
|
| 97 | + $apiResult = $this->httpHelper->get($endpoint, $parameters); |
|
| 98 | 98 | |
| 99 | - $data = unserialize($apiResult); |
|
| 99 | + $data = unserialize($apiResult); |
|
| 100 | 100 | |
| 101 | - return $data['titleblacklist']; |
|
| 102 | - } |
|
| 101 | + return $data['titleblacklist']; |
|
| 102 | + } |
|
| 103 | 103 | } |
| 104 | 104 | \ No newline at end of file |
@@ -10,16 +10,16 @@ |
||
| 10 | 10 | |
| 11 | 11 | interface ITypeAheadHelper |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * @param string $class CSS class to apply this typeahead to. |
|
| 15 | - * @param callable $generator Generator function taking no arguments to return an array of strings. |
|
| 16 | - * |
|
| 17 | - * @return void |
|
| 18 | - */ |
|
| 19 | - public function defineTypeAheadSource($class, callable $generator); |
|
| 13 | + /** |
|
| 14 | + * @param string $class CSS class to apply this typeahead to. |
|
| 15 | + * @param callable $generator Generator function taking no arguments to return an array of strings. |
|
| 16 | + * |
|
| 17 | + * @return void |
|
| 18 | + */ |
|
| 19 | + public function defineTypeAheadSource($class, callable $generator); |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @return string HTML fragment containing a JS block for typeaheads. |
|
| 23 | - */ |
|
| 24 | - public function getTypeAheadScriptBlock(); |
|
| 21 | + /** |
|
| 22 | + * @return string HTML fragment containing a JS block for typeaheads. |
|
| 23 | + */ |
|
| 24 | + public function getTypeAheadScriptBlock(); |
|
| 25 | 25 | } |
| 26 | 26 | \ No newline at end of file |