function ip_address

cis7 ip_address()
cle7 ip_address()
elmsmedia7 ip_address()
icor7 ip_address()
meedjum_blog7 ip_address()
mooc7 ip_address()

Returns the IP address of the client machine.

If Drupal is behind a reverse proxy, we use the X-Forwarded-For header instead of $_SERVER['REMOTE_ADDR'], which would be the IP address of the proxy server, and not the client's. The actual header name can be configured by the reverse_proxy_header variable.

Return value

IP address of client machine, adjusted for reverse proxy and/or cluster environments.

20 calls to ip_address()
comment_save in modules/comment/comment.module
Accepts a submission of new or changed comment content.
drupal_anonymous_user in includes/
Generates a default anonymous $user object.
drupal_block_denied in includes/
Handles denied users.
entity_iframe_statistics_exit in sites/all/modules/elmsln_contrib/entity_iframe/modules/entity_iframe_statistics/entity_iframe_statistics.module
Implements hook_exit().
flood_clear_event in includes/
Makes the flood control mechanism forget an event for the current visitor.

... See full list


includes/, line 2890
Functions that need to be loaded on every Drupal request.


function ip_address() {
  $ip_address = &drupal_static(__FUNCTION__);

  if (!isset($ip_address)) {
    $ip_address = $_SERVER['REMOTE_ADDR'];

    if (variable_get('reverse_proxy', 0)) {
      $reverse_proxy_header = variable_get('reverse_proxy_header', 'HTTP_X_FORWARDED_FOR');
      if (!empty($_SERVER[$reverse_proxy_header])) {
        // If an array of known reverse proxy IPs is provided, then trust
        // the XFF header if request really comes from one of them.
        $reverse_proxy_addresses = variable_get('reverse_proxy_addresses', array());

        // Turn XFF header into an array.
        $forwarded = explode(',', $_SERVER[$reverse_proxy_header]);

        // Trim the forwarded IPs; they may have been delimited by commas and spaces.
        $forwarded = array_map('trim', $forwarded);

        // Tack direct client IP onto end of forwarded array.
        $forwarded[] = $ip_address;

        // Eliminate all trusted IPs.
        $untrusted = array_diff($forwarded, $reverse_proxy_addresses);

        // The right-most IP is the most specific we can trust.
        $ip_address = array_pop($untrusted);

  return $ip_address;



Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/ in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/
The website encountered an unexpected error. Please try again later.