Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
220
Merge Requests
220
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
2a34c23b
Commit
2a34c23b
authored
Jul 04, 2008
by
Dries
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Patch
#258397
by Dries: fixed spoofing attack.
parent
1415340c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
14 deletions
+17
-14
includes/bootstrap.inc
includes/bootstrap.inc
+17
-14
No files found.
includes/bootstrap.inc
View file @
2a34c23b
...
...
@@ -1175,22 +1175,25 @@ function ip_address($reset = false) {
if
(
!
isset
(
$ip_address
)
||
$reset
)
{
$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'
]));
if
(
variable_get
(
'reverse_proxy'
,
0
))
{
if
(
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'
]));
}
}
}
// When Drupal is run in a cluster environment, REMOTE_ADDR contains the IP
// address of a server in the cluster, while the IP address of the client is
// stored in HTTP_X_CLUSTER_CLIENT_IP.
if
(
array_key_exists
(
'HTTP_X_CLUSTER_CLIENT_IP'
,
$_SERVER
))
{
$ip_address
=
$_SERVER
[
'HTTP_X_CLUSTER_CLIENT_IP'
];
// When Drupal is run in a cluster environment, REMOTE_ADDR contains the IP
// address of a server in the cluster, while the IP address of the client is
// stored in HTTP_X_CLUSTER_CLIENT_IP.
if
(
array_key_exists
(
'HTTP_X_CLUSTER_CLIENT_IP'
,
$_SERVER
))
{
$ip_address
=
$_SERVER
[
'HTTP_X_CLUSTER_CLIENT_IP'
];
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment