davykiash
davykiash

Reputation: 1804

Remote Address Parameter in Zend_Http_Client

Am developing a public site that uses the Zend_Http_Client to access remote logic.Is there a property/way in the Client adapter that I could set the remote address of the user browsing the site?

Currently am using this workaround which combines both remote address and remote useragent.

$client = new Zend_Http_Client();       
$client->setConfig(array(                       
    'useragent' => 'Get Remote Address'.'Get User Agent',       
)); 

Is there a specific property for remote address?

Upvotes: 1

Views: 3752

Answers (1)

David Snabel-Caunt
David Snabel-Caunt

Reputation: 58371

From any Zend_Controller_Action method you can retrieve the user's remote address as follows:

$ip = $this->getRequest()->getServer('REMOTE_ADDR');

If you're not in a Controller, you can use the following assuming the Front Controller was used:

$ip = Zend_Controller_Front::getInstance()->getRequest()->getServer('REMOTE_ADDR');

And finally - these methods are just wrappers for the SERVER superglobal:

$ip = $_SERVER['REMOTE_ADDR'];

Substitute REMOTE_ADDR with HTTP_USER_AGENT to get the user agent.

Upvotes: 5

Related Questions