Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3751810
D1624.id4147.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D1624.id4147.diff
View Options
diff --git a/core.php b/core.php
--- a/core.php
+++ b/core.php
@@ -5,6 +5,8 @@
use Keruald\OmniTools\Debug\Debugger;
use Keruald\OmniTools\Identifiers\UUID;
use Keruald\OmniTools\Network\IP;
+use Keruald\OmniTools\HTTP\Requests\RemoteAddress;
+use Keruald\OmniTools\HTTP\Requests\Request;
use Keruald\OmniTools\Strings\Multibyte\StringUtilities;
/**
@@ -113,17 +115,10 @@
*
* @param string $value the header value
* @return string the IP part
+ * @deprecated
*/
function extract_client_ip_from_header ($value) {
- if (strpos($value, ',') !== false) {
- //Header contains 'clientIP, proxyIP, anotherProxyIP'
- //The first value is so the one to return.
- //See draft-ietf-appsawg-http-forwarded-10.
- $ips = explode(',', $value, 2);
- return trim($ips[0]);
- }
-
- return $value;
+ return (new RemoteAddress($value))->getClientAddress();
}
/**
@@ -133,28 +128,8 @@
* which takes in consideration proxy values, blindly trusted.
*
* @return string the remote address
+ * @deprecated Use Keruald\OmniTools\HTTP\Requests\Request::getRemoteAddress()
*/
function get_remote_addr () {
- $candidates = [
- //Standard header provided by draft-ietf-appsawg-http-forwarded-10
- 'HTTP_X_FORWARDED_FOR',
-
- //Legacy headers
- 'HTTP_CLIENT_IP',
- 'HTTP_FORWARDED',
- 'HTTP_FORWARDED_FOR',
- 'HTTP_X_CLUSTER_CLIENT_IP',
- 'HTTP_X_FORWARDED',
-
- //Default header if no proxy information could be detected
- 'REMOTE_ADDR',
- ];
-
- foreach ($candidates as $candidate) {
- if (array_key_exists($candidate, $_SERVER)) {
- return extract_client_ip_from_header($_SERVER[$candidate]);
- }
- }
-
- return '';
+ return Request::getRemoteAddress();
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 18, 12:47 (17 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2250669
Default Alt Text
D1624.id4147.diff (1 KB)
Attached To
Mode
D1624: Switch remote address functions to Keruald\OmniTools\HTTP\Requests
Attached
Detach File
Event Timeline
Log In to Comment