Completed
Branch newinternal (cd27a7)
by Simon
03:47
created

config.inc.php (5 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 276 and the first side effect is on line 21.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
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
/**************************************************************************
10
**********                   IMPORTANT NOTICE                    **********
11
***************************************************************************
12
** YOU MUST OVERRIDE THE CONFIGURATION IN THIS FILE WITH A LOCAL COPY!!! **
13
** IT IS VERY IMPORTANT THAT THAT FILE IS CALLED config.local.inc.php    **
14
***************************************************************************/
15
16
/*********************************
17
 * Databases and stuff
18
 */
19
20
// Main database location and access details.
21
$toolserver_username = "";
22
$toolserver_password = "";
23
$toolserver_host = "";
24
$toolserver_database = "";
25
26
$toolserver_notification_database = "notifications";
27
$toolserver_notification_dbhost = "dbmaster.srv.stwalkerster.net";
28
$notifications_username = "";
29
$notifications_password = "";
30
31
// The antispoof configuration.
32
$antispoof_equivset = "equivset.php";
33
$antispoof_host = "sql-s1";
34
$antispoof_db = "enwiki_p";
35
$antispoof_table = "spoofuser";
36
37
/**********************************
38
 * File paths etc
39
 */
40
41
$mediawikiWebServiceEndpoint = "https://en.wikipedia.org/w/api.php";
42
$mediawikiScriptPath = "https://en.wikipedia.org/w/index.php";
43
$metaWikimediaWebServiceEndpoint = "https://meta.wikimedia.org/w/api.php";
44
45
// URL of the current copy of the tool.
46
$baseurl = "https://accounts.wmflabs.org";
47
48
// Root pathname of the local installation of the tool.
49
$filepath = "/projects/acc/www/"; 
50
51
// Pathname to the local installation of Peachy.
52
$peachyPath = ""; 
53
54
// Location outside web directory to place temporary files.
55
$varfilepath = "/projects/acc/"; 
56
57
// Set up cookies and session information.
58
$cookiepath = '/acc/';
59
$sessionname = 'ACC';
60
61
$xff_trusted_hosts_file = '../TrustedXFF/trusted-hosts.txt';
62
/************************************
63
 * Tool downtime
64
 */
65
66
$dontUseDb = 0; // Disable the tool completely.
67
$dontUseWikiDb = 0; // Disable access to the Wiki database.
68
$dontUseDbReason = ""; // Reason for disabling the tool.
69
$dontUseDbCulprit = ""; // Your name, or the person who broke the tool.
70
	
71
/**************************************
72
 * ACCBot IRC bot
73
 */
74
75
$ircBotDaemonise = true; // Run the IRC bot as a daemon, detached from the terminal.
76
77
$ircBotNickServPassword = ""; // Password for ACCBot's Nickserv account.
78
$ircBotCommunicationKey = ""; // Key used to communicate with the ACCBot.
79
$ircBotNetworkHost = "chat.freenode.net"; // The host to use for connecting.
80
$ircBotNetworkPort = 6667; // The port on the particular host.
81
$ircBotChannel = "#wikipedia-en-accounts"; // The channel in which the discussions are.
82
$ircBotNickname = "ACCBot"; // The nickname of the ACCBot.
83
$ircBotCommandTrigger = '!'; // The ACCBot's command trigger.
84
85
$ircBotNotificationType = 1; // Helpmebot's notification type ID.
86
$ircBotNotificationsEnabled = 1; // Enable Helpmebot's notifications.
87
// Name of this instance of the tool.
88
// This name would be used by the bot as reference point.	
89
$whichami = 'Live';
90
91
/***************************************
92
 * Email confirmation
93
 */
94
95
// Enable request email confirmation.
96
$enableEmailConfirm = 1; 	
0 ignored issues
show
There is some trailing whitespace on this line which should be avoided as per coding-style.
Loading history...
97
// Number of days that are given for a requestor to confirm their email address.
98
$emailConfirmationExpiryDays = 7;
99
100
/**************************************
101
 * Interface registration, interface users, etc.
102
 */
103
104
// Parameters for performing a newbie check on tool registration.
105
$onRegistrationNewbieCheck = true; // Enable the newbie checking.
106
$onRegistrationNewbieCheckEditCount = 20; // Minimum amount of edits on Wikipedia.
107
$onRegistrationNewbieCheckAge = 5184000; // Account age on Wikipedia in seconds.
108
109
// Force identification to the foundation
110
$forceIdentification = true;
111
112
// Time to cache positive automatic identification results, as a MySQL time interval
113
$identificationCacheExpiry = "1 DAY";
114
115
// minimum password version
116
//   0 = hashed
117
//   1 = hashed, salted
118
$minimumPasswordVersion = 0;
119
120
$communityUsername = "[Community]";
121
122
/***********************************
123
 * Reservations
124
 */
125
126
// Reserve requests to a specific user by default.
127
// Adapted from livehack by st - use the userid, zero for unreserved.
128
$defaultReserver = 0;
129
130
/************************************
131
 * Backup Configuration
132
 */
133
134
$BUbasefile = "backup"; // The basefile's name.
135
$BUdir = "/home/project/a/c/c/acc/backups"; // The directory where backups should be stored.
136
$BUmonthdir = $BUdir . "/monthly"; // The directory where monthly backups should be stored.
137
$BUdumper = "/opt/ts/mysql/5.1/bin/mysqldump --defaults-file=~/.my.cnf p_acc_live"; // Add parameters here if they are needed.
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 126 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
138
$BUgzip = "/usr/bin/gzip"; // Add the gzip parameters here if needed.
139
$BUtar = "/bin/tar -cvf"; // Add the tar parameters here if needed.
140
141
/************************************
142
 * OAuth Configuration
143
 */
144
145
$oauthConsumerToken = "";
146
$oauthSecretToken = "";
147
148
// path to Special:OAuth on target wiki.
149
// don't use pretty urls, see [[bugzilla:57500]]
150
$oauthBaseUrl = "https://en.wikipedia.org/w/index.php?title=Special:OAuth";
151
// use this for requests from the server, if some special url is needed.
152
$oauthBaseUrlInternal = "https://en.wikipedia.org/w/index.php?title=Special:OAuth";
153
154
$oauthMediaWikiCanonicalServer = "http://en.wikipedia.org";
155
156
$useOauthSignup = true;
157
$enforceOAuth = false;
158
159
/************************************
160
 * Providers Configuration
161
*/
162
163
// IP GeoLocation
164
// ------------------------
165
// To set this up, change the class to "IpLocationProvider", and put *your* ipinfodb API key in.
166
// You'll need to sign up at IpInfoDb.com to get an API key - it's free.
167
$locationProviderClass = "FakeLocationProvider";
168
$locationProviderApiKey = "super secret"; // ipinfodb api key
169
170
// RDNS Provider ( RDnsLookupProvider / CachedRDnsLookupProvider / FakeRDnsLookupProvider)
171
$rdnsProviderClass = "CachedRDnsLookupProvider";
172
173
$antispoofProviderClass = "FakeAntiSpoofProvider";
174
$xffTrustProviderClass = "XffTrustProvider";
175
176
/***********************************
177
 * Data clear script
178
 */
179
180
$dataclear_interval = '15 DAY';
181
182
/***********************************
183
 * Other stuff that doesn't fit in.
184
 */
185
186
$enableSQLError = 0; // Enable the display of SQL errors.
187
$enableTitleblacklist = 0; // Enable Title Blacklist checks.
188
189
// Enable the use of PATH_INFO for request parameters to prettify URLs.
190
$usePathInfo = true;
191
192
// user agent of the tool.
193
$toolUserAgent = "Wikipedia-ACC Tool/0.1 (+https://accounts.wmflabs.org/internal.php/team)";
194
195
// list of squid proxies requests go through.
196
$squidIpList = array();
197
198
$apiDeployPassword = "super secret update password";
199
200
// request states
201
$availableRequestStates = array(
202
	'Open' =>array(
203
		'defertolog' => 'users', // don't change or you'll break old logs
204
		'deferto' => 'users', 
205
		'header' => 'Open requests',
206
		'api' => "open",
207
		),
208
	'Flagged users'=>array(
209
		'defertolog' => 'flagged users', // don't change or you'll break old logs
210
		'deferto' => 'flagged users',
211
		'header' => 'Flagged user needed',
212
		'api' => "admin",
213
		),
214
	'Checkuser'=>array(
215
		'defertolog' => 'checkusers', // don't change or you'll break old logs
216
		'deferto' => 'checkusers', 
217
		'header' => 'Checkuser needed',
218
		'api' => "checkuser",
219
		),
220
	);
221
	
222
$defaultRequestStateKey = 'Open';
223
224
$providerCacheExpiry = $dataclear_interval;
225
226
// miser mode
227
$requestLimitShowOnly = 25;
228
229
// Enables the Smarty debugging console. This should only be used for development and even then
230
// be left false when you don't need it, since this will open a popup window on every page load.
231
$smartydebug = false;
232
233
// ID of the Email template used for the main "Created!" close reason.
234
$createdid = 1;
235
236
// HSTS expiry - use false to disable header.
237
$strictTransportSecurityExpiry = false;
238
239
// Must be disabled in production.
240
$enableErrorTrace = false;
241
242
// Dangerous.
243
// Don't set this.
244
// Definitely don't set this if there's sensitive data stored here you care about such as OAuth credentials.
245
$curlDisableSSLVerifyPeer = false;
246
247
/**************************************************************************
248
**********                   IMPORTANT NOTICE                    **********
249
***************************************************************************
250
**     DON'T ADD ANY NEW CONFIGURATION OPTIONS BELOW THIS LINE!!!        **
251
**     THEY WILL NOT BE CHANGABLE BY THE LOCAL CONFIGURATION FILE.       **
252
***************************************************************************/
253
254
// Retriving the local configuration file.
255
require_once('config.local.inc.php');
256
257
$cDatabaseConfig = array(
258
	"acc" => array(
259
		"dsrcname" => "mysql:host=" . $toolserver_host . ";dbname=" . $toolserver_database,
260
		"username" => $toolserver_username,
261
		"password" => $toolserver_password
262
	),
263
	"wikipedia" => array(
264
		"dsrcname" => "mysql:host=" . $antispoof_host . ";dbname=" . $antispoof_db,
265
		"username" => $toolserver_username,
266
		"password" => $toolserver_password
267
	),
268
	"notifications" => array(
269
		"dsrcname" => "mysql:host=" . $toolserver_notification_dbhost . ";dbname=" . $toolserver_notification_database,
270
		"username" => $notifications_username,
271
		"password" => $notifications_password
272
	),
273
);
274
275
// //Keep the included files from being executed.
276
define("ACC", 1);
277
278
// Sets the values of the cookie configuration options.
279
ini_set('session.cookie_path', $cookiepath);
280
ini_set('session.name', $sessionname);
281
ini_set('user_agent', $toolUserAgent);
282
283
foreach (array( 
284
	"mbstring", // unicode and stuff
285
	"pdo", "pdo_mysql", // new database module
286
	"session", "date", "pcre", // core stuff
287
	"curl", // mediawiki api access etc
288
	"mcrypt", "openssl", // password encryption etc
289
	) as $x) {if (!extension_loaded($x)) {die("extension $x is required."); }}
290
291
// Set up the AutoLoader
292
require_once($filepath . "includes/AutoLoader.php");
293
spl_autoload_register('Waca\\AutoLoader::load');
294
require_once($filepath . 'vendor/autoload.php');
295
296
// Extra includes which are just plain awkward wherever they are.
297
require_once($filepath . 'lib/mediawiki-extensions-OAuth/lib/OAuth.php');
298
require_once($filepath . 'lib/mediawiki-extensions-OAuth/lib/JWT.php');
299
300
// Crap that's needed for libraries. >:(
301
/**
302
 * Don't use me. I'm only here because the MediaWiki OAuth library we're using requires it.
303
 *
304
 * @param $section
305
 * @param $message
306
 */
307
function wfDebugLog($section, $message)
0 ignored issues
show
The parameter $section is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $message is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
308
{
309
}
310
311
// Initialise the site configuration object
312
$siteConfiguration = new \Waca\SiteConfiguration();
313
314
$siteConfiguration->setBaseUrl($baseurl)
315
	->setFilePath($filepath)
316
	->setDebuggingTraceEnabled($enableErrorTrace)
317
	->setForceIdentification($forceIdentification)
318
	->setIdentificationCacheExpiry($identificationCacheExpiry)
319
	->setMediawikiScriptPath($mediawikiScriptPath)
320
	->setMediawikiWebServiceEndpoint($mediawikiWebServiceEndpoint)
321
	->setMetaWikimediaWebServiceEndpoint($metaWikimediaWebServiceEndpoint)
322
	->setEnforceOAuth($enforceOAuth)
323
	->setEmailConfirmationEnabled($enableEmailConfirm == 1)
324
	->setEmailConfirmationExpiryDays($emailConfirmationExpiryDays)
325
	->setMiserModeLimit($requestLimitShowOnly)
326
	->setRequestStates($availableRequestStates)
327
	->setSquidList($squidIpList)
328
	->setDefaultCreatedTemplateId($createdid)
329
	->setDefaultRequestStateKey($defaultRequestStateKey)
330
	->setUseStrictTransportSecurity($strictTransportSecurityExpiry)
331
	->setUserAgent($toolUserAgent)
332
	->setCurlDisableVerifyPeer($curlDisableSSLVerifyPeer)
333
	->setUseOAuthSignup($useOauthSignup)
334
	->setOAuthBaseUrl($oauthBaseUrl)
335
	->setOAuthConsumerToken($oauthConsumerToken)
336
	->setOAuthConsumerSecret($oauthSecretToken)
337
	->setDataClearInterval($dataclear_interval)
338
	->setXffTrustedHostsFile($xff_trusted_hosts_file)
339
	->setIrcNotificationsEnabled($ircBotNotificationsEnabled == 1)
340
	->setIrcNotificationType($ircBotNotificationType)
341
	->setIrcNotificationsInstance($whichami)
342
	->setTitleBlacklistEnabled($enableTitleblacklist == 1)
343
	;
344