Passed
Push — smarty5 ( d2d462...e191ca )
by Simon
10:11 queued 06:07
created
includes/Offline.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -18,58 +18,58 @@
 block discarded – undo
18 18
  */
19 19
 class Offline
20 20
 {
21
-    /**
22
-     * Determines if the tool is offline
23
-     * @return bool
24
-     */
25
-    public static function isOffline(SiteConfiguration $configuration): bool
26
-    {
27
-        return (bool)$configuration->getOffline()['offline'];
28
-    }
21
+	/**
22
+	 * Determines if the tool is offline
23
+	 * @return bool
24
+	 */
25
+	public static function isOffline(SiteConfiguration $configuration): bool
26
+	{
27
+		return (bool)$configuration->getOffline()['offline'];
28
+	}
29 29
 
30
-    /**
31
-     * Gets the offline message
32
-     *
33
-     * @throws SmartyException
34
-     */
35
-    public static function getOfflineMessage(bool $external, SiteConfiguration $configuration, ?string $message = null): string
36
-    {
37
-        $baseurl = $configuration->getBaseUrl();
38
-        $culprit = $configuration->getOffline()['culprit'];
39
-        $reason = $configuration->getOffline()['reason'];
30
+	/**
31
+	 * Gets the offline message
32
+	 *
33
+	 * @throws SmartyException
34
+	 */
35
+	public static function getOfflineMessage(bool $external, SiteConfiguration $configuration, ?string $message = null): string
36
+	{
37
+		$baseurl = $configuration->getBaseUrl();
38
+		$culprit = $configuration->getOffline()['culprit'];
39
+		$reason = $configuration->getOffline()['reason'];
40 40
 
41
-        $smarty = new Smarty();
42
-        $smarty->assign("baseurl", $baseurl);
43
-        $smarty->assign("resourceCacheEpoch", 0);
44
-        $smarty->assign("alerts", []);
45
-        $smarty->assign("toolversion", Environment::getToolVersion());
46
-        $smarty->assign("onlineusers", []);
41
+		$smarty = new Smarty();
42
+		$smarty->assign("baseurl", $baseurl);
43
+		$smarty->assign("resourceCacheEpoch", 0);
44
+		$smarty->assign("alerts", []);
45
+		$smarty->assign("toolversion", Environment::getToolVersion());
46
+		$smarty->assign("onlineusers", []);
47 47
 
48
-        if (!headers_sent()) {
49
-            header("HTTP/1.1 503 Service Unavailable");
50
-        }
48
+		if (!headers_sent()) {
49
+			header("HTTP/1.1 503 Service Unavailable");
50
+		}
51 51
 
52
-        if ($external) {
53
-            return $smarty->fetch("offline/external.tpl");
54
-        }
55
-        else {
56
-            $hideCulprit = true;
52
+		if ($external) {
53
+			return $smarty->fetch("offline/external.tpl");
54
+		}
55
+		else {
56
+			$hideCulprit = true;
57 57
 
58
-            // Use the provided message if possible
59
-            if ($message === null) {
60
-                $hideCulprit = false;
61
-                $message = $reason;
62
-            }
58
+			// Use the provided message if possible
59
+			if ($message === null) {
60
+				$hideCulprit = false;
61
+				$message = $reason;
62
+			}
63 63
 
64
-            $smarty->assign("hideCulprit", $hideCulprit);
65
-            $smarty->assign("dontUseDbCulprit", $culprit);
66
-            $smarty->assign("dontUseDbReason", $message);
67
-            $smarty->assign("alerts", []);
68
-            $smarty->assign('currentUser', User::getCommunity());
69
-            $smarty->assign('skin', 'main');
70
-            $smarty->assign('currentDomain', null);
64
+			$smarty->assign("hideCulprit", $hideCulprit);
65
+			$smarty->assign("dontUseDbCulprit", $culprit);
66
+			$smarty->assign("dontUseDbReason", $message);
67
+			$smarty->assign("alerts", []);
68
+			$smarty->assign('currentUser', User::getCommunity());
69
+			$smarty->assign('skin', 'main');
70
+			$smarty->assign('currentDomain', null);
71 71
 
72
-            return $smarty->fetch("offline/internal.tpl");
73
-        }
74
-    }
72
+			return $smarty->fetch("offline/internal.tpl");
73
+		}
74
+	}
75 75
 }
Please login to merge, or discard this patch.
includes/Fragments/RequestData.php 1 patch
Indentation   +358 added lines, -358 removed lines patch added patch discarded remove patch
@@ -27,364 +27,364 @@
 block discarded – undo
27 27
 
28 28
 trait RequestData
29 29
 {
30
-    /** @return SiteConfiguration */
31
-    protected abstract function getSiteConfiguration();
32
-
33
-    /**
34
-     * @var array Array of IP address classed as 'private' by RFC1918.
35
-     */
36
-    protected static $rfc1918ips = array(
37
-        "10.0.0.0"    => "10.255.255.255",
38
-        "172.16.0.0"  => "172.31.255.255",
39
-        "192.168.0.0" => "192.168.255.255",
40
-        "169.254.0.0" => "169.254.255.255",
41
-        "127.0.0.0"   => "127.255.255.255",
42
-    );
43
-
44
-    /**
45
-     * Gets a request object
46
-     *
47
-     * @param PdoDatabase $database  The database connection
48
-     * @param int|null    $requestId The ID of the request to retrieve
49
-     *
50
-     * @return Request
51
-     * @throws ApplicationLogicException
52
-     */
53
-    protected function getRequest(PdoDatabase $database, $requestId)
54
-    {
55
-        if ($requestId === null) {
56
-            throw new ApplicationLogicException("No request specified");
57
-        }
58
-
59
-        $request = Request::getById($requestId, $database);
60
-        if ($request === false || !is_a($request, Request::class)) {
61
-            throw new ApplicationLogicException('Could not load the requested request!');
62
-        }
63
-
64
-        return $request;
65
-    }
66
-
67
-    /**
68
-     * Returns a value stating whether the user is allowed to see private data or not
69
-     *
70
-     * @param Request $request
71
-     * @param User    $currentUser
72
-     *
73
-     * @return bool
74
-     * @category Security-Critical
75
-     */
76
-    protected function isAllowedPrivateData(Request $request, User $currentUser)
77
-    {
78
-        // Test the main security barrier for private data access using SecurityManager
79
-        if ($this->barrierTest('alwaysSeePrivateData', $currentUser, 'RequestData')) {
80
-            // Tool admins/check-users can always see private data
81
-            return true;
82
-        }
83
-
84
-        // reserving user is allowed to see the data
85
-        if ($currentUser->getId() === $request->getReserved()
86
-            && $request->getReserved() !== null
87
-            && $this->barrierTest('seePrivateDataWhenReserved', $currentUser, 'RequestData')
88
-        ) {
89
-            return true;
90
-        }
91
-
92
-        // user has the reveal hash
93
-        if (WebRequest::getString('hash') === $request->getRevealHash()
94
-            && $this->barrierTest('seePrivateDataWithHash', $currentUser, 'RequestData')
95
-        ) {
96
-            return true;
97
-        }
98
-
99
-        // nope. Not allowed.
100
-        return false;
101
-    }
102
-
103
-    /**
104
-     * Tests the security barrier for a specified action.
105
-     *
106
-     * Don't use within templates
107
-     *
108
-     * @param string      $action
109
-     *
110
-     * @param User        $user
111
-     * @param null|string $pageName
112
-     *
113
-     * @return bool
114
-     * @category Security-Critical
115
-     */
116
-    abstract protected function barrierTest($action, User $user, $pageName = null);
117
-
118
-    /**
119
-     * Gets the name of the route that has been passed from the request router.
120
-     * @return string
121
-     */
122
-    abstract protected function getRouteName();
123
-
124
-    abstract protected function getSecurityManager(): ISecurityManager;
125
-
126
-    /**
127
-     * Sets the name of the template this page should display.
128
-     *
129
-     * @param string $name
130
-     */
131
-    abstract protected function setTemplate($name);
132
-
133
-    /** @return IXffTrustProvider */
134
-    abstract protected function getXffTrustProvider();
135
-
136
-    /** @return ILocationProvider */
137
-    abstract protected function getLocationProvider();
138
-
139
-    /** @return IRDnsProvider */
140
-    abstract protected function getRdnsProvider();
141
-
142
-    /**
143
-     * Assigns a Smarty variable
144
-     *
145
-     * @param  array|string $name  the template variable name(s)
146
-     * @param  mixed        $value the value to assign
147
-     */
148
-    abstract protected function assign($name, $value);
149
-
150
-    /**
151
-     * @param int|null    $requestReservationId
152
-     * @param PdoDatabase $database
153
-     * @param User        $currentUser
154
-     */
155
-    protected function setupReservationDetails($requestReservationId, PdoDatabase $database, User $currentUser)
156
-    {
157
-        $requestIsReserved = $requestReservationId !== null;
158
-        $this->assign('requestIsReserved', $requestIsReserved);
159
-        $this->assign('requestIsReservedByMe', false);
160
-
161
-        if ($requestIsReserved) {
162
-            $this->assign('requestReservedByName', User::getById($requestReservationId, $database)->getUsername());
163
-            $this->assign('requestReservedById', $requestReservationId);
164
-
165
-            if ($requestReservationId === $currentUser->getId()) {
166
-                $this->assign('requestIsReservedByMe', true);
167
-            }
168
-        }
169
-
170
-        $this->assign('canBreakReservation', $this->barrierTest('force', $currentUser, PageBreakReservation::class));
171
-    }
172
-
173
-    /**
174
-     * Adds private request data to Smarty. DO NOT USE WITHOUT FIRST CHECKING THAT THE USER IS AUTHORISED!
175
-     *
176
-     * @param Request           $request
177
-     * @param SiteConfiguration $configuration
178
-     */
179
-    protected function setupPrivateData(
180
-        $request,
181
-        SiteConfiguration $configuration
182
-    ) {
183
-        $xffProvider = $this->getXffTrustProvider();
184
-
185
-        $this->assign('requestEmail', $request->getEmail());
186
-        $emailDomain = explode("@", $request->getEmail())[1];
187
-        $this->assign("emailurl", $emailDomain);
188
-        $this->assign('commonEmailDomain', in_array(strtolower($emailDomain), $configuration->getCommonEmailDomains())
189
-            || $request->getEmail() === $this->getSiteConfiguration()->getDataClearEmail());
190
-
191
-        $trustedIp = $xffProvider->getTrustedClientIp($request->getIp(), $request->getForwardedIp());
192
-        $this->assign('requestTrustedIp', $trustedIp);
193
-        $this->assign('requestTrustedIpProtocol', $this->getIpProtocol($trustedIp));
194
-        $this->assign('requestRealIp', $request->getIp());
195
-        $this->assign('requestForwardedIp', $request->getForwardedIp());
196
-
197
-        $trustedIpLocation = $this->getLocationProvider()->getIpLocation($trustedIp);
198
-        $this->assign('requestTrustedIpLocation', $trustedIpLocation);
199
-
200
-        $this->assign('requestHasForwardedIp', $request->getForwardedIp() !== null);
201
-
202
-        $this->setupForwardedIpData($request);
203
-    }
204
-
205
-    /**
206
-     * Adds related request data to Smarty. DO NOT USE WITHOUT FIRST CHECKING THAT THE USER IS AUTHORISED!
207
-     *
208
-     * @param Request           $request
209
-     * @param SiteConfiguration $configuration
210
-     * @param PdoDatabase       $database
211
-     */
212
-    protected function setupRelatedRequests(
213
-        Request $request,
214
-        SiteConfiguration $configuration,
215
-        PdoDatabase $database)
216
-    {
217
-        $this->assign('canSeeRelatedRequests', true);
218
-
219
-        // TODO: Do we want to return results from other domains?
220
-        $relatedEmailRequests = RequestSearchHelper::get($database, null)
221
-            ->byEmailAddress($request->getEmail())
222
-            ->withConfirmedEmail()
223
-            ->excludingPurgedData($configuration)
224
-            ->excludingRequest($request->getId())
225
-            ->fetch();
226
-
227
-        $this->assign('requestRelatedEmailRequestsCount', count($relatedEmailRequests));
228
-        $this->assign('requestRelatedEmailRequests', $relatedEmailRequests);
229
-
230
-        $trustedIp = $this->getXffTrustProvider()->getTrustedClientIp($request->getIp(), $request->getForwardedIp());
231
-
232
-        // TODO: Do we want to return results from other domains?
233
-        $relatedIpRequests = RequestSearchHelper::get($database, null)
234
-            ->byIp($trustedIp)
235
-            ->withConfirmedEmail()
236
-            ->excludingPurgedData($configuration)
237
-            ->excludingRequest($request->getId())
238
-            ->fetch();
239
-
240
-        $this->assign('requestRelatedIpRequestsCount', count($relatedIpRequests));
241
-        $this->assign('requestRelatedIpRequests', $relatedIpRequests);
242
-    }
243
-
244
-    /**
245
-     * Adds checkuser request data to Smarty. DO NOT USE WITHOUT FIRST CHECKING THAT THE USER IS AUTHORISED!
246
-     *
247
-     * @param Request $request
248
-     */
249
-    protected function setupCheckUserData(Request $request)
250
-    {
251
-        $this->assign('requestUserAgent', $request->getUserAgent());
252
-
253
-        $data = \Waca\DataObjects\RequestData::getForRequest($request->getId(), $request->getDatabase(), \Waca\DataObjects\RequestData::TYPE_CLIENTHINT);
254
-        $this->assign('requestClientHints', $data);
255
-    }
256
-
257
-    /**
258
-     * Sets up the basic data for this request, and adds it to Smarty
259
-     *
260
-     * @param Request           $request
261
-     * @param SiteConfiguration $config
262
-     */
263
-    protected function setupBasicData(Request $request, SiteConfiguration $config)
264
-    {
265
-        $this->assign('requestId', $request->getId());
266
-        $this->assign('updateVersion', $request->getUpdateVersion());
267
-        $this->assign('requestName', $request->getName());
268
-        $this->assign('requestDate', $request->getDate());
269
-        $this->assign('requestStatus', $request->getStatus());
270
-
271
-        $this->assign('requestQueue', null);
272
-        if ($request->getQueue() !== null) {
273
-            /** @var RequestQueue $queue */
274
-            $queue = RequestQueue::getById($request->getQueue(), $this->getDatabase());
275
-            $this->assign('requestQueue', $queue->getHeader());
276
-            $this->assign('requestQueueApiName', $queue->getApiName());
277
-        }
278
-
279
-        $this->assign('canPreviewForm', $this->barrierTest('view', User::getCurrent($this->getDatabase()), PageRequestFormManagement::class));
280
-        $this->assign('originForm', $request->getOriginFormObject());
281
-
282
-        $isClosed = $request->getStatus() === RequestStatus::CLOSED || $request->getStatus() === RequestStatus::JOBQUEUE;
283
-        $this->assign('requestIsClosed', $isClosed);
30
+	/** @return SiteConfiguration */
31
+	protected abstract function getSiteConfiguration();
32
+
33
+	/**
34
+	 * @var array Array of IP address classed as 'private' by RFC1918.
35
+	 */
36
+	protected static $rfc1918ips = array(
37
+		"10.0.0.0"    => "10.255.255.255",
38
+		"172.16.0.0"  => "172.31.255.255",
39
+		"192.168.0.0" => "192.168.255.255",
40
+		"169.254.0.0" => "169.254.255.255",
41
+		"127.0.0.0"   => "127.255.255.255",
42
+	);
43
+
44
+	/**
45
+	 * Gets a request object
46
+	 *
47
+	 * @param PdoDatabase $database  The database connection
48
+	 * @param int|null    $requestId The ID of the request to retrieve
49
+	 *
50
+	 * @return Request
51
+	 * @throws ApplicationLogicException
52
+	 */
53
+	protected function getRequest(PdoDatabase $database, $requestId)
54
+	{
55
+		if ($requestId === null) {
56
+			throw new ApplicationLogicException("No request specified");
57
+		}
58
+
59
+		$request = Request::getById($requestId, $database);
60
+		if ($request === false || !is_a($request, Request::class)) {
61
+			throw new ApplicationLogicException('Could not load the requested request!');
62
+		}
63
+
64
+		return $request;
65
+	}
66
+
67
+	/**
68
+	 * Returns a value stating whether the user is allowed to see private data or not
69
+	 *
70
+	 * @param Request $request
71
+	 * @param User    $currentUser
72
+	 *
73
+	 * @return bool
74
+	 * @category Security-Critical
75
+	 */
76
+	protected function isAllowedPrivateData(Request $request, User $currentUser)
77
+	{
78
+		// Test the main security barrier for private data access using SecurityManager
79
+		if ($this->barrierTest('alwaysSeePrivateData', $currentUser, 'RequestData')) {
80
+			// Tool admins/check-users can always see private data
81
+			return true;
82
+		}
83
+
84
+		// reserving user is allowed to see the data
85
+		if ($currentUser->getId() === $request->getReserved()
86
+			&& $request->getReserved() !== null
87
+			&& $this->barrierTest('seePrivateDataWhenReserved', $currentUser, 'RequestData')
88
+		) {
89
+			return true;
90
+		}
91
+
92
+		// user has the reveal hash
93
+		if (WebRequest::getString('hash') === $request->getRevealHash()
94
+			&& $this->barrierTest('seePrivateDataWithHash', $currentUser, 'RequestData')
95
+		) {
96
+			return true;
97
+		}
98
+
99
+		// nope. Not allowed.
100
+		return false;
101
+	}
102
+
103
+	/**
104
+	 * Tests the security barrier for a specified action.
105
+	 *
106
+	 * Don't use within templates
107
+	 *
108
+	 * @param string      $action
109
+	 *
110
+	 * @param User        $user
111
+	 * @param null|string $pageName
112
+	 *
113
+	 * @return bool
114
+	 * @category Security-Critical
115
+	 */
116
+	abstract protected function barrierTest($action, User $user, $pageName = null);
117
+
118
+	/**
119
+	 * Gets the name of the route that has been passed from the request router.
120
+	 * @return string
121
+	 */
122
+	abstract protected function getRouteName();
123
+
124
+	abstract protected function getSecurityManager(): ISecurityManager;
125
+
126
+	/**
127
+	 * Sets the name of the template this page should display.
128
+	 *
129
+	 * @param string $name
130
+	 */
131
+	abstract protected function setTemplate($name);
132
+
133
+	/** @return IXffTrustProvider */
134
+	abstract protected function getXffTrustProvider();
135
+
136
+	/** @return ILocationProvider */
137
+	abstract protected function getLocationProvider();
138
+
139
+	/** @return IRDnsProvider */
140
+	abstract protected function getRdnsProvider();
141
+
142
+	/**
143
+	 * Assigns a Smarty variable
144
+	 *
145
+	 * @param  array|string $name  the template variable name(s)
146
+	 * @param  mixed        $value the value to assign
147
+	 */
148
+	abstract protected function assign($name, $value);
149
+
150
+	/**
151
+	 * @param int|null    $requestReservationId
152
+	 * @param PdoDatabase $database
153
+	 * @param User        $currentUser
154
+	 */
155
+	protected function setupReservationDetails($requestReservationId, PdoDatabase $database, User $currentUser)
156
+	{
157
+		$requestIsReserved = $requestReservationId !== null;
158
+		$this->assign('requestIsReserved', $requestIsReserved);
159
+		$this->assign('requestIsReservedByMe', false);
160
+
161
+		if ($requestIsReserved) {
162
+			$this->assign('requestReservedByName', User::getById($requestReservationId, $database)->getUsername());
163
+			$this->assign('requestReservedById', $requestReservationId);
164
+
165
+			if ($requestReservationId === $currentUser->getId()) {
166
+				$this->assign('requestIsReservedByMe', true);
167
+			}
168
+		}
169
+
170
+		$this->assign('canBreakReservation', $this->barrierTest('force', $currentUser, PageBreakReservation::class));
171
+	}
172
+
173
+	/**
174
+	 * Adds private request data to Smarty. DO NOT USE WITHOUT FIRST CHECKING THAT THE USER IS AUTHORISED!
175
+	 *
176
+	 * @param Request           $request
177
+	 * @param SiteConfiguration $configuration
178
+	 */
179
+	protected function setupPrivateData(
180
+		$request,
181
+		SiteConfiguration $configuration
182
+	) {
183
+		$xffProvider = $this->getXffTrustProvider();
184
+
185
+		$this->assign('requestEmail', $request->getEmail());
186
+		$emailDomain = explode("@", $request->getEmail())[1];
187
+		$this->assign("emailurl", $emailDomain);
188
+		$this->assign('commonEmailDomain', in_array(strtolower($emailDomain), $configuration->getCommonEmailDomains())
189
+			|| $request->getEmail() === $this->getSiteConfiguration()->getDataClearEmail());
190
+
191
+		$trustedIp = $xffProvider->getTrustedClientIp($request->getIp(), $request->getForwardedIp());
192
+		$this->assign('requestTrustedIp', $trustedIp);
193
+		$this->assign('requestTrustedIpProtocol', $this->getIpProtocol($trustedIp));
194
+		$this->assign('requestRealIp', $request->getIp());
195
+		$this->assign('requestForwardedIp', $request->getForwardedIp());
196
+
197
+		$trustedIpLocation = $this->getLocationProvider()->getIpLocation($trustedIp);
198
+		$this->assign('requestTrustedIpLocation', $trustedIpLocation);
199
+
200
+		$this->assign('requestHasForwardedIp', $request->getForwardedIp() !== null);
201
+
202
+		$this->setupForwardedIpData($request);
203
+	}
204
+
205
+	/**
206
+	 * Adds related request data to Smarty. DO NOT USE WITHOUT FIRST CHECKING THAT THE USER IS AUTHORISED!
207
+	 *
208
+	 * @param Request           $request
209
+	 * @param SiteConfiguration $configuration
210
+	 * @param PdoDatabase       $database
211
+	 */
212
+	protected function setupRelatedRequests(
213
+		Request $request,
214
+		SiteConfiguration $configuration,
215
+		PdoDatabase $database)
216
+	{
217
+		$this->assign('canSeeRelatedRequests', true);
218
+
219
+		// TODO: Do we want to return results from other domains?
220
+		$relatedEmailRequests = RequestSearchHelper::get($database, null)
221
+			->byEmailAddress($request->getEmail())
222
+			->withConfirmedEmail()
223
+			->excludingPurgedData($configuration)
224
+			->excludingRequest($request->getId())
225
+			->fetch();
226
+
227
+		$this->assign('requestRelatedEmailRequestsCount', count($relatedEmailRequests));
228
+		$this->assign('requestRelatedEmailRequests', $relatedEmailRequests);
229
+
230
+		$trustedIp = $this->getXffTrustProvider()->getTrustedClientIp($request->getIp(), $request->getForwardedIp());
231
+
232
+		// TODO: Do we want to return results from other domains?
233
+		$relatedIpRequests = RequestSearchHelper::get($database, null)
234
+			->byIp($trustedIp)
235
+			->withConfirmedEmail()
236
+			->excludingPurgedData($configuration)
237
+			->excludingRequest($request->getId())
238
+			->fetch();
239
+
240
+		$this->assign('requestRelatedIpRequestsCount', count($relatedIpRequests));
241
+		$this->assign('requestRelatedIpRequests', $relatedIpRequests);
242
+	}
243
+
244
+	/**
245
+	 * Adds checkuser request data to Smarty. DO NOT USE WITHOUT FIRST CHECKING THAT THE USER IS AUTHORISED!
246
+	 *
247
+	 * @param Request $request
248
+	 */
249
+	protected function setupCheckUserData(Request $request)
250
+	{
251
+		$this->assign('requestUserAgent', $request->getUserAgent());
252
+
253
+		$data = \Waca\DataObjects\RequestData::getForRequest($request->getId(), $request->getDatabase(), \Waca\DataObjects\RequestData::TYPE_CLIENTHINT);
254
+		$this->assign('requestClientHints', $data);
255
+	}
256
+
257
+	/**
258
+	 * Sets up the basic data for this request, and adds it to Smarty
259
+	 *
260
+	 * @param Request           $request
261
+	 * @param SiteConfiguration $config
262
+	 */
263
+	protected function setupBasicData(Request $request, SiteConfiguration $config)
264
+	{
265
+		$this->assign('requestId', $request->getId());
266
+		$this->assign('updateVersion', $request->getUpdateVersion());
267
+		$this->assign('requestName', $request->getName());
268
+		$this->assign('requestDate', $request->getDate());
269
+		$this->assign('requestStatus', $request->getStatus());
270
+
271
+		$this->assign('requestQueue', null);
272
+		if ($request->getQueue() !== null) {
273
+			/** @var RequestQueue $queue */
274
+			$queue = RequestQueue::getById($request->getQueue(), $this->getDatabase());
275
+			$this->assign('requestQueue', $queue->getHeader());
276
+			$this->assign('requestQueueApiName', $queue->getApiName());
277
+		}
278
+
279
+		$this->assign('canPreviewForm', $this->barrierTest('view', User::getCurrent($this->getDatabase()), PageRequestFormManagement::class));
280
+		$this->assign('originForm', $request->getOriginFormObject());
281
+
282
+		$isClosed = $request->getStatus() === RequestStatus::CLOSED || $request->getStatus() === RequestStatus::JOBQUEUE;
283
+		$this->assign('requestIsClosed', $isClosed);
284 284
 		$isHospital = $request->getStatus() === RequestStatus::HOSPITAL;
285 285
 		$this->assign('requestIsHospital', $isHospital);
286
-    }
287
-
288
-    /**
289
-     * Sets up the forwarded IP data for this request and adds it to Smarty
290
-     *
291
-     * @param Request $request
292
-     */
293
-    protected function setupForwardedIpData(Request $request)
294
-    {
295
-        if ($request->getForwardedIp() !== null) {
296
-            $requestProxyData = array(); // Initialize array to store data to be output in Smarty template.
297
-            $proxyIndex = 0;
298
-
299
-            // Assuming [client] <=> [proxy1] <=> [proxy2] <=> [proxy3] <=> [us], we will see an XFF header of [client],
300
-            // [proxy1], [proxy2], and our actual IP will be [proxy3]
301
-            $proxies = explode(",", $request->getForwardedIp());
302
-            $proxies[] = $request->getIp();
303
-
304
-            // Origin is the supposed "client" IP.
305
-            $origin = $proxies[0];
306
-            $this->assign("forwardedOrigin", $origin);
307
-
308
-            // We step through the servers in reverse order, from closest to furthest
309
-            $proxies = array_reverse($proxies);
310
-
311
-            // By default, we have trust, because the first in the chain is now REMOTE_ADDR, which is hardest to spoof.
312
-            $trust = true;
313
-
314
-            /**
315
-             * @var int    $index     The zero-based index of the proxy.
316
-             * @var string $proxyData The proxy IP address (although possibly not!)
317
-             */
318
-            foreach ($proxies as $index => $proxyData) {
319
-                $proxyAddress = trim($proxyData);
320
-                $requestProxyData[$proxyIndex]['ip'] = $proxyAddress;
321
-                $requestProxyData[$proxyIndex]['protocol'] = $this->getIpProtocol($proxyAddress);
322
-
323
-                // get data on this IP.
324
-                $thisProxyIsTrusted = $this->getXffTrustProvider()->isTrusted($proxyAddress);
325
-
326
-                $proxyIsInPrivateRange = $this->getXffTrustProvider()
327
-                    ->ipInRange(self::$rfc1918ips, $proxyAddress);
328
-
329
-                if (!$proxyIsInPrivateRange) {
330
-                    $proxyReverseDns = $this->getRdnsProvider()->getReverseDNS($proxyAddress);
331
-                    $proxyLocation = $this->getLocationProvider()->getIpLocation($proxyAddress);
332
-                }
333
-                else {
334
-                    // this is going to fail, so why bother trying?
335
-                    $proxyReverseDns = false;
336
-                    $proxyLocation = false;
337
-                }
338
-
339
-                // current trust chain status BEFORE this link
340
-                $preLinkTrust = $trust;
341
-
342
-                // is *this* link trusted? Note, this will be true even if there is an untrusted link before this!
343
-                $requestProxyData[$proxyIndex]['trustedlink'] = $thisProxyIsTrusted;
344
-
345
-                // set the trust status of the chain to this point
346
-                $trust = $trust & $thisProxyIsTrusted;
347
-
348
-                // If this is the origin address, and the chain was trusted before this point, then we can trust
349
-                // the origin.
350
-                if ($preLinkTrust && $proxyAddress == $origin) {
351
-                    // if this is the origin, then we are at the last point in the chain.
352
-                    // @todo: this is probably the cause of some bugs when an IP appears twice - we're missing a check
353
-                    // to see if this is *really* the last in the chain, rather than just the same IP as it.
354
-                    $trust = true;
355
-                }
356
-
357
-                $requestProxyData[$proxyIndex]['trust'] = $trust;
358
-
359
-                $requestProxyData[$proxyIndex]['rdnsfailed'] = $proxyReverseDns === false;
360
-                $requestProxyData[$proxyIndex]['rdns'] = $proxyReverseDns;
361
-                $requestProxyData[$proxyIndex]['routable'] = !$proxyIsInPrivateRange;
362
-
363
-                $requestProxyData[$proxyIndex]['location'] = $proxyLocation;
364
-
365
-                if ($proxyReverseDns === $proxyAddress && $proxyIsInPrivateRange === false) {
366
-                    $requestProxyData[$proxyIndex]['rdns'] = null;
367
-                }
368
-
369
-                $showLinks = (!$trust || $proxyAddress == $origin) && !$proxyIsInPrivateRange;
370
-                $requestProxyData[$proxyIndex]['showlinks'] = $showLinks;
371
-
372
-                $proxyIndex++;
373
-            }
374
-
375
-            $this->assign("requestProxyData", $requestProxyData);
376
-        }
377
-    }
378
-
379
-    private function getIpProtocol(string $ip): ?int
380
-    {
381
-        if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
382
-            return 4;
383
-        }
384
-        if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
385
-            return 6;
386
-        }
387
-
388
-        return null;
389
-    }
286
+	}
287
+
288
+	/**
289
+	 * Sets up the forwarded IP data for this request and adds it to Smarty
290
+	 *
291
+	 * @param Request $request
292
+	 */
293
+	protected function setupForwardedIpData(Request $request)
294
+	{
295
+		if ($request->getForwardedIp() !== null) {
296
+			$requestProxyData = array(); // Initialize array to store data to be output in Smarty template.
297
+			$proxyIndex = 0;
298
+
299
+			// Assuming [client] <=> [proxy1] <=> [proxy2] <=> [proxy3] <=> [us], we will see an XFF header of [client],
300
+			// [proxy1], [proxy2], and our actual IP will be [proxy3]
301
+			$proxies = explode(",", $request->getForwardedIp());
302
+			$proxies[] = $request->getIp();
303
+
304
+			// Origin is the supposed "client" IP.
305
+			$origin = $proxies[0];
306
+			$this->assign("forwardedOrigin", $origin);
307
+
308
+			// We step through the servers in reverse order, from closest to furthest
309
+			$proxies = array_reverse($proxies);
310
+
311
+			// By default, we have trust, because the first in the chain is now REMOTE_ADDR, which is hardest to spoof.
312
+			$trust = true;
313
+
314
+			/**
315
+			 * @var int    $index     The zero-based index of the proxy.
316
+			 * @var string $proxyData The proxy IP address (although possibly not!)
317
+			 */
318
+			foreach ($proxies as $index => $proxyData) {
319
+				$proxyAddress = trim($proxyData);
320
+				$requestProxyData[$proxyIndex]['ip'] = $proxyAddress;
321
+				$requestProxyData[$proxyIndex]['protocol'] = $this->getIpProtocol($proxyAddress);
322
+
323
+				// get data on this IP.
324
+				$thisProxyIsTrusted = $this->getXffTrustProvider()->isTrusted($proxyAddress);
325
+
326
+				$proxyIsInPrivateRange = $this->getXffTrustProvider()
327
+					->ipInRange(self::$rfc1918ips, $proxyAddress);
328
+
329
+				if (!$proxyIsInPrivateRange) {
330
+					$proxyReverseDns = $this->getRdnsProvider()->getReverseDNS($proxyAddress);
331
+					$proxyLocation = $this->getLocationProvider()->getIpLocation($proxyAddress);
332
+				}
333
+				else {
334
+					// this is going to fail, so why bother trying?
335
+					$proxyReverseDns = false;
336
+					$proxyLocation = false;
337
+				}
338
+
339
+				// current trust chain status BEFORE this link
340
+				$preLinkTrust = $trust;
341
+
342
+				// is *this* link trusted? Note, this will be true even if there is an untrusted link before this!
343
+				$requestProxyData[$proxyIndex]['trustedlink'] = $thisProxyIsTrusted;
344
+
345
+				// set the trust status of the chain to this point
346
+				$trust = $trust & $thisProxyIsTrusted;
347
+
348
+				// If this is the origin address, and the chain was trusted before this point, then we can trust
349
+				// the origin.
350
+				if ($preLinkTrust && $proxyAddress == $origin) {
351
+					// if this is the origin, then we are at the last point in the chain.
352
+					// @todo: this is probably the cause of some bugs when an IP appears twice - we're missing a check
353
+					// to see if this is *really* the last in the chain, rather than just the same IP as it.
354
+					$trust = true;
355
+				}
356
+
357
+				$requestProxyData[$proxyIndex]['trust'] = $trust;
358
+
359
+				$requestProxyData[$proxyIndex]['rdnsfailed'] = $proxyReverseDns === false;
360
+				$requestProxyData[$proxyIndex]['rdns'] = $proxyReverseDns;
361
+				$requestProxyData[$proxyIndex]['routable'] = !$proxyIsInPrivateRange;
362
+
363
+				$requestProxyData[$proxyIndex]['location'] = $proxyLocation;
364
+
365
+				if ($proxyReverseDns === $proxyAddress && $proxyIsInPrivateRange === false) {
366
+					$requestProxyData[$proxyIndex]['rdns'] = null;
367
+				}
368
+
369
+				$showLinks = (!$trust || $proxyAddress == $origin) && !$proxyIsInPrivateRange;
370
+				$requestProxyData[$proxyIndex]['showlinks'] = $showLinks;
371
+
372
+				$proxyIndex++;
373
+			}
374
+
375
+			$this->assign("requestProxyData", $requestProxyData);
376
+		}
377
+	}
378
+
379
+	private function getIpProtocol(string $ip): ?int
380
+	{
381
+		if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
382
+			return 4;
383
+		}
384
+		if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
385
+			return 6;
386
+		}
387
+
388
+		return null;
389
+	}
390 390
 }
Please login to merge, or discard this patch.
includes/API/Actions/MetricsAction.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -18,57 +18,57 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class MetricsAction extends TextApiPageBase implements IApiAction
20 20
 {
21
-    private array $metrics = [];
21
+	private array $metrics = [];
22 22
 
23
-    private function defineMetric(string $name, string $help, string $type = 'gauge'): void
24
-    {
25
-        $this->metrics[$name] = ['help' => $help, 'type' => $type, 'values' => []];
26
-    }
23
+	private function defineMetric(string $name, string $help, string $type = 'gauge'): void
24
+	{
25
+		$this->metrics[$name] = ['help' => $help, 'type' => $type, 'values' => []];
26
+	}
27 27
 
28
-    private function setMetric(string $name, array $labels = [], int $value = 0): void
29
-    {
30
-        $calculatedLabel = '';
28
+	private function setMetric(string $name, array $labels = [], int $value = 0): void
29
+	{
30
+		$calculatedLabel = '';
31 31
 
32
-        if (count($labels) > 0) {
33
-            ksort($labels);
32
+		if (count($labels) > 0) {
33
+			ksort($labels);
34 34
 
35
-            $labelData = [];
36
-            foreach ($labels as $label => $labelValue) {
37
-                $labelData[] = $label . '="' . $labelValue . '"';
38
-            }
35
+			$labelData = [];
36
+			foreach ($labels as $label => $labelValue) {
37
+				$labelData[] = $label . '="' . $labelValue . '"';
38
+			}
39 39
 
40
-            $calculatedLabel = '{' . implode(',', $labelData) . '}';
41
-        }
40
+			$calculatedLabel = '{' . implode(',', $labelData) . '}';
41
+		}
42 42
 
43
-        $this->metrics[$name]['values'][$calculatedLabel] = $value;
44
-    }
43
+		$this->metrics[$name]['values'][$calculatedLabel] = $value;
44
+	}
45 45
 
46
-    public function runApiPage(): string
47
-    {
48
-        $this->defineMetric('acc_users', 'Number of users');
49
-        $statement = $this->getDatabase()->query('SELECT status, COUNT(*) AS count FROM user GROUP BY status;');
46
+	public function runApiPage(): string
47
+	{
48
+		$this->defineMetric('acc_users', 'Number of users');
49
+		$statement = $this->getDatabase()->query('SELECT status, COUNT(*) AS count FROM user GROUP BY status;');
50 50
 
51
-        foreach ($statement->fetchAll(PDO::FETCH_ASSOC) as $row) {
52
-            $this->setMetric('acc_users', ['status' => $row['status']], $row['count']);
53
-        }
54
-        $statement->closeCursor();
51
+		foreach ($statement->fetchAll(PDO::FETCH_ASSOC) as $row) {
52
+			$this->setMetric('acc_users', ['status' => $row['status']], $row['count']);
53
+		}
54
+		$statement->closeCursor();
55 55
 
56
-        $this->defineMetric('acc_active_domain_users', 'Number of active users in each domain');
57
-        $statement = $this->getDatabase()->query('
56
+		$this->defineMetric('acc_active_domain_users', 'Number of active users in each domain');
57
+		$statement = $this->getDatabase()->query('
58 58
             SELECT d.shortname, COUNT(1) AS count FROM userdomain ud 
59 59
             INNER JOIN user u ON ud.user = u.id
60 60
             INNER JOIN domain d on ud.domain = d.id
61 61
             WHERE u.status = \'Active\'
62 62
             GROUP BY d.shortname;');
63 63
 
64
-        foreach ($statement->fetchAll(PDO::FETCH_ASSOC) as $row) {
65
-            $this->setMetric('acc_active_domain_users', ['domain' => $row['shortname']], $row['count']);
66
-        }
67
-        $statement->closeCursor();
64
+		foreach ($statement->fetchAll(PDO::FETCH_ASSOC) as $row) {
65
+			$this->setMetric('acc_active_domain_users', ['domain' => $row['shortname']], $row['count']);
66
+		}
67
+		$statement->closeCursor();
68 68
 
69 69
 
70
-        $this->defineMetric('acc_active_domain_roles', 'Number of active users in each role');
71
-        $statement = $this->getDatabase()->query('
70
+		$this->defineMetric('acc_active_domain_roles', 'Number of active users in each role');
71
+		$statement = $this->getDatabase()->query('
72 72
             SELECT coalesce(d.shortname, \'\') AS domain, ur.role, COUNT(1) AS count
73 73
             FROM userrole ur
74 74
             INNER JOIN user u ON ur.user = u.id
@@ -76,53 +76,53 @@  discard block
 block discarded – undo
76 76
             WHERE u.status = \'Active\' AND ur.role <> \'user\'
77 77
             GROUP BY d.shortname, ur.role;');
78 78
 
79
-        foreach ($statement->fetchAll(PDO::FETCH_ASSOC) as $row) {
80
-            $this->setMetric('acc_active_domain_roles', ['domain' => $row['domain'], 'role' => $row['role']], $row['count']);
81
-        }
82
-        $statement->closeCursor();
79
+		foreach ($statement->fetchAll(PDO::FETCH_ASSOC) as $row) {
80
+			$this->setMetric('acc_active_domain_roles', ['domain' => $row['domain'], 'role' => $row['role']], $row['count']);
81
+		}
82
+		$statement->closeCursor();
83 83
 
84 84
 
85
-        $this->defineMetric('acc_active_domain_bans', 'Number of active bans in each domain');
86
-        $statement = $this->getDatabase()->query('
85
+		$this->defineMetric('acc_active_domain_bans', 'Number of active bans in each domain');
86
+		$statement = $this->getDatabase()->query('
87 87
             SELECT coalesce(d.shortname, \'\') AS domain, COUNT(1) AS count
88 88
             FROM ban b LEFT JOIN domain d ON b.domain = d.id
89 89
             WHERE (b.duration > UNIX_TIMESTAMP() OR b.duration is null) AND b.active = 1
90 90
             GROUP BY d.shortname;');
91 91
 
92
-        foreach ($statement->fetchAll(PDO::FETCH_ASSOC) as $row) {
93
-            $this->setMetric('acc_active_domain_bans', ['domain' => $row['domain'], 'role' => $row['role']], $row['count']);
94
-        }
95
-        $statement->closeCursor();
92
+		foreach ($statement->fetchAll(PDO::FETCH_ASSOC) as $row) {
93
+			$this->setMetric('acc_active_domain_bans', ['domain' => $row['domain'], 'role' => $row['role']], $row['count']);
94
+		}
95
+		$statement->closeCursor();
96 96
 
97 97
 
98
-        $this->defineMetric('acc_queued_requests', 'Number of requests in each queue');
99
-        $statement = $this->getDatabase()->query('
98
+		$this->defineMetric('acc_queued_requests', 'Number of requests in each queue');
99
+		$statement = $this->getDatabase()->query('
100 100
             SELECT r.status, d.shortname, rq.header, COUNT(1) as count FROM request r
101 101
             INNER JOIN domain d on r.domain = d.id
102 102
             LEFT JOIN requestqueue rq ON r.queue = rq.id
103 103
             WHERE r.status <> \'Closed\' AND r.emailconfirm = \'Confirmed\'
104 104
             GROUP BY r.status, d.shortname, rq.header;');
105 105
 
106
-        foreach ($statement->fetchAll(PDO::FETCH_ASSOC) as $row) {
107
-            $this->setMetric('acc_queued_requests', ['status' => $row['status'], 'shortname' => $row['shortname'], 'queue' => $row['header']], $row['count']);
108
-        }
109
-        $statement->closeCursor();
106
+		foreach ($statement->fetchAll(PDO::FETCH_ASSOC) as $row) {
107
+			$this->setMetric('acc_queued_requests', ['status' => $row['status'], 'shortname' => $row['shortname'], 'queue' => $row['header']], $row['count']);
108
+		}
109
+		$statement->closeCursor();
110 110
 
111
-        return $this->writeMetrics();
112
-    }
111
+		return $this->writeMetrics();
112
+	}
113 113
 
114
-    private function writeMetrics() : string
115
-    {
116
-        $data = '';
114
+	private function writeMetrics() : string
115
+	{
116
+		$data = '';
117 117
 
118
-        foreach ($this->metrics as $name => $metricData) {
119
-            $data .= "# HELP {$name} {$metricData['help']}\n";
120
-            $data .= "# TYPE {$name} {$metricData['type']}\n";
121
-            foreach ($metricData['values'] as $label => $value) {
122
-                $data .= "{$name}{$label} {$value}\n";
123
-            }
124
-        }
118
+		foreach ($this->metrics as $name => $metricData) {
119
+			$data .= "# HELP {$name} {$metricData['help']}\n";
120
+			$data .= "# TYPE {$name} {$metricData['type']}\n";
121
+			foreach ($metricData['values'] as $label => $value) {
122
+				$data .= "{$name}{$label} {$value}\n";
123
+			}
124
+		}
125 125
 
126
-        return $data;
127
-    }
126
+		return $data;
127
+	}
128 128
 }
Please login to merge, or discard this patch.
includes/SiteConfiguration.php 1 patch
Indentation   +1124 added lines, -1124 removed lines patch added patch discarded remove patch
@@ -18,1128 +18,1128 @@
 block discarded – undo
18 18
  */
19 19
 class SiteConfiguration
20 20
 {
21
-    private $baseUrl = 'https://accounts.wmflabs.org';
22
-    private $filePath = __DIR__ . '/..';
23
-    private $schemaVersion = 51;
24
-    private $debuggingTraceEnabled = false;
25
-    private $debuggingCssBreakpointsEnabled = false;
26
-    private $dataClearIp = '127.0.0.1';
27
-    private $dataClearEmail = '[email protected]';
28
-    private $dataClearInterval = '15 DAY';
29
-    private $forceIdentification = true;
30
-    private $identificationCacheExpiry = '1 DAY';
31
-    private $metaWikimediaWebServiceEndpoint = 'https://meta.wikimedia.org/w/api.php';
32
-    private $enforceOAuth = false;
33
-    private $emailConfirmationEnabled = true;
34
-    private $emailConfirmationExpiryDays = 7;
35
-    private $miserModeLimit = 25;
36
-    private $squidList = array();
37
-    private $useStrictTransportSecurity = false;
38
-    private $userAgent = 'Wikipedia-ACC Tool/0.1 (+https://accounts.wmflabs.org/internal.php/team)';
39
-    private $curlDisableVerifyPeer = false;
40
-    private $useOAuthSignup = true;
41
-    private $oauthConsumerToken;
42
-    /** @var array */
43
-    private $oauthLegacyConsumerTokens;
44
-    private $oauthConsumerSecret;
45
-    private $oauthIdentityGraceTime = '24 hours';
46
-    private $oauthMediaWikiCanonicalServer = 'https://en.wikipedia.org';
47
-    private $xffTrustedHostsFile = '../TrustedXFF/trusted-hosts.txt';
48
-    private $crossOriginResourceSharingHosts = array(
49
-        "https://en.wikipedia.org",
50
-        "https://meta.wikimedia.org",
51
-    );
52
-    private $ircNotificationsEnabled = true;
53
-    private $ircNotificationsInstance = 'Development';
54
-    private $errorLog = 'errorlog';
55
-    private $titleBlacklistEnabled = false;
56
-    /** @var null|string $locationProviderApiKey */
57
-    private $locationProviderApiKey = null;
58
-    private $torExitPaths = array();
59
-    private $creationBotUsername = '';
60
-    private $creationBotPassword = '';
61
-    private $curlCookieJar = __DIR__ . '/../../cookies.txt';
62
-    private $yubicoApiId = 0;
63
-    private $yubicoApiKey = "";
64
-    private $totpEncryptionKey = "1234";
65
-    private $identificationNoticeboardPage = 'Access to nonpublic personal data policy/Noticeboard';
66
-    private $identificationNoticeboardWebserviceEndpoint = 'https://meta.wikimedia.org/w/api.php';
67
-    private $registrationAllowed = true;
68
-    private $cspReportUri = null;
69
-    private $resourceCacheEpoch = 1;
70
-    private $commonEmailDomains = ['gmail.com', 'hotmail.com', 'outlook.com'];
71
-    private $banMaxIpBlockRange = [4 => 20, 6 => 48];
72
-    private $banMaxIpRange = [4 => 16, 6 => 32];
73
-    private $jobQueueBatchSize = 10;
74
-    private $amqpConfiguration = ['host' => 'localhost', 'port' => 5672, 'user' => 'guest', 'password' => 'guest', 'vhost' => '/', 'exchange' => '', 'tls' => false];
75
-    private $emailSender = '[email protected]';
76
-    private $acceptClientHints = [];
77
-    private string $cookiePath = '/';
78
-    private string $cookieSessionName = 'ACC';
79
-    private array $offline = ['offline' => false, 'reason' => '', 'culprit' => ''];
80
-    private array $databaseConfig = [
81
-        'datasource' => 'mysql:host=localhost;dbname=waca',
82
-        'username' => 'waca',
83
-        'password' => 'waca'
84
-    ];
85
-    private string $privacyStatementPath = '';
86
-
87
-    private string $createAccountLink = '{articlePath}/Special:CreateAccount';
88
-
89
-    /**
90
-     * Gets the base URL of the tool
91
-     *
92
-     * If the internal page of the tool is at http://localhost/path/internal.php, this would be set to
93
-     * http://localhost/path
94
-     * @return string
95
-     */
96
-    public function getBaseUrl()
97
-    {
98
-        return $this->baseUrl;
99
-    }
100
-
101
-    /**
102
-     * @param string $baseUrl
103
-     *
104
-     * @return SiteConfiguration
105
-     */
106
-    public function setBaseUrl($baseUrl)
107
-    {
108
-        $this->baseUrl = $baseUrl;
109
-
110
-        return $this;
111
-    }
112
-
113
-    /**
114
-     * Path on disk to the directory containing the tool's code
115
-     * @return string
116
-     */
117
-    public function getFilePath()
118
-    {
119
-        return $this->filePath;
120
-    }
121
-
122
-    /**
123
-     * @param string $filePath
124
-     *
125
-     * @return SiteConfiguration
126
-     */
127
-    public function setFilePath($filePath)
128
-    {
129
-        $this->filePath = $filePath;
130
-
131
-        return $this;
132
-    }
133
-
134
-    /**
135
-     * @return int
136
-     */
137
-    public function getSchemaVersion()
138
-    {
139
-        return $this->schemaVersion;
140
-    }
141
-
142
-    /**
143
-     * @param int $schemaVersion
144
-     *
145
-     * @return SiteConfiguration
146
-     */
147
-    public function setSchemaVersion($schemaVersion)
148
-    {
149
-        $this->schemaVersion = $schemaVersion;
150
-
151
-        return $this;
152
-    }
153
-
154
-    /**
155
-     * @return mixed
156
-     */
157
-    public function getDebuggingTraceEnabled()
158
-    {
159
-        return $this->debuggingTraceEnabled;
160
-    }
161
-
162
-    /**
163
-     * @param mixed $debuggingTraceEnabled
164
-     *
165
-     * @return SiteConfiguration
166
-     */
167
-    public function setDebuggingTraceEnabled($debuggingTraceEnabled)
168
-    {
169
-        $this->debuggingTraceEnabled = $debuggingTraceEnabled;
170
-
171
-        return $this;
172
-    }
173
-
174
-    public function getDebuggingCssBreakpointsEnabled() : bool
175
-    {
176
-        return $this->debuggingCssBreakpointsEnabled;
177
-    }
178
-
179
-    public function setDebuggingCssBreakpointsEnabled(bool $debuggingCssBreakpointsEnabled) : SiteConfiguration
180
-    {
181
-        $this->debuggingCssBreakpointsEnabled = $debuggingCssBreakpointsEnabled;
182
-
183
-        return $this;
184
-    }
185
-
186
-    /**
187
-     * @return string
188
-     */
189
-    public function getDataClearIp()
190
-    {
191
-        return $this->dataClearIp;
192
-    }
193
-
194
-    /**
195
-     * @param string $dataClearIp
196
-     *
197
-     * @return SiteConfiguration
198
-     */
199
-    public function setDataClearIp($dataClearIp)
200
-    {
201
-        $this->dataClearIp = $dataClearIp;
202
-
203
-        return $this;
204
-    }
205
-
206
-    /**
207
-     * @return string
208
-     */
209
-    public function getDataClearEmail()
210
-    {
211
-        return $this->dataClearEmail;
212
-    }
213
-
214
-    /**
215
-     * @param string $dataClearEmail
216
-     *
217
-     * @return SiteConfiguration
218
-     */
219
-    public function setDataClearEmail($dataClearEmail)
220
-    {
221
-        $this->dataClearEmail = $dataClearEmail;
222
-
223
-        return $this;
224
-    }
225
-
226
-    /**
227
-     * @return boolean
228
-     */
229
-    public function getForceIdentification()
230
-    {
231
-        return $this->forceIdentification;
232
-    }
233
-
234
-    /**
235
-     * @param boolean $forceIdentification
236
-     *
237
-     * @return SiteConfiguration
238
-     */
239
-    public function setForceIdentification($forceIdentification)
240
-    {
241
-        $this->forceIdentification = $forceIdentification;
242
-
243
-        return $this;
244
-    }
245
-
246
-    /**
247
-     * @return string
248
-     */
249
-    public function getIdentificationCacheExpiry()
250
-    {
251
-        return $this->identificationCacheExpiry;
252
-    }
253
-
254
-    /**
255
-     * @param string $identificationCacheExpiry
256
-     *
257
-     * @return SiteConfiguration
258
-     */
259
-    public function setIdentificationCacheExpiry($identificationCacheExpiry)
260
-    {
261
-        $this->identificationCacheExpiry = $identificationCacheExpiry;
262
-
263
-        return $this;
264
-    }
265
-
266
-    /**
267
-     * @return string
268
-     */
269
-    public function getMetaWikimediaWebServiceEndpoint()
270
-    {
271
-        return $this->metaWikimediaWebServiceEndpoint;
272
-    }
273
-
274
-    /**
275
-     * @param string $metaWikimediaWebServiceEndpoint
276
-     *
277
-     * @return SiteConfiguration
278
-     */
279
-    public function setMetaWikimediaWebServiceEndpoint($metaWikimediaWebServiceEndpoint)
280
-    {
281
-        $this->metaWikimediaWebServiceEndpoint = $metaWikimediaWebServiceEndpoint;
282
-
283
-        return $this;
284
-    }
285
-
286
-    /**
287
-     * @return boolean
288
-     */
289
-    public function getEnforceOAuth()
290
-    {
291
-        return $this->enforceOAuth;
292
-    }
293
-
294
-    /**
295
-     * @param boolean $enforceOAuth
296
-     *
297
-     * @return SiteConfiguration
298
-     */
299
-    public function setEnforceOAuth($enforceOAuth)
300
-    {
301
-        $this->enforceOAuth = $enforceOAuth;
302
-
303
-        return $this;
304
-    }
305
-
306
-    /**
307
-     * @return boolean
308
-     */
309
-    public function getEmailConfirmationEnabled()
310
-    {
311
-        return $this->emailConfirmationEnabled;
312
-    }
313
-
314
-    /**
315
-     * @param boolean $emailConfirmationEnabled
316
-     *
317
-     * @return $this
318
-     */
319
-    public function setEmailConfirmationEnabled($emailConfirmationEnabled)
320
-    {
321
-        $this->emailConfirmationEnabled = $emailConfirmationEnabled;
322
-
323
-        return $this;
324
-    }
325
-
326
-    /**
327
-     * @return int
328
-     */
329
-    public function getMiserModeLimit()
330
-    {
331
-        return $this->miserModeLimit;
332
-    }
333
-
334
-    /**
335
-     * @param int $miserModeLimit
336
-     *
337
-     * @return SiteConfiguration
338
-     */
339
-    public function setMiserModeLimit($miserModeLimit)
340
-    {
341
-        $this->miserModeLimit = $miserModeLimit;
342
-
343
-        return $this;
344
-    }
345
-
346
-    /**
347
-     * @return array
348
-     */
349
-    public function getSquidList()
350
-    {
351
-        return $this->squidList;
352
-    }
353
-
354
-    /**
355
-     * @param array $squidList
356
-     *
357
-     * @return SiteConfiguration
358
-     */
359
-    public function setSquidList($squidList)
360
-    {
361
-        $this->squidList = $squidList;
362
-
363
-        return $this;
364
-    }
365
-
366
-    /**
367
-     * @return boolean
368
-     */
369
-    public function getUseStrictTransportSecurity()
370
-    {
371
-        return $this->useStrictTransportSecurity;
372
-    }
373
-
374
-    /**
375
-     * @param boolean $useStrictTransportSecurity
376
-     *
377
-     * @return SiteConfiguration
378
-     */
379
-    public function setUseStrictTransportSecurity($useStrictTransportSecurity)
380
-    {
381
-        $this->useStrictTransportSecurity = $useStrictTransportSecurity;
382
-
383
-        return $this;
384
-    }
385
-
386
-    /**
387
-     * @return string
388
-     */
389
-    public function getUserAgent()
390
-    {
391
-        return $this->userAgent;
392
-    }
393
-
394
-    /**
395
-     * @param string $userAgent
396
-     *
397
-     * @return SiteConfiguration
398
-     */
399
-    public function setUserAgent($userAgent)
400
-    {
401
-        $this->userAgent = $userAgent;
402
-
403
-        return $this;
404
-    }
405
-
406
-    /**
407
-     * @return boolean
408
-     */
409
-    public function getCurlDisableVerifyPeer()
410
-    {
411
-        return $this->curlDisableVerifyPeer;
412
-    }
413
-
414
-    /**
415
-     * @param boolean $curlDisableVerifyPeer
416
-     *
417
-     * @return SiteConfiguration
418
-     */
419
-    public function setCurlDisableVerifyPeer($curlDisableVerifyPeer)
420
-    {
421
-        $this->curlDisableVerifyPeer = $curlDisableVerifyPeer;
422
-
423
-        return $this;
424
-    }
425
-
426
-    /**
427
-     * @return boolean
428
-     */
429
-    public function getUseOAuthSignup()
430
-    {
431
-        return $this->useOAuthSignup;
432
-    }
433
-
434
-    /**
435
-     * @param boolean $useOAuthSignup
436
-     *
437
-     * @return SiteConfiguration
438
-     */
439
-    public function setUseOAuthSignup($useOAuthSignup)
440
-    {
441
-        $this->useOAuthSignup = $useOAuthSignup;
442
-
443
-        return $this;
444
-    }
445
-
446
-    /**
447
-     * @return mixed
448
-     */
449
-    public function getOAuthConsumerToken()
450
-    {
451
-        return $this->oauthConsumerToken;
452
-    }
453
-
454
-    /**
455
-     * @param mixed $oauthConsumerToken
456
-     *
457
-     * @return SiteConfiguration
458
-     */
459
-    public function setOAuthConsumerToken($oauthConsumerToken)
460
-    {
461
-        $this->oauthConsumerToken = $oauthConsumerToken;
462
-
463
-        return $this;
464
-    }
465
-
466
-    /**
467
-     * @return mixed
468
-     */
469
-    public function getOAuthConsumerSecret()
470
-    {
471
-        return $this->oauthConsumerSecret;
472
-    }
473
-
474
-    /**
475
-     * @param mixed $oauthConsumerSecret
476
-     *
477
-     * @return SiteConfiguration
478
-     */
479
-    public function setOAuthConsumerSecret($oauthConsumerSecret)
480
-    {
481
-        $this->oauthConsumerSecret = $oauthConsumerSecret;
482
-
483
-        return $this;
484
-    }
485
-
486
-    /**
487
-     * @return string
488
-     */
489
-    public function getDataClearInterval()
490
-    {
491
-        return $this->dataClearInterval;
492
-    }
493
-
494
-    /**
495
-     * @param string $dataClearInterval
496
-     *
497
-     * @return SiteConfiguration
498
-     */
499
-    public function setDataClearInterval($dataClearInterval)
500
-    {
501
-        $this->dataClearInterval = $dataClearInterval;
502
-
503
-        return $this;
504
-    }
505
-
506
-    /**
507
-     * @return string
508
-     */
509
-    public function getXffTrustedHostsFile()
510
-    {
511
-        return $this->xffTrustedHostsFile;
512
-    }
513
-
514
-    /**
515
-     * @param string $xffTrustedHostsFile
516
-     *
517
-     * @return SiteConfiguration
518
-     */
519
-    public function setXffTrustedHostsFile($xffTrustedHostsFile)
520
-    {
521
-        $this->xffTrustedHostsFile = $xffTrustedHostsFile;
522
-
523
-        return $this;
524
-    }
525
-
526
-    /**
527
-     * @return array
528
-     */
529
-    public function getCrossOriginResourceSharingHosts()
530
-    {
531
-        return $this->crossOriginResourceSharingHosts;
532
-    }
533
-
534
-    /**
535
-     * @param array $crossOriginResourceSharingHosts
536
-     *
537
-     * @return SiteConfiguration
538
-     */
539
-    public function setCrossOriginResourceSharingHosts($crossOriginResourceSharingHosts)
540
-    {
541
-        $this->crossOriginResourceSharingHosts = $crossOriginResourceSharingHosts;
542
-
543
-        return $this;
544
-    }
545
-
546
-    /**
547
-     * @return boolean
548
-     */
549
-    public function getIrcNotificationsEnabled()
550
-    {
551
-        return $this->ircNotificationsEnabled;
552
-    }
553
-
554
-    /**
555
-     * @param boolean $ircNotificationsEnabled
556
-     *
557
-     * @return SiteConfiguration
558
-     */
559
-    public function setIrcNotificationsEnabled($ircNotificationsEnabled)
560
-    {
561
-        $this->ircNotificationsEnabled = $ircNotificationsEnabled;
562
-
563
-        return $this;
564
-    }
565
-
566
-    /**
567
-     * @param string $errorLog
568
-     *
569
-     * @return SiteConfiguration
570
-     */
571
-    public function setErrorLog($errorLog)
572
-    {
573
-        $this->errorLog = $errorLog;
574
-
575
-        return $this;
576
-    }
577
-
578
-    /**
579
-     * @return string
580
-     */
581
-    public function getErrorLog()
582
-    {
583
-        return $this->errorLog;
584
-    }
585
-
586
-    /**
587
-     * @param int $emailConfirmationExpiryDays
588
-     *
589
-     * @return SiteConfiguration
590
-     */
591
-    public function setEmailConfirmationExpiryDays($emailConfirmationExpiryDays)
592
-    {
593
-        $this->emailConfirmationExpiryDays = $emailConfirmationExpiryDays;
594
-
595
-        return $this;
596
-    }
597
-
598
-    /**
599
-     * @return int
600
-     */
601
-    public function getEmailConfirmationExpiryDays()
602
-    {
603
-        return $this->emailConfirmationExpiryDays;
604
-    }
605
-
606
-    /**
607
-     * @param string $ircNotificationsInstance
608
-     *
609
-     * @return SiteConfiguration
610
-     */
611
-    public function setIrcNotificationsInstance($ircNotificationsInstance)
612
-    {
613
-        $this->ircNotificationsInstance = $ircNotificationsInstance;
614
-
615
-        return $this;
616
-    }
617
-
618
-    /**
619
-     * @return string
620
-     */
621
-    public function getIrcNotificationsInstance()
622
-    {
623
-        return $this->ircNotificationsInstance;
624
-    }
625
-
626
-    /**
627
-     * @param boolean $titleBlacklistEnabled
628
-     *
629
-     * @return SiteConfiguration
630
-     */
631
-    public function setTitleBlacklistEnabled($titleBlacklistEnabled)
632
-    {
633
-        $this->titleBlacklistEnabled = $titleBlacklistEnabled;
634
-
635
-        return $this;
636
-    }
637
-
638
-    /**
639
-     * @return boolean
640
-     */
641
-    public function getTitleBlacklistEnabled()
642
-    {
643
-        return $this->titleBlacklistEnabled;
644
-    }
645
-
646
-    /**
647
-     * @param string|null $locationProviderApiKey
648
-     *
649
-     * @return SiteConfiguration
650
-     */
651
-    public function setLocationProviderApiKey($locationProviderApiKey)
652
-    {
653
-        $this->locationProviderApiKey = $locationProviderApiKey;
654
-
655
-        return $this;
656
-    }
657
-
658
-    /**
659
-     * @return null|string
660
-     */
661
-    public function getLocationProviderApiKey()
662
-    {
663
-        return $this->locationProviderApiKey;
664
-    }
665
-
666
-    /**
667
-     * @param array $torExitPaths
668
-     *
669
-     * @return SiteConfiguration
670
-     */
671
-    public function setTorExitPaths($torExitPaths)
672
-    {
673
-        $this->torExitPaths = $torExitPaths;
674
-
675
-        return $this;
676
-    }
677
-
678
-    /**
679
-     * @return array
680
-     */
681
-    public function getTorExitPaths()
682
-    {
683
-        return $this->torExitPaths;
684
-    }
685
-
686
-    /**
687
-     * @param string $oauthIdentityGraceTime
688
-     *
689
-     * @return SiteConfiguration
690
-     */
691
-    public function setOauthIdentityGraceTime($oauthIdentityGraceTime)
692
-    {
693
-        $this->oauthIdentityGraceTime = $oauthIdentityGraceTime;
694
-
695
-        return $this;
696
-    }
697
-
698
-    /**
699
-     * @return string
700
-     */
701
-    public function getOauthIdentityGraceTime()
702
-    {
703
-        return $this->oauthIdentityGraceTime;
704
-    }
705
-
706
-    /**
707
-     * @param string $oauthMediaWikiCanonicalServer
708
-     *
709
-     * @return SiteConfiguration
710
-     */
711
-    public function setOauthMediaWikiCanonicalServer($oauthMediaWikiCanonicalServer)
712
-    {
713
-        $this->oauthMediaWikiCanonicalServer = $oauthMediaWikiCanonicalServer;
714
-
715
-        return $this;
716
-    }
717
-
718
-    /**
719
-     * @return string
720
-     */
721
-    public function getOauthMediaWikiCanonicalServer()
722
-    {
723
-        return $this->oauthMediaWikiCanonicalServer;
724
-    }
725
-
726
-    /**
727
-     * @param string $creationBotUsername
728
-     *
729
-     * @return SiteConfiguration
730
-     */
731
-    public function setCreationBotUsername($creationBotUsername)
732
-    {
733
-        $this->creationBotUsername = $creationBotUsername;
734
-
735
-        return $this;
736
-    }
737
-
738
-    /**
739
-     * @return string
740
-     */
741
-    public function getCreationBotUsername()
742
-    {
743
-        return $this->creationBotUsername;
744
-    }
745
-
746
-    /**
747
-     * @param string $creationBotPassword
748
-     *
749
-     * @return SiteConfiguration
750
-     */
751
-    public function setCreationBotPassword($creationBotPassword)
752
-    {
753
-        $this->creationBotPassword = $creationBotPassword;
754
-
755
-        return $this;
756
-    }
757
-
758
-    /**
759
-     * @return string
760
-     */
761
-    public function getCreationBotPassword()
762
-    {
763
-        return $this->creationBotPassword;
764
-    }
765
-
766
-    /**
767
-     * @param string|null $curlCookieJar
768
-     *
769
-     * @return SiteConfiguration
770
-     */
771
-    public function setCurlCookieJar($curlCookieJar)
772
-    {
773
-        $this->curlCookieJar = $curlCookieJar;
774
-
775
-        return $this;
776
-    }
777
-
778
-    /**
779
-     * @return string|null
780
-     */
781
-    public function getCurlCookieJar()
782
-    {
783
-        return $this->curlCookieJar;
784
-    }
785
-
786
-    public function getYubicoApiId()
787
-    {
788
-        return $this->yubicoApiId;
789
-    }
790
-
791
-    public function setYubicoApiId($id)
792
-    {
793
-        $this->yubicoApiId = $id;
794
-
795
-        return $this;
796
-    }
797
-
798
-    public function getYubicoApiKey()
799
-    {
800
-        return $this->yubicoApiKey;
801
-    }
802
-
803
-    public function setYubicoApiKey($key)
804
-    {
805
-        $this->yubicoApiKey = $key;
806
-
807
-        return $this;
808
-    }
809
-
810
-    /**
811
-     * @return string
812
-     */
813
-    public function getTotpEncryptionKey()
814
-    {
815
-        return $this->totpEncryptionKey;
816
-    }
817
-
818
-    /**
819
-     * @param string $totpEncryptionKey
820
-     *
821
-     * @return SiteConfiguration
822
-     */
823
-    public function setTotpEncryptionKey($totpEncryptionKey)
824
-    {
825
-        $this->totpEncryptionKey = $totpEncryptionKey;
826
-
827
-        return $this;
828
-    }
829
-
830
-    /**
831
-     * @return string
832
-     */
833
-    public function getIdentificationNoticeboardPage()
834
-    {
835
-        return $this->identificationNoticeboardPage;
836
-    }
837
-
838
-    /**
839
-     * @param string $identificationNoticeboardPage
840
-     *
841
-     * @return SiteConfiguration
842
-     */
843
-    public function setIdentificationNoticeboardPage($identificationNoticeboardPage)
844
-    {
845
-        $this->identificationNoticeboardPage = $identificationNoticeboardPage;
846
-
847
-        return $this;
848
-    }
849
-
850
-    public function setIdentificationNoticeboardWebserviceEndpoint(string $identificationNoticeboardWebserviceEndpoint
851
-    ): SiteConfiguration {
852
-        $this->identificationNoticeboardWebserviceEndpoint = $identificationNoticeboardWebserviceEndpoint;
853
-
854
-        return $this;
855
-    }
856
-
857
-    public function getIdentificationNoticeboardWebserviceEndpoint(): string
858
-    {
859
-        return $this->identificationNoticeboardWebserviceEndpoint;
860
-    }
861
-
862
-    public function isRegistrationAllowed(): bool
863
-    {
864
-        return $this->registrationAllowed;
865
-    }
866
-
867
-    public function setRegistrationAllowed(bool $registrationAllowed): SiteConfiguration
868
-    {
869
-        $this->registrationAllowed = $registrationAllowed;
870
-
871
-        return $this;
872
-    }
873
-
874
-    /**
875
-     * @return string|null
876
-     */
877
-    public function getCspReportUri()
878
-    {
879
-        return $this->cspReportUri;
880
-    }
881
-
882
-    /**
883
-     * @param string|null $cspReportUri
884
-     *
885
-     * @return SiteConfiguration
886
-     */
887
-    public function setCspReportUri($cspReportUri)
888
-    {
889
-        $this->cspReportUri = $cspReportUri;
890
-
891
-        return $this;
892
-    }
893
-
894
-    /**
895
-     * @return int
896
-     */
897
-    public function getResourceCacheEpoch(): int
898
-    {
899
-        return $this->resourceCacheEpoch;
900
-    }
901
-
902
-    /**
903
-     * @param int $resourceCacheEpoch
904
-     *
905
-     * @return SiteConfiguration
906
-     */
907
-    public function setResourceCacheEpoch(int $resourceCacheEpoch): SiteConfiguration
908
-    {
909
-        $this->resourceCacheEpoch = $resourceCacheEpoch;
910
-
911
-        return $this;
912
-    }
913
-
914
-    /**
915
-     * @return array
916
-     */
917
-    public function getCommonEmailDomains(): array
918
-    {
919
-        return $this->commonEmailDomains;
920
-    }
921
-
922
-    /**
923
-     * @param array $commonEmailDomains
924
-     *
925
-     * @return SiteConfiguration
926
-     */
927
-    public function setCommonEmailDomains(array $commonEmailDomains): SiteConfiguration
928
-    {
929
-        $this->commonEmailDomains = $commonEmailDomains;
930
-
931
-        return $this;
932
-    }
933
-
934
-    /**
935
-     * @param int[] $banMaxIpBlockRange
936
-     *
937
-     * @return SiteConfiguration
938
-     */
939
-    public function setBanMaxIpBlockRange(array $banMaxIpBlockRange): SiteConfiguration
940
-    {
941
-        $this->banMaxIpBlockRange = $banMaxIpBlockRange;
942
-
943
-        return $this;
944
-    }
945
-
946
-    /**
947
-     * @return int[]
948
-     */
949
-    public function getBanMaxIpBlockRange(): array
950
-    {
951
-        return $this->banMaxIpBlockRange;
952
-    }
953
-
954
-    /**
955
-     * @param int[] $banMaxIpRange
956
-     *
957
-     * @return SiteConfiguration
958
-     */
959
-    public function setBanMaxIpRange(array $banMaxIpRange): SiteConfiguration
960
-    {
961
-        $this->banMaxIpRange = $banMaxIpRange;
962
-
963
-        return $this;
964
-    }
965
-
966
-    /**
967
-     * @return int[]
968
-     */
969
-    public function getBanMaxIpRange(): array
970
-    {
971
-        return $this->banMaxIpRange;
972
-    }
973
-
974
-    /**
975
-     * @param array $oauthLegacyConsumerTokens
976
-     *
977
-     * @return SiteConfiguration
978
-     */
979
-    public function setOauthLegacyConsumerTokens(array $oauthLegacyConsumerTokens): SiteConfiguration
980
-    {
981
-        $this->oauthLegacyConsumerTokens = $oauthLegacyConsumerTokens;
982
-
983
-        return $this;
984
-    }
985
-
986
-    /**
987
-     * @return array
988
-     */
989
-    public function getOauthLegacyConsumerTokens(): array
990
-    {
991
-        return $this->oauthLegacyConsumerTokens;
992
-    }
993
-
994
-    /**
995
-     * @return int
996
-     */
997
-    public function getJobQueueBatchSize(): int
998
-    {
999
-        return $this->jobQueueBatchSize;
1000
-    }
1001
-
1002
-    /**
1003
-     * @param int $jobQueueBatchSize
1004
-     *
1005
-     * @return SiteConfiguration
1006
-     */
1007
-    public function setJobQueueBatchSize(int $jobQueueBatchSize): SiteConfiguration
1008
-    {
1009
-        $this->jobQueueBatchSize = $jobQueueBatchSize;
1010
-
1011
-        return $this;
1012
-    }
1013
-
1014
-    /**
1015
-     * @return array
1016
-     */
1017
-    public function getAmqpConfiguration(): array
1018
-    {
1019
-        return $this->amqpConfiguration;
1020
-    }
1021
-
1022
-    /**
1023
-     * @param array $amqpConfiguration
1024
-     *
1025
-     * @return SiteConfiguration
1026
-     */
1027
-    public function setAmqpConfiguration(array $amqpConfiguration): SiteConfiguration
1028
-    {
1029
-        $this->amqpConfiguration = $amqpConfiguration;
1030
-
1031
-        return $this;
1032
-    }
1033
-
1034
-    /**
1035
-     * @return string
1036
-     */
1037
-    public function getEmailSender(): string
1038
-    {
1039
-        return $this->emailSender;
1040
-    }
1041
-
1042
-    /**
1043
-     * @param string $emailSender
1044
-     *
1045
-     * @return SiteConfiguration
1046
-     */
1047
-    public function setEmailSender(string $emailSender): SiteConfiguration
1048
-    {
1049
-        $this->emailSender = $emailSender;
1050
-
1051
-        return $this;
1052
-    }
1053
-
1054
-    /**
1055
-     * @param array $acceptClientHints
1056
-     *
1057
-     * @return SiteConfiguration
1058
-     */
1059
-    public function setAcceptClientHints(array $acceptClientHints): SiteConfiguration
1060
-    {
1061
-        $this->acceptClientHints = $acceptClientHints;
1062
-
1063
-        return $this;
1064
-    }
1065
-
1066
-    /**
1067
-     * @return array
1068
-     */
1069
-    public function getAcceptClientHints(): array
1070
-    {
1071
-        return $this->acceptClientHints;
1072
-    }
1073
-
1074
-    public function setCookiePath(string $cookiePath): SiteConfiguration
1075
-    {
1076
-        $this->cookiePath = $cookiePath;
1077
-
1078
-        return $this;
1079
-    }
1080
-
1081
-    public function getCookiePath(): string
1082
-    {
1083
-        return $this->cookiePath;
1084
-    }
1085
-
1086
-    public function setCookieSessionName(string $cookieSessionName): SiteConfiguration
1087
-    {
1088
-        $this->cookieSessionName = $cookieSessionName;
1089
-
1090
-        return $this;
1091
-    }
1092
-
1093
-    public function getCookieSessionName(): string
1094
-    {
1095
-        return $this->cookieSessionName;
1096
-    }
1097
-
1098
-    public function setOffline(array $offline): SiteConfiguration
1099
-    {
1100
-        $this->offline = $offline;
1101
-
1102
-        return $this;
1103
-    }
1104
-
1105
-    public function getOffline(): array
1106
-    {
1107
-        return $this->offline;
1108
-    }
1109
-
1110
-    public function setDatabaseConfig(array $databaseConfig): SiteConfiguration
1111
-    {
1112
-        $this->databaseConfig = $databaseConfig;
1113
-
1114
-        return $this;
1115
-    }
1116
-
1117
-    public function getDatabaseConfig(): array
1118
-    {
1119
-        return $this->databaseConfig;
1120
-    }
1121
-
1122
-    public function getPrivacyStatementPath(): string
1123
-    {
1124
-        return $this->privacyStatementPath;
1125
-    }
1126
-
1127
-    public function setPrivacyStatementPath(string $privacyStatementPath): SiteConfiguration
1128
-    {
1129
-        $this->privacyStatementPath = $privacyStatementPath;
1130
-
1131
-        return $this;
1132
-    }
1133
-
1134
-    public function getCreateAccountLink(): string
1135
-    {
1136
-        return $this->createAccountLink;
1137
-    }
1138
-
1139
-    public function setCreateAccountLink(string $createAccountLink): SiteConfiguration
1140
-    {
1141
-        $this->createAccountLink = $createAccountLink;
1142
-
1143
-        return $this;
1144
-    }
21
+	private $baseUrl = 'https://accounts.wmflabs.org';
22
+	private $filePath = __DIR__ . '/..';
23
+	private $schemaVersion = 51;
24
+	private $debuggingTraceEnabled = false;
25
+	private $debuggingCssBreakpointsEnabled = false;
26
+	private $dataClearIp = '127.0.0.1';
27
+	private $dataClearEmail = '[email protected]';
28
+	private $dataClearInterval = '15 DAY';
29
+	private $forceIdentification = true;
30
+	private $identificationCacheExpiry = '1 DAY';
31
+	private $metaWikimediaWebServiceEndpoint = 'https://meta.wikimedia.org/w/api.php';
32
+	private $enforceOAuth = false;
33
+	private $emailConfirmationEnabled = true;
34
+	private $emailConfirmationExpiryDays = 7;
35
+	private $miserModeLimit = 25;
36
+	private $squidList = array();
37
+	private $useStrictTransportSecurity = false;
38
+	private $userAgent = 'Wikipedia-ACC Tool/0.1 (+https://accounts.wmflabs.org/internal.php/team)';
39
+	private $curlDisableVerifyPeer = false;
40
+	private $useOAuthSignup = true;
41
+	private $oauthConsumerToken;
42
+	/** @var array */
43
+	private $oauthLegacyConsumerTokens;
44
+	private $oauthConsumerSecret;
45
+	private $oauthIdentityGraceTime = '24 hours';
46
+	private $oauthMediaWikiCanonicalServer = 'https://en.wikipedia.org';
47
+	private $xffTrustedHostsFile = '../TrustedXFF/trusted-hosts.txt';
48
+	private $crossOriginResourceSharingHosts = array(
49
+		"https://en.wikipedia.org",
50
+		"https://meta.wikimedia.org",
51
+	);
52
+	private $ircNotificationsEnabled = true;
53
+	private $ircNotificationsInstance = 'Development';
54
+	private $errorLog = 'errorlog';
55
+	private $titleBlacklistEnabled = false;
56
+	/** @var null|string $locationProviderApiKey */
57
+	private $locationProviderApiKey = null;
58
+	private $torExitPaths = array();
59
+	private $creationBotUsername = '';
60
+	private $creationBotPassword = '';
61
+	private $curlCookieJar = __DIR__ . '/../../cookies.txt';
62
+	private $yubicoApiId = 0;
63
+	private $yubicoApiKey = "";
64
+	private $totpEncryptionKey = "1234";
65
+	private $identificationNoticeboardPage = 'Access to nonpublic personal data policy/Noticeboard';
66
+	private $identificationNoticeboardWebserviceEndpoint = 'https://meta.wikimedia.org/w/api.php';
67
+	private $registrationAllowed = true;
68
+	private $cspReportUri = null;
69
+	private $resourceCacheEpoch = 1;
70
+	private $commonEmailDomains = ['gmail.com', 'hotmail.com', 'outlook.com'];
71
+	private $banMaxIpBlockRange = [4 => 20, 6 => 48];
72
+	private $banMaxIpRange = [4 => 16, 6 => 32];
73
+	private $jobQueueBatchSize = 10;
74
+	private $amqpConfiguration = ['host' => 'localhost', 'port' => 5672, 'user' => 'guest', 'password' => 'guest', 'vhost' => '/', 'exchange' => '', 'tls' => false];
75
+	private $emailSender = '[email protected]';
76
+	private $acceptClientHints = [];
77
+	private string $cookiePath = '/';
78
+	private string $cookieSessionName = 'ACC';
79
+	private array $offline = ['offline' => false, 'reason' => '', 'culprit' => ''];
80
+	private array $databaseConfig = [
81
+		'datasource' => 'mysql:host=localhost;dbname=waca',
82
+		'username' => 'waca',
83
+		'password' => 'waca'
84
+	];
85
+	private string $privacyStatementPath = '';
86
+
87
+	private string $createAccountLink = '{articlePath}/Special:CreateAccount';
88
+
89
+	/**
90
+	 * Gets the base URL of the tool
91
+	 *
92
+	 * If the internal page of the tool is at http://localhost/path/internal.php, this would be set to
93
+	 * http://localhost/path
94
+	 * @return string
95
+	 */
96
+	public function getBaseUrl()
97
+	{
98
+		return $this->baseUrl;
99
+	}
100
+
101
+	/**
102
+	 * @param string $baseUrl
103
+	 *
104
+	 * @return SiteConfiguration
105
+	 */
106
+	public function setBaseUrl($baseUrl)
107
+	{
108
+		$this->baseUrl = $baseUrl;
109
+
110
+		return $this;
111
+	}
112
+
113
+	/**
114
+	 * Path on disk to the directory containing the tool's code
115
+	 * @return string
116
+	 */
117
+	public function getFilePath()
118
+	{
119
+		return $this->filePath;
120
+	}
121
+
122
+	/**
123
+	 * @param string $filePath
124
+	 *
125
+	 * @return SiteConfiguration
126
+	 */
127
+	public function setFilePath($filePath)
128
+	{
129
+		$this->filePath = $filePath;
130
+
131
+		return $this;
132
+	}
133
+
134
+	/**
135
+	 * @return int
136
+	 */
137
+	public function getSchemaVersion()
138
+	{
139
+		return $this->schemaVersion;
140
+	}
141
+
142
+	/**
143
+	 * @param int $schemaVersion
144
+	 *
145
+	 * @return SiteConfiguration
146
+	 */
147
+	public function setSchemaVersion($schemaVersion)
148
+	{
149
+		$this->schemaVersion = $schemaVersion;
150
+
151
+		return $this;
152
+	}
153
+
154
+	/**
155
+	 * @return mixed
156
+	 */
157
+	public function getDebuggingTraceEnabled()
158
+	{
159
+		return $this->debuggingTraceEnabled;
160
+	}
161
+
162
+	/**
163
+	 * @param mixed $debuggingTraceEnabled
164
+	 *
165
+	 * @return SiteConfiguration
166
+	 */
167
+	public function setDebuggingTraceEnabled($debuggingTraceEnabled)
168
+	{
169
+		$this->debuggingTraceEnabled = $debuggingTraceEnabled;
170
+
171
+		return $this;
172
+	}
173
+
174
+	public function getDebuggingCssBreakpointsEnabled() : bool
175
+	{
176
+		return $this->debuggingCssBreakpointsEnabled;
177
+	}
178
+
179
+	public function setDebuggingCssBreakpointsEnabled(bool $debuggingCssBreakpointsEnabled) : SiteConfiguration
180
+	{
181
+		$this->debuggingCssBreakpointsEnabled = $debuggingCssBreakpointsEnabled;
182
+
183
+		return $this;
184
+	}
185
+
186
+	/**
187
+	 * @return string
188
+	 */
189
+	public function getDataClearIp()
190
+	{
191
+		return $this->dataClearIp;
192
+	}
193
+
194
+	/**
195
+	 * @param string $dataClearIp
196
+	 *
197
+	 * @return SiteConfiguration
198
+	 */
199
+	public function setDataClearIp($dataClearIp)
200
+	{
201
+		$this->dataClearIp = $dataClearIp;
202
+
203
+		return $this;
204
+	}
205
+
206
+	/**
207
+	 * @return string
208
+	 */
209
+	public function getDataClearEmail()
210
+	{
211
+		return $this->dataClearEmail;
212
+	}
213
+
214
+	/**
215
+	 * @param string $dataClearEmail
216
+	 *
217
+	 * @return SiteConfiguration
218
+	 */
219
+	public function setDataClearEmail($dataClearEmail)
220
+	{
221
+		$this->dataClearEmail = $dataClearEmail;
222
+
223
+		return $this;
224
+	}
225
+
226
+	/**
227
+	 * @return boolean
228
+	 */
229
+	public function getForceIdentification()
230
+	{
231
+		return $this->forceIdentification;
232
+	}
233
+
234
+	/**
235
+	 * @param boolean $forceIdentification
236
+	 *
237
+	 * @return SiteConfiguration
238
+	 */
239
+	public function setForceIdentification($forceIdentification)
240
+	{
241
+		$this->forceIdentification = $forceIdentification;
242
+
243
+		return $this;
244
+	}
245
+
246
+	/**
247
+	 * @return string
248
+	 */
249
+	public function getIdentificationCacheExpiry()
250
+	{
251
+		return $this->identificationCacheExpiry;
252
+	}
253
+
254
+	/**
255
+	 * @param string $identificationCacheExpiry
256
+	 *
257
+	 * @return SiteConfiguration
258
+	 */
259
+	public function setIdentificationCacheExpiry($identificationCacheExpiry)
260
+	{
261
+		$this->identificationCacheExpiry = $identificationCacheExpiry;
262
+
263
+		return $this;
264
+	}
265
+
266
+	/**
267
+	 * @return string
268
+	 */
269
+	public function getMetaWikimediaWebServiceEndpoint()
270
+	{
271
+		return $this->metaWikimediaWebServiceEndpoint;
272
+	}
273
+
274
+	/**
275
+	 * @param string $metaWikimediaWebServiceEndpoint
276
+	 *
277
+	 * @return SiteConfiguration
278
+	 */
279
+	public function setMetaWikimediaWebServiceEndpoint($metaWikimediaWebServiceEndpoint)
280
+	{
281
+		$this->metaWikimediaWebServiceEndpoint = $metaWikimediaWebServiceEndpoint;
282
+
283
+		return $this;
284
+	}
285
+
286
+	/**
287
+	 * @return boolean
288
+	 */
289
+	public function getEnforceOAuth()
290
+	{
291
+		return $this->enforceOAuth;
292
+	}
293
+
294
+	/**
295
+	 * @param boolean $enforceOAuth
296
+	 *
297
+	 * @return SiteConfiguration
298
+	 */
299
+	public function setEnforceOAuth($enforceOAuth)
300
+	{
301
+		$this->enforceOAuth = $enforceOAuth;
302
+
303
+		return $this;
304
+	}
305
+
306
+	/**
307
+	 * @return boolean
308
+	 */
309
+	public function getEmailConfirmationEnabled()
310
+	{
311
+		return $this->emailConfirmationEnabled;
312
+	}
313
+
314
+	/**
315
+	 * @param boolean $emailConfirmationEnabled
316
+	 *
317
+	 * @return $this
318
+	 */
319
+	public function setEmailConfirmationEnabled($emailConfirmationEnabled)
320
+	{
321
+		$this->emailConfirmationEnabled = $emailConfirmationEnabled;
322
+
323
+		return $this;
324
+	}
325
+
326
+	/**
327
+	 * @return int
328
+	 */
329
+	public function getMiserModeLimit()
330
+	{
331
+		return $this->miserModeLimit;
332
+	}
333
+
334
+	/**
335
+	 * @param int $miserModeLimit
336
+	 *
337
+	 * @return SiteConfiguration
338
+	 */
339
+	public function setMiserModeLimit($miserModeLimit)
340
+	{
341
+		$this->miserModeLimit = $miserModeLimit;
342
+
343
+		return $this;
344
+	}
345
+
346
+	/**
347
+	 * @return array
348
+	 */
349
+	public function getSquidList()
350
+	{
351
+		return $this->squidList;
352
+	}
353
+
354
+	/**
355
+	 * @param array $squidList
356
+	 *
357
+	 * @return SiteConfiguration
358
+	 */
359
+	public function setSquidList($squidList)
360
+	{
361
+		$this->squidList = $squidList;
362
+
363
+		return $this;
364
+	}
365
+
366
+	/**
367
+	 * @return boolean
368
+	 */
369
+	public function getUseStrictTransportSecurity()
370
+	{
371
+		return $this->useStrictTransportSecurity;
372
+	}
373
+
374
+	/**
375
+	 * @param boolean $useStrictTransportSecurity
376
+	 *
377
+	 * @return SiteConfiguration
378
+	 */
379
+	public function setUseStrictTransportSecurity($useStrictTransportSecurity)
380
+	{
381
+		$this->useStrictTransportSecurity = $useStrictTransportSecurity;
382
+
383
+		return $this;
384
+	}
385
+
386
+	/**
387
+	 * @return string
388
+	 */
389
+	public function getUserAgent()
390
+	{
391
+		return $this->userAgent;
392
+	}
393
+
394
+	/**
395
+	 * @param string $userAgent
396
+	 *
397
+	 * @return SiteConfiguration
398
+	 */
399
+	public function setUserAgent($userAgent)
400
+	{
401
+		$this->userAgent = $userAgent;
402
+
403
+		return $this;
404
+	}
405
+
406
+	/**
407
+	 * @return boolean
408
+	 */
409
+	public function getCurlDisableVerifyPeer()
410
+	{
411
+		return $this->curlDisableVerifyPeer;
412
+	}
413
+
414
+	/**
415
+	 * @param boolean $curlDisableVerifyPeer
416
+	 *
417
+	 * @return SiteConfiguration
418
+	 */
419
+	public function setCurlDisableVerifyPeer($curlDisableVerifyPeer)
420
+	{
421
+		$this->curlDisableVerifyPeer = $curlDisableVerifyPeer;
422
+
423
+		return $this;
424
+	}
425
+
426
+	/**
427
+	 * @return boolean
428
+	 */
429
+	public function getUseOAuthSignup()
430
+	{
431
+		return $this->useOAuthSignup;
432
+	}
433
+
434
+	/**
435
+	 * @param boolean $useOAuthSignup
436
+	 *
437
+	 * @return SiteConfiguration
438
+	 */
439
+	public function setUseOAuthSignup($useOAuthSignup)
440
+	{
441
+		$this->useOAuthSignup = $useOAuthSignup;
442
+
443
+		return $this;
444
+	}
445
+
446
+	/**
447
+	 * @return mixed
448
+	 */
449
+	public function getOAuthConsumerToken()
450
+	{
451
+		return $this->oauthConsumerToken;
452
+	}
453
+
454
+	/**
455
+	 * @param mixed $oauthConsumerToken
456
+	 *
457
+	 * @return SiteConfiguration
458
+	 */
459
+	public function setOAuthConsumerToken($oauthConsumerToken)
460
+	{
461
+		$this->oauthConsumerToken = $oauthConsumerToken;
462
+
463
+		return $this;
464
+	}
465
+
466
+	/**
467
+	 * @return mixed
468
+	 */
469
+	public function getOAuthConsumerSecret()
470
+	{
471
+		return $this->oauthConsumerSecret;
472
+	}
473
+
474
+	/**
475
+	 * @param mixed $oauthConsumerSecret
476
+	 *
477
+	 * @return SiteConfiguration
478
+	 */
479
+	public function setOAuthConsumerSecret($oauthConsumerSecret)
480
+	{
481
+		$this->oauthConsumerSecret = $oauthConsumerSecret;
482
+
483
+		return $this;
484
+	}
485
+
486
+	/**
487
+	 * @return string
488
+	 */
489
+	public function getDataClearInterval()
490
+	{
491
+		return $this->dataClearInterval;
492
+	}
493
+
494
+	/**
495
+	 * @param string $dataClearInterval
496
+	 *
497
+	 * @return SiteConfiguration
498
+	 */
499
+	public function setDataClearInterval($dataClearInterval)
500
+	{
501
+		$this->dataClearInterval = $dataClearInterval;
502
+
503
+		return $this;
504
+	}
505
+
506
+	/**
507
+	 * @return string
508
+	 */
509
+	public function getXffTrustedHostsFile()
510
+	{
511
+		return $this->xffTrustedHostsFile;
512
+	}
513
+
514
+	/**
515
+	 * @param string $xffTrustedHostsFile
516
+	 *
517
+	 * @return SiteConfiguration
518
+	 */
519
+	public function setXffTrustedHostsFile($xffTrustedHostsFile)
520
+	{
521
+		$this->xffTrustedHostsFile = $xffTrustedHostsFile;
522
+
523
+		return $this;
524
+	}
525
+
526
+	/**
527
+	 * @return array
528
+	 */
529
+	public function getCrossOriginResourceSharingHosts()
530
+	{
531
+		return $this->crossOriginResourceSharingHosts;
532
+	}
533
+
534
+	/**
535
+	 * @param array $crossOriginResourceSharingHosts
536
+	 *
537
+	 * @return SiteConfiguration
538
+	 */
539
+	public function setCrossOriginResourceSharingHosts($crossOriginResourceSharingHosts)
540
+	{
541
+		$this->crossOriginResourceSharingHosts = $crossOriginResourceSharingHosts;
542
+
543
+		return $this;
544
+	}
545
+
546
+	/**
547
+	 * @return boolean
548
+	 */
549
+	public function getIrcNotificationsEnabled()
550
+	{
551
+		return $this->ircNotificationsEnabled;
552
+	}
553
+
554
+	/**
555
+	 * @param boolean $ircNotificationsEnabled
556
+	 *
557
+	 * @return SiteConfiguration
558
+	 */
559
+	public function setIrcNotificationsEnabled($ircNotificationsEnabled)
560
+	{
561
+		$this->ircNotificationsEnabled = $ircNotificationsEnabled;
562
+
563
+		return $this;
564
+	}
565
+
566
+	/**
567
+	 * @param string $errorLog
568
+	 *
569
+	 * @return SiteConfiguration
570
+	 */
571
+	public function setErrorLog($errorLog)
572
+	{
573
+		$this->errorLog = $errorLog;
574
+
575
+		return $this;
576
+	}
577
+
578
+	/**
579
+	 * @return string
580
+	 */
581
+	public function getErrorLog()
582
+	{
583
+		return $this->errorLog;
584
+	}
585
+
586
+	/**
587
+	 * @param int $emailConfirmationExpiryDays
588
+	 *
589
+	 * @return SiteConfiguration
590
+	 */
591
+	public function setEmailConfirmationExpiryDays($emailConfirmationExpiryDays)
592
+	{
593
+		$this->emailConfirmationExpiryDays = $emailConfirmationExpiryDays;
594
+
595
+		return $this;
596
+	}
597
+
598
+	/**
599
+	 * @return int
600
+	 */
601
+	public function getEmailConfirmationExpiryDays()
602
+	{
603
+		return $this->emailConfirmationExpiryDays;
604
+	}
605
+
606
+	/**
607
+	 * @param string $ircNotificationsInstance
608
+	 *
609
+	 * @return SiteConfiguration
610
+	 */
611
+	public function setIrcNotificationsInstance($ircNotificationsInstance)
612
+	{
613
+		$this->ircNotificationsInstance = $ircNotificationsInstance;
614
+
615
+		return $this;
616
+	}
617
+
618
+	/**
619
+	 * @return string
620
+	 */
621
+	public function getIrcNotificationsInstance()
622
+	{
623
+		return $this->ircNotificationsInstance;
624
+	}
625
+
626
+	/**
627
+	 * @param boolean $titleBlacklistEnabled
628
+	 *
629
+	 * @return SiteConfiguration
630
+	 */
631
+	public function setTitleBlacklistEnabled($titleBlacklistEnabled)
632
+	{
633
+		$this->titleBlacklistEnabled = $titleBlacklistEnabled;
634
+
635
+		return $this;
636
+	}
637
+
638
+	/**
639
+	 * @return boolean
640
+	 */
641
+	public function getTitleBlacklistEnabled()
642
+	{
643
+		return $this->titleBlacklistEnabled;
644
+	}
645
+
646
+	/**
647
+	 * @param string|null $locationProviderApiKey
648
+	 *
649
+	 * @return SiteConfiguration
650
+	 */
651
+	public function setLocationProviderApiKey($locationProviderApiKey)
652
+	{
653
+		$this->locationProviderApiKey = $locationProviderApiKey;
654
+
655
+		return $this;
656
+	}
657
+
658
+	/**
659
+	 * @return null|string
660
+	 */
661
+	public function getLocationProviderApiKey()
662
+	{
663
+		return $this->locationProviderApiKey;
664
+	}
665
+
666
+	/**
667
+	 * @param array $torExitPaths
668
+	 *
669
+	 * @return SiteConfiguration
670
+	 */
671
+	public function setTorExitPaths($torExitPaths)
672
+	{
673
+		$this->torExitPaths = $torExitPaths;
674
+
675
+		return $this;
676
+	}
677
+
678
+	/**
679
+	 * @return array
680
+	 */
681
+	public function getTorExitPaths()
682
+	{
683
+		return $this->torExitPaths;
684
+	}
685
+
686
+	/**
687
+	 * @param string $oauthIdentityGraceTime
688
+	 *
689
+	 * @return SiteConfiguration
690
+	 */
691
+	public function setOauthIdentityGraceTime($oauthIdentityGraceTime)
692
+	{
693
+		$this->oauthIdentityGraceTime = $oauthIdentityGraceTime;
694
+
695
+		return $this;
696
+	}
697
+
698
+	/**
699
+	 * @return string
700
+	 */
701
+	public function getOauthIdentityGraceTime()
702
+	{
703
+		return $this->oauthIdentityGraceTime;
704
+	}
705
+
706
+	/**
707
+	 * @param string $oauthMediaWikiCanonicalServer
708
+	 *
709
+	 * @return SiteConfiguration
710
+	 */
711
+	public function setOauthMediaWikiCanonicalServer($oauthMediaWikiCanonicalServer)
712
+	{
713
+		$this->oauthMediaWikiCanonicalServer = $oauthMediaWikiCanonicalServer;
714
+
715
+		return $this;
716
+	}
717
+
718
+	/**
719
+	 * @return string
720
+	 */
721
+	public function getOauthMediaWikiCanonicalServer()
722
+	{
723
+		return $this->oauthMediaWikiCanonicalServer;
724
+	}
725
+
726
+	/**
727
+	 * @param string $creationBotUsername
728
+	 *
729
+	 * @return SiteConfiguration
730
+	 */
731
+	public function setCreationBotUsername($creationBotUsername)
732
+	{
733
+		$this->creationBotUsername = $creationBotUsername;
734
+
735
+		return $this;
736
+	}
737
+
738
+	/**
739
+	 * @return string
740
+	 */
741
+	public function getCreationBotUsername()
742
+	{
743
+		return $this->creationBotUsername;
744
+	}
745
+
746
+	/**
747
+	 * @param string $creationBotPassword
748
+	 *
749
+	 * @return SiteConfiguration
750
+	 */
751
+	public function setCreationBotPassword($creationBotPassword)
752
+	{
753
+		$this->creationBotPassword = $creationBotPassword;
754
+
755
+		return $this;
756
+	}
757
+
758
+	/**
759
+	 * @return string
760
+	 */
761
+	public function getCreationBotPassword()
762
+	{
763
+		return $this->creationBotPassword;
764
+	}
765
+
766
+	/**
767
+	 * @param string|null $curlCookieJar
768
+	 *
769
+	 * @return SiteConfiguration
770
+	 */
771
+	public function setCurlCookieJar($curlCookieJar)
772
+	{
773
+		$this->curlCookieJar = $curlCookieJar;
774
+
775
+		return $this;
776
+	}
777
+
778
+	/**
779
+	 * @return string|null
780
+	 */
781
+	public function getCurlCookieJar()
782
+	{
783
+		return $this->curlCookieJar;
784
+	}
785
+
786
+	public function getYubicoApiId()
787
+	{
788
+		return $this->yubicoApiId;
789
+	}
790
+
791
+	public function setYubicoApiId($id)
792
+	{
793
+		$this->yubicoApiId = $id;
794
+
795
+		return $this;
796
+	}
797
+
798
+	public function getYubicoApiKey()
799
+	{
800
+		return $this->yubicoApiKey;
801
+	}
802
+
803
+	public function setYubicoApiKey($key)
804
+	{
805
+		$this->yubicoApiKey = $key;
806
+
807
+		return $this;
808
+	}
809
+
810
+	/**
811
+	 * @return string
812
+	 */
813
+	public function getTotpEncryptionKey()
814
+	{
815
+		return $this->totpEncryptionKey;
816
+	}
817
+
818
+	/**
819
+	 * @param string $totpEncryptionKey
820
+	 *
821
+	 * @return SiteConfiguration
822
+	 */
823
+	public function setTotpEncryptionKey($totpEncryptionKey)
824
+	{
825
+		$this->totpEncryptionKey = $totpEncryptionKey;
826
+
827
+		return $this;
828
+	}
829
+
830
+	/**
831
+	 * @return string
832
+	 */
833
+	public function getIdentificationNoticeboardPage()
834
+	{
835
+		return $this->identificationNoticeboardPage;
836
+	}
837
+
838
+	/**
839
+	 * @param string $identificationNoticeboardPage
840
+	 *
841
+	 * @return SiteConfiguration
842
+	 */
843
+	public function setIdentificationNoticeboardPage($identificationNoticeboardPage)
844
+	{
845
+		$this->identificationNoticeboardPage = $identificationNoticeboardPage;
846
+
847
+		return $this;
848
+	}
849
+
850
+	public function setIdentificationNoticeboardWebserviceEndpoint(string $identificationNoticeboardWebserviceEndpoint
851
+	): SiteConfiguration {
852
+		$this->identificationNoticeboardWebserviceEndpoint = $identificationNoticeboardWebserviceEndpoint;
853
+
854
+		return $this;
855
+	}
856
+
857
+	public function getIdentificationNoticeboardWebserviceEndpoint(): string
858
+	{
859
+		return $this->identificationNoticeboardWebserviceEndpoint;
860
+	}
861
+
862
+	public function isRegistrationAllowed(): bool
863
+	{
864
+		return $this->registrationAllowed;
865
+	}
866
+
867
+	public function setRegistrationAllowed(bool $registrationAllowed): SiteConfiguration
868
+	{
869
+		$this->registrationAllowed = $registrationAllowed;
870
+
871
+		return $this;
872
+	}
873
+
874
+	/**
875
+	 * @return string|null
876
+	 */
877
+	public function getCspReportUri()
878
+	{
879
+		return $this->cspReportUri;
880
+	}
881
+
882
+	/**
883
+	 * @param string|null $cspReportUri
884
+	 *
885
+	 * @return SiteConfiguration
886
+	 */
887
+	public function setCspReportUri($cspReportUri)
888
+	{
889
+		$this->cspReportUri = $cspReportUri;
890
+
891
+		return $this;
892
+	}
893
+
894
+	/**
895
+	 * @return int
896
+	 */
897
+	public function getResourceCacheEpoch(): int
898
+	{
899
+		return $this->resourceCacheEpoch;
900
+	}
901
+
902
+	/**
903
+	 * @param int $resourceCacheEpoch
904
+	 *
905
+	 * @return SiteConfiguration
906
+	 */
907
+	public function setResourceCacheEpoch(int $resourceCacheEpoch): SiteConfiguration
908
+	{
909
+		$this->resourceCacheEpoch = $resourceCacheEpoch;
910
+
911
+		return $this;
912
+	}
913
+
914
+	/**
915
+	 * @return array
916
+	 */
917
+	public function getCommonEmailDomains(): array
918
+	{
919
+		return $this->commonEmailDomains;
920
+	}
921
+
922
+	/**
923
+	 * @param array $commonEmailDomains
924
+	 *
925
+	 * @return SiteConfiguration
926
+	 */
927
+	public function setCommonEmailDomains(array $commonEmailDomains): SiteConfiguration
928
+	{
929
+		$this->commonEmailDomains = $commonEmailDomains;
930
+
931
+		return $this;
932
+	}
933
+
934
+	/**
935
+	 * @param int[] $banMaxIpBlockRange
936
+	 *
937
+	 * @return SiteConfiguration
938
+	 */
939
+	public function setBanMaxIpBlockRange(array $banMaxIpBlockRange): SiteConfiguration
940
+	{
941
+		$this->banMaxIpBlockRange = $banMaxIpBlockRange;
942
+
943
+		return $this;
944
+	}
945
+
946
+	/**
947
+	 * @return int[]
948
+	 */
949
+	public function getBanMaxIpBlockRange(): array
950
+	{
951
+		return $this->banMaxIpBlockRange;
952
+	}
953
+
954
+	/**
955
+	 * @param int[] $banMaxIpRange
956
+	 *
957
+	 * @return SiteConfiguration
958
+	 */
959
+	public function setBanMaxIpRange(array $banMaxIpRange): SiteConfiguration
960
+	{
961
+		$this->banMaxIpRange = $banMaxIpRange;
962
+
963
+		return $this;
964
+	}
965
+
966
+	/**
967
+	 * @return int[]
968
+	 */
969
+	public function getBanMaxIpRange(): array
970
+	{
971
+		return $this->banMaxIpRange;
972
+	}
973
+
974
+	/**
975
+	 * @param array $oauthLegacyConsumerTokens
976
+	 *
977
+	 * @return SiteConfiguration
978
+	 */
979
+	public function setOauthLegacyConsumerTokens(array $oauthLegacyConsumerTokens): SiteConfiguration
980
+	{
981
+		$this->oauthLegacyConsumerTokens = $oauthLegacyConsumerTokens;
982
+
983
+		return $this;
984
+	}
985
+
986
+	/**
987
+	 * @return array
988
+	 */
989
+	public function getOauthLegacyConsumerTokens(): array
990
+	{
991
+		return $this->oauthLegacyConsumerTokens;
992
+	}
993
+
994
+	/**
995
+	 * @return int
996
+	 */
997
+	public function getJobQueueBatchSize(): int
998
+	{
999
+		return $this->jobQueueBatchSize;
1000
+	}
1001
+
1002
+	/**
1003
+	 * @param int $jobQueueBatchSize
1004
+	 *
1005
+	 * @return SiteConfiguration
1006
+	 */
1007
+	public function setJobQueueBatchSize(int $jobQueueBatchSize): SiteConfiguration
1008
+	{
1009
+		$this->jobQueueBatchSize = $jobQueueBatchSize;
1010
+
1011
+		return $this;
1012
+	}
1013
+
1014
+	/**
1015
+	 * @return array
1016
+	 */
1017
+	public function getAmqpConfiguration(): array
1018
+	{
1019
+		return $this->amqpConfiguration;
1020
+	}
1021
+
1022
+	/**
1023
+	 * @param array $amqpConfiguration
1024
+	 *
1025
+	 * @return SiteConfiguration
1026
+	 */
1027
+	public function setAmqpConfiguration(array $amqpConfiguration): SiteConfiguration
1028
+	{
1029
+		$this->amqpConfiguration = $amqpConfiguration;
1030
+
1031
+		return $this;
1032
+	}
1033
+
1034
+	/**
1035
+	 * @return string
1036
+	 */
1037
+	public function getEmailSender(): string
1038
+	{
1039
+		return $this->emailSender;
1040
+	}
1041
+
1042
+	/**
1043
+	 * @param string $emailSender
1044
+	 *
1045
+	 * @return SiteConfiguration
1046
+	 */
1047
+	public function setEmailSender(string $emailSender): SiteConfiguration
1048
+	{
1049
+		$this->emailSender = $emailSender;
1050
+
1051
+		return $this;
1052
+	}
1053
+
1054
+	/**
1055
+	 * @param array $acceptClientHints
1056
+	 *
1057
+	 * @return SiteConfiguration
1058
+	 */
1059
+	public function setAcceptClientHints(array $acceptClientHints): SiteConfiguration
1060
+	{
1061
+		$this->acceptClientHints = $acceptClientHints;
1062
+
1063
+		return $this;
1064
+	}
1065
+
1066
+	/**
1067
+	 * @return array
1068
+	 */
1069
+	public function getAcceptClientHints(): array
1070
+	{
1071
+		return $this->acceptClientHints;
1072
+	}
1073
+
1074
+	public function setCookiePath(string $cookiePath): SiteConfiguration
1075
+	{
1076
+		$this->cookiePath = $cookiePath;
1077
+
1078
+		return $this;
1079
+	}
1080
+
1081
+	public function getCookiePath(): string
1082
+	{
1083
+		return $this->cookiePath;
1084
+	}
1085
+
1086
+	public function setCookieSessionName(string $cookieSessionName): SiteConfiguration
1087
+	{
1088
+		$this->cookieSessionName = $cookieSessionName;
1089
+
1090
+		return $this;
1091
+	}
1092
+
1093
+	public function getCookieSessionName(): string
1094
+	{
1095
+		return $this->cookieSessionName;
1096
+	}
1097
+
1098
+	public function setOffline(array $offline): SiteConfiguration
1099
+	{
1100
+		$this->offline = $offline;
1101
+
1102
+		return $this;
1103
+	}
1104
+
1105
+	public function getOffline(): array
1106
+	{
1107
+		return $this->offline;
1108
+	}
1109
+
1110
+	public function setDatabaseConfig(array $databaseConfig): SiteConfiguration
1111
+	{
1112
+		$this->databaseConfig = $databaseConfig;
1113
+
1114
+		return $this;
1115
+	}
1116
+
1117
+	public function getDatabaseConfig(): array
1118
+	{
1119
+		return $this->databaseConfig;
1120
+	}
1121
+
1122
+	public function getPrivacyStatementPath(): string
1123
+	{
1124
+		return $this->privacyStatementPath;
1125
+	}
1126
+
1127
+	public function setPrivacyStatementPath(string $privacyStatementPath): SiteConfiguration
1128
+	{
1129
+		$this->privacyStatementPath = $privacyStatementPath;
1130
+
1131
+		return $this;
1132
+	}
1133
+
1134
+	public function getCreateAccountLink(): string
1135
+	{
1136
+		return $this->createAccountLink;
1137
+	}
1138
+
1139
+	public function setCreateAccountLink(string $createAccountLink): SiteConfiguration
1140
+	{
1141
+		$this->createAccountLink = $createAccountLink;
1142
+
1143
+		return $this;
1144
+	}
1145 1145
 }
Please login to merge, or discard this patch.
includes/Pages/PageViewRequest.php 1 patch
Indentation   +375 added lines, -375 removed lines patch added patch discarded remove patch
@@ -33,380 +33,380 @@
 block discarded – undo
33 33
 
34 34
 class PageViewRequest extends InternalPageBase
35 35
 {
36
-    use RequestData;
36
+	use RequestData;
37 37
 
38
-    const STATUS_SYMBOL_OPEN = '&#927';
39
-    const STATUS_SYMBOL_ACCEPTED = '&#x2611';
40
-    const STATUS_SYMBOL_REJECTED = '&#x2612';
41
-
42
-    /**
43
-     * Main function for this page, when no specific actions are called.
44
-     * @throws ApplicationLogicException
45
-     */
46
-    protected function main()
47
-    {
48
-        // set up csrf protection
49
-        $this->assignCSRFToken();
50
-
51
-        // get some useful objects
52
-        $database = $this->getDatabase();
53
-        $request = $this->getRequest($database, WebRequest::getInt('id'));
54
-        $config = $this->getSiteConfiguration();
55
-        $currentUser = User::getCurrent($database);
56
-
57
-        /** @var Domain $domain */
58
-        $domain = Domain::getById($request->getDomain(), $this->getDatabase());
59
-        $this->assign('mediawikiScriptPath', $domain->getWikiArticlePath());
60
-
61
-        // Shows a page if the email is not confirmed.
62
-        if ($request->getEmailConfirm() !== 'Confirmed') {
63
-            // Show a banner if the user can manually confirm the request
64
-            $viewConfirm = $this->barrierTest(RoleConfigurationBase::MAIN, $currentUser, PageManuallyConfirm::class);
65
-
66
-            // If the request is purged, there's nothing to confirm!
67
-            if ($request->getEmail() === $this->getSiteConfiguration()->getDataClearEmail()) {
68
-                $viewConfirm = false;
69
-            }
70
-
71
-            // Render
72
-            $this->setTemplate("view-request/not-confirmed.tpl");
73
-            $this->assign("requestId", $request->getId());
74
-            $this->assign("requestVersion", $request->getUpdateVersion());
75
-            $this->assign('canViewConfirmButton', $viewConfirm);
76
-
77
-            // Make sure to return, to prevent the leaking of other information.
78
-            return;
79
-        }
80
-
81
-        $this->setupBasicData($request, $config);
82
-
83
-        $this->setupUsernameData($request);
84
-
85
-        $this->setupTitle($request);
86
-
87
-        $this->setupReservationDetails($request->getReserved(), $database, $currentUser);
88
-        $this->setupGeneralData($database);
89
-
90
-        $this->assign('requestDataCleared', false);
91
-        if ($request->getEmail() === $this->getSiteConfiguration()->getDataClearEmail()) {
92
-            $this->assign('requestDataCleared', true);
93
-        }
94
-
95
-        $allowedPrivateData = $this->isAllowedPrivateData($request, $currentUser);
96
-
97
-        $this->setupCreationTypes($currentUser);
98
-
99
-        $this->setupLogData($request, $database, $allowedPrivateData);
100
-
101
-        $this->addJs("/api.php?action=templates&targetVariable=templateconfirms");
102
-
103
-        $this->assign('showRevealLink', false);
104
-        if ($request->getReserved() === $currentUser->getId() ||
105
-            $this->barrierTest('alwaysSeeHash', $currentUser, 'RequestData')
106
-        ) {
107
-            $this->assign('showRevealLink', true);
108
-            $this->assign('revealHash', $request->getRevealHash());
109
-        }
110
-
111
-        $this->assign('canSeeRelatedRequests', false);
112
-        if ($allowedPrivateData || $this->barrierTest('seeRelatedRequests', $currentUser, 'RequestData')) {
113
-            $this->setupRelatedRequests($request, $config, $database);
114
-        }
115
-
116
-        $this->assign('canCreateLocalAccount', $this->barrierTest('createLocalAccount', $currentUser, 'RequestData'));
117
-
118
-        $closureDate = $request->getClosureDate();
119
-        $date = new DateTime();
120
-        $date->modify("-7 days");
121
-        if ($request->getStatus() == "Closed" && $closureDate < $date) {
122
-            $this->assign('isOldRequest', true);
123
-        }
124
-        $this->assign('canResetOldRequest', $this->barrierTest('reopenOldRequest', $currentUser, 'RequestData'));
125
-        $this->assign('canResetPurgedRequest', $this->barrierTest('reopenClearedRequest', $currentUser, 'RequestData'));
126
-
127
-        $this->assign('requestEmailSent', $request->getEmailSent());
128
-
129
-        if ($allowedPrivateData) {
130
-            $this->assign('manualCreationUrl', $this->getCreationUrl($domain));
131
-
132
-            $this->setTemplate('view-request/main-with-data.tpl');
133
-            $this->setupPrivateData($request, $config);
134
-            $this->assign('canSetBan', $this->barrierTest('set', $currentUser, PageBan::class));
135
-            $this->assign('canSeeCheckuserData', $this->barrierTest('seeUserAgentData', $currentUser, 'RequestData'));
136
-
137
-            if ($this->barrierTest('seeUserAgentData', $currentUser, 'RequestData')) {
138
-                $this->setTemplate('view-request/main-with-checkuser-data.tpl');
139
-                $this->setupCheckUserData($request);
140
-            }
141
-        }
142
-        else {
143
-            $this->setTemplate('view-request/main.tpl');
144
-        }
145
-    }
146
-
147
-    /**
148
-     * @param Request $request
149
-     */
150
-    protected function setupTitle(Request $request)
151
-    {
152
-        $statusSymbol = self::STATUS_SYMBOL_OPEN;
153
-        if ($request->getStatus() === RequestStatus::CLOSED) {
154
-            if ($request->getWasCreated()) {
155
-                $statusSymbol = self::STATUS_SYMBOL_ACCEPTED;
156
-            }
157
-            else {
158
-                $statusSymbol = self::STATUS_SYMBOL_REJECTED;
159
-            }
160
-        }
161
-
162
-        $this->setHtmlTitle($statusSymbol . ' #' . $request->getId());
163
-    }
164
-
165
-    /**
166
-     * Sets up data unrelated to the request, such as the email template information
167
-     *
168
-     * @param PdoDatabase $database
169
-     */
170
-    protected function setupGeneralData(PdoDatabase $database)
171
-    {
172
-        $this->assign('createAccountReason', 'Requested account at [[WP:ACC]], request #');
173
-
174
-        // FIXME: domains
175
-        /** @var Domain $domain */
176
-        $domain = Domain::getById(1, $database);
177
-        $this->assign('defaultRequestState', RequestQueue::getDefaultQueue($database, 1)->getApiName());
178
-        $this->assign('activeRequestQueues', RequestQueue::getEnabledQueues($database));
179
-
180
-        /** @var EmailTemplate $createdTemplate */
181
-        $createdTemplate = EmailTemplate::getById($domain->getDefaultClose(), $database);
182
-
183
-        $this->assign('createdHasJsQuestion', $createdTemplate->getJsquestion() != '');
184
-        $this->assign('createdId', $createdTemplate->getId());
185
-        $this->assign('createdName', $createdTemplate->getName());
186
-
187
-        $preferenceManager = PreferenceManager::getForCurrent($database);
188
-        $skipJsAborts = $preferenceManager->getPreference(PreferenceManager::PREF_SKIP_JS_ABORT);
189
-        $preferredCreationMode = (int)$preferenceManager->getPreference(PreferenceManager::PREF_CREATION_MODE);
190
-        $this->assign('skipJsAborts', $skipJsAborts);
191
-        $this->assign('preferredCreationMode', $preferredCreationMode);
192
-
193
-        $createReasons = EmailTemplate::getActiveNonpreloadTemplates(
194
-            EmailTemplate::ACTION_CREATED,
195
-            $database,
196
-            $domain->getId(),
197
-            $domain->getDefaultClose());
198
-        $this->assign("createReasons", $createReasons);
199
-
200
-        $declineReasons = EmailTemplate::getActiveNonpreloadTemplates(
201
-            EmailTemplate::ACTION_NOT_CREATED,
202
-            $database,
203
-            $domain->getId());
204
-        $this->assign("declineReasons", $declineReasons);
205
-
206
-        $allCreateReasons = EmailTemplate::getAllActiveTemplates(
207
-            EmailTemplate::ACTION_CREATED,
208
-            $database,
209
-            $domain->getId());
210
-        $this->assign("allCreateReasons", $allCreateReasons);
211
-
212
-        $allDeclineReasons = EmailTemplate::getAllActiveTemplates(
213
-            EmailTemplate::ACTION_NOT_CREATED,
214
-            $database,
215
-            $domain->getId());
216
-        $this->assign("allDeclineReasons", $allDeclineReasons);
217
-
218
-        $allOtherReasons = EmailTemplate::getAllActiveTemplates(
219
-            false,
220
-            $database,
221
-            $domain->getId());
222
-        $this->assign("allOtherReasons", $allOtherReasons);
223
-    }
224
-
225
-    private function setupLogData(Request $request, PdoDatabase $database, bool $allowedPrivateData)
226
-    {
227
-        $currentUser = User::getCurrent($database);
228
-
229
-        $logs = LogHelper::getRequestLogsWithComments($request->getId(), $database, $this->getSecurityManager());
230
-        $requestLogs = array();
231
-
232
-        /** @var User[] $nameCache */
233
-        $nameCache = array();
234
-
235
-        $editableComments = $this->barrierTest('editOthers', $currentUser, PageEditComment::class);
236
-
237
-        $canFlag = $this->barrierTest(RoleConfigurationBase::MAIN, $currentUser, PageFlagComment::class);
238
-        $canUnflag = $this->barrierTest('unflag', $currentUser, PageFlagComment::class);
239
-
240
-        /** @var Log|Comment $entry */
241
-        foreach ($logs as $entry) {
242
-            // both log and comment have a 'user' field
243
-            if (!array_key_exists($entry->getUser(), $nameCache)) {
244
-                $entryUser = User::getById($entry->getUser(), $database);
245
-                $nameCache[$entry->getUser()] = $entryUser;
246
-            }
247
-
248
-            if ($entry instanceof Comment) {
249
-                // Determine if the comment contains private information.
250
-                // Private defined as flagged or restricted visibility, but only when the user isn't allowed
251
-                // to see private data
252
-                $commentIsRestricted =
253
-                    ($entry->getFlagged()
254
-                        || $entry->getVisibility() == 'admin' || $entry->getVisibility() == 'checkuser')
255
-                    && !$allowedPrivateData;
256
-
257
-                // Only allow comment editing if the user is able to edit comments or this is the user's own comment,
258
-                // but only when they're allowed to see the comment itself.
259
-                $commentIsEditable = ($editableComments || $entry->getUser() == $currentUser->getId())
260
-                    && !$commentIsRestricted;
261
-
262
-                // Flagging/unflagging can only be done if you can see the comment
263
-                $canFlagThisComment = $canFlag
264
-                    && (
265
-                        (!$entry->getFlagged() && !$commentIsRestricted)
266
-                        || ($entry->getFlagged() && $canUnflag && $commentIsEditable)
267
-                    );
268
-
269
-                $requestLogs[] = array(
270
-                    'type'          => 'comment',
271
-                    'security'      => $entry->getVisibility(),
272
-                    'user'          => $entry->getVisibility() == 'requester' ? $request->getName() : $nameCache[$entry->getUser()]->getUsername(),
273
-                    'userid'        => $entry->getUser() == -1 ? null : $entry->getUser(),
274
-                    'entry'         => null,
275
-                    'time'          => $entry->getTime(),
276
-                    'canedit'       => $commentIsEditable,
277
-                    'id'            => $entry->getId(),
278
-                    'comment'       => $entry->getComment(),
279
-                    'flagged'       => $entry->getFlagged(),
280
-                    'canflag'       => $canFlagThisComment,
281
-                    'updateversion' => $entry->getUpdateVersion(),
282
-                    'edited'        => $entry->getEdited(),
283
-                    'hidden'        => $commentIsRestricted
284
-                );
285
-            }
286
-
287
-            if ($entry instanceof Log) {
288
-                $invalidUserId = $entry->getUser() === -1 || $entry->getUser() === 0;
289
-                $entryUser = $invalidUserId ? User::getCommunity() : $nameCache[$entry->getUser()];
290
-
291
-                $entryComment = $entry->getComment();
292
-
293
-                if ($entry->getAction() === 'JobIssueRequest' || $entry->getAction() === 'JobCompletedRequest') {
294
-                    $data = unserialize($entry->getComment());
295
-                    /** @var JobQueue $job */
296
-                    $job = JobQueue::getById($data['job'], $database);
297
-                    $requestLogs[] = array(
298
-                        'type'     => 'joblog',
299
-                        'security' => 'user',
300
-                        'userid'   => $entry->getUser() == -1 ? null : $entry->getUser(),
301
-                        'user'     => $entryUser->getUsername(),
302
-                        'entry'    => LogHelper::getLogDescription($entry),
303
-                        'time'     => $entry->getTimestamp(),
304
-                        'canedit'  => false,
305
-                        'id'       => $entry->getId(),
306
-                        'jobId'    => $job->getId(),
307
-                        'jobDesc'  => JobQueue::getTaskDescriptions()[$job->getTask()],
308
-                    );
309
-                }
310
-                else {
311
-                    $requestLogs[] = array(
312
-                        'type'     => 'log',
313
-                        'security' => 'user',
314
-                        'userid'   => $entry->getUser() == -1 ? null : $entry->getUser(),
315
-                        'user'     => $entryUser->getUsername(),
316
-                        'entry'    => LogHelper::getLogDescription($entry),
317
-                        'time'     => $entry->getTimestamp(),
318
-                        'canedit'  => false,
319
-                        'id'       => $entry->getId(),
320
-                        'comment'  => $entryComment,
321
-                    );
322
-                }
323
-            }
324
-        }
325
-
326
-        $this->addJs("/api.php?action=users&targetVariable=typeaheaddata");
327
-
328
-        $this->assign("requestLogs", $requestLogs);
329
-    }
330
-
331
-    /**
332
-     * @param Request $request
333
-     */
334
-    protected function setupUsernameData(Request $request)
335
-    {
336
-        $blacklistData = $this->getBlacklistHelper()->isBlacklisted($request->getName());
337
-
338
-        $this->assign('requestIsBlacklisted', $blacklistData !== false);
339
-        $this->assign('requestBlacklist', $blacklistData);
340
-
341
-        try {
342
-            $spoofs = $this->getAntiSpoofProvider()->getSpoofs($request->getName());
343
-        }
344
-        catch (Exception $ex) {
345
-            $spoofs = $ex->getMessage();
346
-        }
347
-
348
-        $this->assign("spoofs", $spoofs);
349
-    }
350
-
351
-    private function setupCreationTypes(User $user)
352
-    {
353
-        $this->assign('allowWelcomeSkip', false);
354
-        $this->assign('forceWelcomeSkip', false);
355
-
356
-        $database = $this->getDatabase();
357
-        $preferenceManager = PreferenceManager::getForCurrent($database);
358
-
359
-        $oauth = new OAuthUserHelper($user, $database, $this->getOAuthProtocolHelper(), $this->getSiteConfiguration());
360
-
361
-        $welcomeTemplate = $preferenceManager->getPreference(PreferenceManager::PREF_WELCOMETEMPLATE);
362
-
363
-        if ($welcomeTemplate != null) {
364
-            $this->assign('allowWelcomeSkip', true);
365
-
366
-            if (!$oauth->canWelcome()) {
367
-                $this->assign('forceWelcomeSkip', true);
368
-            }
369
-        }
370
-
371
-        // test credentials
372
-        $canManualCreate = $this->barrierTest(PreferenceManager::CREATION_MANUAL, $user, 'RequestCreation');
373
-        $canOauthCreate = $this->barrierTest(PreferenceManager::CREATION_OAUTH, $user, 'RequestCreation');
374
-        $canBotCreate = $this->barrierTest(PreferenceManager::CREATION_BOT, $user, 'RequestCreation');
375
-
376
-        $this->assign('canManualCreate', $canManualCreate);
377
-        $this->assign('canOauthCreate', $canOauthCreate);
378
-        $this->assign('canBotCreate', $canBotCreate);
379
-
380
-        // show/hide the type radio buttons
381
-        $creationHasChoice = count(array_filter([$canManualCreate, $canOauthCreate, $canBotCreate])) > 1;
382
-
383
-        $creationModePreference = $preferenceManager->getPreference(PreferenceManager::PREF_CREATION_MODE);
384
-        if (!$this->barrierTest($creationModePreference, $user, 'RequestCreation')) {
385
-            // user is not allowed to use their default. Force a choice.
386
-            $creationHasChoice = true;
387
-        }
388
-
389
-        $this->assign('creationHasChoice', $creationHasChoice);
390
-
391
-        // determine problems in creation types
392
-        $this->assign('botProblem', false);
393
-        if ($canBotCreate && $this->getSiteConfiguration()->getCreationBotPassword() === null) {
394
-            $this->assign('botProblem', true);
395
-        }
396
-
397
-        $this->assign('oauthProblem', false);
398
-        if ($canOauthCreate && !$oauth->canCreateAccount()) {
399
-            $this->assign('oauthProblem', true);
400
-        }
401
-    }
402
-
403
-    private function getCreationUrl(Domain $domain): string
404
-    {
405
-        $template = $this->getSiteConfiguration()->getCreateAccountLink();
406
-
407
-        $template = str_replace('{articlePath}', $domain->getWikiArticlePath(), $template);
408
-        $template = str_replace('{wikiId}', $domain->getShortName(), $template);
409
-
410
-        return $template;
411
-    }
38
+	const STATUS_SYMBOL_OPEN = '&#927';
39
+	const STATUS_SYMBOL_ACCEPTED = '&#x2611';
40
+	const STATUS_SYMBOL_REJECTED = '&#x2612';
41
+
42
+	/**
43
+	 * Main function for this page, when no specific actions are called.
44
+	 * @throws ApplicationLogicException
45
+	 */
46
+	protected function main()
47
+	{
48
+		// set up csrf protection
49
+		$this->assignCSRFToken();
50
+
51
+		// get some useful objects
52
+		$database = $this->getDatabase();
53
+		$request = $this->getRequest($database, WebRequest::getInt('id'));
54
+		$config = $this->getSiteConfiguration();
55
+		$currentUser = User::getCurrent($database);
56
+
57
+		/** @var Domain $domain */
58
+		$domain = Domain::getById($request->getDomain(), $this->getDatabase());
59
+		$this->assign('mediawikiScriptPath', $domain->getWikiArticlePath());
60
+
61
+		// Shows a page if the email is not confirmed.
62
+		if ($request->getEmailConfirm() !== 'Confirmed') {
63
+			// Show a banner if the user can manually confirm the request
64
+			$viewConfirm = $this->barrierTest(RoleConfigurationBase::MAIN, $currentUser, PageManuallyConfirm::class);
65
+
66
+			// If the request is purged, there's nothing to confirm!
67
+			if ($request->getEmail() === $this->getSiteConfiguration()->getDataClearEmail()) {
68
+				$viewConfirm = false;
69
+			}
70
+
71
+			// Render
72
+			$this->setTemplate("view-request/not-confirmed.tpl");
73
+			$this->assign("requestId", $request->getId());
74
+			$this->assign("requestVersion", $request->getUpdateVersion());
75
+			$this->assign('canViewConfirmButton', $viewConfirm);
76
+
77
+			// Make sure to return, to prevent the leaking of other information.
78
+			return;
79
+		}
80
+
81
+		$this->setupBasicData($request, $config);
82
+
83
+		$this->setupUsernameData($request);
84
+
85
+		$this->setupTitle($request);
86
+
87
+		$this->setupReservationDetails($request->getReserved(), $database, $currentUser);
88
+		$this->setupGeneralData($database);
89
+
90
+		$this->assign('requestDataCleared', false);
91
+		if ($request->getEmail() === $this->getSiteConfiguration()->getDataClearEmail()) {
92
+			$this->assign('requestDataCleared', true);
93
+		}
94
+
95
+		$allowedPrivateData = $this->isAllowedPrivateData($request, $currentUser);
96
+
97
+		$this->setupCreationTypes($currentUser);
98
+
99
+		$this->setupLogData($request, $database, $allowedPrivateData);
100
+
101
+		$this->addJs("/api.php?action=templates&targetVariable=templateconfirms");
102
+
103
+		$this->assign('showRevealLink', false);
104
+		if ($request->getReserved() === $currentUser->getId() ||
105
+			$this->barrierTest('alwaysSeeHash', $currentUser, 'RequestData')
106
+		) {
107
+			$this->assign('showRevealLink', true);
108
+			$this->assign('revealHash', $request->getRevealHash());
109
+		}
110
+
111
+		$this->assign('canSeeRelatedRequests', false);
112
+		if ($allowedPrivateData || $this->barrierTest('seeRelatedRequests', $currentUser, 'RequestData')) {
113
+			$this->setupRelatedRequests($request, $config, $database);
114
+		}
115
+
116
+		$this->assign('canCreateLocalAccount', $this->barrierTest('createLocalAccount', $currentUser, 'RequestData'));
117
+
118
+		$closureDate = $request->getClosureDate();
119
+		$date = new DateTime();
120
+		$date->modify("-7 days");
121
+		if ($request->getStatus() == "Closed" && $closureDate < $date) {
122
+			$this->assign('isOldRequest', true);
123
+		}
124
+		$this->assign('canResetOldRequest', $this->barrierTest('reopenOldRequest', $currentUser, 'RequestData'));
125
+		$this->assign('canResetPurgedRequest', $this->barrierTest('reopenClearedRequest', $currentUser, 'RequestData'));
126
+
127
+		$this->assign('requestEmailSent', $request->getEmailSent());
128
+
129
+		if ($allowedPrivateData) {
130
+			$this->assign('manualCreationUrl', $this->getCreationUrl($domain));
131
+
132
+			$this->setTemplate('view-request/main-with-data.tpl');
133
+			$this->setupPrivateData($request, $config);
134
+			$this->assign('canSetBan', $this->barrierTest('set', $currentUser, PageBan::class));
135
+			$this->assign('canSeeCheckuserData', $this->barrierTest('seeUserAgentData', $currentUser, 'RequestData'));
136
+
137
+			if ($this->barrierTest('seeUserAgentData', $currentUser, 'RequestData')) {
138
+				$this->setTemplate('view-request/main-with-checkuser-data.tpl');
139
+				$this->setupCheckUserData($request);
140
+			}
141
+		}
142
+		else {
143
+			$this->setTemplate('view-request/main.tpl');
144
+		}
145
+	}
146
+
147
+	/**
148
+	 * @param Request $request
149
+	 */
150
+	protected function setupTitle(Request $request)
151
+	{
152
+		$statusSymbol = self::STATUS_SYMBOL_OPEN;
153
+		if ($request->getStatus() === RequestStatus::CLOSED) {
154
+			if ($request->getWasCreated()) {
155
+				$statusSymbol = self::STATUS_SYMBOL_ACCEPTED;
156
+			}
157
+			else {
158
+				$statusSymbol = self::STATUS_SYMBOL_REJECTED;
159
+			}
160
+		}
161
+
162
+		$this->setHtmlTitle($statusSymbol . ' #' . $request->getId());
163
+	}
164
+
165
+	/**
166
+	 * Sets up data unrelated to the request, such as the email template information
167
+	 *
168
+	 * @param PdoDatabase $database
169
+	 */
170
+	protected function setupGeneralData(PdoDatabase $database)
171
+	{
172
+		$this->assign('createAccountReason', 'Requested account at [[WP:ACC]], request #');
173
+
174
+		// FIXME: domains
175
+		/** @var Domain $domain */
176
+		$domain = Domain::getById(1, $database);
177
+		$this->assign('defaultRequestState', RequestQueue::getDefaultQueue($database, 1)->getApiName());
178
+		$this->assign('activeRequestQueues', RequestQueue::getEnabledQueues($database));
179
+
180
+		/** @var EmailTemplate $createdTemplate */
181
+		$createdTemplate = EmailTemplate::getById($domain->getDefaultClose(), $database);
182
+
183
+		$this->assign('createdHasJsQuestion', $createdTemplate->getJsquestion() != '');
184
+		$this->assign('createdId', $createdTemplate->getId());
185
+		$this->assign('createdName', $createdTemplate->getName());
186
+
187
+		$preferenceManager = PreferenceManager::getForCurrent($database);
188
+		$skipJsAborts = $preferenceManager->getPreference(PreferenceManager::PREF_SKIP_JS_ABORT);
189
+		$preferredCreationMode = (int)$preferenceManager->getPreference(PreferenceManager::PREF_CREATION_MODE);
190
+		$this->assign('skipJsAborts', $skipJsAborts);
191
+		$this->assign('preferredCreationMode', $preferredCreationMode);
192
+
193
+		$createReasons = EmailTemplate::getActiveNonpreloadTemplates(
194
+			EmailTemplate::ACTION_CREATED,
195
+			$database,
196
+			$domain->getId(),
197
+			$domain->getDefaultClose());
198
+		$this->assign("createReasons", $createReasons);
199
+
200
+		$declineReasons = EmailTemplate::getActiveNonpreloadTemplates(
201
+			EmailTemplate::ACTION_NOT_CREATED,
202
+			$database,
203
+			$domain->getId());
204
+		$this->assign("declineReasons", $declineReasons);
205
+
206
+		$allCreateReasons = EmailTemplate::getAllActiveTemplates(
207
+			EmailTemplate::ACTION_CREATED,
208
+			$database,
209
+			$domain->getId());
210
+		$this->assign("allCreateReasons", $allCreateReasons);
211
+
212
+		$allDeclineReasons = EmailTemplate::getAllActiveTemplates(
213
+			EmailTemplate::ACTION_NOT_CREATED,
214
+			$database,
215
+			$domain->getId());
216
+		$this->assign("allDeclineReasons", $allDeclineReasons);
217
+
218
+		$allOtherReasons = EmailTemplate::getAllActiveTemplates(
219
+			false,
220
+			$database,
221
+			$domain->getId());
222
+		$this->assign("allOtherReasons", $allOtherReasons);
223
+	}
224
+
225
+	private function setupLogData(Request $request, PdoDatabase $database, bool $allowedPrivateData)
226
+	{
227
+		$currentUser = User::getCurrent($database);
228
+
229
+		$logs = LogHelper::getRequestLogsWithComments($request->getId(), $database, $this->getSecurityManager());
230
+		$requestLogs = array();
231
+
232
+		/** @var User[] $nameCache */
233
+		$nameCache = array();
234
+
235
+		$editableComments = $this->barrierTest('editOthers', $currentUser, PageEditComment::class);
236
+
237
+		$canFlag = $this->barrierTest(RoleConfigurationBase::MAIN, $currentUser, PageFlagComment::class);
238
+		$canUnflag = $this->barrierTest('unflag', $currentUser, PageFlagComment::class);
239
+
240
+		/** @var Log|Comment $entry */
241
+		foreach ($logs as $entry) {
242
+			// both log and comment have a 'user' field
243
+			if (!array_key_exists($entry->getUser(), $nameCache)) {
244
+				$entryUser = User::getById($entry->getUser(), $database);
245
+				$nameCache[$entry->getUser()] = $entryUser;
246
+			}
247
+
248
+			if ($entry instanceof Comment) {
249
+				// Determine if the comment contains private information.
250
+				// Private defined as flagged or restricted visibility, but only when the user isn't allowed
251
+				// to see private data
252
+				$commentIsRestricted =
253
+					($entry->getFlagged()
254
+						|| $entry->getVisibility() == 'admin' || $entry->getVisibility() == 'checkuser')
255
+					&& !$allowedPrivateData;
256
+
257
+				// Only allow comment editing if the user is able to edit comments or this is the user's own comment,
258
+				// but only when they're allowed to see the comment itself.
259
+				$commentIsEditable = ($editableComments || $entry->getUser() == $currentUser->getId())
260
+					&& !$commentIsRestricted;
261
+
262
+				// Flagging/unflagging can only be done if you can see the comment
263
+				$canFlagThisComment = $canFlag
264
+					&& (
265
+						(!$entry->getFlagged() && !$commentIsRestricted)
266
+						|| ($entry->getFlagged() && $canUnflag && $commentIsEditable)
267
+					);
268
+
269
+				$requestLogs[] = array(
270
+					'type'          => 'comment',
271
+					'security'      => $entry->getVisibility(),
272
+					'user'          => $entry->getVisibility() == 'requester' ? $request->getName() : $nameCache[$entry->getUser()]->getUsername(),
273
+					'userid'        => $entry->getUser() == -1 ? null : $entry->getUser(),
274
+					'entry'         => null,
275
+					'time'          => $entry->getTime(),
276
+					'canedit'       => $commentIsEditable,
277
+					'id'            => $entry->getId(),
278
+					'comment'       => $entry->getComment(),
279
+					'flagged'       => $entry->getFlagged(),
280
+					'canflag'       => $canFlagThisComment,
281
+					'updateversion' => $entry->getUpdateVersion(),
282
+					'edited'        => $entry->getEdited(),
283
+					'hidden'        => $commentIsRestricted
284
+				);
285
+			}
286
+
287
+			if ($entry instanceof Log) {
288
+				$invalidUserId = $entry->getUser() === -1 || $entry->getUser() === 0;
289
+				$entryUser = $invalidUserId ? User::getCommunity() : $nameCache[$entry->getUser()];
290
+
291
+				$entryComment = $entry->getComment();
292
+
293
+				if ($entry->getAction() === 'JobIssueRequest' || $entry->getAction() === 'JobCompletedRequest') {
294
+					$data = unserialize($entry->getComment());
295
+					/** @var JobQueue $job */
296
+					$job = JobQueue::getById($data['job'], $database);
297
+					$requestLogs[] = array(
298
+						'type'     => 'joblog',
299
+						'security' => 'user',
300
+						'userid'   => $entry->getUser() == -1 ? null : $entry->getUser(),
301
+						'user'     => $entryUser->getUsername(),
302
+						'entry'    => LogHelper::getLogDescription($entry),
303
+						'time'     => $entry->getTimestamp(),
304
+						'canedit'  => false,
305
+						'id'       => $entry->getId(),
306
+						'jobId'    => $job->getId(),
307
+						'jobDesc'  => JobQueue::getTaskDescriptions()[$job->getTask()],
308
+					);
309
+				}
310
+				else {
311
+					$requestLogs[] = array(
312
+						'type'     => 'log',
313
+						'security' => 'user',
314
+						'userid'   => $entry->getUser() == -1 ? null : $entry->getUser(),
315
+						'user'     => $entryUser->getUsername(),
316
+						'entry'    => LogHelper::getLogDescription($entry),
317
+						'time'     => $entry->getTimestamp(),
318
+						'canedit'  => false,
319
+						'id'       => $entry->getId(),
320
+						'comment'  => $entryComment,
321
+					);
322
+				}
323
+			}
324
+		}
325
+
326
+		$this->addJs("/api.php?action=users&targetVariable=typeaheaddata");
327
+
328
+		$this->assign("requestLogs", $requestLogs);
329
+	}
330
+
331
+	/**
332
+	 * @param Request $request
333
+	 */
334
+	protected function setupUsernameData(Request $request)
335
+	{
336
+		$blacklistData = $this->getBlacklistHelper()->isBlacklisted($request->getName());
337
+
338
+		$this->assign('requestIsBlacklisted', $blacklistData !== false);
339
+		$this->assign('requestBlacklist', $blacklistData);
340
+
341
+		try {
342
+			$spoofs = $this->getAntiSpoofProvider()->getSpoofs($request->getName());
343
+		}
344
+		catch (Exception $ex) {
345
+			$spoofs = $ex->getMessage();
346
+		}
347
+
348
+		$this->assign("spoofs", $spoofs);
349
+	}
350
+
351
+	private function setupCreationTypes(User $user)
352
+	{
353
+		$this->assign('allowWelcomeSkip', false);
354
+		$this->assign('forceWelcomeSkip', false);
355
+
356
+		$database = $this->getDatabase();
357
+		$preferenceManager = PreferenceManager::getForCurrent($database);
358
+
359
+		$oauth = new OAuthUserHelper($user, $database, $this->getOAuthProtocolHelper(), $this->getSiteConfiguration());
360
+
361
+		$welcomeTemplate = $preferenceManager->getPreference(PreferenceManager::PREF_WELCOMETEMPLATE);
362
+
363
+		if ($welcomeTemplate != null) {
364
+			$this->assign('allowWelcomeSkip', true);
365
+
366
+			if (!$oauth->canWelcome()) {
367
+				$this->assign('forceWelcomeSkip', true);
368
+			}
369
+		}
370
+
371
+		// test credentials
372
+		$canManualCreate = $this->barrierTest(PreferenceManager::CREATION_MANUAL, $user, 'RequestCreation');
373
+		$canOauthCreate = $this->barrierTest(PreferenceManager::CREATION_OAUTH, $user, 'RequestCreation');
374
+		$canBotCreate = $this->barrierTest(PreferenceManager::CREATION_BOT, $user, 'RequestCreation');
375
+
376
+		$this->assign('canManualCreate', $canManualCreate);
377
+		$this->assign('canOauthCreate', $canOauthCreate);
378
+		$this->assign('canBotCreate', $canBotCreate);
379
+
380
+		// show/hide the type radio buttons
381
+		$creationHasChoice = count(array_filter([$canManualCreate, $canOauthCreate, $canBotCreate])) > 1;
382
+
383
+		$creationModePreference = $preferenceManager->getPreference(PreferenceManager::PREF_CREATION_MODE);
384
+		if (!$this->barrierTest($creationModePreference, $user, 'RequestCreation')) {
385
+			// user is not allowed to use their default. Force a choice.
386
+			$creationHasChoice = true;
387
+		}
388
+
389
+		$this->assign('creationHasChoice', $creationHasChoice);
390
+
391
+		// determine problems in creation types
392
+		$this->assign('botProblem', false);
393
+		if ($canBotCreate && $this->getSiteConfiguration()->getCreationBotPassword() === null) {
394
+			$this->assign('botProblem', true);
395
+		}
396
+
397
+		$this->assign('oauthProblem', false);
398
+		if ($canOauthCreate && !$oauth->canCreateAccount()) {
399
+			$this->assign('oauthProblem', true);
400
+		}
401
+	}
402
+
403
+	private function getCreationUrl(Domain $domain): string
404
+	{
405
+		$template = $this->getSiteConfiguration()->getCreateAccountLink();
406
+
407
+		$template = str_replace('{articlePath}', $domain->getWikiArticlePath(), $template);
408
+		$template = str_replace('{wikiId}', $domain->getShortName(), $template);
409
+
410
+		return $template;
411
+	}
412 412
 }
Please login to merge, or discard this patch.
redir.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -8,53 +8,53 @@
 block discarded – undo
8 8
  ******************************************************************************/
9 9
 
10 10
 $toolList = array(
11
-    'tparis-pcount'      => '//tools.wmflabs.org/supercount/index.php?user=%DATA%&project=en.wikipedia',
12
-    'guc'                => '//tools.wmflabs.org/guc/?by=date&user=%DATA%',
13
-    'oq-whois'           => 'https://whois.domaintools.com/%DATA%',
14
-    'tl-whois'           => 'https://tools.wmflabs.org/whois/gateway.py?lookup=true&ip=%DATA%',
15
-    'honeypot'           => 'https://www.projecthoneypot.org/ip_%DATA%',
16
-    'stopforumspam'      => 'https://www.stopforumspam.com/ipcheck/%DATA%',
17
-    'spur'               => 'https://app.spur.us/context?q=%DATA%',
18
-    'google'             => 'https://www.google.com/search?q=%DATA%',
19
-    'domain'             => 'https://%DATA%/',
20
-    'rangefinder'        => 'https://tools.wmflabs.org/rangeblockfinder/?ip=%DATA%',
21
-    'ipcheck'            => 'https://ipcheck.toolforge.org/index.php?ip=%DATA%',
22
-    'bgpview'            => 'https://bgpview.io/ip/%DATA%',
23
-    'bullseye'           => 'https://bullseye.toolforge.org/ip/%DATA%',
24
-    'ipalyzer'           => 'https://ipalyzer.com/%DATA%'
11
+	'tparis-pcount'      => '//tools.wmflabs.org/supercount/index.php?user=%DATA%&project=en.wikipedia',
12
+	'guc'                => '//tools.wmflabs.org/guc/?by=date&user=%DATA%',
13
+	'oq-whois'           => 'https://whois.domaintools.com/%DATA%',
14
+	'tl-whois'           => 'https://tools.wmflabs.org/whois/gateway.py?lookup=true&ip=%DATA%',
15
+	'honeypot'           => 'https://www.projecthoneypot.org/ip_%DATA%',
16
+	'stopforumspam'      => 'https://www.stopforumspam.com/ipcheck/%DATA%',
17
+	'spur'               => 'https://app.spur.us/context?q=%DATA%',
18
+	'google'             => 'https://www.google.com/search?q=%DATA%',
19
+	'domain'             => 'https://%DATA%/',
20
+	'rangefinder'        => 'https://tools.wmflabs.org/rangeblockfinder/?ip=%DATA%',
21
+	'ipcheck'            => 'https://ipcheck.toolforge.org/index.php?ip=%DATA%',
22
+	'bgpview'            => 'https://bgpview.io/ip/%DATA%',
23
+	'bullseye'           => 'https://bullseye.toolforge.org/ip/%DATA%',
24
+	'ipalyzer'           => 'https://ipalyzer.com/%DATA%'
25 25
 );
26 26
 
27 27
 if (!isset($_GET['tool'])
28
-    || !isset($toolList[$_GET['tool']])
29
-    || !isset($_GET['data'])
28
+	|| !isset($toolList[$_GET['tool']])
29
+	|| !isset($_GET['data'])
30 30
 ) {
31
-    header("HTTP/1.1 403 Forbidden");
31
+	header("HTTP/1.1 403 Forbidden");
32 32
 
33
-    return;
33
+	return;
34 34
 }
35 35
 
36 36
 if (isset($_GET['round2'])) {
37
-    $data = $_GET['data'];
38
-    $tool = $_GET['tool'];
37
+	$data = $_GET['data'];
38
+	$tool = $_GET['tool'];
39 39
 
40
-    if ($tool === 'domain') {
41
-        // quick security check - if you want to exploit something, you better be sure your exploit resolves via dns.
42
-        // this is not intended to catch everything, just as a quick sanity check.
43
-        if (gethostbyname($data) == $data) {
44
-            echo 'Error resolving hostname, it doesn\'t look like this domain exists.';
45
-            die();
46
-        }
47
-    }
48
-    elseif (filter_var($data, FILTER_VALIDATE_IP) !== false) {
49
-        // IP address, we don't need to encode it.
50
-        // It *should* already be safe.
51
-    }
52
-    else {
53
-        $data = urlencode($data);
54
-    }
40
+	if ($tool === 'domain') {
41
+		// quick security check - if you want to exploit something, you better be sure your exploit resolves via dns.
42
+		// this is not intended to catch everything, just as a quick sanity check.
43
+		if (gethostbyname($data) == $data) {
44
+			echo 'Error resolving hostname, it doesn\'t look like this domain exists.';
45
+			die();
46
+		}
47
+	}
48
+	elseif (filter_var($data, FILTER_VALIDATE_IP) !== false) {
49
+		// IP address, we don't need to encode it.
50
+		// It *should* already be safe.
51
+	}
52
+	else {
53
+		$data = urlencode($data);
54
+	}
55 55
 
56
-    echo '<script>window.location.href=' . json_encode(str_replace("%DATA%", $data, $toolList[$tool])) . '</script>';
56
+	echo '<script>window.location.href=' . json_encode(str_replace("%DATA%", $data, $toolList[$tool])) . '</script>';
57 57
 }
58 58
 else {
59
-    header("Location: " . $_SERVER["REQUEST_URI"] . "&round2=true");
59
+	header("Location: " . $_SERVER["REQUEST_URI"] . "&round2=true");
60 60
 }
Please login to merge, or discard this patch.
smarty-plugins/modifier.cidr.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -17,48 +17,48 @@
 block discarded – undo
17 17
  * @return string
18 18
  */
19 19
 function smarty_modifier_cidr(string $ipAddress, ?int $cidr): string {
20
-    if (filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
21
-        if ($cidr === null) {
22
-            $cidr = 32;
23
-        }
20
+	if (filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
21
+		if ($cidr === null) {
22
+			$cidr = 32;
23
+		}
24 24
 
25
-        if ($cidr < 0 || $cidr > 32) {
26
-            throw new InvalidArgumentException("Invalid CIDR prefix for IPv4: $cidr");
27
-        }
25
+		if ($cidr < 0 || $cidr > 32) {
26
+			throw new InvalidArgumentException("Invalid CIDR prefix for IPv4: $cidr");
27
+		}
28 28
 
29
-        $ipLong = ip2long($ipAddress);
30
-        $mask = -1 << (32 - $cidr);
31
-        $network = $ipLong & $mask;
29
+		$ipLong = ip2long($ipAddress);
30
+		$mask = -1 << (32 - $cidr);
31
+		$network = $ipLong & $mask;
32 32
 
33
-        return long2ip($network);
34
-    }
35
-    elseif (filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
36
-        if ($cidr === null) {
37
-            $cidr = 64;
38
-        }
33
+		return long2ip($network);
34
+	}
35
+	elseif (filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
36
+		if ($cidr === null) {
37
+			$cidr = 64;
38
+		}
39 39
 
40
-        if ($cidr < 0 || $cidr > 128) {
41
-            throw new InvalidArgumentException("Invalid CIDR prefix for IPv6: $cidr");
42
-        }
40
+		if ($cidr < 0 || $cidr > 128) {
41
+			throw new InvalidArgumentException("Invalid CIDR prefix for IPv6: $cidr");
42
+		}
43 43
 
44
-        $ipBin = inet_pton($ipAddress);
45
-        $prefix = $cidr;
46
-        $bin = '';
47
-        for ($i = 0; $i < strlen($ipBin); $i++) {
48
-            $bits = 8;
49
-            if ($prefix < 8) {
50
-                $bits = $prefix;
51
-            }
52
-            $mask = $bits === 0 ? 0 : (0xFF << (8 - $bits)) & 0xFF;
53
-            $bin .= chr(ord($ipBin[$i]) & $mask);
54
-            $prefix -= $bits;
55
-            if ($prefix <= 0) {
56
-                $prefix = 0;
57
-            }
58
-        }
44
+		$ipBin = inet_pton($ipAddress);
45
+		$prefix = $cidr;
46
+		$bin = '';
47
+		for ($i = 0; $i < strlen($ipBin); $i++) {
48
+			$bits = 8;
49
+			if ($prefix < 8) {
50
+				$bits = $prefix;
51
+			}
52
+			$mask = $bits === 0 ? 0 : (0xFF << (8 - $bits)) & 0xFF;
53
+			$bin .= chr(ord($ipBin[$i]) & $mask);
54
+			$prefix -= $bits;
55
+			if ($prefix <= 0) {
56
+				$prefix = 0;
57
+			}
58
+		}
59 59
 
60
-        return inet_ntop($bin);
61
-    }
60
+		return inet_ntop($bin);
61
+	}
62 62
 
63
-    throw new InvalidArgumentException("Invalid IP address: $ipAddress");
63
+	throw new InvalidArgumentException("Invalid IP address: $ipAddress");
64 64
 }
65 65
\ No newline at end of file
Please login to merge, or discard this patch.