@@ -21,22 +21,22 @@ |
||
21 | 21 | */ |
22 | 22 | abstract class ReadableException extends Exception |
23 | 23 | { |
24 | - use TemplateOutput; |
|
24 | + use TemplateOutput; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Returns a readable HTML error message that's displayable to the user using templates. |
|
28 | - * @return string |
|
29 | - */ |
|
30 | - abstract public function getReadableError(); |
|
26 | + /** |
|
27 | + * Returns a readable HTML error message that's displayable to the user using templates. |
|
28 | + * @return string |
|
29 | + */ |
|
30 | + abstract public function getReadableError(); |
|
31 | 31 | |
32 | - /** |
|
33 | - * @return SiteConfiguration |
|
34 | - */ |
|
35 | - protected function getSiteConfiguration() |
|
36 | - { |
|
37 | - // Uck. However, we have encountered an exception. |
|
38 | - global $siteConfiguration; |
|
32 | + /** |
|
33 | + * @return SiteConfiguration |
|
34 | + */ |
|
35 | + protected function getSiteConfiguration() |
|
36 | + { |
|
37 | + // Uck. However, we have encountered an exception. |
|
38 | + global $siteConfiguration; |
|
39 | 39 | |
40 | - return $siteConfiguration; |
|
41 | - } |
|
40 | + return $siteConfiguration; |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | \ No newline at end of file |
@@ -21,13 +21,13 @@ |
||
21 | 21 | */ |
22 | 22 | class EnvironmentException extends Exception |
23 | 23 | { |
24 | - /** |
|
25 | - * EnvironmentException constructor. |
|
26 | - * |
|
27 | - * @param string $friendlyMessage |
|
28 | - */ |
|
29 | - public function __construct($friendlyMessage) |
|
30 | - { |
|
31 | - parent::__construct($friendlyMessage); |
|
32 | - } |
|
24 | + /** |
|
25 | + * EnvironmentException constructor. |
|
26 | + * |
|
27 | + * @param string $friendlyMessage |
|
28 | + */ |
|
29 | + public function __construct($friendlyMessage) |
|
30 | + { |
|
31 | + parent::__construct($friendlyMessage); |
|
32 | + } |
|
33 | 33 | } |
34 | 34 | \ No newline at end of file |
@@ -22,60 +22,60 @@ |
||
22 | 22 | */ |
23 | 23 | class AccessDeniedException extends ReadableException |
24 | 24 | { |
25 | - public function getReadableError() |
|
26 | - { |
|
27 | - if (!headers_sent()) { |
|
28 | - header("HTTP/1.1 403 Forbidden"); |
|
29 | - } |
|
25 | + public function getReadableError() |
|
26 | + { |
|
27 | + if (!headers_sent()) { |
|
28 | + header("HTTP/1.1 403 Forbidden"); |
|
29 | + } |
|
30 | 30 | |
31 | - $this->setUpSmarty(); |
|
31 | + $this->setUpSmarty(); |
|
32 | 32 | |
33 | - // uck. We should still be able to access the database in this situation though. |
|
34 | - $database = PdoDatabase::getDatabaseConnection('acc'); |
|
35 | - $currentUser = User::getCurrent($database); |
|
36 | - $this->assign('currentUser', $currentUser); |
|
37 | - $this->assign("loggedIn", (!$currentUser->isCommunityUser())); |
|
33 | + // uck. We should still be able to access the database in this situation though. |
|
34 | + $database = PdoDatabase::getDatabaseConnection('acc'); |
|
35 | + $currentUser = User::getCurrent($database); |
|
36 | + $this->assign('currentUser', $currentUser); |
|
37 | + $this->assign("loggedIn", (!$currentUser->isCommunityUser())); |
|
38 | 38 | |
39 | - if ($currentUser->isDeclined()) { |
|
40 | - $this->assign('htmlTitle', 'Account Declined'); |
|
41 | - $this->assign('declineReason', $this->getLogEntry('Declined', $currentUser, $database)); |
|
39 | + if ($currentUser->isDeclined()) { |
|
40 | + $this->assign('htmlTitle', 'Account Declined'); |
|
41 | + $this->assign('declineReason', $this->getLogEntry('Declined', $currentUser, $database)); |
|
42 | 42 | |
43 | - return $this->fetchTemplate("exception/account-declined.tpl"); |
|
44 | - } |
|
43 | + return $this->fetchTemplate("exception/account-declined.tpl"); |
|
44 | + } |
|
45 | 45 | |
46 | - if ($currentUser->isSuspended()) { |
|
47 | - $this->assign('htmlTitle', 'Account Suspended'); |
|
48 | - $this->assign('suspendReason', $this->getLogEntry('Suspended', $currentUser, $database)); |
|
46 | + if ($currentUser->isSuspended()) { |
|
47 | + $this->assign('htmlTitle', 'Account Suspended'); |
|
48 | + $this->assign('suspendReason', $this->getLogEntry('Suspended', $currentUser, $database)); |
|
49 | 49 | |
50 | - return $this->fetchTemplate("exception/account-suspended.tpl"); |
|
51 | - } |
|
50 | + return $this->fetchTemplate("exception/account-suspended.tpl"); |
|
51 | + } |
|
52 | 52 | |
53 | - if ($currentUser->isNewUser()) { |
|
54 | - $this->assign('htmlTitle', 'Account Pending'); |
|
53 | + if ($currentUser->isNewUser()) { |
|
54 | + $this->assign('htmlTitle', 'Account Pending'); |
|
55 | 55 | |
56 | - return $this->fetchTemplate("exception/account-new.tpl"); |
|
57 | - } |
|
56 | + return $this->fetchTemplate("exception/account-new.tpl"); |
|
57 | + } |
|
58 | 58 | |
59 | - return $this->fetchTemplate("exception/access-denied.tpl"); |
|
60 | - } |
|
59 | + return $this->fetchTemplate("exception/access-denied.tpl"); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @param string $action |
|
64 | - * @param User $user |
|
65 | - * @param PdoDatabase $database |
|
66 | - * |
|
67 | - * @return null|string |
|
68 | - */ |
|
69 | - private function getLogEntry($action, User $user, PdoDatabase $database) |
|
70 | - { |
|
71 | - /** @var Log[] $logs */ |
|
72 | - $logs = LogSearchHelper::get($database) |
|
73 | - ->byAction($action) |
|
74 | - ->byObjectType('User') |
|
75 | - ->byObjectId($user->getId()) |
|
76 | - ->limit(1) |
|
77 | - ->fetch(); |
|
62 | + /** |
|
63 | + * @param string $action |
|
64 | + * @param User $user |
|
65 | + * @param PdoDatabase $database |
|
66 | + * |
|
67 | + * @return null|string |
|
68 | + */ |
|
69 | + private function getLogEntry($action, User $user, PdoDatabase $database) |
|
70 | + { |
|
71 | + /** @var Log[] $logs */ |
|
72 | + $logs = LogSearchHelper::get($database) |
|
73 | + ->byAction($action) |
|
74 | + ->byObjectType('User') |
|
75 | + ->byObjectId($user->getId()) |
|
76 | + ->limit(1) |
|
77 | + ->fetch(); |
|
78 | 78 | |
79 | - return $logs[0]->getComment(); |
|
80 | - } |
|
79 | + return $logs[0]->getComment(); |
|
80 | + } |
|
81 | 81 | } |
82 | 82 | \ No newline at end of file |
@@ -15,112 +15,112 @@ |
||
15 | 15 | |
16 | 16 | class PdoDatabase extends PDO |
17 | 17 | { |
18 | - /** |
|
19 | - * @var PdoDatabase[] |
|
20 | - */ |
|
21 | - private static $connections = array(); |
|
22 | - /** |
|
23 | - * @var bool True if a transaction is active |
|
24 | - */ |
|
25 | - protected $hasActiveTransaction = false; |
|
26 | - |
|
27 | - /** |
|
28 | - * Unless you're doing low-level work, this is not the function you want. |
|
29 | - * |
|
30 | - * @param string $connectionName |
|
31 | - * |
|
32 | - * @return PdoDatabase |
|
33 | - * @throws Exception |
|
34 | - */ |
|
35 | - public static function getDatabaseConnection($connectionName) |
|
36 | - { |
|
37 | - if (!isset(self::$connections[$connectionName])) { |
|
38 | - global $cDatabaseConfig; |
|
39 | - |
|
40 | - if (!array_key_exists($connectionName, $cDatabaseConfig)) { |
|
41 | - throw new Exception("Database configuration not found for alias $connectionName"); |
|
42 | - } |
|
43 | - |
|
44 | - try { |
|
45 | - $databaseObject = new PdoDatabase( |
|
46 | - $cDatabaseConfig[$connectionName]["dsrcname"], |
|
47 | - $cDatabaseConfig[$connectionName]["username"], |
|
48 | - $cDatabaseConfig[$connectionName]["password"] |
|
49 | - ); |
|
50 | - } |
|
51 | - catch (PDOException $ex) { |
|
52 | - // wrap around any potential stack traces which may include passwords |
|
53 | - throw new EnvironmentException("Error connecting to database '$connectionName': " . $ex->getMessage()); |
|
54 | - } |
|
55 | - |
|
56 | - $databaseObject->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
|
57 | - |
|
58 | - // emulating prepared statements gives a performance boost on MySQL. |
|
59 | - // |
|
60 | - // however, our version of PDO doesn't seem to understand parameter types when emulating |
|
61 | - // the prepared statements, so we're forced to turn this off for now. |
|
62 | - // -- stw 2014-02-11 |
|
63 | - $databaseObject->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); |
|
64 | - |
|
65 | - self::$connections[$connectionName] = $databaseObject; |
|
66 | - } |
|
67 | - |
|
68 | - return self::$connections[$connectionName]; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * Determines if this connection has a transaction in progress or not |
|
73 | - * @return boolean true if there is a transaction in progress. |
|
74 | - */ |
|
75 | - public function hasActiveTransaction() |
|
76 | - { |
|
77 | - return $this->hasActiveTransaction; |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Summary of beginTransaction |
|
82 | - * @return bool |
|
83 | - */ |
|
84 | - public function beginTransaction() |
|
85 | - { |
|
86 | - // Override the pre-existing method, which doesn't stop you from |
|
87 | - // starting transactions within transactions - which doesn't work and |
|
88 | - // will throw an exception. This eliminates the need to catch exceptions |
|
89 | - // all over the rest of the code |
|
90 | - if ($this->hasActiveTransaction) { |
|
91 | - return false; |
|
92 | - } |
|
93 | - else { |
|
94 | - // set the transaction isolation level for every transaction. |
|
95 | - $this->exec("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;"); |
|
96 | - |
|
97 | - // start a new transaction, and return whether or not the start was |
|
98 | - // successful |
|
99 | - $this->hasActiveTransaction = parent::beginTransaction(); |
|
100 | - |
|
101 | - return $this->hasActiveTransaction; |
|
102 | - } |
|
103 | - } |
|
104 | - |
|
105 | - /** |
|
106 | - * Commits the active transaction |
|
107 | - */ |
|
108 | - public function commit() |
|
109 | - { |
|
110 | - if ($this->hasActiveTransaction) { |
|
111 | - parent::commit(); |
|
112 | - $this->hasActiveTransaction = false; |
|
113 | - } |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * Rolls back a transaction |
|
118 | - */ |
|
119 | - public function rollBack() |
|
120 | - { |
|
121 | - if ($this->hasActiveTransaction) { |
|
122 | - parent::rollback(); |
|
123 | - $this->hasActiveTransaction = false; |
|
124 | - } |
|
125 | - } |
|
18 | + /** |
|
19 | + * @var PdoDatabase[] |
|
20 | + */ |
|
21 | + private static $connections = array(); |
|
22 | + /** |
|
23 | + * @var bool True if a transaction is active |
|
24 | + */ |
|
25 | + protected $hasActiveTransaction = false; |
|
26 | + |
|
27 | + /** |
|
28 | + * Unless you're doing low-level work, this is not the function you want. |
|
29 | + * |
|
30 | + * @param string $connectionName |
|
31 | + * |
|
32 | + * @return PdoDatabase |
|
33 | + * @throws Exception |
|
34 | + */ |
|
35 | + public static function getDatabaseConnection($connectionName) |
|
36 | + { |
|
37 | + if (!isset(self::$connections[$connectionName])) { |
|
38 | + global $cDatabaseConfig; |
|
39 | + |
|
40 | + if (!array_key_exists($connectionName, $cDatabaseConfig)) { |
|
41 | + throw new Exception("Database configuration not found for alias $connectionName"); |
|
42 | + } |
|
43 | + |
|
44 | + try { |
|
45 | + $databaseObject = new PdoDatabase( |
|
46 | + $cDatabaseConfig[$connectionName]["dsrcname"], |
|
47 | + $cDatabaseConfig[$connectionName]["username"], |
|
48 | + $cDatabaseConfig[$connectionName]["password"] |
|
49 | + ); |
|
50 | + } |
|
51 | + catch (PDOException $ex) { |
|
52 | + // wrap around any potential stack traces which may include passwords |
|
53 | + throw new EnvironmentException("Error connecting to database '$connectionName': " . $ex->getMessage()); |
|
54 | + } |
|
55 | + |
|
56 | + $databaseObject->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
|
57 | + |
|
58 | + // emulating prepared statements gives a performance boost on MySQL. |
|
59 | + // |
|
60 | + // however, our version of PDO doesn't seem to understand parameter types when emulating |
|
61 | + // the prepared statements, so we're forced to turn this off for now. |
|
62 | + // -- stw 2014-02-11 |
|
63 | + $databaseObject->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); |
|
64 | + |
|
65 | + self::$connections[$connectionName] = $databaseObject; |
|
66 | + } |
|
67 | + |
|
68 | + return self::$connections[$connectionName]; |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * Determines if this connection has a transaction in progress or not |
|
73 | + * @return boolean true if there is a transaction in progress. |
|
74 | + */ |
|
75 | + public function hasActiveTransaction() |
|
76 | + { |
|
77 | + return $this->hasActiveTransaction; |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Summary of beginTransaction |
|
82 | + * @return bool |
|
83 | + */ |
|
84 | + public function beginTransaction() |
|
85 | + { |
|
86 | + // Override the pre-existing method, which doesn't stop you from |
|
87 | + // starting transactions within transactions - which doesn't work and |
|
88 | + // will throw an exception. This eliminates the need to catch exceptions |
|
89 | + // all over the rest of the code |
|
90 | + if ($this->hasActiveTransaction) { |
|
91 | + return false; |
|
92 | + } |
|
93 | + else { |
|
94 | + // set the transaction isolation level for every transaction. |
|
95 | + $this->exec("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;"); |
|
96 | + |
|
97 | + // start a new transaction, and return whether or not the start was |
|
98 | + // successful |
|
99 | + $this->hasActiveTransaction = parent::beginTransaction(); |
|
100 | + |
|
101 | + return $this->hasActiveTransaction; |
|
102 | + } |
|
103 | + } |
|
104 | + |
|
105 | + /** |
|
106 | + * Commits the active transaction |
|
107 | + */ |
|
108 | + public function commit() |
|
109 | + { |
|
110 | + if ($this->hasActiveTransaction) { |
|
111 | + parent::commit(); |
|
112 | + $this->hasActiveTransaction = false; |
|
113 | + } |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * Rolls back a transaction |
|
118 | + */ |
|
119 | + public function rollBack() |
|
120 | + { |
|
121 | + if ($this->hasActiveTransaction) { |
|
122 | + parent::rollback(); |
|
123 | + $this->hasActiveTransaction = false; |
|
124 | + } |
|
125 | + } |
|
126 | 126 | } |
@@ -13,22 +13,22 @@ discard block |
||
13 | 13 | |
14 | 14 | class ExceptionHandler |
15 | 15 | { |
16 | - /** |
|
17 | - * Global exception handler |
|
18 | - * |
|
19 | - * Smarty would be nice to use, but it COULD BE smarty that throws the errors. |
|
20 | - * Let's build something ourselves, and hope it works. |
|
21 | - * |
|
22 | - * @param $exception |
|
23 | - * |
|
24 | - * @category Security-Critical - has the potential to leak data when exception is thrown. |
|
25 | - */ |
|
26 | - public static function exceptionHandler(Exception $exception) |
|
27 | - { |
|
28 | - /** @global $siteConfiguration SiteConfiguration */ |
|
29 | - global $siteConfiguration; |
|
30 | - |
|
31 | - $errorDocument = <<<HTML |
|
16 | + /** |
|
17 | + * Global exception handler |
|
18 | + * |
|
19 | + * Smarty would be nice to use, but it COULD BE smarty that throws the errors. |
|
20 | + * Let's build something ourselves, and hope it works. |
|
21 | + * |
|
22 | + * @param $exception |
|
23 | + * |
|
24 | + * @category Security-Critical - has the potential to leak data when exception is thrown. |
|
25 | + */ |
|
26 | + public static function exceptionHandler(Exception $exception) |
|
27 | + { |
|
28 | + /** @global $siteConfiguration SiteConfiguration */ |
|
29 | + global $siteConfiguration; |
|
30 | + |
|
31 | + $errorDocument = <<<HTML |
|
32 | 32 | <!DOCTYPE html> |
33 | 33 | <html lang="en"><head> |
34 | 34 | <meta charset="utf-8"> |
@@ -49,77 +49,77 @@ discard block |
||
49 | 49 | </div></body></html> |
50 | 50 | HTML; |
51 | 51 | |
52 | - $errorData = self::getExceptionData($exception); |
|
53 | - $errorData['server'] = $_SERVER; |
|
54 | - $errorData['get'] = $_GET; |
|
55 | - $errorData['post'] = $_POST; |
|
56 | - |
|
57 | - $state = serialize($errorData); |
|
58 | - $errorId = sha1($state); |
|
59 | - |
|
60 | - // Save the error for later analysis |
|
61 | - file_put_contents($siteConfiguration->getErrorLog() . '/' . $errorId . '.log', $state); |
|
62 | - |
|
63 | - // clear and discard any content that's been saved to the output buffer |
|
64 | - if (ob_get_level() > 0) { |
|
65 | - ob_end_clean(); |
|
66 | - } |
|
67 | - |
|
68 | - // push error ID into the document. |
|
69 | - $message = str_replace('$1$', $errorId, $errorDocument); |
|
70 | - |
|
71 | - if ($siteConfiguration->getDebuggingTraceEnabled()) { |
|
72 | - ob_start(); |
|
73 | - var_dump($errorData); |
|
74 | - $textErrorData = ob_get_contents(); |
|
75 | - ob_end_clean(); |
|
76 | - |
|
77 | - $message = str_replace('$2$', $textErrorData, $message); |
|
78 | - } |
|
79 | - else { |
|
80 | - $message = str_replace('$2$', "", $message); |
|
81 | - } |
|
82 | - |
|
83 | - // While we *shouldn't* have sent headers by now due to the output buffering, PHPUnit does weird things. |
|
84 | - // This is "only" needed for the tests, but it's a good idea to wrap this anyway. |
|
85 | - if (!headers_sent()) { |
|
86 | - header('HTTP/1.1 500 Internal Server Error'); |
|
87 | - } |
|
88 | - |
|
89 | - // output the document |
|
90 | - print $message; |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * @param int $errorSeverity The severity level of the exception. |
|
95 | - * @param string $errorMessage The Exception message to throw. |
|
96 | - * @param string $errorFile The filename where the exception is thrown. |
|
97 | - * @param int $errorLine The line number where the exception is thrown. |
|
98 | - * |
|
99 | - * @throws ErrorException |
|
100 | - */ |
|
101 | - public static function errorHandler($errorSeverity, $errorMessage, $errorFile, $errorLine) |
|
102 | - { |
|
103 | - // call into the main exception handler above |
|
104 | - throw new ErrorException($errorMessage, 0, $errorSeverity, $errorFile, $errorLine); |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * @param Exception $exception |
|
109 | - * |
|
110 | - * @return null|array |
|
111 | - */ |
|
112 | - private static function getExceptionData($exception) |
|
113 | - { |
|
114 | - if ($exception == null) { |
|
115 | - return null; |
|
116 | - } |
|
117 | - |
|
118 | - return array( |
|
119 | - 'exception' => get_class($exception), |
|
120 | - 'message' => $exception->getMessage(), |
|
121 | - 'stack' => $exception->getTraceAsString(), |
|
122 | - 'previous' => self::getExceptionData($exception->getPrevious()), |
|
123 | - ); |
|
124 | - } |
|
52 | + $errorData = self::getExceptionData($exception); |
|
53 | + $errorData['server'] = $_SERVER; |
|
54 | + $errorData['get'] = $_GET; |
|
55 | + $errorData['post'] = $_POST; |
|
56 | + |
|
57 | + $state = serialize($errorData); |
|
58 | + $errorId = sha1($state); |
|
59 | + |
|
60 | + // Save the error for later analysis |
|
61 | + file_put_contents($siteConfiguration->getErrorLog() . '/' . $errorId . '.log', $state); |
|
62 | + |
|
63 | + // clear and discard any content that's been saved to the output buffer |
|
64 | + if (ob_get_level() > 0) { |
|
65 | + ob_end_clean(); |
|
66 | + } |
|
67 | + |
|
68 | + // push error ID into the document. |
|
69 | + $message = str_replace('$1$', $errorId, $errorDocument); |
|
70 | + |
|
71 | + if ($siteConfiguration->getDebuggingTraceEnabled()) { |
|
72 | + ob_start(); |
|
73 | + var_dump($errorData); |
|
74 | + $textErrorData = ob_get_contents(); |
|
75 | + ob_end_clean(); |
|
76 | + |
|
77 | + $message = str_replace('$2$', $textErrorData, $message); |
|
78 | + } |
|
79 | + else { |
|
80 | + $message = str_replace('$2$', "", $message); |
|
81 | + } |
|
82 | + |
|
83 | + // While we *shouldn't* have sent headers by now due to the output buffering, PHPUnit does weird things. |
|
84 | + // This is "only" needed for the tests, but it's a good idea to wrap this anyway. |
|
85 | + if (!headers_sent()) { |
|
86 | + header('HTTP/1.1 500 Internal Server Error'); |
|
87 | + } |
|
88 | + |
|
89 | + // output the document |
|
90 | + print $message; |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * @param int $errorSeverity The severity level of the exception. |
|
95 | + * @param string $errorMessage The Exception message to throw. |
|
96 | + * @param string $errorFile The filename where the exception is thrown. |
|
97 | + * @param int $errorLine The line number where the exception is thrown. |
|
98 | + * |
|
99 | + * @throws ErrorException |
|
100 | + */ |
|
101 | + public static function errorHandler($errorSeverity, $errorMessage, $errorFile, $errorLine) |
|
102 | + { |
|
103 | + // call into the main exception handler above |
|
104 | + throw new ErrorException($errorMessage, 0, $errorSeverity, $errorFile, $errorLine); |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * @param Exception $exception |
|
109 | + * |
|
110 | + * @return null|array |
|
111 | + */ |
|
112 | + private static function getExceptionData($exception) |
|
113 | + { |
|
114 | + if ($exception == null) { |
|
115 | + return null; |
|
116 | + } |
|
117 | + |
|
118 | + return array( |
|
119 | + 'exception' => get_class($exception), |
|
120 | + 'message' => $exception->getMessage(), |
|
121 | + 'stack' => $exception->getTraceAsString(), |
|
122 | + 'previous' => self::getExceptionData($exception->getPrevious()), |
|
123 | + ); |
|
124 | + } |
|
125 | 125 | } |
126 | 126 | \ 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 | } |
@@ -12,99 +12,99 @@ |
||
12 | 12 | |
13 | 13 | class ValidationError |
14 | 14 | { |
15 | - const NAME_EMPTY = "name_empty"; |
|
16 | - const NAME_EXISTS = "name_exists"; |
|
17 | - const NAME_EXISTS_SUL = "name_exists"; |
|
18 | - const NAME_NUMONLY = "name_numonly"; |
|
19 | - const NAME_INVALIDCHAR = "name_invalidchar"; |
|
20 | - const NAME_SANITISED = "name_sanitised"; |
|
21 | - const EMAIL_EMPTY = "email_empty"; |
|
22 | - const EMAIL_WIKIMEDIA = "email_wikimedia"; |
|
23 | - const EMAIL_INVALID = "email_invalid"; |
|
24 | - const EMAIL_MISMATCH = "email_mismatch"; |
|
25 | - const OPEN_REQUEST_NAME = "open_request_name"; |
|
26 | - const BANNED = "banned"; |
|
27 | - const BANNED_TOR = "banned_tor"; |
|
28 | - /** |
|
29 | - * @var array Error text for the above |
|
30 | - */ |
|
31 | - private static $errorText = array( |
|
32 | - self::NAME_EMPTY => 'You\'ve not chosen a username!', |
|
33 | - self::NAME_EXISTS => 'I\'m sorry, but the username you selected is already taken. Please try another. ' |
|
34 | - . 'Please note that Wikipedia automatically capitalizes the first letter of any user name, therefore ' |
|
35 | - . '[[User:example]] would become [[User:Example]].', |
|
36 | - self::NAME_EXISTS_SUL => 'I\'m sorry, but the username you selected is already taken. Please try another. ' |
|
37 | - . 'Please note that Wikipedia automatically capitalizes the first letter of any user name, therefore ' |
|
38 | - . '[[User:example]] would become [[User:Example]].', |
|
39 | - self::NAME_NUMONLY => 'The username you chose is invalid: it consists entirely of numbers. Please retry ' |
|
40 | - . 'with a valid username.', |
|
41 | - self::NAME_INVALIDCHAR => 'There appears to be an invalid character in your username. Please note that the ' |
|
42 | - . 'following characters are not allowed: <code># @ / < > [ ] | { }</code>', |
|
43 | - self::NAME_SANITISED => 'Your requested username has been automatically adjusted due to technical ' |
|
44 | - . 'restrictions. Underscores have been replaced with spaces, and the first character has been capitalised.', |
|
45 | - self::EMAIL_EMPTY => 'You need to supply an email address.', |
|
46 | - self::EMAIL_WIKIMEDIA => 'Please provide your email address here.', |
|
47 | - self::EMAIL_INVALID => 'Invalid E-mail address supplied. Please check you entered it correctly.', |
|
48 | - self::EMAIL_MISMATCH => 'The email addresses you entered do not match. Please try again.', |
|
49 | - self::OPEN_REQUEST_NAME => 'There is already an open request with this name in this system.', |
|
50 | - self::BANNED => 'I\'m sorry, but you are currently banned from requesting accounts using this tool. ' |
|
51 | - . 'However, you can still send an email to [email protected] to request an account.', |
|
52 | - self::BANNED_TOR => 'Tor exit nodes are currently banned from using this tool due to excessive abuse. ' |
|
53 | - . 'Please note that Tor is also currently banned from editing Wikipedia.', |
|
54 | - ); |
|
55 | - /** |
|
56 | - * Summary of $errorCode |
|
57 | - * @var string |
|
58 | - */ |
|
59 | - private $errorCode; |
|
60 | - /** |
|
61 | - * Summary of $isError |
|
62 | - * @var bool |
|
63 | - */ |
|
64 | - private $isError; |
|
15 | + const NAME_EMPTY = "name_empty"; |
|
16 | + const NAME_EXISTS = "name_exists"; |
|
17 | + const NAME_EXISTS_SUL = "name_exists"; |
|
18 | + const NAME_NUMONLY = "name_numonly"; |
|
19 | + const NAME_INVALIDCHAR = "name_invalidchar"; |
|
20 | + const NAME_SANITISED = "name_sanitised"; |
|
21 | + const EMAIL_EMPTY = "email_empty"; |
|
22 | + const EMAIL_WIKIMEDIA = "email_wikimedia"; |
|
23 | + const EMAIL_INVALID = "email_invalid"; |
|
24 | + const EMAIL_MISMATCH = "email_mismatch"; |
|
25 | + const OPEN_REQUEST_NAME = "open_request_name"; |
|
26 | + const BANNED = "banned"; |
|
27 | + const BANNED_TOR = "banned_tor"; |
|
28 | + /** |
|
29 | + * @var array Error text for the above |
|
30 | + */ |
|
31 | + private static $errorText = array( |
|
32 | + self::NAME_EMPTY => 'You\'ve not chosen a username!', |
|
33 | + self::NAME_EXISTS => 'I\'m sorry, but the username you selected is already taken. Please try another. ' |
|
34 | + . 'Please note that Wikipedia automatically capitalizes the first letter of any user name, therefore ' |
|
35 | + . '[[User:example]] would become [[User:Example]].', |
|
36 | + self::NAME_EXISTS_SUL => 'I\'m sorry, but the username you selected is already taken. Please try another. ' |
|
37 | + . 'Please note that Wikipedia automatically capitalizes the first letter of any user name, therefore ' |
|
38 | + . '[[User:example]] would become [[User:Example]].', |
|
39 | + self::NAME_NUMONLY => 'The username you chose is invalid: it consists entirely of numbers. Please retry ' |
|
40 | + . 'with a valid username.', |
|
41 | + self::NAME_INVALIDCHAR => 'There appears to be an invalid character in your username. Please note that the ' |
|
42 | + . 'following characters are not allowed: <code># @ / < > [ ] | { }</code>', |
|
43 | + self::NAME_SANITISED => 'Your requested username has been automatically adjusted due to technical ' |
|
44 | + . 'restrictions. Underscores have been replaced with spaces, and the first character has been capitalised.', |
|
45 | + self::EMAIL_EMPTY => 'You need to supply an email address.', |
|
46 | + self::EMAIL_WIKIMEDIA => 'Please provide your email address here.', |
|
47 | + self::EMAIL_INVALID => 'Invalid E-mail address supplied. Please check you entered it correctly.', |
|
48 | + self::EMAIL_MISMATCH => 'The email addresses you entered do not match. Please try again.', |
|
49 | + self::OPEN_REQUEST_NAME => 'There is already an open request with this name in this system.', |
|
50 | + self::BANNED => 'I\'m sorry, but you are currently banned from requesting accounts using this tool. ' |
|
51 | + . 'However, you can still send an email to [email protected] to request an account.', |
|
52 | + self::BANNED_TOR => 'Tor exit nodes are currently banned from using this tool due to excessive abuse. ' |
|
53 | + . 'Please note that Tor is also currently banned from editing Wikipedia.', |
|
54 | + ); |
|
55 | + /** |
|
56 | + * Summary of $errorCode |
|
57 | + * @var string |
|
58 | + */ |
|
59 | + private $errorCode; |
|
60 | + /** |
|
61 | + * Summary of $isError |
|
62 | + * @var bool |
|
63 | + */ |
|
64 | + private $isError; |
|
65 | 65 | |
66 | - /** |
|
67 | - * Summary of __construct |
|
68 | - * |
|
69 | - * @param string $errorCode |
|
70 | - * @param bool $isError |
|
71 | - */ |
|
72 | - public function __construct($errorCode, $isError = true) |
|
73 | - { |
|
74 | - $this->errorCode = $errorCode; |
|
75 | - $this->isError = $isError; |
|
76 | - } |
|
66 | + /** |
|
67 | + * Summary of __construct |
|
68 | + * |
|
69 | + * @param string $errorCode |
|
70 | + * @param bool $isError |
|
71 | + */ |
|
72 | + public function __construct($errorCode, $isError = true) |
|
73 | + { |
|
74 | + $this->errorCode = $errorCode; |
|
75 | + $this->isError = $isError; |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Summary of getErrorCode |
|
80 | - * @return string |
|
81 | - */ |
|
82 | - public function getErrorCode() |
|
83 | - { |
|
84 | - return $this->errorCode; |
|
85 | - } |
|
78 | + /** |
|
79 | + * Summary of getErrorCode |
|
80 | + * @return string |
|
81 | + */ |
|
82 | + public function getErrorCode() |
|
83 | + { |
|
84 | + return $this->errorCode; |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * @return string |
|
89 | - * @throws Exception |
|
90 | - */ |
|
91 | - public function getErrorMessage() |
|
92 | - { |
|
93 | - $text = self::$errorText[$this->errorCode]; |
|
87 | + /** |
|
88 | + * @return string |
|
89 | + * @throws Exception |
|
90 | + */ |
|
91 | + public function getErrorMessage() |
|
92 | + { |
|
93 | + $text = self::$errorText[$this->errorCode]; |
|
94 | 94 | |
95 | - if ($text == null) { |
|
96 | - throw new Exception('Unknown validation error'); |
|
97 | - } |
|
95 | + if ($text == null) { |
|
96 | + throw new Exception('Unknown validation error'); |
|
97 | + } |
|
98 | 98 | |
99 | - return $text; |
|
100 | - } |
|
99 | + return $text; |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * Summary of isError |
|
104 | - * @return bool |
|
105 | - */ |
|
106 | - public function isError() |
|
107 | - { |
|
108 | - return $this->isError; |
|
109 | - } |
|
102 | + /** |
|
103 | + * Summary of isError |
|
104 | + * @return bool |
|
105 | + */ |
|
106 | + public function isError() |
|
107 | + { |
|
108 | + return $this->isError; |
|
109 | + } |
|
110 | 110 | } |
@@ -12,80 +12,80 @@ |
||
12 | 12 | |
13 | 13 | class Token |
14 | 14 | { |
15 | - /** @var string */ |
|
16 | - private $tokenData; |
|
17 | - /** @var string */ |
|
18 | - private $context; |
|
19 | - /** @var DateTimeImmutable */ |
|
20 | - private $generationTimestamp; |
|
21 | - /** @var DateTimeImmutable */ |
|
22 | - private $usageTimestamp; |
|
23 | - /** @var bool */ |
|
24 | - private $used; |
|
15 | + /** @var string */ |
|
16 | + private $tokenData; |
|
17 | + /** @var string */ |
|
18 | + private $context; |
|
19 | + /** @var DateTimeImmutable */ |
|
20 | + private $generationTimestamp; |
|
21 | + /** @var DateTimeImmutable */ |
|
22 | + private $usageTimestamp; |
|
23 | + /** @var bool */ |
|
24 | + private $used; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Token constructor. |
|
28 | - * |
|
29 | - * @param string $tokenData |
|
30 | - * @param string $context |
|
31 | - */ |
|
32 | - public function __construct($tokenData, $context) |
|
33 | - { |
|
34 | - $this->tokenData = $tokenData; |
|
35 | - $this->context = $context; |
|
36 | - $this->generationTimestamp = new DateTimeImmutable(); |
|
37 | - $this->usageTimestamp = null; |
|
38 | - $this->used = false; |
|
39 | - } |
|
26 | + /** |
|
27 | + * Token constructor. |
|
28 | + * |
|
29 | + * @param string $tokenData |
|
30 | + * @param string $context |
|
31 | + */ |
|
32 | + public function __construct($tokenData, $context) |
|
33 | + { |
|
34 | + $this->tokenData = $tokenData; |
|
35 | + $this->context = $context; |
|
36 | + $this->generationTimestamp = new DateTimeImmutable(); |
|
37 | + $this->usageTimestamp = null; |
|
38 | + $this->used = false; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @return DateTimeImmutable |
|
43 | - */ |
|
44 | - public function getGenerationTimestamp() |
|
45 | - { |
|
46 | - return $this->generationTimestamp; |
|
47 | - } |
|
41 | + /** |
|
42 | + * @return DateTimeImmutable |
|
43 | + */ |
|
44 | + public function getGenerationTimestamp() |
|
45 | + { |
|
46 | + return $this->generationTimestamp; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @return string |
|
51 | - */ |
|
52 | - public function getContext() |
|
53 | - { |
|
54 | - return $this->context; |
|
55 | - } |
|
49 | + /** |
|
50 | + * @return string |
|
51 | + */ |
|
52 | + public function getContext() |
|
53 | + { |
|
54 | + return $this->context; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public function getTokenData() |
|
61 | - { |
|
62 | - return $this->tokenData; |
|
63 | - } |
|
57 | + /** |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public function getTokenData() |
|
61 | + { |
|
62 | + return $this->tokenData; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Returns a value indicating whether the token has already been used or not |
|
67 | - * |
|
68 | - * @return boolean |
|
69 | - */ |
|
70 | - public function isUsed() |
|
71 | - { |
|
72 | - return $this->used; |
|
73 | - } |
|
65 | + /** |
|
66 | + * Returns a value indicating whether the token has already been used or not |
|
67 | + * |
|
68 | + * @return boolean |
|
69 | + */ |
|
70 | + public function isUsed() |
|
71 | + { |
|
72 | + return $this->used; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Marks the token as used |
|
77 | - */ |
|
78 | - public function markAsUsed() |
|
79 | - { |
|
80 | - $this->used = true; |
|
81 | - $this->usageTimestamp = new DateTimeImmutable(); |
|
82 | - } |
|
75 | + /** |
|
76 | + * Marks the token as used |
|
77 | + */ |
|
78 | + public function markAsUsed() |
|
79 | + { |
|
80 | + $this->used = true; |
|
81 | + $this->usageTimestamp = new DateTimeImmutable(); |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * @return DateTimeImmutable |
|
86 | - */ |
|
87 | - public function getUsageTimestamp() |
|
88 | - { |
|
89 | - return $this->usageTimestamp; |
|
90 | - } |
|
84 | + /** |
|
85 | + * @return DateTimeImmutable |
|
86 | + */ |
|
87 | + public function getUsageTimestamp() |
|
88 | + { |
|
89 | + return $this->usageTimestamp; |
|
90 | + } |
|
91 | 91 | } |
92 | 92 | \ No newline at end of file |
@@ -15,186 +15,186 @@ |
||
15 | 15 | */ |
16 | 16 | final class SecurityConfiguration |
17 | 17 | { |
18 | - const ALLOW = "allow"; |
|
19 | - const DENY = "deny"; |
|
20 | - private $admin = "default"; |
|
21 | - private $user = "default"; |
|
22 | - private $checkuser = "default"; |
|
23 | - private $community = "default"; |
|
24 | - private $suspended = "default"; |
|
25 | - private $declined = "default"; |
|
26 | - private $new = "default"; |
|
27 | - private $requireIdentified; |
|
28 | - |
|
29 | - /** |
|
30 | - * Sets whether a checkuser is able to gain access. |
|
31 | - * |
|
32 | - * This is private because it's DANGEROUS. Checkusers are not mutually-exclusive with other rights. As such, a |
|
33 | - * suspended checkuser who tries to access a page which allows checkusers will be granted access to the page, UNLESS |
|
34 | - * that page is also set to DENY (note, not default) New/Declined/Suspended users. I have no problem with this |
|
35 | - * method being used, but please ONLY use it in this class in static methods of Security. Nowhere else. |
|
36 | - * |
|
37 | - * @param string $checkuser |
|
38 | - * |
|
39 | - * @return SecurityConfiguration |
|
40 | - * @category Security-Critical |
|
41 | - */ |
|
42 | - public function setCheckuser($checkuser) |
|
43 | - { |
|
44 | - $this->checkuser = $checkuser; |
|
45 | - |
|
46 | - return $this; |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * Returns if a user is required to be identified. |
|
51 | - * |
|
52 | - * @return boolean |
|
53 | - */ |
|
54 | - public function requiresIdentifiedUser() |
|
55 | - { |
|
56 | - return $this->requireIdentified; |
|
57 | - } |
|
58 | - |
|
59 | - /** |
|
60 | - * @return string |
|
61 | - */ |
|
62 | - public function getAdmin() |
|
63 | - { |
|
64 | - return $this->admin; |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * @param string $admin |
|
69 | - * |
|
70 | - * @return SecurityConfiguration |
|
71 | - * @category Security-Critical |
|
72 | - */ |
|
73 | - public function setAdmin($admin) |
|
74 | - { |
|
75 | - $this->admin = $admin; |
|
76 | - |
|
77 | - return $this; |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * @return string |
|
82 | - */ |
|
83 | - public function getUser() |
|
84 | - { |
|
85 | - return $this->user; |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * @param string $user |
|
90 | - * |
|
91 | - * @return SecurityConfiguration |
|
92 | - * @category Security-Critical |
|
93 | - */ |
|
94 | - public function setUser($user) |
|
95 | - { |
|
96 | - $this->user = $user; |
|
97 | - |
|
98 | - return $this; |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * @return string |
|
103 | - */ |
|
104 | - public function getCheckuser() |
|
105 | - { |
|
106 | - return $this->checkuser; |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * @return string |
|
111 | - */ |
|
112 | - public function getCommunity() |
|
113 | - { |
|
114 | - return $this->community; |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * @param string $community |
|
119 | - * |
|
120 | - * @return SecurityConfiguration |
|
121 | - * @category Security-Critical |
|
122 | - */ |
|
123 | - public function setCommunity($community) |
|
124 | - { |
|
125 | - $this->community = $community; |
|
126 | - |
|
127 | - return $this; |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * @return string |
|
132 | - */ |
|
133 | - public function getSuspended() |
|
134 | - { |
|
135 | - return $this->suspended; |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * @param string $suspended |
|
140 | - * |
|
141 | - * @return SecurityConfiguration |
|
142 | - * @category Security-Critical |
|
143 | - */ |
|
144 | - public function setSuspended($suspended) |
|
145 | - { |
|
146 | - $this->suspended = $suspended; |
|
147 | - |
|
148 | - return $this; |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * @return string |
|
153 | - */ |
|
154 | - public function getDeclined() |
|
155 | - { |
|
156 | - return $this->declined; |
|
157 | - } |
|
158 | - |
|
159 | - /** |
|
160 | - * @param string $declined |
|
161 | - * |
|
162 | - * @return SecurityConfiguration |
|
163 | - * @category Security-Critical |
|
164 | - */ |
|
165 | - public function setDeclined($declined) |
|
166 | - { |
|
167 | - $this->declined = $declined; |
|
168 | - |
|
169 | - return $this; |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * @return string |
|
174 | - */ |
|
175 | - public function getNew() |
|
176 | - { |
|
177 | - return $this->new; |
|
178 | - } |
|
179 | - |
|
180 | - /** |
|
181 | - * @param string $new |
|
182 | - * |
|
183 | - * @return SecurityConfiguration |
|
184 | - * @category Security-Critical |
|
185 | - */ |
|
186 | - public function setNew($new) |
|
187 | - { |
|
188 | - $this->new = $new; |
|
189 | - |
|
190 | - return $this; |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * @param boolean $requireIdentified |
|
195 | - */ |
|
196 | - public function setRequireIdentified($requireIdentified) |
|
197 | - { |
|
198 | - $this->requireIdentified = $requireIdentified; |
|
199 | - } |
|
18 | + const ALLOW = "allow"; |
|
19 | + const DENY = "deny"; |
|
20 | + private $admin = "default"; |
|
21 | + private $user = "default"; |
|
22 | + private $checkuser = "default"; |
|
23 | + private $community = "default"; |
|
24 | + private $suspended = "default"; |
|
25 | + private $declined = "default"; |
|
26 | + private $new = "default"; |
|
27 | + private $requireIdentified; |
|
28 | + |
|
29 | + /** |
|
30 | + * Sets whether a checkuser is able to gain access. |
|
31 | + * |
|
32 | + * This is private because it's DANGEROUS. Checkusers are not mutually-exclusive with other rights. As such, a |
|
33 | + * suspended checkuser who tries to access a page which allows checkusers will be granted access to the page, UNLESS |
|
34 | + * that page is also set to DENY (note, not default) New/Declined/Suspended users. I have no problem with this |
|
35 | + * method being used, but please ONLY use it in this class in static methods of Security. Nowhere else. |
|
36 | + * |
|
37 | + * @param string $checkuser |
|
38 | + * |
|
39 | + * @return SecurityConfiguration |
|
40 | + * @category Security-Critical |
|
41 | + */ |
|
42 | + public function setCheckuser($checkuser) |
|
43 | + { |
|
44 | + $this->checkuser = $checkuser; |
|
45 | + |
|
46 | + return $this; |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * Returns if a user is required to be identified. |
|
51 | + * |
|
52 | + * @return boolean |
|
53 | + */ |
|
54 | + public function requiresIdentifiedUser() |
|
55 | + { |
|
56 | + return $this->requireIdentified; |
|
57 | + } |
|
58 | + |
|
59 | + /** |
|
60 | + * @return string |
|
61 | + */ |
|
62 | + public function getAdmin() |
|
63 | + { |
|
64 | + return $this->admin; |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * @param string $admin |
|
69 | + * |
|
70 | + * @return SecurityConfiguration |
|
71 | + * @category Security-Critical |
|
72 | + */ |
|
73 | + public function setAdmin($admin) |
|
74 | + { |
|
75 | + $this->admin = $admin; |
|
76 | + |
|
77 | + return $this; |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * @return string |
|
82 | + */ |
|
83 | + public function getUser() |
|
84 | + { |
|
85 | + return $this->user; |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * @param string $user |
|
90 | + * |
|
91 | + * @return SecurityConfiguration |
|
92 | + * @category Security-Critical |
|
93 | + */ |
|
94 | + public function setUser($user) |
|
95 | + { |
|
96 | + $this->user = $user; |
|
97 | + |
|
98 | + return $this; |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * @return string |
|
103 | + */ |
|
104 | + public function getCheckuser() |
|
105 | + { |
|
106 | + return $this->checkuser; |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * @return string |
|
111 | + */ |
|
112 | + public function getCommunity() |
|
113 | + { |
|
114 | + return $this->community; |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * @param string $community |
|
119 | + * |
|
120 | + * @return SecurityConfiguration |
|
121 | + * @category Security-Critical |
|
122 | + */ |
|
123 | + public function setCommunity($community) |
|
124 | + { |
|
125 | + $this->community = $community; |
|
126 | + |
|
127 | + return $this; |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * @return string |
|
132 | + */ |
|
133 | + public function getSuspended() |
|
134 | + { |
|
135 | + return $this->suspended; |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * @param string $suspended |
|
140 | + * |
|
141 | + * @return SecurityConfiguration |
|
142 | + * @category Security-Critical |
|
143 | + */ |
|
144 | + public function setSuspended($suspended) |
|
145 | + { |
|
146 | + $this->suspended = $suspended; |
|
147 | + |
|
148 | + return $this; |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * @return string |
|
153 | + */ |
|
154 | + public function getDeclined() |
|
155 | + { |
|
156 | + return $this->declined; |
|
157 | + } |
|
158 | + |
|
159 | + /** |
|
160 | + * @param string $declined |
|
161 | + * |
|
162 | + * @return SecurityConfiguration |
|
163 | + * @category Security-Critical |
|
164 | + */ |
|
165 | + public function setDeclined($declined) |
|
166 | + { |
|
167 | + $this->declined = $declined; |
|
168 | + |
|
169 | + return $this; |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * @return string |
|
174 | + */ |
|
175 | + public function getNew() |
|
176 | + { |
|
177 | + return $this->new; |
|
178 | + } |
|
179 | + |
|
180 | + /** |
|
181 | + * @param string $new |
|
182 | + * |
|
183 | + * @return SecurityConfiguration |
|
184 | + * @category Security-Critical |
|
185 | + */ |
|
186 | + public function setNew($new) |
|
187 | + { |
|
188 | + $this->new = $new; |
|
189 | + |
|
190 | + return $this; |
|
191 | + } |
|
192 | + |
|
193 | + /** |
|
194 | + * @param boolean $requireIdentified |
|
195 | + */ |
|
196 | + public function setRequireIdentified($requireIdentified) |
|
197 | + { |
|
198 | + $this->requireIdentified = $requireIdentified; |
|
199 | + } |
|
200 | 200 | } |
201 | 201 | \ No newline at end of file |