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
|
|
|
/************************************************************************** |
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
|
|
|
// Pathname to the local installation of Peachy. |
49
|
|
|
$peachyPath = ""; |
50
|
|
|
|
51
|
|
|
// Location outside web directory to place temporary files. |
52
|
|
|
$varfilepath = "/projects/acc/"; |
53
|
|
|
|
54
|
|
|
// Set up cookies and session information. |
55
|
|
|
$cookiepath = '/acc/'; |
56
|
|
|
$sessionname = 'ACC'; |
57
|
|
|
|
58
|
|
|
$xff_trusted_hosts_file = '../TrustedXFF/trusted-hosts.txt'; |
59
|
|
|
/************************************ |
60
|
|
|
* Tool downtime |
61
|
|
|
*/ |
62
|
|
|
|
63
|
|
|
$dontUseDb = 0; // Disable the tool completely. |
64
|
|
|
$dontUseWikiDb = 0; // Disable access to the Wiki database. |
65
|
|
|
$dontUseDbReason = ""; // Reason for disabling the tool. |
66
|
|
|
$dontUseDbCulprit = ""; // Your name, or the person who broke the tool. |
67
|
|
|
|
68
|
|
|
/************************************** |
69
|
|
|
* ACCBot IRC bot |
70
|
|
|
*/ |
71
|
|
|
|
72
|
|
|
$ircBotDaemonise = true; // Run the IRC bot as a daemon, detached from the terminal. |
73
|
|
|
|
74
|
|
|
$ircBotNickServPassword = ""; // Password for ACCBot's Nickserv account. |
75
|
|
|
$ircBotCommunicationKey = ""; // Key used to communicate with the ACCBot. |
76
|
|
|
$ircBotNetworkHost = "chat.freenode.net"; // The host to use for connecting. |
77
|
|
|
$ircBotNetworkPort = 6667; // The port on the particular host. |
78
|
|
|
$ircBotChannel = "#wikipedia-en-accounts"; // The channel in which the discussions are. |
79
|
|
|
$ircBotNickname = "ACCBot"; // The nickname of the ACCBot. |
80
|
|
|
$ircBotCommandTrigger = '!'; // The ACCBot's command trigger. |
81
|
|
|
|
82
|
|
|
$ircBotNotificationType = 1; // Helpmebot's notification type ID. |
83
|
|
|
$ircBotNotificationsEnabled = 1; // Enable Helpmebot's notifications. |
84
|
|
|
// Name of this instance of the tool. |
85
|
|
|
// This name would be used by the bot as reference point. |
86
|
|
|
$whichami = 'Live'; |
87
|
|
|
|
88
|
|
|
/*************************************** |
89
|
|
|
* Email confirmation |
90
|
|
|
*/ |
91
|
|
|
|
92
|
|
|
// Enable request email confirmation. |
93
|
|
|
$enableEmailConfirm = 1; |
94
|
|
|
// Number of days that are given for a requestor to confirm their email address. |
95
|
|
|
$emailConfirmationExpiryDays = 7; |
96
|
|
|
|
97
|
|
|
/************************************** |
98
|
|
|
* Interface registration, interface users, etc. |
99
|
|
|
*/ |
100
|
|
|
|
101
|
|
|
$allowRegistration = true; |
102
|
|
|
|
103
|
|
|
// Parameters for performing a newbie check on tool registration. |
104
|
|
|
$onRegistrationNewbieCheck = true; // Enable the newbie checking. |
105
|
|
|
$onRegistrationNewbieCheckEditCount = 20; // Minimum amount of edits on Wikipedia. |
106
|
|
|
$onRegistrationNewbieCheckAge = 5184000; // Account age on Wikipedia in seconds. |
107
|
|
|
|
108
|
|
|
// Force identification to the foundation |
109
|
|
|
$forceIdentification = true; |
110
|
|
|
|
111
|
|
|
// Time to cache positive automatic identification results, as a MySQL time interval |
112
|
|
|
$identificationCacheExpiry = "1 DAY"; |
113
|
|
|
|
114
|
|
|
// minimum password version |
115
|
|
|
// 0 = hashed |
116
|
|
|
// 1 = hashed, salted |
117
|
|
|
$minimumPasswordVersion = 0; |
118
|
|
|
|
119
|
|
|
$communityUsername = "[Community]"; |
120
|
|
|
|
121
|
|
|
/*********************************** |
122
|
|
|
* Reservations |
123
|
|
|
*/ |
124
|
|
|
|
125
|
|
|
// Reserve requests to a specific user by default. |
126
|
|
|
// Adapted from livehack by st - use the userid, zero for unreserved. |
127
|
|
|
$defaultReserver = 0; |
128
|
|
|
|
129
|
|
|
/************************************ |
130
|
|
|
* Backup Configuration |
131
|
|
|
*/ |
132
|
|
|
|
133
|
|
|
$BUbasefile = "backup"; // The basefile's name. |
134
|
|
|
$BUdir = "/home/project/a/c/c/acc/backups"; // The directory where backups should be stored. |
135
|
|
|
$BUmonthdir = $BUdir . "/monthly"; // The directory where monthly backups should be stored. |
136
|
|
|
$BUdumper = "/opt/ts/mysql/5.1/bin/mysqldump --defaults-file=~/.my.cnf p_acc_live"; // Add parameters here if they are needed. |
137
|
|
|
$BUgzip = "/usr/bin/gzip"; // Add the gzip parameters here if needed. |
138
|
|
|
$BUtar = "/bin/tar -cvf"; // Add the tar parameters here if needed. |
139
|
|
|
|
140
|
|
|
/************************************ |
141
|
|
|
* OAuth Configuration |
142
|
|
|
*/ |
143
|
|
|
|
144
|
|
|
$oauthConsumerToken = ""; |
145
|
|
|
$oauthSecretToken = ""; |
146
|
|
|
|
147
|
|
|
// path to Special:OAuth on target wiki. |
148
|
|
|
// don't use pretty urls, see [[bugzilla:57500]] |
149
|
|
|
$oauthBaseUrl = "https://en.wikipedia.org/w/index.php?title=Special:OAuth"; |
150
|
|
|
// use this for requests from the server, if some special url is needed. |
151
|
|
|
$oauthBaseUrlInternal = "https://en.wikipedia.org/w/index.php?title=Special:OAuth"; |
152
|
|
|
|
153
|
|
|
$oauthMediaWikiCanonicalServer = "http://en.wikipedia.org"; |
154
|
|
|
|
155
|
|
|
$useOauthSignup = true; |
156
|
|
|
$enforceOAuth = false; |
157
|
|
|
|
158
|
|
|
// Password for the creation bot when this is used in place of OAuth |
159
|
|
|
$creationBotUsername = ''; |
160
|
|
|
$creationBotPassword = ''; |
161
|
|
|
|
162
|
|
|
/************************************ |
163
|
|
|
* Providers Configuration |
164
|
|
|
*/ |
165
|
|
|
|
166
|
|
|
// IP GeoLocation |
167
|
|
|
// ------------------------ |
168
|
|
|
// To set this up, change the class to "IpLocationProvider", and put *your* ipinfodb API key in. |
169
|
|
|
// You'll need to sign up at IpInfoDb.com to get an API key - it's free. |
170
|
|
|
$locationProviderClass = "FakeLocationProvider"; |
171
|
|
|
$locationProviderApiKey = "super secret"; // ipinfodb api key |
172
|
|
|
|
173
|
|
|
// RDNS Provider ( RDnsLookupProvider / CachedRDnsLookupProvider / FakeRDnsLookupProvider) |
174
|
|
|
$rdnsProviderClass = "CachedRDnsLookupProvider"; |
175
|
|
|
|
176
|
|
|
$antispoofProviderClass = "FakeAntiSpoofProvider"; |
177
|
|
|
$xffTrustProviderClass = "XffTrustProvider"; |
178
|
|
|
|
179
|
|
|
/*********************************** |
180
|
|
|
* Data clear script |
181
|
|
|
*/ |
182
|
|
|
|
183
|
|
|
$dataclear_interval = '15 DAY'; |
184
|
|
|
|
185
|
|
|
/*********************************** |
186
|
|
|
* Other stuff that doesn't fit in. |
187
|
|
|
*/ |
188
|
|
|
|
189
|
|
|
$enableSQLError = 0; // Enable the display of SQL errors. |
190
|
|
|
$enableTitleblacklist = 0; // Enable Title Blacklist checks. |
191
|
|
|
|
192
|
|
|
// Enable the use of PATH_INFO for request parameters to prettify URLs. |
193
|
|
|
$usePathInfo = true; |
194
|
|
|
|
195
|
|
|
// user agent of the tool. |
196
|
|
|
$toolUserAgent = "Wikipedia-ACC Tool/0.1 (+https://accounts.wmflabs.org/internal.php/team)"; |
197
|
|
|
|
198
|
|
|
// list of squid proxies requests go through. |
199
|
|
|
$squidIpList = array(); |
200
|
|
|
|
201
|
|
|
$apiDeployPassword = "super secret update password"; |
202
|
|
|
|
203
|
|
|
// request states |
204
|
|
|
$availableRequestStates = array( |
205
|
|
|
'Open' => array( |
206
|
|
|
'defertolog' => 'users', // don't change or you'll break old logs |
207
|
|
|
'deferto' => 'users', |
208
|
|
|
'header' => 'Open requests', |
209
|
|
|
'api' => "open", |
210
|
|
|
), |
211
|
|
|
'Flagged users' => array( |
212
|
|
|
'defertolog' => 'flagged users', // don't change or you'll break old logs |
213
|
|
|
'deferto' => 'flagged users', |
214
|
|
|
'header' => 'Flagged user needed', |
215
|
|
|
'api' => "admin", |
216
|
|
|
), |
217
|
|
|
'Checkuser' => array( |
218
|
|
|
'defertolog' => 'checkusers', // don't change or you'll break old logs |
219
|
|
|
'deferto' => 'checkusers', |
220
|
|
|
'header' => 'Checkuser needed', |
221
|
|
|
'api' => "checkuser", |
222
|
|
|
), |
223
|
|
|
); |
224
|
|
|
|
225
|
|
|
$defaultRequestStateKey = 'Open'; |
226
|
|
|
|
227
|
|
|
$providerCacheExpiry = $dataclear_interval; |
228
|
|
|
|
229
|
|
|
// miser mode |
230
|
|
|
$requestLimitShowOnly = 25; |
231
|
|
|
|
232
|
|
|
// Enables the Smarty debugging console. This should only be used for development and even then |
233
|
|
|
// be left false when you don't need it, since this will open a popup window on every page load. |
234
|
|
|
$smartydebug = false; |
235
|
|
|
|
236
|
|
|
// ID of the Email template used for the main "Created!" close reason. |
237
|
|
|
$createdid = 1; |
238
|
|
|
|
239
|
|
|
// HSTS expiry - use false to disable header. |
240
|
|
|
$strictTransportSecurityExpiry = false; |
241
|
|
|
|
242
|
|
|
// Must be disabled in production. |
243
|
|
|
$enableErrorTrace = false; |
244
|
|
|
|
245
|
|
|
// Dangerous. |
246
|
|
|
// Don't set this. |
247
|
|
|
// Definitely don't set this if there's sensitive data stored here you care about such as OAuth credentials. |
248
|
|
|
$curlDisableSSLVerifyPeer = false; |
249
|
|
|
|
250
|
|
|
// Change this to be outside the web directory. |
251
|
|
|
$curlCookieJar = __DIR__ . '/../cookies.txt'; |
252
|
|
|
|
253
|
|
|
$yubicoApiId = 0; |
254
|
|
|
$yubicoApiKey = ""; |
255
|
|
|
|
256
|
|
|
$totpEncryptionKey = "1234"; |
257
|
|
|
|
258
|
|
|
/************************************************************************** |
259
|
|
|
********** IMPORTANT NOTICE ********** |
260
|
|
|
*************************************************************************** |
261
|
|
|
** DON'T ADD ANY NEW CONFIGURATION OPTIONS BELOW THIS LINE!!! ** |
262
|
|
|
** THEY WILL NOT BE CHANGABLE BY THE LOCAL CONFIGURATION FILE. ** |
263
|
|
|
***************************************************************************/ |
264
|
|
|
|
265
|
|
|
// Retriving the local configuration file. |
266
|
|
|
require_once('config.local.inc.php'); |
267
|
|
|
|
268
|
|
|
$cDatabaseConfig = array( |
269
|
|
|
"acc" => array( |
270
|
|
|
"dsrcname" => "mysql:host=" . $toolserver_host . ";dbname=" . $toolserver_database, |
271
|
|
|
"username" => $toolserver_username, |
272
|
|
|
"password" => $toolserver_password, |
273
|
|
|
"options" => array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4'), |
274
|
|
|
), |
275
|
|
|
"wikipedia" => array( |
276
|
|
|
"dsrcname" => "mysql:host=" . $antispoof_host . ";dbname=" . $antispoof_db, |
277
|
|
|
"username" => $toolserver_username, |
278
|
|
|
"password" => $toolserver_password, |
279
|
|
|
"options" => array(), |
280
|
|
|
), |
281
|
|
|
"notifications" => array( |
282
|
|
|
"dsrcname" => "mysql:host=" . $toolserver_notification_dbhost . ";dbname=" . $toolserver_notification_database, |
283
|
|
|
"username" => $notifications_username, |
284
|
|
|
"password" => $notifications_password, |
285
|
|
|
"options" => array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4'), |
286
|
|
|
), |
287
|
|
|
); |
288
|
|
|
|
289
|
|
|
// //Keep the included files from being executed. |
290
|
|
|
define("ACC", 1); |
291
|
|
|
|
292
|
|
|
// Sets the values of the cookie configuration options. |
293
|
|
|
ini_set('session.cookie_path', $cookiepath); |
294
|
|
|
ini_set('session.name', $sessionname); |
295
|
|
|
ini_set('user_agent', $toolUserAgent); |
296
|
|
|
|
297
|
|
|
foreach (array( |
298
|
|
|
"mbstring", // unicode and stuff |
299
|
|
|
"pdo", |
300
|
|
|
"pdo_mysql", // new database module |
301
|
|
|
"session", |
302
|
|
|
"date", |
303
|
|
|
"pcre", // core stuff |
304
|
|
|
"curl", // mediawiki api access etc |
305
|
|
|
"openssl", // token generation |
306
|
|
|
) as $x) { |
307
|
|
|
if (!extension_loaded($x)) { |
308
|
|
|
die("extension $x is required."); |
309
|
|
|
} |
310
|
|
|
} |
311
|
|
|
|
312
|
|
|
// Set up the AutoLoader |
313
|
|
|
require_once(__DIR__ . "/includes/AutoLoader.php"); |
314
|
|
|
spl_autoload_register('Waca\\AutoLoader::load'); |
315
|
|
|
require_once(__DIR__ . '/vendor/autoload.php'); |
316
|
|
|
|
317
|
|
|
// Extra includes which are just plain awkward wherever they are. |
318
|
|
|
require_once(__DIR__ . '/lib/mediawiki-extensions-OAuth/lib/OAuth.php'); |
319
|
|
|
require_once(__DIR__ . '/lib/mediawiki-extensions-OAuth/lib/JWT.php'); |
320
|
|
|
|
321
|
|
|
// Crap that's needed for libraries. >:( |
322
|
|
|
/** |
323
|
|
|
* Don't use me. I'm only here because the MediaWiki OAuth library we're using requires it. |
324
|
|
|
* |
325
|
|
|
* @param $section |
326
|
|
|
* @param $message |
327
|
|
|
*/ |
328
|
|
|
function wfDebugLog($section, $message) |
|
|
|
|
329
|
|
|
{ |
330
|
|
|
} |
331
|
|
|
|
332
|
|
|
// Initialise the site configuration object |
333
|
|
|
$siteConfiguration = new \Waca\SiteConfiguration(); |
|
|
|
|
334
|
|
|
|
335
|
|
|
$siteConfiguration->setBaseUrl($baseurl) |
336
|
|
|
->setFilePath(__DIR__) |
337
|
|
|
->setDebuggingTraceEnabled($enableErrorTrace) |
338
|
|
|
->setForceIdentification($forceIdentification) |
339
|
|
|
->setIdentificationCacheExpiry($identificationCacheExpiry) |
340
|
|
|
->setMediawikiScriptPath($mediawikiScriptPath) |
341
|
|
|
->setMediawikiWebServiceEndpoint($mediawikiWebServiceEndpoint) |
342
|
|
|
->setMetaWikimediaWebServiceEndpoint($metaWikimediaWebServiceEndpoint) |
343
|
|
|
->setEnforceOAuth($enforceOAuth) |
344
|
|
|
->setEmailConfirmationEnabled($enableEmailConfirm == 1) |
345
|
|
|
->setEmailConfirmationExpiryDays($emailConfirmationExpiryDays) |
346
|
|
|
->setMiserModeLimit($requestLimitShowOnly) |
347
|
|
|
->setRequestStates($availableRequestStates) |
348
|
|
|
->setSquidList($squidIpList) |
349
|
|
|
->setDefaultCreatedTemplateId($createdid) |
350
|
|
|
->setDefaultRequestStateKey($defaultRequestStateKey) |
351
|
|
|
->setUseStrictTransportSecurity($strictTransportSecurityExpiry) |
352
|
|
|
->setUserAgent($toolUserAgent) |
353
|
|
|
->setCurlDisableVerifyPeer($curlDisableSSLVerifyPeer) |
354
|
|
|
->setUseOAuthSignup($useOauthSignup) |
355
|
|
|
->setOAuthBaseUrl($oauthBaseUrl) |
356
|
|
|
->setOAuthConsumerToken($oauthConsumerToken) |
357
|
|
|
->setOAuthConsumerSecret($oauthSecretToken) |
358
|
|
|
->setOauthMediaWikiCanonicalServer($oauthMediaWikiCanonicalServer) |
359
|
|
|
->setDataClearInterval($dataclear_interval) |
360
|
|
|
->setXffTrustedHostsFile($xff_trusted_hosts_file) |
361
|
|
|
->setIrcNotificationsEnabled($ircBotNotificationsEnabled == 1) |
362
|
|
|
->setIrcNotificationType($ircBotNotificationType) |
363
|
|
|
->setIrcNotificationsInstance($whichami) |
364
|
|
|
->setTitleBlacklistEnabled($enableTitleblacklist == 1) |
365
|
|
|
->setTorExitPaths(array_merge(gethostbynamel('en.wikipedia.org'), gethostbynamel('accounts.wmflabs.org'))) |
366
|
|
|
->setCreationBotUsername($creationBotUsername) |
367
|
|
|
->setCreationBotPassword($creationBotPassword) |
368
|
|
|
->setCurlCookieJar($curlCookieJar) |
369
|
|
|
->setYubicoApiId($yubicoApiId) |
370
|
|
|
->setYubicoApiKey($yubicoApiKey) |
371
|
|
|
->setTotpEncryptionKey($totpEncryptionKey) |
372
|
|
|
->setRegistrationAllowed($allowRegistration); |
373
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.