Development

Changeset 13018

You must first sign up to be able to contribute.

Changeset 13018

Show
Ignore:
Timestamp:
11/15/08 22:12:39 (8 months ago)
Author:
FabianLange
Message:

[1.2] fixed #2798 by applying Patch from Nebelmann

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.2/lib/request/sfWebRequest.class.php

    r11954 r13018  
    592592   * @return  array Path information 
    593593   */ 
    594   protected function getPathInfoArray() 
     594  public function getPathInfoArray() 
    595595  { 
    596596    if (!$this->pathInfoArray) 
     
    767767 
    768768  /** 
    769    * Returns the remote IP address for the request. 
     769   * Returns the remote IP address that made the request. 
    770770   * 
    771771   * @return string The remote IP address 
     
    779779 
    780780  /** 
    781    * Returns the remote IP addressed after resolved from the forward. 
    782    * 
    783    * This is useful if you are testing to see if the user is behind a proxy. However, 
    784    * it should not be trusted. 
    785    * 
    786    * @return string|null The remote IP address resolved from a forward, null if none set 
    787    */ 
    788   public function getForwardedRemoteAddress() 
     781   * Returns an array containing a list of IPs, the first being the client address 
     782   * and the others the addresses of each proxy that passed the request. The address  
     783   * for the last proxy can be retrieved via getRemoteAddress(). 
     784   * 
     785   * This method returns null if no proxy passed this request. Note that some proxies 
     786   * do not use this header, and act as if they were the client. 
     787   * 
     788   * @return string|null An array of IP from the client and the proxies that passed 
     789   * the request, or null if no proxy was used. 
     790   */ 
     791  public function getForwardedFor() 
    789792  { 
    790793    $pathInfo = $this->getPathInfoArray(); 
     
    795798    } 
    796799 
    797     return $pathInfo['HTTP_X_FORWARDED_FOR']
     800    return split(', ', $pathInfo['HTTP_X_FORWARDED_FOR'])
    798801  } 
    799802 
  • branches/1.2/test/unit/request/sfWebRequestTest.php

    r11254 r13018  
    138138$t->is($request->getRemoteAddress(), '127.0.0.1', '->getRemoteAddress() returns the remote address'); 
    139139 
    140 // ->getForwardedRemoteAddress() 
    141 $t->diag('->getForwardedRemoteAddress()'); 
    142 $t->is($request->getForwardedRemoteAddress(), null, '->getForwardedRemoteAddress() returns null if the request was not forwarded.'); 
    143 $_SERVER['HTTP_X_FORWARDED_FOR'] = '10.0.0.1'; 
    144 $t->is($request->getForwardedRemoteAddress(), '10.0.0.1', '->getForwardedRemoteAddress() returns the value from HTTP_X_FORWARDED_FOR'); 
     140// ->getForwardedFor() 
     141$t->diag('->getForwardedFor()'); 
     142$t->is($request->getForwardedFor(), null, '->getForwardedFor() returns null if the request was not forwarded.'); 
     143$_SERVER['HTTP_X_FORWARDED_FOR'] = '10.0.0.1, 10.0.0.2'; 
     144$t->is_deeply($request->getForwardedFor(), array('10.0.0.1', '10.0.0.2'), '->getForwardedFor() returns the value from HTTP_X_FORWARDED_FOR'); 
    145145 
    146146// methods 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.