Commit graph

80 commits

Author SHA1 Message Date
Alexandre Emsenhuber
d1f8640a3b Added missing GPLv2 headers in some places.
Also made file/class documentation more consistent.

Change-Id: Ia45d0756cd84138da267bf1cbd1a58be7f28c6d1
2012-05-11 10:34:29 +02:00
Arthur Richards
05e5a81962 Refactors the check if a particular IP is in the list of configured squid servers into its own function. 2012-02-21 22:00:58 +00:00
Jeroen De Dauw
0b105ebf1d added missing deprecation notices 2011-12-13 19:51:03 +00:00
Roan Kattouw
75681bc57a Expand some more URLs: for feeds, referers and the proxy script 2011-08-19 17:31:40 +00:00
Alexandre Emsenhuber
4ae4dea93e Removed mention of AOL, no longer true since r39892 2011-08-18 21:04:29 +00:00
Alexandre Emsenhuber
77a3987052 Moved wfGetIP() to WebRequest::getIP():
* Changed all calls in core to the latter
* Also marked wfGetForwardedFor() as deprecated
* Moved wfGetIP() tests to WebRequestTest
2011-08-18 20:03:30 +00:00
Antoine Musso
ab0ebed3fd Tests for wfGetIP() follow up r89407
* wfGetIP() now support resetting its internal static variable. Thanks to
Platonides which introduced this trick with r92960.
* Various tests for $_SERVER['REMOTE_ADDR'] and $wgCommandLineMode.

revert r94575:
 - reenable testGetFromServerRemoteAddr() which was not an issue

reintroduce r94558:
 - per CR on r94558 by Aaron use meaningful parameter to wfGetIP() when
   resetting the static variable ( 'reset' instead of true).
 - keep testLackOfRemoteAddrThrowAnException() test in the broken group
   with a comment for later fixing.

TODO:

- implements tests for XFF headers.


TEST PLAN:

$ ./phpunit.php --filter wfGetIP --testdox
PHPUnit 3.5.14 by Sebastian Bergmann.

wfGetIP
[x] Get loopback address when in command line
[x] Get from server remote addr
[x] Lack of remote addr throw an exception
$
2011-08-16 14:15:07 +00:00
Antoine Musso
56cc7371dd back off r94558:
- reverts ./includes/ProxyTools.php
 - marks tests broken

In our test suite, the first call to wfGetIP() set the static variable.
Hence the remaining of the code is only tested on the first call to it.
Resetting the static variable enlight a bug somewhere in our code where
we are calling wfGetIP() but can not reliably get an IP, somehow REMOTE_ADDR
does not exist and $wgCommandLineMode is disabled.
Will have to track this bug further when I got time.
2011-08-15 21:45:18 +00:00
Antoine Musso
aecf8ea396 Tests for wfGetIP() follow up r89407
* wfGetIP() now support resetting its internal static variable. Thanks to
 Platonides which introduced this trick with r92960.
* Various tests for $_SERVER['REMOTE_ADDR'] and $wgCommandLineMode.

TODO:

- implements tests for XFF headers.


TEST PLAN:

$ ./phpunit.php --filter wfGetIP --testdox
PHPUnit 3.5.14 by Sebastian Bergmann.

wfGetIP
 [x] Get loopback address when in command line
 [x] Get from server remote addr
 [x] Lack of remote addr throw an exception
$
2011-08-15 20:16:15 +00:00
Ryan Schmidt
88152f01f7 * Revert r94487 and r19889 to an extent -- ONLY check for the X-Forwarded-For header when we are behind a proxy, as mostly every properly configured proxy software sets it, and attempting to support those that do not opens up the ability to spoof IP addresses by setting arbitrary headers. 2011-08-15 05:25:56 +00:00
Ryan Schmidt
6b20263893 When MediaWiki is being run behind a proxy, also check the X-Real-IP header to determine the client's actual IP address (some servers such as nginx might set this instead of X-Forwarded-For depending on configuration). 2011-08-15 04:50:51 +00:00
Sam Reed
ead9055a62 Update code comments that point to 1.18 to point to 1.19 2011-07-18 23:01:08 +00:00
Alexandre Emsenhuber
e663f9bce6 Moved wfIsLocallyBlockedProxy() to User::isLocallyBlockedProxy() to put it near other proxy checks. No other call to that function in core or extension.
Also added a check to not execute a part of User::getBlockedStatus() if $ip is null.
2011-06-19 12:57:31 +00:00
Sam Reed
16842c0b73 Swap else if for elseif
Trimming trailing whitespace also

