php - How to get ip address of client connected to remote desktop -


i need retrieve ip address of client connected through remote desktop windows server.

i need possibly through php.

so client connects remote desktop , run browser php page on server client connected.

if run print_r($_server) get:

array ( ... [http_host] => 10.80.3.107 //this server ip ... [server_name] => 10.80.3.107 //this server ip [server_addr] => 10.80.3.107 //this server ip [server_port] => 80 [remote_addr] => 10.80.3.107 //this server ip -> need client ip here ... ) 

is there solution?

can use cmd info , take php using exec?

i can't use netstat -n | find ":3389" | find "established" because gives me client connected , not 1 need.

thanks!

this can achieve using $_server['remote_addr'] or $_server['remote_host'] variables of php.

the below both functions equivalent difference in how , values retrieved.

in first function have used getenv() used value of environment variable in php

// function client ip address using getenv() function

    function get_client_ipaddress() {      $ip_address = '';      if (getenv('http_client_ip'))          $ip_address = getenv('http_client_ip');      else if(getenv('http_x_forwarded_for'))          $ip_address = getenv('http_x_forwarded_for'");      else if(getenv('http_x_forwarded'))          $ip_address = getenv('http_x_forwarded');      else if(getenv('http_forwarded_for'))          $ip_address = getenv('http_forwarded_for');      else if(getenv('http_forwarded'))         $ip_address = getenv('http_forwarded');      else if(getenv('remote_addr'))          $ip_address = getenv('remote_addr');      else          $ip_address = 'unknown';       return $ip_address;  } 

without using getenv() function:

    function get_client_ipaddress() {      $ip_address = '';      if ($_server['http_client_ip'])          $ip_address = $_server['http_client_ip'];      else if($_server['http_x_forwarded_for'])          $ip_address = $_server['http_x_forwarded_for'];      else if($_server['http_x_forwarded'])          $ip_address = $_server['http_x_forwarded'];      else if($_server['http_forwarded_for'])          $ip_address = $_server['http_forwarded_for'];      else if($_server['http_forwarded'])          $ip_address = $_server['http_forwarded'];      else if($_server['remote_addr'])          $ip_address = $_server['remote_addr'];      else          $ip_address = 'unknown';       return $ip_address;  } 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -