This class checks a call time configurable list of headers in the $_SERVER superglobal to determine the client's IP address.
Author: Daniel Bruce (dbruce@vectorface.com)
Author: Cory Darby (ckdarby@vectorface.com)
Esempio n. 1
0
 protected function isGranted(MvcEvent $event)
 {
     return false !== $this->whip->getValidIpAddress();
 }
Esempio n. 2
0
 /**
  * Test HTTP_X_REAL_IP header.
  */
 public function testHttpXRealIpHeader()
 {
     $_SERVER = array('REMOTE_ADDR' => '127.0.0.1', 'HTTP_X_REAL_IP' => '24.24.24.24');
     $lookup = new Whip(Whip::PROXY_HEADERS | Whip::REMOTE_ADDR);
     $this->assertEquals('24.24.24.24', $lookup->getIpAddress());
 }
Esempio n. 3
0
 /**
  * Tests that if we specify the source array through Whip::setSource, the
  * class will override any values found in $_SERVER.
  */
 public function testSetSourceArrayOverridesServerSuperglobal()
 {
     $source = array('REMOTE_ADDR' => '24.24.24.24');
     $lookup = new Whip(Whip::REMOTE_ADDR, array(), array('REMOTE_ADDR' => '127.0.0.1'));
     $this->assertNotEquals($source['REMOTE_ADDR'], $lookup->getIpAddress());
     $lookup->setSource($source);
     $this->assertEquals($source['REMOTE_ADDR'], $lookup->getIpAddress());
 }