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 | * OAuth Configuration |
||||||||
131 | */ |
||||||||
132 | |||||||||
133 | $oauthConsumerToken = ""; |
||||||||
134 | $oauthSecretToken = ""; |
||||||||
135 | |||||||||
136 | // Formerly-used OAuth tokens to permit reading identities from |
||||||||
137 | $oauthLegacyTokens = []; |
||||||||
138 | |||||||||
139 | // path to Special:OAuth on target wiki. |
||||||||
140 | // don't use pretty urls, see [[bugzilla:57500]] |
||||||||
141 | $oauthBaseUrl = "https://en.wikipedia.org/w/index.php?title=Special:OAuth"; |
||||||||
142 | // use this for requests from the server, if some special url is needed. |
||||||||
143 | $oauthBaseUrlInternal = "https://en.wikipedia.org/w/index.php?title=Special:OAuth"; |
||||||||
144 | |||||||||
145 | $oauthMediaWikiCanonicalServer = "http://en.wikipedia.org"; |
||||||||
146 | |||||||||
147 | $useOauthSignup = true; |
||||||||
148 | $enforceOAuth = false; |
||||||||
149 | |||||||||
150 | // Password for the creation bot when this is used in place of OAuth |
||||||||
151 | $creationBotUsername = ''; |
||||||||
152 | $creationBotPassword = ''; |
||||||||
153 | |||||||||
154 | /************************************ |
||||||||
155 | * Providers Configuration |
||||||||
156 | */ |
||||||||
157 | |||||||||
158 | // IP GeoLocation |
||||||||
159 | // ------------------------ |
||||||||
160 | // To set this up, change the class to "IpLocationProvider", and put *your* ipinfodb API key in. |
||||||||
161 | // You'll need to sign up at IpInfoDb.com to get an API key - it's free. |
||||||||
162 | $locationProviderClass = "FakeLocationProvider"; |
||||||||
163 | $locationProviderApiKey = "super secret"; // ipinfodb api key |
||||||||
164 | |||||||||
165 | // RDNS Provider ( RDnsLookupProvider / CachedRDnsLookupProvider / FakeRDnsLookupProvider) |
||||||||
166 | $rdnsProviderClass = "CachedRDnsLookupProvider"; |
||||||||
167 | |||||||||
168 | $antispoofProviderClass = "FakeAntiSpoofProvider"; |
||||||||
169 | $xffTrustProviderClass = "XffTrustProvider"; |
||||||||
170 | |||||||||
171 | /*********************************** |
||||||||
172 | * Data clear script |
||||||||
173 | */ |
||||||||
174 | |||||||||
175 | $dataclear_interval = '15 DAY'; |
||||||||
176 | |||||||||
177 | /*********************************** |
||||||||
178 | * Other stuff that doesn't fit in. |
||||||||
179 | */ |
||||||||
180 | |||||||||
181 | $enableSQLError = 0; // Enable the display of SQL errors. |
||||||||
182 | $enableTitleblacklist = 0; // Enable Title Blacklist checks. |
||||||||
183 | |||||||||
184 | // Enable the use of PATH_INFO for request parameters to prettify URLs. |
||||||||
185 | $usePathInfo = true; |
||||||||
186 | |||||||||
187 | // user agent of the tool. |
||||||||
188 | $toolUserAgent = "Wikipedia-ACC Tool/0.1 (+https://accounts.wmflabs.org/internal.php/team)"; |
||||||||
189 | |||||||||
190 | // list of squid proxies requests go through. |
||||||||
191 | $squidIpList = array(); |
||||||||
192 | |||||||||
193 | // request states |
||||||||
194 | $availableRequestStates = array( |
||||||||
195 | 'Open' => array( |
||||||||
196 | 'defertolog' => 'users', // don't change or you'll break old logs |
||||||||
197 | 'deferto' => 'users', |
||||||||
198 | 'header' => 'Open requests', |
||||||||
199 | 'api' => "open", |
||||||||
200 | 'queuehelp' => null |
||||||||
201 | ), |
||||||||
202 | 'Flagged users' => array( |
||||||||
203 | 'defertolog' => 'flagged users', // don't change or you'll break old logs |
||||||||
204 | 'deferto' => 'flagged users', |
||||||||
205 | 'header' => 'Flagged user needed', |
||||||||
206 | 'api' => "admin", |
||||||||
207 | 'queuehelp' => 'This queue lists the requests which require a user with the <code>accountcreator</code> flag to create.<br />If creation is determined to be the correct course of action, requests here will require the overriding the AntiSpoof checks or the title blacklist in order to create. It is recommended to try to create the account <em>without</em> checking the flags to validate the results of the AntiSpoof and/or title blacklist hits.' |
||||||||
208 | ), |
||||||||
209 | 'Checkuser' => array( |
||||||||
210 | 'defertolog' => 'checkusers', // don't change or you'll break old logs |
||||||||
211 | 'deferto' => 'checkusers', |
||||||||
212 | 'header' => 'Checkuser needed', |
||||||||
213 | 'api' => "checkuser", |
||||||||
214 | 'queuehelp' => null |
||||||||
215 | ), |
||||||||
216 | ); |
||||||||
217 | |||||||||
218 | $defaultRequestStateKey = 'Open'; |
||||||||
219 | |||||||||
220 | $providerCacheExpiry = $dataclear_interval; |
||||||||
221 | |||||||||
222 | // miser mode |
||||||||
223 | $requestLimitShowOnly = 25; |
||||||||
224 | |||||||||
225 | // Enables the Smarty debugging console. This should only be used for development and even then |
||||||||
226 | // be left false when you don't need it, since this will open a popup window on every page load. |
||||||||
227 | $smartydebug = false; |
||||||||
228 | |||||||||
229 | // ID of the Email template used for the main "Created!" close reason. |
||||||||
230 | $createdid = 1; |
||||||||
231 | |||||||||
232 | // HSTS expiry - use false to disable header. |
||||||||
233 | $strictTransportSecurityExpiry = false; |
||||||||
234 | |||||||||
235 | // CSP violation report URI |
||||||||
236 | $cspReportUri = null; |
||||||||
237 | |||||||||
238 | // Must be disabled in production. |
||||||||
239 | $enableErrorTrace = false; |
||||||||
240 | |||||||||
241 | // Dangerous. |
||||||||
242 | // Don't set this. |
||||||||
243 | // Definitely don't set this if there's sensitive data stored here you care about such as OAuth credentials. |
||||||||
244 | $curlDisableSSLVerifyPeer = false; |
||||||||
245 | |||||||||
246 | // Change this to be outside the web directory. |
||||||||
247 | $curlCookieJar = __DIR__ . '/../cookies.txt'; |
||||||||
248 | |||||||||
249 | $yubicoApiId = 0; |
||||||||
250 | $yubicoApiKey = ""; |
||||||||
251 | |||||||||
252 | $totpEncryptionKey = "1234"; |
||||||||
253 | |||||||||
254 | // external resource cache epoch value. Bump me to force clients to reload assets |
||||||||
255 | $resourceCacheEpoch = 1; |
||||||||
256 | |||||||||
257 | $commonEmailDomains = ['gmail.com', 'hotmail.com', 'outlook.com']; |
||||||||
258 | |||||||||
259 | // limit for block/drop ban actions |
||||||||
260 | $banMaxIpBlockRange = [4 => 20, 6 => 48]; |
||||||||
261 | // limit for *all* ban actions, including block/drop. |
||||||||
262 | $banMaxIpRange = [4 => 16, 6 => 32]; |
||||||||
263 | |||||||||
264 | $jobQueueBatchSize = 10; |
||||||||
265 | |||||||||
266 | /************************************************************************** |
||||||||
267 | ********** IMPORTANT NOTICE ********** |
||||||||
268 | *************************************************************************** |
||||||||
269 | ** DON'T ADD ANY NEW CONFIGURATION OPTIONS BELOW THIS LINE!!! ** |
||||||||
270 | ** THEY WILL NOT BE CHANGABLE BY THE LOCAL CONFIGURATION FILE. ** |
||||||||
271 | ***************************************************************************/ |
||||||||
272 | |||||||||
273 | // Retriving the local configuration file. |
||||||||
274 | require_once('config.local.inc.php'); |
||||||||
275 | |||||||||
276 | $cDatabaseConfig = array( |
||||||||
277 | "acc" => array( |
||||||||
278 | "dsrcname" => "mysql:host=" . $toolserver_host . ";dbname=" . $toolserver_database, |
||||||||
279 | "username" => $toolserver_username, |
||||||||
280 | "password" => $toolserver_password, |
||||||||
281 | "options" => array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4'), |
||||||||
282 | ), |
||||||||
283 | "wikipedia" => array( |
||||||||
284 | "dsrcname" => "mysql:host=" . $antispoof_host . ";dbname=" . $antispoof_db, |
||||||||
285 | "username" => $toolserver_username, |
||||||||
286 | "password" => $toolserver_password, |
||||||||
287 | "options" => array(), |
||||||||
288 | ), |
||||||||
289 | "notifications" => array( |
||||||||
290 | "dsrcname" => "mysql:host=" . $toolserver_notification_dbhost . ";dbname=" . $toolserver_notification_database, |
||||||||
291 | "username" => $notifications_username, |
||||||||
292 | "password" => $notifications_password, |
||||||||
293 | "options" => array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4'), |
||||||||
294 | ), |
||||||||
295 | ); |
||||||||
296 | |||||||||
297 | // //Keep the included files from being executed. |
||||||||
298 | define("ACC", 1); |
||||||||
299 | |||||||||
300 | // Sets the values of the cookie configuration options. |
||||||||
301 | ini_set('session.cookie_path', $cookiepath); |
||||||||
302 | ini_set('session.name', $sessionname); |
||||||||
303 | ini_set('user_agent', $toolUserAgent); |
||||||||
304 | |||||||||
305 | foreach (array( |
||||||||
306 | "mbstring", // unicode and stuff |
||||||||
307 | "pdo", |
||||||||
308 | "pdo_mysql", // new database module |
||||||||
309 | "session", |
||||||||
310 | "date", |
||||||||
311 | "pcre", // core stuff |
||||||||
312 | "curl", // mediawiki api access etc |
||||||||
313 | "openssl", // token generation |
||||||||
314 | ) as $x) { |
||||||||
315 | if (!extension_loaded($x)) { |
||||||||
316 | die("extension $x is required."); |
||||||||
317 | } |
||||||||
318 | } |
||||||||
319 | |||||||||
320 | // Set up the AutoLoader |
||||||||
321 | require_once(__DIR__ . "/includes/AutoLoader.php"); |
||||||||
322 | spl_autoload_register('Waca\\AutoLoader::load'); |
||||||||
323 | require_once(__DIR__ . '/vendor/autoload.php'); |
||||||||
324 | |||||||||
325 | // Crap that's needed for libraries. >:( |
||||||||
326 | /** |
||||||||
327 | * Don't use me. I'm only here because the MediaWiki OAuth library we're using requires it. |
||||||||
328 | * |
||||||||
329 | * @param $section |
||||||||
330 | * @param $message |
||||||||
331 | */ |
||||||||
332 | function wfDebugLog($section, $message) |
||||||||
0 ignored issues
–
show
The parameter
$section is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||||||
333 | { |
||||||||
334 | } |
||||||||
335 | |||||||||
336 | // Initialise the site configuration object |
||||||||
337 | /** @noinspection PhpFullyQualifiedNameUsageInspection */ |
||||||||
338 | $siteConfiguration = new \Waca\SiteConfiguration(); |
||||||||
339 | |||||||||
340 | $siteConfiguration->setBaseUrl($baseurl) |
||||||||
0 ignored issues
–
show
The function
Waca\SiteConfiguration::...aultCreatedTemplateId() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() The function
Waca\SiteConfiguration::setRequestStates() has been deprecated: To be removed after dynamic queues hit production. This will need to be major point release.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead. ![]() The function
Waca\SiteConfiguration::...efaultRequestStateKey() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
341 | ->setFilePath(__DIR__) |
||||||||
342 | ->setDebuggingTraceEnabled($enableErrorTrace) |
||||||||
343 | ->setForceIdentification($forceIdentification) |
||||||||
344 | ->setIdentificationCacheExpiry($identificationCacheExpiry) |
||||||||
345 | ->setMediawikiScriptPath($mediawikiScriptPath) |
||||||||
346 | ->setMediawikiWebServiceEndpoint($mediawikiWebServiceEndpoint) |
||||||||
347 | ->setMetaWikimediaWebServiceEndpoint($metaWikimediaWebServiceEndpoint) |
||||||||
348 | ->setEnforceOAuth($enforceOAuth) |
||||||||
349 | ->setEmailConfirmationEnabled($enableEmailConfirm == 1) |
||||||||
350 | ->setEmailConfirmationExpiryDays($emailConfirmationExpiryDays) |
||||||||
351 | ->setMiserModeLimit($requestLimitShowOnly) |
||||||||
352 | ->setRequestStates($availableRequestStates) |
||||||||
353 | ->setSquidList($squidIpList) |
||||||||
354 | ->setDefaultCreatedTemplateId($createdid) |
||||||||
355 | ->setDefaultRequestStateKey($defaultRequestStateKey) |
||||||||
356 | ->setUseStrictTransportSecurity($strictTransportSecurityExpiry) |
||||||||
357 | ->setUserAgent($toolUserAgent) |
||||||||
358 | ->setCurlDisableVerifyPeer($curlDisableSSLVerifyPeer) |
||||||||
359 | ->setUseOAuthSignup($useOauthSignup) |
||||||||
360 | ->setOAuthBaseUrl($oauthBaseUrl)// |
||||||||
361 | ->setOAuthConsumerToken($oauthConsumerToken) |
||||||||
362 | ->setOAuthLegacyConsumerTokens($oauthLegacyTokens) |
||||||||
363 | ->setOAuthConsumerSecret($oauthSecretToken) |
||||||||
364 | ->setOauthMediaWikiCanonicalServer($oauthMediaWikiCanonicalServer) |
||||||||
365 | ->setDataClearInterval($dataclear_interval) |
||||||||
366 | ->setXffTrustedHostsFile($xff_trusted_hosts_file) |
||||||||
367 | ->setIrcNotificationsEnabled($ircBotNotificationsEnabled == 1) |
||||||||
368 | ->setIrcNotificationType($ircBotNotificationType) |
||||||||
369 | ->setIrcNotificationsInstance($whichami) |
||||||||
370 | ->setTitleBlacklistEnabled($enableTitleblacklist == 1) |
||||||||
371 | ->setTorExitPaths(array_merge(gethostbynamel('en.wikipedia.org'), gethostbynamel('accounts.wmflabs.org'))) |
||||||||
372 | ->setCreationBotUsername($creationBotUsername) |
||||||||
373 | ->setCreationBotPassword($creationBotPassword) |
||||||||
374 | ->setCurlCookieJar($curlCookieJar) |
||||||||
375 | ->setYubicoApiId($yubicoApiId) |
||||||||
376 | ->setYubicoApiKey($yubicoApiKey) |
||||||||
377 | ->setTotpEncryptionKey($totpEncryptionKey) |
||||||||
378 | ->setRegistrationAllowed($allowRegistration) |
||||||||
379 | ->setCspReportUri($cspReportUri) |
||||||||
380 | ->setResourceCacheEpoch($resourceCacheEpoch) |
||||||||
381 | ->setLocationProviderApiKey($locationProviderApiKey) |
||||||||
382 | ->setCommonEmailDomains($commonEmailDomains) |
||||||||
383 | ->setBanMaxIpRange($banMaxIpRange) |
||||||||
384 | ->setBanMaxIpBlockRange($banMaxIpBlockRange) |
||||||||
385 | ->setJobQueueBatchSize($jobQueueBatchSize); |
||||||||
386 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.