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