How to learn the guest's ip

How to learn the guest's ip

In management systems of Internet resources which can be used by both authorized users, and the unregistered visitors the scripts carry the last to separate group. In most cases in the control panel this group of the non-authorized users of the website is called "Guests". If definition of the IP address of the authorized visitors, as a rule, is standard function of scripts, then for group "Guests" obtaining this parameter can be not such simple business.


1. If the output of the IP address of the unauthorized user of a chat, a forum, the blog or other similar web resource is provided by vendor of scripts on the basis of which this resource works, you need to include the necessary option only. By default it is deactivated to save Web server resources. Look for this installation in settings of a management system. If to find it independently it will not turn out, read the description, contact support of vendor of a script or ask a question at a forum of users of your system.

2. The script can not have such setup, but if in its internal operations the function of definition the IP address is used, it can try to be involved also in your purposes. It will be for this purpose necessary to make changes to the system code therefore from you some skills of work with initial codes of modules in management systems of the websites or server programming languages will be required - usually such scripts are written in the PHP language. Open the source code of the page in which you want to see the guest's IP address, define the variable containing the necessary value, and place it in the right place. For example, in widely used UCOZ management system for an output of this value it is necessary to insert the code of $ _IP_ADDRESS$ into the page.

3. As a last resort, it is possible to use own function of definition the IP address in the PHP language. This option will be suitable for systems which allow to insert into pages the code in this language. Certainly, such way will demand a bigger level of knowledge of language. You should program independently an output in the IP addresses page, and function of its definition can look so:

function getIPaddress () {
$guestIP = getenv ('HTTP_CLIENT_IP') or of $guestIP = getenv ('HTTP_X_FORWARDED_FOR') or of $guestIP = getenv ('REMOTE_ADDR');
return trim (preg_replace ('#^ ([^]+) (. *) ?#', '$1', $guestIP));

Author: «MirrorInfo» Dream Team