Doing in 3 commits (2/3), so hopefully reviewable in CR...
2011-06-17 16:05:05 +00:00
Alexandre Emsenhuber
f33f9ec7ee Don't execute the loop if there's no X-Forwarded-For header, also don't use isset() to check only for null 2011-06-03 10:55:38 +00:00
Alexandre Emsenhuber
8f7038afe3 Deprecated wfGetAgent(), use $wgRequest->getHeader( 'User-Agent' ) instead 2011-06-03 10:41:53 +00:00
Alexandre Emsenhuber
49c718d871 Removed more functions marked for removal in 1.19: wfParseCIDR(), wfRFC822Phrase() and userMailer(). 2011-05-06 18:22:37 +00:00
Sam Reed
8775ac3b20 Type hinting
Braces

Remove extra whitespace
2011-04-25 21:25:45 +00:00
Paul Copperman
efb8c6b899 Fix some Notices:
* LanguageKaa.php: Fix ucfirst and lcfirst for empty strings.
* SkinTemplate.php: Fix undefined array access.
* ProxyTools.php: When running hiphop in cli mode, apache_request_headers() returns null. Fix wfGetForwardedFor() to account for that.
2011-04-11 16:49:36 +00:00
Alexandre Emsenhuber
f765c2582d Mark wfParseCIDR(), was moved to IP::parseCIDR() in r16625; also tag for removal, no use in core or extensions. 2010-11-07 15:51:56 +00:00
Platonides
32b3fa74f0 Remove $wgIP global, but add a hook instead.
This allows extensions to "make mediawiki ignore ips completely", as requested earlier today in #mediawiki
2010-09-11 13:45:51 +00:00
Alexandre Emsenhuber
7b79d94515 * Standardised file description headers
* Added some descriptions
* Added @file where needed
2010-08-14 17:42:40 +00:00
Alexandre Emsenhuber
bccd2ad03b fix some doxygen errors 2009-12-11 22:19:37 +00:00
Alexandre Emsenhuber
2d0dd7959c $fname -> __METHOD__ 2009-11-07 14:23:09 +00:00
OverlordQ
033860134c Followup to r52671, fix redirection syntax to work with windows as well. 2009-08-25 15:47:46 +00:00
Chad Horohoe
1219a4f717 Use wfGetNull() instead of hardcoded /dev/null 2009-07-02 00:55:48 +00:00
Alexandre Emsenhuber
5b2c98b2ef Fix for r51774, r51784: set '127.0.0.1' as IP for CLI, but with explicit check for $wgCommandLineMode so that the exception "Unable to determine IP" is not thrown in this case. 2009-06-12 09:34:49 +00:00
Alexandre Emsenhuber
8f79397a7c Fixes for r51774:
* declare $ip and $ipchain so that it doesn't throw notices and warnings
* don't set $ip to false after getting it from $_SERVER['REMOTE_ADDR'], otherwise it won't work when there's no XFF header
* fix logic when throwing the exception: throw it when there's no IP
2009-06-12 09:17:21 +00:00
Chad Horohoe
026546e3ad Revert r51725 (fall back to 127.0.0.1 when IP cannot be determined). On further discussion, it's best if we don't make up a fake IP. Tweak the logic here a bit (per Tim) to let XFF attempt to determine the actual IP. Throw an exception if we can't. 2009-06-12 01:34:44 +00:00
Chad Horohoe
38b5865216 (bug 18173) Login form exception on malformed REMOTE_ADDR, wfGetIP() now falls back to 127.0.01 if the IP cannot be determined, which is more sane than returning null. 2009-06-11 03:20:15 +00:00
Brion Vibber
4e01dba6cc Revert r44254 "Cleanup to wfGetNull(): * Add override in case /dev/null isn't accessible (bug 11009)"
Doesn't seem like a proper fix here... At best, this'll be dumping random crap to some random file unless the user has a local copy of the /dev/null device file, which seems.... wrong. :)
For anything generating command lines, it probably won't make any difference (assuming exec() is enabled at all!) since open_basedir won't be searching through the command line (I think).
Assuming the core use case actually happens (open_basedir is set, but proc_open() is available to run tidy), a more correct fix is probably to go ahead and read in stderr and toss the results, or maybe better pass it through to PHP's stderr FD instead of opening /dev/null ourselves. Tidy has a -q option which should suppress random "hi i'm tidy version XYZ" if it's currently present.
2008-12-10 22:58:24 +00:00
Chad Horohoe
f36d56a2fe Cleanup to wfGetNull():
* Add override in case /dev/null isn't accessible (bug 11009)
* Use wfGetNull() in ProxyTools rather than hardcoding it
2008-12-05 17:25:22 +00:00
Charles Melbye
a83333c4a5 Added a new configuration option ($wgUsePrivateIPs) to force MediaWiki to use forwarded Private IPs from a Proxy server 2008-11-20 23:30:08 +00:00
Tim Starling
9e103d3dc3 Reverting r40323, as per comments on wikitech-l. Deprecated doesn't mean removed. It doesn't even mean it'll be removed in the future. It just means you shouldn't use it. 2008-09-03 02:28:41 +00:00
Chad Horohoe
85eee307b2 Fully deprecate $wgProxyKey. Has been marked as deprecated since 1.4, but never seems to have been done. Sites with $wgProxyKey set will continue to use the setting (added a fallback in Setup). Fixes bugs 9258 and 12089. 2008-09-02 15:15:54 +00:00
Tim Starling
9a70df9bf1 Removed the AOL hack. Use the TrustedXFF extension instead. 2008-08-24 06:45:07 +00:00
Aryeh Gregor
efddfe98e4 Add comment explaining mystery list of IP addresses 2008-07-01 22:30:06 +00:00
Alexandre Emsenhuber
087a9f70c5 WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>

Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage

One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
Siebrand Mazeland
79d5225c0e * remove end of line whitespace
* remove empty lines at end of file
* remove "?>" where still present
2008-04-14 07:45:50 +00:00
Alexandre Emsenhuber
cf0fb622b5 Withespaces fixes. 2008-03-08 16:22:05 +00:00
Anders Wegge Jakobsen
65f73d8439 Fix for 13281: Normalize header names as per RFC 2616 2008-03-07 22:12:34 +00:00
Alexandre Emsenhuber
7248aeaaff * Update docs/memcached.txt
* Kill call to $wgUseMemCached in includes/ProxyTools.php
2008-03-01 15:08:49 +00:00
Aryeh Gregor
a15c419b3d Remove ?>'s from files. They're pointless, and just asking for people to mess with the files and add trailing whitespace. (Yes, I looked over every one and reverted those that were bogus. Slash-enter a million times in less worked well enough, although it was a bit mind-numbing.) 2007-06-29 01:19:14 +00:00
Aaron Schulz
72dd9a7e4d *Remove wfGetLastIPfromXFF() from r19889 2007-04-24 19:00:45 +00:00
Brion Vibber
cc8e3c5a4b Reverting more fucked up untested code from r21448 and r21449 2007-04-24 14:31:52 +00:00
Aaron Schulz
d1ff03cd1d *Document some older functions 2007-04-23 18:06:37 +00:00
Aaron Schulz
b30bf261f4 *Remove wfGetLastIPfromXFF(), add a new wfGetClientIPfromXFF(), which was removed in r21353 2007-04-21 16:45:36 +00:00
Brion Vibber
a1b4a52dc4 *stab stab stab* 2007-04-19 13:59:00 +00:00
Brion Vibber
6273156469 wfGetLastIPfromXFF() was clearly never tested either because it also DOESN'T FUCKING WORK
and HAS NO FUCKING DOCUMENTATION
and CAUSES ERRORS AND FAILURES
This quick hack should make it appear to basically work, assuming it does anything useful at all.
2007-04-19 13:33:13 +00:00
Brion Vibber
f203eb5234 Revert r21158 and r21159 -- clearly broken code.
wfGetClientIPfromXFF() uses undeclared variables -- it will never return a non-null value, but will in most cases trigger PHP notices about accessing unused variables.
It's also not documented as to what it does or how it's supposed to differ from the functions above it.
Please document, rewrite, and test this function if it is required.
2007-04-18 18:53:54 +00:00