Skip to content

Commit

Permalink
https://github.com/opencart/opencart/issues/13927
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkerr committed May 10, 2024
1 parent 3c4a930 commit 6efe939
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
19 changes: 18 additions & 1 deletion upload/system/helper/general.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
<?php
// String
/*
* @return string
*/
function oc_get_ip(): string {
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
return $_SERVER['HTTP_X_FORWARDED_FOR'];
} elseif (!empty($_SERVER['HTTP_CLIENT_IP'])) {
return $_SERVER['HTTP_CLIENT_IP'];
} else {
return $_SERVER['REMOTE_ADDR'];
}
}

/**
* @param string $string
*
* @return string
*/
function oc_strlen(string $string): int {
return mb_strlen($string);
}
Expand Down
6 changes: 2 additions & 4 deletions upload/system/startup.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@
$_SERVER['HTTPS'] = false;
}

// Check IP if forwarded IP
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
} elseif (!empty($_SERVER['HTTP_CLIENT_IP'])) {
// Check IP
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CLIENT_IP'];
}

Expand Down

0 comments on commit 6efe939

Please sign in to comment.