protected function isGranted(MvcEvent $event) { return false !== $this->whip->getValidIpAddress(); }
/** * 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()); }
/** * 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()); }