jetpack_protect_get_ip

Jetpack Protect Get IP.

Description

jetpack_protect_get_ip(); 

Usage

  1. if ( !function_exists( 'jetpack_protect_get_ip' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/modules/protect/shared-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = jetpack_protect_get_ip(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/modules/protect/shared-functions.php  
  1. function jetpack_protect_get_ip() { 
  2.  
  3. $trusted_header_data = get_site_option( 'trusted_ip_header' ); 
  4.  
  5. if ( isset( $trusted_header_data->trusted_header ) && isset( $_SERVER[ $trusted_header_data->trusted_header ] ) ) { 
  6. $ip = $_SERVER[ $trusted_header_data->trusted_header ]; 
  7. $segments = $trusted_header_data->segments; 
  8. $reverse_order = $trusted_header_data->reverse; 
  9. } else { 
  10. $ip = $_SERVER['REMOTE_ADDR']; 
  11.  
  12. $ips = explode( ', ', $ip ); 
  13.  
  14. if ( ! isset( $segments ) || ! $segments ) { 
  15. $segments = 1; 
  16. if ( isset( $reverse_order ) && $reverse_order ) { 
  17. $ips = array_reverse( $ips ); 
  18.  
  19.  
  20.  
  21. $ip_count = count( $ips ); 
  22.  
  23. if ( 1 == $ip_count ) { 
  24. return jetpack_clean_ip( $ips[0] ); 
  25. } elseif ( $ip_count >= $segments ) { 
  26. $the_one = $ip_count - $segments; 
  27.  
  28. return jetpack_clean_ip( $ips[ $the_one ] ); 
  29. } else { 
  30. return jetpack_clean_ip( $_SERVER['REMOTE_ADDR'] );