Completed
Branch newinternal (830cd7)
by Simon
03:46
created

SiteConfiguration::getMediawikiScriptPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
/******************************************************************************
3
 * Wikipedia Account Creation Assistance tool                                 *
4
 *                                                                            *
5
 * All code in this file is released into the public domain by the ACC        *
6
 * Development Team. Please see team.json for a list of contributors.         *
7
 ******************************************************************************/
8
9
namespace Waca;
10
11
/**
12
 * Class SiteConfiguration
13
 *
14
 * IMPORTANT: This class must never throw an exception or trigger an error. It's used in the error handler.
15
 *
16
 * @package Waca
17
 */
18
class SiteConfiguration
19
{
20
	private $baseUrl;
21
	private $filePath;
22
	private $schemaVersion = 20;
23
	private $debuggingTraceEnabled;
24
	private $dataClearIp = '127.0.0.1';
25
	private $dataClearEmail = '[email protected]';
26
	private $dataClearInterval = '15 DAY';
27
	private $forceIdentification = true;
28
	private $identificationCacheExpiry = '1 DAY';
29
	private $mediawikiScriptPath = 'https://en.wikipedia.org/w/index.php';
30
	private $mediawikiWebServiceEndpoint = 'https://en.wikipedia.org/w/api.php';
31
	private $metaWikimediaWebServiceEndpoint = 'https://meta.wikimedia.org/w/api.php';
32
	private $enforceOAuth = true;
33
	private $emailConfirmationEnabled = true;
34
	private $emailConfirmationExpiryDays = 7;
35
	private $miserModeLimit = 25;
36
	private $requestStates = array(
37
		'Open'          => array(
38
			'defertolog' => 'users', // don't change or you'll break old logs
39
			'deferto'    => 'users',
40
			'header'     => 'Open requests',
41
			'api'        => "open",
42
		),
43
		'Flagged users' => array(
44
			'defertolog' => 'flagged users', // don't change or you'll break old logs
45
			'deferto'    => 'flagged users',
46
			'header'     => 'Flagged user needed',
47
			'api'        => "admin",
48
		),
49
		'Checkuser'     => array(
50
			'defertolog' => 'checkusers', // don't change or you'll break old logs
51
			'deferto'    => 'checkusers',
52
			'header'     => 'Checkuser needed',
53
			'api'        => "checkuser",
54
		),
55
	);
56
	private $squidList = array();
57
	private $defaultCreatedTemplateId = 1;
58
	private $defaultRequestStateKey = 'Open';
59
	private $defaultRequestDeferredStateKey = 'Flagged users';
60
	private $useStrictTransportSecurity = false;
61
	private $userAgent = 'Wikipedia-ACC Tool/0.1 (+https://accounts.wmflabs.org/internal.php/team)';
62
	private $curlDisableVerifyPeer = false;
63
	private $useOAuthSignup = true;
64
	private $oauthBaseUrl;
65
	private $oauthConsumerToken;
66
	private $oauthConsumerSecret;
67
	private $xffTrustedHostsFile = '../TrustedXFF/trusted-hosts.txt';
68
	private $crossOriginResourceSharingHosts = array(
69
		"http://en.wikipedia.org",
70
		"https://en.wikipedia.org",
71
		"http://meta.wikimedia.org",
72
		"https://meta.wikimedia.org",
73
	);
74
	private $ircNotificationType = 1;
75
	private $ircNotificationsEnabled = true;
76
	private $ircNotificationsInstance = 'Development';
77
	private $errorLog = 'errorlog';
78
	private $titleBlacklistEnabled = false;
79
	/** @var null|string $locationProviderApiKey */
80
	private $locationProviderApiKey = null;
81
82
	/**
83
	 * Gets the base URL of the tool
84
	 *
85
	 * If the internal page of the tool is at http://localhost/path/internal.php, this would be set to
86
	 * http://localhost/path
87
	 * @return string
88
	 */
89
	public function getBaseUrl()
90
	{
91
		return $this->baseUrl;
92
	}
93
94
	/**
95
	 * @param string $baseUrl
96
	 *
97
	 * @return SiteConfiguration
98
	 */
99
	public function setBaseUrl($baseUrl)
100
	{
101
		$this->baseUrl = $baseUrl;
102
103
		return $this;
104
	}
105
106
	/**
107
	 * Path on disk to the directory containing the tool's code
108
	 * @return string
109
	 */
110
	public function getFilePath()
111
	{
112
		return $this->filePath;
113
	}
114
115
	/**
116
	 * @param string $filePath
117
	 *
118
	 * @return SiteConfiguration
119
	 */
120
	public function setFilePath($filePath)
121
	{
122
		$this->filePath = $filePath;
123
124
		return $this;
125
	}
126
127
	/**
128
	 * @return int
129
	 */
130
	public function getSchemaVersion()
131
	{
132
		return $this->schemaVersion;
133
	}
134
135
	/**
136
	 * @return mixed
137
	 */
138
	public function getDebuggingTraceEnabled()
139
	{
140
		return $this->debuggingTraceEnabled;
141
	}
142
143
	/**
144
	 * @param mixed $debuggingTraceEnabled
145
	 *
146
	 * @return SiteConfiguration
147
	 */
148
	public function setDebuggingTraceEnabled($debuggingTraceEnabled)
149
	{
150
		$this->debuggingTraceEnabled = $debuggingTraceEnabled;
151
152
		return $this;
153
	}
154
155
	/**
156
	 * @return string
157
	 */
158
	public function getDataClearIp()
159
	{
160
		return $this->dataClearIp;
161
	}
162
163
	/**
164
	 * @param string $dataClearIp
165
	 *
166
	 * @return SiteConfiguration
167
	 */
168
	public function setDataClearIp($dataClearIp)
169
	{
170
		$this->dataClearIp = $dataClearIp;
171
172
		return $this;
173
	}
174
175
	/**
176
	 * @return string
177
	 */
178
	public function getDataClearEmail()
179
	{
180
		return $this->dataClearEmail;
181
	}
182
183
	/**
184
	 * @param string $dataClearEmail
185
	 *
186
	 * @return SiteConfiguration
187
	 */
188
	public function setDataClearEmail($dataClearEmail)
189
	{
190
		$this->dataClearEmail = $dataClearEmail;
191
192
		return $this;
193
	}
194
195
	/**
196
	 * @return boolean
197
	 */
198
	public function getForceIdentification()
199
	{
200
		return $this->forceIdentification;
201
	}
202
203
	/**
204
	 * @param boolean $forceIdentification
205
	 *
206
	 * @return SiteConfiguration
207
	 */
208
	public function setForceIdentification($forceIdentification)
209
	{
210
		$this->forceIdentification = $forceIdentification;
211
212
		return $this;
213
	}
214
215
	/**
216
	 * @return string
217
	 */
218
	public function getIdentificationCacheExpiry()
219
	{
220
		return $this->identificationCacheExpiry;
221
	}
222
223
	/**
224
	 * @param string $identificationCacheExpiry
225
	 * @return SiteConfiguration
226
	 */
227
	public function setIdentificationCacheExpiry($identificationCacheExpiry)
228
	{
229
		$this->identificationCacheExpiry = $identificationCacheExpiry;
230
		return $this;
231
	}
232
233
	/**
234
	 * @return string
235
	 */
236
	public function getMediawikiScriptPath()
237
	{
238
		return $this->mediawikiScriptPath;
239
	}
240
241
	/**
242
	 * @param string $mediawikiScriptPath
243
	 *
244
	 * @return SiteConfiguration
245
	 */
246
	public function setMediawikiScriptPath($mediawikiScriptPath)
247
	{
248
		$this->mediawikiScriptPath = $mediawikiScriptPath;
249
250
		return $this;
251
	}
252
253
	/**
254
	 * @return string
255
	 */
256
	public function getMediawikiWebServiceEndpoint()
257
	{
258
		return $this->mediawikiWebServiceEndpoint;
259
	}
260
261
	/**
262
	 * @param string $mediawikiWebServiceEndpoint
263
	 *
264
	 * @return SiteConfiguration
265
	 */
266
	public function setMediawikiWebServiceEndpoint($mediawikiWebServiceEndpoint)
267
	{
268
		$this->mediawikiWebServiceEndpoint = $mediawikiWebServiceEndpoint;
269
270
		return $this;
271
	}
272
273
	/**
274
	 * @return string
275
	 */
276
	public function getMetaWikimediaWebServiceEndpoint()
277
	{
278
		return $this->metaWikimediaWebServiceEndpoint;
279
	}
280
281
	/**
282
	 * @param string $metaWikimediaWebServiceEndpoint
283
	 * @return SiteConfiguration
284
	 */
285
	public function setMetaWikimediaWebServiceEndpoint($metaWikimediaWebServiceEndpoint)
286
	{
287
		$this->metaWikimediaWebServiceEndpoint = $metaWikimediaWebServiceEndpoint;
288
289
		return $this;
290
	}
291
292
	/**
293
	 * @return boolean
294
	 */
295
	public function getEnforceOAuth()
296
	{
297
		return $this->enforceOAuth;
298
	}
299
300
	/**
301
	 * @param boolean $enforceOAuth
302
	 *
303
	 * @return SiteConfiguration
304
	 */
305
	public function setEnforceOAuth($enforceOAuth)
306
	{
307
		$this->enforceOAuth = $enforceOAuth;
308
309
		return $this;
310
	}
311
312
	/**
313
	 * @return boolean
314
	 */
315
	public function getEmailConfirmationEnabled()
316
	{
317
		return $this->emailConfirmationEnabled;
318
	}
319
320
	/**
321
	 * @param boolean $emailConfirmationEnabled
322
	 *
323
	 * @return $this
324
	 */
325
	public function setEmailConfirmationEnabled($emailConfirmationEnabled)
326
	{
327
		$this->emailConfirmationEnabled = $emailConfirmationEnabled;
328
329
		return $this;
330
	}
331
332
	/**
333
	 * @return int
334
	 */
335
	public function getMiserModeLimit()
336
	{
337
		return $this->miserModeLimit;
338
	}
339
340
	/**
341
	 * @param int $miserModeLimit
342
	 *
343
	 * @return SiteConfiguration
344
	 */
345
	public function setMiserModeLimit($miserModeLimit)
346
	{
347
		$this->miserModeLimit = $miserModeLimit;
348
349
		return $this;
350
	}
351
352
	/**
353
	 * @return array
354
	 */
355
	public function getRequestStates()
356
	{
357
		return $this->requestStates;
358
	}
359
360
	/**
361
	 * @param array $requestStates
362
	 *
363
	 * @return SiteConfiguration
364
	 */
365
	public function setRequestStates($requestStates)
366
	{
367
		$this->requestStates = $requestStates;
368
369
		return $this;
370
	}
371
372
	/**
373
	 * @return array
374
	 */
375
	public function getSquidList()
376
	{
377
		return $this->squidList;
378
	}
379
380
	/**
381
	 * @param array $squidList
382
	 *
383
	 * @return SiteConfiguration
384
	 */
385
	public function setSquidList($squidList)
386
	{
387
		$this->squidList = $squidList;
388
389
		return $this;
390
	}
391
392
	/**
393
	 * @return int
394
	 */
395
	public function getDefaultCreatedTemplateId()
396
	{
397
		return $this->defaultCreatedTemplateId;
398
	}
399
400
	/**
401
	 * @param int $defaultCreatedTemplateId
402
	 *
403
	 * @return SiteConfiguration
404
	 */
405
	public function setDefaultCreatedTemplateId($defaultCreatedTemplateId)
406
	{
407
		$this->defaultCreatedTemplateId = $defaultCreatedTemplateId;
408
409
		return $this;
410
	}
411
412
	/**
413
	 * @return string
414
	 */
415
	public function getDefaultRequestStateKey()
416
	{
417
		return $this->defaultRequestStateKey;
418
	}
419
420
	/**
421
	 * @param string $defaultRequestStateKey
422
	 *
423
	 * @return SiteConfiguration
424
	 */
425
	public function setDefaultRequestStateKey($defaultRequestStateKey)
426
	{
427
		$this->defaultRequestStateKey = $defaultRequestStateKey;
428
429
		return $this;
430
	}
431
432
	/**
433
	 * @return string
434
	 */
435
	public function getDefaultRequestDeferredStateKey()
436
	{
437
		return $this->defaultRequestDeferredStateKey;
438
	}
439
440
	/**
441
	 * @param string $defaultRequestDeferredStateKey
442
	 *
443
	 * @return SiteConfiguration
444
	 */
445
	public function setDefaultRequestDeferredStateKey($defaultRequestDeferredStateKey)
446
	{
447
		$this->defaultRequestDeferredStateKey = $defaultRequestDeferredStateKey;
448
449
		return $this;
450
	}
451
452
	/**
453
	 * @return boolean
454
	 */
455
	public function getUseStrictTransportSecurity()
456
	{
457
		return $this->useStrictTransportSecurity;
458
	}
459
460
	/**
461
	 * @param boolean $useStrictTransportSecurity
462
	 *
463
	 * @return SiteConfiguration
464
	 */
465
	public function setUseStrictTransportSecurity($useStrictTransportSecurity)
466
	{
467
		$this->useStrictTransportSecurity = $useStrictTransportSecurity;
468
469
		return $this;
470
	}
471
472
	/**
473
	 * @return string
474
	 */
475
	public function getUserAgent()
476
	{
477
		return $this->userAgent;
478
	}
479
480
	/**
481
	 * @param string $userAgent
482
	 *
483
	 * @return SiteConfiguration
484
	 */
485
	public function setUserAgent($userAgent)
486
	{
487
		$this->userAgent = $userAgent;
488
489
		return $this;
490
	}
491
492
	/**
493
	 * @return boolean
494
	 */
495
	public function getCurlDisableVerifyPeer()
496
	{
497
		return $this->curlDisableVerifyPeer;
498
	}
499
500
	/**
501
	 * @param boolean $curlDisableVerifyPeer
502
	 *
503
	 * @return SiteConfiguration
504
	 */
505
	public function setCurlDisableVerifyPeer($curlDisableVerifyPeer)
506
	{
507
		$this->curlDisableVerifyPeer = $curlDisableVerifyPeer;
508
509
		return $this;
510
	}
511
512
	/**
513
	 * @return boolean
514
	 */
515
	public function getUseOAuthSignup()
516
	{
517
		return $this->useOAuthSignup;
518
	}
519
520
	/**
521
	 * @param boolean $useOAuthSignup
522
	 *
523
	 * @return SiteConfiguration
524
	 */
525
	public function setUseOAuthSignup($useOAuthSignup)
526
	{
527
		$this->useOAuthSignup = $useOAuthSignup;
528
529
		return $this;
530
	}
531
532
	/**
533
	 * @return string
534
	 */
535
	public function getOAuthBaseUrl()
536
	{
537
		return $this->oauthBaseUrl;
538
	}
539
540
	/**
541
	 * @param string $oauthBaseUrl
542
	 *
543
	 * @return SiteConfiguration
544
	 */
545
	public function setOAuthBaseUrl($oauthBaseUrl)
546
	{
547
		$this->oauthBaseUrl = $oauthBaseUrl;
548
549
		return $this;
550
	}
551
552
	/**
553
	 * @return mixed
554
	 */
555
	public function getOAuthConsumerToken()
556
	{
557
		return $this->oauthConsumerToken;
558
	}
559
560
	/**
561
	 * @param mixed $oauthConsumerToken
562
	 *
563
	 * @return SiteConfiguration
564
	 */
565
	public function setOAuthConsumerToken($oauthConsumerToken)
566
	{
567
		$this->oauthConsumerToken = $oauthConsumerToken;
568
569
		return $this;
570
	}
571
572
	/**
573
	 * @return mixed
574
	 */
575
	public function getOAuthConsumerSecret()
576
	{
577
		return $this->oauthConsumerSecret;
578
	}
579
580
	/**
581
	 * @param mixed $oauthConsumerSecret
582
	 *
583
	 * @return SiteConfiguration
584
	 */
585
	public function setOAuthConsumerSecret($oauthConsumerSecret)
586
	{
587
		$this->oauthConsumerSecret = $oauthConsumerSecret;
588
589
		return $this;
590
	}
591
592
	/**
593
	 * @return string
594
	 */
595
	public function getDataClearInterval()
596
	{
597
		return $this->dataClearInterval;
598
	}
599
600
	/**
601
	 * @param string $dataClearInterval
602
	 *
603
	 * @return SiteConfiguration
604
	 */
605
	public function setDataClearInterval($dataClearInterval)
606
	{
607
		$this->dataClearInterval = $dataClearInterval;
608
609
		return $this;
610
	}
611
612
	/**
613
	 * @return string
614
	 */
615
	public function getXffTrustedHostsFile()
616
	{
617
		return $this->xffTrustedHostsFile;
618
	}
619
620
	/**
621
	 * @param string $xffTrustedHostsFile
622
	 *
623
	 * @return SiteConfiguration
624
	 */
625
	public function setXffTrustedHostsFile($xffTrustedHostsFile)
626
	{
627
		$this->xffTrustedHostsFile = $xffTrustedHostsFile;
628
629
		return $this;
630
	}
631
632
	/**
633
	 * @return array
634
	 */
635
	public function getCrossOriginResourceSharingHosts()
636
	{
637
		return $this->crossOriginResourceSharingHosts;
638
	}
639
640
	/**
641
	 * @param array $crossOriginResourceSharingHosts
642
	 *
643
	 * @return SiteConfiguration
644
	 */
645
	public function setCrossOriginResourceSharingHosts($crossOriginResourceSharingHosts)
646
	{
647
		$this->crossOriginResourceSharingHosts = $crossOriginResourceSharingHosts;
648
649
		return $this;
650
	}
651
652
	/**
653
	 * @return boolean
654
	 */
655
	public function getIrcNotificationsEnabled()
656
	{
657
		return $this->ircNotificationsEnabled;
658
	}
659
660
	/**
661
	 * @param boolean $ircNotificationsEnabled
662
	 *
663
	 * @return SiteConfiguration
664
	 */
665
	public function setIrcNotificationsEnabled($ircNotificationsEnabled)
666
	{
667
		$this->ircNotificationsEnabled = $ircNotificationsEnabled;
668
669
		return $this;
670
	}
671
672
	/**
673
	 * @return int
674
	 */
675
	public function getIrcNotificationType()
676
	{
677
		return $this->ircNotificationType;
678
	}
679
680
	/**
681
	 * @param int $ircNotificationType
682
	 *
683
	 * @return SiteConfiguration
684
	 */
685
	public function setIrcNotificationType($ircNotificationType)
686
	{
687
		$this->ircNotificationType = $ircNotificationType;
688
689
		return $this;
690
	}
691
692
	/**
693
	 * @param string $errorLog
694
	 *
695
	 * @return SiteConfiguration
696
	 */
697
	public function setErrorLog($errorLog)
698
	{
699
		$this->errorLog = $errorLog;
700
701
		return $this;
702
	}
703
704
	/**
705
	 * @return string
706
	 */
707
	public function getErrorLog()
708
	{
709
		return $this->errorLog;
710
	}
711
712
	/**
713
	 * @param int $emailConfirmationExpiryDays
714
	 *
715
	 * @return SiteConfiguration
716
	 */
717
	public function setEmailConfirmationExpiryDays($emailConfirmationExpiryDays)
718
	{
719
		$this->emailConfirmationExpiryDays = $emailConfirmationExpiryDays;
720
721
		return $this;
722
	}
723
724
	/**
725
	 * @return int
726
	 */
727
	public function getEmailConfirmationExpiryDays()
728
	{
729
		return $this->emailConfirmationExpiryDays;
730
	}
731
732
	/**
733
	 * @param string $ircNotificationsInstance
734
	 *
735
	 * @return SiteConfiguration
736
	 */
737
	public function setIrcNotificationsInstance($ircNotificationsInstance)
738
	{
739
		$this->ircNotificationsInstance = $ircNotificationsInstance;
740
741
		return $this;
742
	}
743
744
	/**
745
	 * @return string
746
	 */
747
	public function getIrcNotificationsInstance()
748
	{
749
		return $this->ircNotificationsInstance;
750
	}
751
752
	/**
753
	 * @param boolean $titleBlacklistEnabled
754
	 *
755
	 * @return SiteConfiguration
756
	 */
757
	public function setTitleBlacklistEnabled($titleBlacklistEnabled)
758
	{
759
		$this->titleBlacklistEnabled = $titleBlacklistEnabled;
760
761
		return $this;
762
	}
763
764
	/**
765
	 * @return boolean
766
	 */
767
	public function getTitleBlacklistEnabled()
768
	{
769
		return $this->titleBlacklistEnabled;
770
	}
771
772
	/**
773
	 * @param string|null $locationProviderApiKey
774
	 *
775
	 * @return SiteConfiguration
776
	 */
777
	public function setLocationProviderApiKey($locationProviderApiKey)
778
	{
779
		$this->locationProviderApiKey = $locationProviderApiKey;
780
781
		return $this;
782
	}
783
784
	/**
785
	 * @return null|string
786
	 */
787
	public function getLocationProviderApiKey()
788
	{
789
		return $this->locationProviderApiKey;
790
	}
791
}