Passed
Push — dependabot/composer/php8/forta... ( 9a9f56...0ecb64 )
by
unknown
17:53 queued 14:02
created
includes/Pages/UserAuth/PageForgotPassword.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -46,8 +46,7 @@  discard block
 block discarded – undo
46 46
             SessionAlert::success('<strong>Your password reset request has been completed.</strong> If the details you have provided match our records, you should receive an email shortly.');
47 47
 
48 48
             $this->redirect('login');
49
-        }
50
-        else {
49
+        } else {
51 50
             $this->assignCSRFToken();
52 51
             $this->setTemplate('forgot-password/forgotpw.tpl');
53 52
         }
@@ -130,8 +129,7 @@  discard block
 block discarded – undo
130 129
 
131 130
                 return;
132 131
             }
133
-        }
134
-        else {
132
+        } else {
135 133
             $this->assignCSRFToken();
136 134
             $this->assign('user', $user);
137 135
             $this->setTemplate('forgot-password/forgotpwreset.tpl');
Please login to merge, or discard this patch.
Indentation   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -23,213 +23,213 @@
 block discarded – undo
23 23
 
24 24
 class PageForgotPassword extends InternalPageBase
25 25
 {
26
-    /**
27
-     * Main function for this page, when no specific actions are called.
28
-     *
29
-     * This is the forgotten password reset form
30
-     * @category Security-Critical
31
-     */
32
-    protected function main()
33
-    {
34
-        if (WebRequest::wasPosted()) {
35
-            $this->validateCSRFToken();
36
-            $username = WebRequest::postString('username');
37
-            $email = WebRequest::postEmail('email');
38
-            $database = $this->getDatabase();
39
-
40
-            if ($username === null || trim($username) === "" || $email === null || trim($email) === "") {
41
-                throw new ApplicationLogicException("Both username and email address must be specified!");
42
-            }
43
-
44
-            $user = User::getByUsername($username, $database);
45
-            $this->sendResetMail($user, $email);
46
-
47
-            SessionAlert::success('<strong>Your password reset request has been completed.</strong> If the details you have provided match our records, you should receive an email shortly.');
48
-
49
-            $this->redirect('login');
50
-        }
51
-        else {
52
-            $this->assignCSRFToken();
53
-            $this->setTemplate('forgot-password/forgotpw.tpl');
54
-        }
55
-    }
56
-
57
-    /**
58
-     * Sends a reset email if the user is authenticated
59
-     *
60
-     * @param User|boolean $user  The user located from the database, or false. Doesn't really matter, since we do the
61
-     *                            check anyway within this method and silently skip if we don't have a user.
62
-     * @param string       $email The provided email address
63
-     */
64
-    private function sendResetMail($user, $email)
65
-    {
66
-        // If the user isn't found, or the email address is wrong, skip sending the details silently.
67
-        if (!$user instanceof User) {
68
-            return;
69
-        }
70
-
71
-        if (strtolower($user->getEmail()) === strtolower($email)) {
72
-            $clientIp = $this->getXffTrustProvider()
73
-                ->getTrustedClientIp(WebRequest::remoteAddress(), WebRequest::forwardedAddress());
74
-
75
-            $this->cleanExistingTokens($user);
76
-
77
-            $hash = Base32::encodeUpper(openssl_random_pseudo_bytes(30));
78
-
79
-            $encryptionHelper = new EncryptionHelper($this->getSiteConfiguration());
80
-
81
-            $cred = new Credential();
82
-            $cred->setDatabase($this->getDatabase());
83
-            $cred->setFactor(-1);
84
-            $cred->setUserId($user->getId());
85
-            $cred->setType('reset');
86
-            $cred->setData($encryptionHelper->encryptData($hash));
87
-            $cred->setVersion(0);
88
-            $cred->setDisabled(0);
89
-            $cred->setTimeout(new DateTimeImmutable('+ 1 hour'));
90
-            $cred->setPriority(9);
91
-            $cred->save();
92
-
93
-            $this->assign("user", $user);
94
-            $this->assign("hash", $hash);
95
-            $this->assign("remoteAddress", $clientIp);
96
-
97
-            $emailContent = $this->fetchTemplate('forgot-password/reset-mail.tpl');
98
-
99
-            // FIXME: domains!
100
-            /** @var Domain $domain */
101
-            $domain = Domain::getById(1, $this->getDatabase());
102
-            $this->getEmailHelper()->sendMail(
103
-                null, $user->getEmail(), "WP:ACC password reset", $emailContent);
104
-        }
105
-    }
106
-
107
-    /**
108
-     * Entry point for the reset action
109
-     *
110
-     * This is the reset password part of the form.
111
-     * @category Security-Critical
112
-     */
113
-    protected function reset()
114
-    {
115
-        $si = WebRequest::getString('si');
116
-        $id = WebRequest::getString('id');
117
-
118
-        if ($si === null || trim($si) === "" || $id === null || trim($id) === "") {
119
-            throw new ApplicationLogicException("Link not valid, please ensure it has copied correctly");
120
-        }
121
-
122
-        $database = $this->getDatabase();
123
-        $user = $this->getResettingUser($id, $database, $si);
124
-
125
-        // Dual mode
126
-        if (WebRequest::wasPosted()) {
127
-            $this->validateCSRFToken();
128
-            try {
129
-                $this->doReset($user);
130
-                $this->cleanExistingTokens($user);
131
-            }
132
-            catch (ApplicationLogicException $ex) {
133
-                SessionAlert::error($ex->getMessage());
134
-                $this->redirect('forgotPassword', 'reset', array('si' => $si, 'id' => $id));
135
-
136
-                return;
137
-            }
138
-        }
139
-        else {
140
-            $this->assignCSRFToken();
141
-            $this->assign('user', $user);
142
-            $this->setTemplate('forgot-password/forgotpwreset.tpl');
143
-            $this->addJs("/vendor/dropbox/zxcvbn/dist/zxcvbn.js");
144
-        }
145
-    }
146
-
147
-    /**
148
-     * Gets the user resetting their password from the database, or throwing an exception if that is not possible.
149
-     *
150
-     * @param integer     $id       The ID of the user to retrieve
151
-     * @param PdoDatabase $database The database object to use
152
-     * @param string      $si       The reset hash provided
153
-     *
154
-     * @return User
155
-     * @throws ApplicationLogicException
156
-     */
157
-    private function getResettingUser($id, $database, $si)
158
-    {
159
-        $user = User::getById($id, $database);
160
-
161
-        if ($user === false || $user->isCommunityUser()) {
162
-            throw new ApplicationLogicException("Password reset failed. Please try again.");
163
-        }
164
-
165
-        $statement = $database->prepare("SELECT * FROM credential WHERE type = 'reset' AND user = :user;");
166
-        $statement->execute([':user' => $user->getId()]);
167
-
168
-        /** @var Credential $credential */
169
-        $credential = $statement->fetchObject(Credential::class);
170
-
171
-        $statement->closeCursor();
172
-
173
-        if ($credential === false) {
174
-            throw new ApplicationLogicException("Password reset failed. Please try again.");
175
-        }
176
-
177
-        $credential->setDatabase($database);
178
-
179
-        $encryptionHelper = new EncryptionHelper($this->getSiteConfiguration());
180
-        if ($encryptionHelper->decryptData($credential->getData()) != $si) {
181
-            throw new ApplicationLogicException("Password reset failed. Please try again.");
182
-        }
183
-
184
-        if ($credential->getTimeout() < new DateTimeImmutable()) {
185
-            $credential->delete();
186
-            throw new ApplicationLogicException("Password reset token expired. Please try again.");
187
-        }
188
-
189
-        return $user;
190
-    }
191
-
192
-    /**
193
-     * Performs the setting of the new password
194
-     *
195
-     * @param User $user The user to set the password for
196
-     *
197
-     * @throws ApplicationLogicException
198
-     */
199
-    private function doReset(User $user)
200
-    {
201
-        $pw = WebRequest::postString('newpassword');
202
-        $pw2 = WebRequest::postString('newpasswordconfirm');
203
-
204
-        if ($pw !== $pw2) {
205
-            throw new ApplicationLogicException('Passwords do not match!');
206
-        }
207
-
208
-        $passwordCredentialProvider = new PasswordCredentialProvider($user->getDatabase(), $this->getSiteConfiguration());
209
-        $passwordCredentialProvider->setCredential($user, 1, $pw);
210
-
211
-        SessionAlert::success('You may now log in!');
212
-        $this->redirect('login');
213
-    }
214
-
215
-    protected function isProtectedPage()
216
-    {
217
-        return false;
218
-    }
219
-
220
-    /**
221
-     * @param $user
222
-     */
223
-    private function cleanExistingTokens($user): void
224
-    {
225
-        // clean out existing reset tokens
226
-        $statement = $this->getDatabase()->prepare("SELECT * FROM credential WHERE type = 'reset' AND user = :user;");
227
-        $statement->execute([':user' => $user->getId()]);
228
-        $existing = $statement->fetchAll(PdoDatabase::FETCH_CLASS, Credential::class);
229
-
230
-        foreach ($existing as $c) {
231
-            $c->setDatabase($this->getDatabase());
232
-            $c->delete();
233
-        }
234
-    }
26
+	/**
27
+	 * Main function for this page, when no specific actions are called.
28
+	 *
29
+	 * This is the forgotten password reset form
30
+	 * @category Security-Critical
31
+	 */
32
+	protected function main()
33
+	{
34
+		if (WebRequest::wasPosted()) {
35
+			$this->validateCSRFToken();
36
+			$username = WebRequest::postString('username');
37
+			$email = WebRequest::postEmail('email');
38
+			$database = $this->getDatabase();
39
+
40
+			if ($username === null || trim($username) === "" || $email === null || trim($email) === "") {
41
+				throw new ApplicationLogicException("Both username and email address must be specified!");
42
+			}
43
+
44
+			$user = User::getByUsername($username, $database);
45
+			$this->sendResetMail($user, $email);
46
+
47
+			SessionAlert::success('<strong>Your password reset request has been completed.</strong> If the details you have provided match our records, you should receive an email shortly.');
48
+
49
+			$this->redirect('login');
50
+		}
51
+		else {
52
+			$this->assignCSRFToken();
53
+			$this->setTemplate('forgot-password/forgotpw.tpl');
54
+		}
55
+	}
56
+
57
+	/**
58
+	 * Sends a reset email if the user is authenticated
59
+	 *
60
+	 * @param User|boolean $user  The user located from the database, or false. Doesn't really matter, since we do the
61
+	 *                            check anyway within this method and silently skip if we don't have a user.
62
+	 * @param string       $email The provided email address
63
+	 */
64
+	private function sendResetMail($user, $email)
65
+	{
66
+		// If the user isn't found, or the email address is wrong, skip sending the details silently.
67
+		if (!$user instanceof User) {
68
+			return;
69
+		}
70
+
71
+		if (strtolower($user->getEmail()) === strtolower($email)) {
72
+			$clientIp = $this->getXffTrustProvider()
73
+				->getTrustedClientIp(WebRequest::remoteAddress(), WebRequest::forwardedAddress());
74
+
75
+			$this->cleanExistingTokens($user);
76
+
77
+			$hash = Base32::encodeUpper(openssl_random_pseudo_bytes(30));
78
+
79
+			$encryptionHelper = new EncryptionHelper($this->getSiteConfiguration());
80
+
81
+			$cred = new Credential();
82
+			$cred->setDatabase($this->getDatabase());
83
+			$cred->setFactor(-1);
84
+			$cred->setUserId($user->getId());
85
+			$cred->setType('reset');
86
+			$cred->setData($encryptionHelper->encryptData($hash));
87
+			$cred->setVersion(0);
88
+			$cred->setDisabled(0);
89
+			$cred->setTimeout(new DateTimeImmutable('+ 1 hour'));
90
+			$cred->setPriority(9);
91
+			$cred->save();
92
+
93
+			$this->assign("user", $user);
94
+			$this->assign("hash", $hash);
95
+			$this->assign("remoteAddress", $clientIp);
96
+
97
+			$emailContent = $this->fetchTemplate('forgot-password/reset-mail.tpl');
98
+
99
+			// FIXME: domains!
100
+			/** @var Domain $domain */
101
+			$domain = Domain::getById(1, $this->getDatabase());
102
+			$this->getEmailHelper()->sendMail(
103
+				null, $user->getEmail(), "WP:ACC password reset", $emailContent);
104
+		}
105
+	}
106
+
107
+	/**
108
+	 * Entry point for the reset action
109
+	 *
110
+	 * This is the reset password part of the form.
111
+	 * @category Security-Critical
112
+	 */
113
+	protected function reset()
114
+	{
115
+		$si = WebRequest::getString('si');
116
+		$id = WebRequest::getString('id');
117
+
118
+		if ($si === null || trim($si) === "" || $id === null || trim($id) === "") {
119
+			throw new ApplicationLogicException("Link not valid, please ensure it has copied correctly");
120
+		}
121
+
122
+		$database = $this->getDatabase();
123
+		$user = $this->getResettingUser($id, $database, $si);
124
+
125
+		// Dual mode
126
+		if (WebRequest::wasPosted()) {
127
+			$this->validateCSRFToken();
128
+			try {
129
+				$this->doReset($user);
130
+				$this->cleanExistingTokens($user);
131
+			}
132
+			catch (ApplicationLogicException $ex) {
133
+				SessionAlert::error($ex->getMessage());
134
+				$this->redirect('forgotPassword', 'reset', array('si' => $si, 'id' => $id));
135
+
136
+				return;
137
+			}
138
+		}
139
+		else {
140
+			$this->assignCSRFToken();
141
+			$this->assign('user', $user);
142
+			$this->setTemplate('forgot-password/forgotpwreset.tpl');
143
+			$this->addJs("/vendor/dropbox/zxcvbn/dist/zxcvbn.js");
144
+		}
145
+	}
146
+
147
+	/**
148
+	 * Gets the user resetting their password from the database, or throwing an exception if that is not possible.
149
+	 *
150
+	 * @param integer     $id       The ID of the user to retrieve
151
+	 * @param PdoDatabase $database The database object to use
152
+	 * @param string      $si       The reset hash provided
153
+	 *
154
+	 * @return User
155
+	 * @throws ApplicationLogicException
156
+	 */
157
+	private function getResettingUser($id, $database, $si)
158
+	{
159
+		$user = User::getById($id, $database);
160
+
161
+		if ($user === false || $user->isCommunityUser()) {
162
+			throw new ApplicationLogicException("Password reset failed. Please try again.");
163
+		}
164
+
165
+		$statement = $database->prepare("SELECT * FROM credential WHERE type = 'reset' AND user = :user;");
166
+		$statement->execute([':user' => $user->getId()]);
167
+
168
+		/** @var Credential $credential */
169
+		$credential = $statement->fetchObject(Credential::class);
170
+
171
+		$statement->closeCursor();
172
+
173
+		if ($credential === false) {
174
+			throw new ApplicationLogicException("Password reset failed. Please try again.");
175
+		}
176
+
177
+		$credential->setDatabase($database);
178
+
179
+		$encryptionHelper = new EncryptionHelper($this->getSiteConfiguration());
180
+		if ($encryptionHelper->decryptData($credential->getData()) != $si) {
181
+			throw new ApplicationLogicException("Password reset failed. Please try again.");
182
+		}
183
+
184
+		if ($credential->getTimeout() < new DateTimeImmutable()) {
185
+			$credential->delete();
186
+			throw new ApplicationLogicException("Password reset token expired. Please try again.");
187
+		}
188
+
189
+		return $user;
190
+	}
191
+
192
+	/**
193
+	 * Performs the setting of the new password
194
+	 *
195
+	 * @param User $user The user to set the password for
196
+	 *
197
+	 * @throws ApplicationLogicException
198
+	 */
199
+	private function doReset(User $user)
200
+	{
201
+		$pw = WebRequest::postString('newpassword');
202
+		$pw2 = WebRequest::postString('newpasswordconfirm');
203
+
204
+		if ($pw !== $pw2) {
205
+			throw new ApplicationLogicException('Passwords do not match!');
206
+		}
207
+
208
+		$passwordCredentialProvider = new PasswordCredentialProvider($user->getDatabase(), $this->getSiteConfiguration());
209
+		$passwordCredentialProvider->setCredential($user, 1, $pw);
210
+
211
+		SessionAlert::success('You may now log in!');
212
+		$this->redirect('login');
213
+	}
214
+
215
+	protected function isProtectedPage()
216
+	{
217
+		return false;
218
+	}
219
+
220
+	/**
221
+	 * @param $user
222
+	 */
223
+	private function cleanExistingTokens($user): void
224
+	{
225
+		// clean out existing reset tokens
226
+		$statement = $this->getDatabase()->prepare("SELECT * FROM credential WHERE type = 'reset' AND user = :user;");
227
+		$statement->execute([':user' => $user->getId()]);
228
+		$existing = $statement->fetchAll(PdoDatabase::FETCH_CLASS, Credential::class);
229
+
230
+		foreach ($existing as $c) {
231
+			$c->setDatabase($this->getDatabase());
232
+			$c->delete();
233
+		}
234
+	}
235 235
 }
Please login to merge, or discard this patch.
includes/API/IXmlApiAction.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,12 +16,12 @@
 block discarded – undo
16 16
  */
17 17
 interface IXmlApiAction extends IRoutedTask, IApiAction
18 18
 {
19
-    /**
20
-     * Method that runs API action
21
-     *
22
-     * @param DOMElement $apiDocument
23
-     *
24
-     * @return DOMElement The modified API document
25
-     */
26
-    public function executeApiAction(DOMElement $apiDocument);
19
+	/**
20
+	 * Method that runs API action
21
+	 *
22
+	 * @param DOMElement $apiDocument
23
+	 *
24
+	 * @return DOMElement The modified API document
25
+	 */
26
+	public function executeApiAction(DOMElement $apiDocument);
27 27
 }
Please login to merge, or discard this patch.
includes/API/IJsonApiAction.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -15,10 +15,10 @@
 block discarded – undo
15 15
  */
16 16
 interface IJsonApiAction extends IRoutedTask, IApiAction
17 17
 {
18
-    /**
19
-     * Method that runs API action
20
-     *
21
-     * @return object|array The modified API document
22
-     */
23
-    public function executeApiAction();
18
+	/**
19
+	 * Method that runs API action
20
+	 *
21
+	 * @return object|array The modified API document
22
+	 */
23
+	public function executeApiAction();
24 24
 }
Please login to merge, or discard this patch.
includes/API/Actions/UnknownAction.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,15 +16,15 @@
 block discarded – undo
16 16
  */
17 17
 class UnknownAction extends HelpAction implements IXmlApiAction
18 18
 {
19
-    public function executeApiAction(DOMElement $apiDocument)
20
-    {
21
-        $errorText = "Unknown API action specified.";
22
-        $errorNode = $this->document->createElement("error", $errorText);
23
-        $apiDocument->appendChild($errorNode);
19
+	public function executeApiAction(DOMElement $apiDocument)
20
+	{
21
+		$errorText = "Unknown API action specified.";
22
+		$errorNode = $this->document->createElement("error", $errorText);
23
+		$apiDocument->appendChild($errorNode);
24 24
 
25
-        $helpElement = $this->getHelpElement();
26
-        $apiDocument->appendChild($helpElement);
25
+		$helpElement = $this->getHelpElement();
26
+		$apiDocument->appendChild($helpElement);
27 27
 
28
-        return $apiDocument;
29
-    }
28
+		return $apiDocument;
29
+	}
30 30
 }
Please login to merge, or discard this patch.
includes/API/Actions/HelpAction.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -18,34 +18,34 @@
 block discarded – undo
18 18
  */
19 19
 class HelpAction extends XmlApiPageBase implements IXmlApiAction
20 20
 {
21
-    public function executeApiAction(DOMElement $apiDocument)
22
-    {
23
-        $helpElement = $this->getHelpElement();
24
-        $apiDocument->appendChild($helpElement);
25
-
26
-        return $apiDocument;
27
-    }
28
-
29
-    /**
30
-     * Gets the help information
31
-     * @return DOMElement
32
-     */
33
-    protected function getHelpElement()
34
-    {
35
-        $helpInfo = "API help can be found at https://github.com/enwikipedia-acc/waca/wiki/API";
36
-
37
-        $help = $this->document->createElement("help");
38
-        $helptext = $this->document->createElement("info", $helpInfo);
39
-        $helpactions = $this->document->createElement("actions");
40
-
41
-        foreach (ApiRequestRouter::getActionList() as $action) {
42
-            $actionElement = $this->document->createElement("action", $action);
43
-            $helpactions->appendChild($actionElement);
44
-        }
45
-
46
-        $help->appendChild($helptext);
47
-        $help->appendChild($helpactions);
48
-
49
-        return $help;
50
-    }
21
+	public function executeApiAction(DOMElement $apiDocument)
22
+	{
23
+		$helpElement = $this->getHelpElement();
24
+		$apiDocument->appendChild($helpElement);
25
+
26
+		return $apiDocument;
27
+	}
28
+
29
+	/**
30
+	 * Gets the help information
31
+	 * @return DOMElement
32
+	 */
33
+	protected function getHelpElement()
34
+	{
35
+		$helpInfo = "API help can be found at https://github.com/enwikipedia-acc/waca/wiki/API";
36
+
37
+		$help = $this->document->createElement("help");
38
+		$helptext = $this->document->createElement("info", $helpInfo);
39
+		$helpactions = $this->document->createElement("actions");
40
+
41
+		foreach (ApiRequestRouter::getActionList() as $action) {
42
+			$actionElement = $this->document->createElement("action", $action);
43
+			$helpactions->appendChild($actionElement);
44
+		}
45
+
46
+		$help->appendChild($helptext);
47
+		$help->appendChild($helpactions);
48
+
49
+		return $help;
50
+	}
51 51
 }
Please login to merge, or discard this patch.
includes/API/Actions/MonitorAction.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -23,65 +23,65 @@
 block discarded – undo
23 23
  */
24 24
 class MonitorAction extends XmlApiPageBase implements IXmlApiAction
25 25
 {
26
-    /**
27
-     * @param DOMElement $apiDocument
28
-     *
29
-     * @return DOMElement
30
-     */
31
-    public function executeApiAction(DOMElement $apiDocument)
32
-    {
33
-        $now = new DateTime();
26
+	/**
27
+	 * @param DOMElement $apiDocument
28
+	 *
29
+	 * @return DOMElement
30
+	 */
31
+	public function executeApiAction(DOMElement $apiDocument)
32
+	{
33
+		$now = new DateTime();
34 34
 
35
-        $old = $this->getOldest();
36
-        $oldest = new DateTime($old);
35
+		$old = $this->getOldest();
36
+		$oldest = new DateTime($old);
37 37
 
38
-        $new = $this->getNewest();
39
-        $newest = new DateTime($new);
38
+		$new = $this->getNewest();
39
+		$newest = new DateTime($new);
40 40
 
41
-        $monitoringElement = $this->document->createElement("data");
42
-        $monitoringElement->setAttribute("date", $now->format('c'));
43
-        $monitoringElement->setAttribute("oldest", $old === null ? null : $oldest->format('c'));
44
-        $monitoringElement->setAttribute("newest", $new === null ? null : $newest->format('c'));
45
-        $apiDocument->appendChild($monitoringElement);
41
+		$monitoringElement = $this->document->createElement("data");
42
+		$monitoringElement->setAttribute("date", $now->format('c'));
43
+		$monitoringElement->setAttribute("oldest", $old === null ? null : $oldest->format('c'));
44
+		$monitoringElement->setAttribute("newest", $new === null ? null : $newest->format('c'));
45
+		$apiDocument->appendChild($monitoringElement);
46 46
 
47
-        return $apiDocument;
48
-    }
47
+		return $apiDocument;
48
+	}
49 49
 
50
-    /**
51
-     * @return string|null
52
-     */
53
-    private function getOldest()
54
-    {
55
-        $statement = $this->getDatabase()
56
-            ->prepare("SELECT min(date) FROM request WHERE email != :email AND ip != :ip;");
57
-        $successful = $statement->execute(array(
58
-            ':email' => $this->getSiteConfiguration()->getDataClearEmail(),
59
-            ':ip'    => $this->getSiteConfiguration()->getDataClearIp(),
60
-        ));
50
+	/**
51
+	 * @return string|null
52
+	 */
53
+	private function getOldest()
54
+	{
55
+		$statement = $this->getDatabase()
56
+			->prepare("SELECT min(date) FROM request WHERE email != :email AND ip != :ip;");
57
+		$successful = $statement->execute(array(
58
+			':email' => $this->getSiteConfiguration()->getDataClearEmail(),
59
+			':ip'    => $this->getSiteConfiguration()->getDataClearIp(),
60
+		));
61 61
 
62
-        if (!$successful) {
63
-            return null;
64
-        }
62
+		if (!$successful) {
63
+			return null;
64
+		}
65 65
 
66
-        $result = $statement->fetchColumn();
66
+		$result = $statement->fetchColumn();
67 67
 
68
-        return $result;
69
-    }
68
+		return $result;
69
+	}
70 70
 
71
-    /**
72
-     * @return string
73
-     */
74
-    private function getNewest()
75
-    {
76
-        $statement = $this->getDatabase()
77
-            ->prepare("SELECT max(date) FROM request WHERE email != :email AND ip != :ip;");
78
-        $statement->execute(array(
79
-            ':email' => $this->getSiteConfiguration()->getDataClearEmail(),
80
-            ':ip'    => $this->getSiteConfiguration()->getDataClearIp(),
81
-        ));
71
+	/**
72
+	 * @return string
73
+	 */
74
+	private function getNewest()
75
+	{
76
+		$statement = $this->getDatabase()
77
+			->prepare("SELECT max(date) FROM request WHERE email != :email AND ip != :ip;");
78
+		$statement->execute(array(
79
+			':email' => $this->getSiteConfiguration()->getDataClearEmail(),
80
+			':ip'    => $this->getSiteConfiguration()->getDataClearIp(),
81
+		));
82 82
 
83
-        $result = $statement->fetchColumn(0);
83
+		$result = $statement->fetchColumn(0);
84 84
 
85
-        return $result;
86
-    }
85
+		return $result;
86
+	}
87 87
 }
Please login to merge, or discard this patch.
includes/API/IApiAction.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@
 block discarded – undo
15 15
  */
16 16
 interface IApiAction extends IRoutedTask
17 17
 {
18
-    /**
19
-     * @return string the XML, or false if an error occurred.
20
-     */
21
-    public function runApiPage();
18
+	/**
19
+	 * @return string the XML, or false if an error occurred.
20
+	 */
21
+	public function runApiPage();
22 22
 }
Please login to merge, or discard this patch.
includes/AutoLoader.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -13,37 +13,37 @@
 block discarded – undo
13 13
  */
14 14
 class AutoLoader
15 15
 {
16
-    public static function load($class)
17
-    {
18
-        // handle namespaces sensibly
19
-        if (strpos($class, "Waca") !== false) {
20
-            // strip off the initial namespace
21
-            $class = str_replace("Waca\\", "", $class);
16
+	public static function load($class)
17
+	{
18
+		// handle namespaces sensibly
19
+		if (strpos($class, "Waca") !== false) {
20
+			// strip off the initial namespace
21
+			$class = str_replace("Waca\\", "", $class);
22 22
 
23
-            // swap backslashes for forward slashes to map to directory names
24
-            $class = str_replace("\\", "/", $class);
25
-        }
23
+			// swap backslashes for forward slashes to map to directory names
24
+			$class = str_replace("\\", "/", $class);
25
+		}
26 26
 
27
-        $paths = array(
28
-            __DIR__ . '/' . $class . ".php",
29
-            __DIR__ . '/DataObjects/' . $class . ".php",
30
-            __DIR__ . '/Providers/' . $class . ".php",
31
-            __DIR__ . '/Providers/Interfaces/' . $class . ".php",
32
-            __DIR__ . '/Validation/' . $class . ".php",
33
-            __DIR__ . '/Helpers/' . $class . ".php",
34
-            __DIR__ . '/Helpers/Interfaces/' . $class . ".php",
35
-            __DIR__ . '/' . $class . ".php",
36
-        );
27
+		$paths = array(
28
+			__DIR__ . '/' . $class . ".php",
29
+			__DIR__ . '/DataObjects/' . $class . ".php",
30
+			__DIR__ . '/Providers/' . $class . ".php",
31
+			__DIR__ . '/Providers/Interfaces/' . $class . ".php",
32
+			__DIR__ . '/Validation/' . $class . ".php",
33
+			__DIR__ . '/Helpers/' . $class . ".php",
34
+			__DIR__ . '/Helpers/Interfaces/' . $class . ".php",
35
+			__DIR__ . '/' . $class . ".php",
36
+		);
37 37
 
38
-        foreach ($paths as $file) {
39
-            if (file_exists($file)) {
40
-                /** @noinspection PhpIncludeInspection */
41
-                require_once($file);
42
-            }
38
+		foreach ($paths as $file) {
39
+			if (file_exists($file)) {
40
+				/** @noinspection PhpIncludeInspection */
41
+				require_once($file);
42
+			}
43 43
 
44
-            if (class_exists($class)) {
45
-                return;
46
-            }
47
-        }
48
-    }
44
+			if (class_exists($class)) {
45
+				return;
46
+			}
47
+		}
48
+	}
49 49
 }
Please login to merge, or discard this patch.
includes/Fragments/RequestListData.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,8 @@
 block discarded – undo
38 38
         $requestList->requests = $requests;
39 39
 
40 40
         $userIds = array_map(
41
-            function(Request $entry) {
41
+            function(Request $entry)
42
+            {
42 43
                 return $entry->getReserved();
43 44
             },
44 45
             $requests
Please login to merge, or discard this patch.
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -19,77 +19,77 @@
 block discarded – undo
19 19
 
20 20
 trait RequestListData
21 21
 {
22
-    // function imports from InternalPageBase etc.
23
-    protected abstract function getDatabase();
24
-
25
-    protected abstract function getXffTrustProvider();
26
-
27
-    /** @return SiteConfiguration */
28
-    protected abstract function getSiteConfiguration();
29
-
30
-    protected abstract function barrierTest($action, User $user, $pageName = null);
31
-
32
-    /**
33
-     * @param Request[] $requests
34
-     *
35
-     * @return RequestList
36
-     */
37
-    protected function prepareRequestData(array $requests) : RequestList
38
-    {
39
-        $requestList = new RequestList();
40
-        $requestList->requests = $requests;
41
-
42
-        $userIds = array_map(
43
-            function(Request $entry) {
44
-                return $entry->getReserved();
45
-            },
46
-            $requests
47
-        );
48
-
49
-        $requestList->userList = UserSearchHelper::get($this->getDatabase())->inIds($userIds)->fetchMap('username');
50
-
51
-        $requestList->requestTrustedIp = [];
52
-        $requestList->relatedIpRequests = [];
53
-        $requestList->relatedEmailRequests = [];
54
-
55
-        foreach ($requests as $request) {
56
-            $trustedIp = $this->getXffTrustProvider()->getTrustedClientIp(
57
-                $request->getIp(),
58
-                $request->getForwardedIp()
59
-            );
60
-
61
-            // TODO: Do we really want to return results from other domains?
62
-            RequestSearchHelper::get($this->getDatabase(), null)
63
-                ->byIp($trustedIp)
64
-                ->withConfirmedEmail()
65
-                ->excludingPurgedData($this->getSiteConfiguration())
66
-                ->excludingRequest($request->getId())
67
-                ->getRecordCount($ipCount);
68
-
69
-            RequestSearchHelper::get($this->getDatabase(), null)
70
-                ->byEmailAddress($request->getEmail())
71
-                ->withConfirmedEmail()
72
-                ->excludingPurgedData($this->getSiteConfiguration())
73
-                ->excludingRequest($request->getId())
74
-                ->getRecordCount($emailCount);
75
-
76
-            $requestList->requestTrustedIp[$request->getId()] = $trustedIp;
77
-            $requestList->relatedEmailRequests[$request->getId()] = $emailCount;
78
-            $requestList->relatedIpRequests[$request->getId()] = $ipCount;
79
-
80
-            $emailDomain = explode("@", $request->getEmail())[1];
81
-            $requestList->commonEmail[$request->getId()] = in_array(strtolower($emailDomain), $this->getSiteConfiguration()->getCommonEmailDomains())
82
-               || $request->getEmail() === $this->getSiteConfiguration()->getDataClearEmail();
83
-        }
84
-
85
-        $currentUser = User::getCurrent($this->getDatabase());
86
-
87
-        $requestList->canBan = $this->barrierTest('set', $currentUser, PageBan::class);
88
-        $requestList->canBreakReservation = $this->barrierTest('force', $currentUser, PageBreakReservation::class);
89
-        $requestList->showPrivateData = $this->barrierTest('alwaysSeePrivateData', $currentUser, 'RequestData');
90
-        $requestList->dataClearEmail = $this->getSiteConfiguration()->getDataClearEmail();
91
-        $requestList->dataClearIp = $this->getSiteConfiguration()->getDataClearIp();
92
-
93
-        return $requestList;
94
-    }
22
+	// function imports from InternalPageBase etc.
23
+	protected abstract function getDatabase();
24
+
25
+	protected abstract function getXffTrustProvider();
26
+
27
+	/** @return SiteConfiguration */
28
+	protected abstract function getSiteConfiguration();
29
+
30
+	protected abstract function barrierTest($action, User $user, $pageName = null);
31
+
32
+	/**
33
+	 * @param Request[] $requests
34
+	 *
35
+	 * @return RequestList
36
+	 */
37
+	protected function prepareRequestData(array $requests) : RequestList
38
+	{
39
+		$requestList = new RequestList();
40
+		$requestList->requests = $requests;
41
+
42
+		$userIds = array_map(
43
+			function(Request $entry) {
44
+				return $entry->getReserved();
45
+			},
46
+			$requests
47
+		);
48
+
49
+		$requestList->userList = UserSearchHelper::get($this->getDatabase())->inIds($userIds)->fetchMap('username');
50
+
51
+		$requestList->requestTrustedIp = [];
52
+		$requestList->relatedIpRequests = [];
53
+		$requestList->relatedEmailRequests = [];
54
+
55
+		foreach ($requests as $request) {
56
+			$trustedIp = $this->getXffTrustProvider()->getTrustedClientIp(
57
+				$request->getIp(),
58
+				$request->getForwardedIp()
59
+			);
60
+
61
+			// TODO: Do we really want to return results from other domains?
62
+			RequestSearchHelper::get($this->getDatabase(), null)
63
+				->byIp($trustedIp)
64
+				->withConfirmedEmail()
65
+				->excludingPurgedData($this->getSiteConfiguration())
66
+				->excludingRequest($request->getId())
67
+				->getRecordCount($ipCount);
68
+
69
+			RequestSearchHelper::get($this->getDatabase(), null)
70
+				->byEmailAddress($request->getEmail())
71
+				->withConfirmedEmail()
72
+				->excludingPurgedData($this->getSiteConfiguration())
73
+				->excludingRequest($request->getId())
74
+				->getRecordCount($emailCount);
75
+
76
+			$requestList->requestTrustedIp[$request->getId()] = $trustedIp;
77
+			$requestList->relatedEmailRequests[$request->getId()] = $emailCount;
78
+			$requestList->relatedIpRequests[$request->getId()] = $ipCount;
79
+
80
+			$emailDomain = explode("@", $request->getEmail())[1];
81
+			$requestList->commonEmail[$request->getId()] = in_array(strtolower($emailDomain), $this->getSiteConfiguration()->getCommonEmailDomains())
82
+			   || $request->getEmail() === $this->getSiteConfiguration()->getDataClearEmail();
83
+		}
84
+
85
+		$currentUser = User::getCurrent($this->getDatabase());
86
+
87
+		$requestList->canBan = $this->barrierTest('set', $currentUser, PageBan::class);
88
+		$requestList->canBreakReservation = $this->barrierTest('force', $currentUser, PageBreakReservation::class);
89
+		$requestList->showPrivateData = $this->barrierTest('alwaysSeePrivateData', $currentUser, 'RequestData');
90
+		$requestList->dataClearEmail = $this->getSiteConfiguration()->getDataClearEmail();
91
+		$requestList->dataClearIp = $this->getSiteConfiguration()->getDataClearIp();
92
+
93
+		return $requestList;
94
+	}
95 95
 }
Please login to merge, or discard this patch.