IP Address of current computer
#2
Posted 21 December 2010 - 02:24 AM
If you need the IP address of the user that is visiting your pages then you can use getUserHostAddress() - http://www.yiiframew...tAddress-detail
#3
Posted 21 December 2010 - 03:08 AM
mdomba, on 21 December 2010 - 02:24 AM, said:
If you need the IP address of the user that is visiting your pages then you can use getUserHostAddress() - http://www.yiiframew...tAddress-detail
I want to IP of computer from where the user has logged in or created new account to login. I want to use in login Model.
#4
Posted 21 December 2010 - 03:32 AM
Example:
<?php echo Yii::app()->request->userHostAddress; ?>
#6
Posted 22 December 2010 - 01:45 PM
something like this would solve it
Extensions:
translate modue - module to handle translations
multiActiveRecord - db selection in models
redisCache - redis cache component
mpCpanel - interact with cpanel api
mUploadify - use uploadify uploader in your application
Gustavo Salomé Silva
#7
Posted 23 December 2010 - 06:00 AM
Can you explain, how a user should be able to fake the sender IP address? The $_SERVER['REMOTE_ADDR'] (used in getUserHostAddress()) is not related to the 'Host' header in the HTTP request. It's rather the IP address that PHP/Apache obtains from the network stack. I see no way how this numeric value could in any way get altered by the user.
EDIT:
Fixed typo, it's REMOTE_ADDR, not REMOTE_HOST
This post has been edited by Mike: 23 December 2010 - 06:02 AM
#8
Posted 23 December 2010 - 06:41 AM
Some proxy's (not so effective ones) in turn set another variable to the original users wan ip... but if a proxy is good then you cannot get in any way the original user wan ip...
On top of that there are many variants that could be set by a proxy server like:
$_SERVER["HTTP_VIA"] $_SERVER["CLIENT_IP"] $_SERVER["HTTP_CLIENT_IP"] $_SERVER["HTTP_FROM"] $_SERVER["HTTP_FORWARDED"] $_SERVER["HTTP_X_FORWARDED"] $_SERVER["HTTP_X_FORWARDED_FOR"] $_SERVER["HTTP_PROXY_REMOTE_ADDR"] $_SERVER["HTTP_PROXY_CONNECTION"] $_SERVER["HTTP_REMOTE_IP"] $_SERVER["HTTP_SCANNER_HOST"]
#9
Posted 23 December 2010 - 08:22 AM
Ps.: in the code I wrote in the link posted only checks for the most commom proxys, like aol and a couple others
Extensions:
translate modue - module to handle translations
multiActiveRecord - db selection in models
redisCache - redis cache component
mpCpanel - interact with cpanel api
mUploadify - use uploadify uploader in your application
Gustavo Salomé Silva
#10
Posted 05 April 2011 - 12:58 AM
Any ideas why?
#11
Posted 05 April 2011 - 01:17 AM
#12
Posted 05 April 2011 - 01:22 AM
If you talk about a public server, do you maybe have a reverse proxy in front of your Apache (like nginx)?
#14
Posted 19 April 2011 - 09:50 AM
proxy_set_header REMOTE_ADDR $remote_addr;
#15
Posted 01 May 2011 - 07:38 PM
Mike, on 19 April 2011 - 09:50 AM, said:
proxy_set_header REMOTE_ADDR $remote_addr;
Ah yes, of course. Thanks for the heads up.
Decided to use the Apache Request Header: "X-Forwarded-For" to grab this info.

Help
This topic is locked














