--- referral.module.org Fri Nov 28 05:10:20 2008 +++ referral.module Sat Feb 28 18:40:17 2009 @@ -198,9 +198,9 @@ // Build the userpoints params array $params = array( 'points' => $points, - 'uid' => $cookie[$uid], + 'uid' => $cookie['uid'], 'operation' => 'referral', - 'entity_id' => $cookie[$uid], + 'entity_id' => $cookie['uid'], 'entity_type' => 'user', 'reference' => 'referral' ); @@ -269,7 +269,25 @@ break; } } +function ip_address() { + static $ip_address = NULL; + if (!isset($ip_address)) { + $ip_address = $_SERVER['REMOTE_ADDR']; + if (variable_get('reverse_proxy', 0) && array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) { + // If an array of known reverse proxy IPs is provided, then trust + // the XFF header if request really comes from one of them. + $reverse_proxy_addresses = variable_get('reverse_proxy_addresses', array()); + if (!empty($reverse_proxy_addresses) && in_array($ip_address, $reverse_proxy_addresses, TRUE)) { + // If there are several arguments, we need to check the most + // recently added one, i.e. the last one. + $ip_address = array_pop(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR'])); + } + } + } + + return $ip_address; +} function referral_set_cookie($uid) { $cookie = array( 'uid' => $uid,