Welcome Guest, Not a member yet? Register   Sign In
How can I get my visitor IP address and MAC address
#1

[eluser]chengfeng[/eluser]
Does CI have any code to get the IP and MAC address from the user that log-in with system?
#2

[eluser]InsiteFX[/eluser]
This is in the CI input library.
Code:
$ip_addr = $this->input->ip_address();

// or this if you need the CI instance...
$ip_addr = $this->CI->input->ip_address();

InsiteFX
#3

[eluser]Berserk[/eluser]
i use this function to get user's real ip
Code:
//-----------------
    function get_client_ip() {
        if (!empty($_SERVER['HTTP_CLIENT_IP'])) {   //check ip from share internet
            $ip = $_SERVER['HTTP_CLIENT_IP'];
        } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {   //to check ip is pass from proxy
            $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
        } else {
            $ip = $_SERVER['REMOTE_ADDR'];
        }
        return $ip;
    }
#4

[eluser]InsiteFX[/eluser]
If you check out the CodeIgniter Input Library source it does just all of what you mentioned above!

InsiteFX
#5

[eluser]Twisted1919[/eluser]
For the MAC issue, it is not possible with PHP .
Not even if you can access exec() in linux environment(this will give a limited answer) .
At most, you can get the MAC of the computers in the same LAN(exec() here), but that doesn't help to much, basically because the MAC is not transmitted over network.
#6

[eluser]Unknown[/eluser]
[quote author="InsiteFX" date="1297413135"]This is in the CI input library.
Code:
$ip_addr = $this->input->ip_address();

// or this if you need the CI instance...
$ip_addr = $this->CI->input->ip_address();

InsiteFX[/quote]



Thank you InsiteFX, This worked well for me!




Theme © iAndrew 2016 - Forum software by © MyBB