ip_address

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

includes/bootstrap.inc, строка 1182

Версии
6
ip_address()

Если друпал расположен за инвертированным прокси-сервером, мы используем заголовок X-Forwarded-For вместо $_SERVER['REMOTE_ADDR'], который может быть адресом прокси-сервера, а не клиента.

Возвращаемое значение

IP адрес клиентской машины, скоррекцией на прокси-сервер.

▾ 12 функции вызывают ip_address()

comment_save in modules/comment/comment.module
Сохраняет новый или измененный комментарий.
drupal_anonymous_user in includes/bootstrap.inc
Формирует объект $user со значениями по умолчанию для анонимного пользователя.
flood_is_allowed in includes/common.inc
Check if the current visitor (hostname/IP) is allowed to proceed with the specified event.
flood_register_event in includes/common.inc
Register an event for the current visitor (hostname/IP) to the flood control mechanism.
poll_cancel in modules/poll/poll.module
Submit callback for poll_cancel_form
poll_load in modules/poll/poll.module
Implementation of hook_load().
poll_vote in modules/poll/poll.module
Submit handler for processing a vote
sess_write in includes/session.inc
statistics_exit in modules/statistics/statistics.module
Implementation of hook_exit().
user_block_ip_action in modules/user/user.module
Implementation of a Drupal action. Adds an access rule that blocks the user's IP address.
watchdog in includes/bootstrap.inc
Записывает сообщение в системный журнал ошибок.
_drupal_bootstrap in includes/bootstrap.inc

Код

<?php
function ip_address() {
  static $ip_address = NULL;

  if (!isset($ip_address)) {
    $ip_address = $_SERVER['REMOTE_ADDR'];
    if (variable_get('reverse_proxy', 0) && array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {
      // 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());
      if (!empty($reverse_proxy_addresses) && in_array($ip_address, $reverse_proxy_addresses, TRUE)) {
        // If there are several arguments, we need to check the most
        // recently added one, i.e. the last one.
        $ip_address = array_pop(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']));
      }
    }
  }

  return $ip_address;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему