r21496 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r21495‎ | r21496 | r21497 >
Date:18:06, 23 April 2007
Author:aaron
Status:old
Tags:
Comment:
*Document some older functions
Modified paths:
  • /trunk/phase3/includes/ProxyTools.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ProxyTools.php
@@ -3,6 +3,12 @@
44 * Functions for dealing with proxies
55 */
66
 7+/**
 8+ * Extracts the XFF string from the request header
 9+ * Checks first for "X-Forwarded-For", then "Client-ip"
 10+ * Note: headers are spoofable
 11+ * @return string
 12+ */
713 function wfGetForwardedFor() {
814 if( function_exists( 'apache_request_headers' ) ) {
915 // More reliable than $_SERVER due to case and -/_ folding
@@ -44,6 +50,11 @@
4551 return null;
4652 }
4753
 54+/**
 55+ * Returns the browser/OS data from the request header
 56+ * Note: headers are spoofable
 57+ * @return string
 58+ */
4859 function wfGetAgent() {
4960 if( function_exists( 'apache_request_headers' ) ) {
5061 // More reliable than $_SERVER due to case and -/_ folding
@@ -61,7 +72,11 @@
6273 }
6374 }
6475
65 -/** Work out the IP address based on various globals */
 76+/**
 77+ * Work out the IP address based on various globals
 78+ * For trusted proxies, use the XFF client IP (first of the chain)
 79+ * @return string
 80+ */
6681 function wfGetIP() {
6782 global $wgIP;
6883
@@ -106,6 +121,13 @@
107122 return $ip;
108123 }
109124
 125+/**
 126+ * Checks if an IP is a trusted proxy providor
 127+ * Useful to tell if X-Fowarded-For data is possibly bogus
 128+ * Squid cache servers for the site and AOL are whitelisted
 129+ * @param string $ip
 130+ * @return bool
 131+ */
110132 function wfIsTrustedProxy( $ip ) {
111133 global $wgSquidServers, $wgSquidServersNoPurge;
112134
@@ -170,6 +192,7 @@
171193
172194 /**
173195 * Convert a network specification in CIDR notation to an integer network and a number of bits
 196+ * @return array(string, int)
174197 */
175198 function wfParseCIDR( $range ) {
176199 return IP::parseCIDR( $range );
@@ -177,6 +200,7 @@
178201
179202 /**
180203 * Check if an IP address is in the local proxy list
 204+ * @return bool
181205 */
182206 function wfIsLocallyBlockedProxy( $ip ) {
183207 global $wgProxyList;
@@ -209,6 +233,7 @@
210234 /**
211235 * TODO: move this list to the database in a global IP info table incorporating
212236 * trusted ISP proxies, blocked IP addresses and open proxies.
 237+ * @return bool
213238 */
214239 function wfIsAOLProxy( $ip ) {
215240 $ranges = array(