Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit b287a85

Browse files
author
Christopher Smit
committed
Fixed the checkip.dydns.com function to have a fallback
1 parent d081f18 commit b287a85

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

Helpers/App.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Wrapper\Helpers;
44

5+
use Throwable;
6+
57
class App
68
{
79
public function toXML($array, $rootElement = null, $xml = null) {
@@ -34,9 +36,13 @@ public function toXML($array, $rootElement = null, $xml = null) {
3436

3537
public function getIpAddress(): string
3638
{
37-
$externalContent = file_get_contents('http://checkip.dyndns.com/');
38-
preg_match('/Current IP Address: \[?([:.0-9a-fA-F]+)\]?/', $externalContent, $m);
39-
return $m[1];
39+
try {
40+
$externalContent = @file_get_contents('http://checkip.dyndns.com/');
41+
preg_match('/Current IP Address: \[?([:.0-9a-fA-F]+)\]?/', $externalContent ?? "", $m);
42+
return $m[1] ?? $_SERVER['REMOTE_ADDR'];
43+
} catch (Throwable $ex) {
44+
return $_SERVER['REMOTE_ADDR'];
45+
}
4046
}
4147

4248
public function initializeSoapClient($WSDL, $KeyCert = "", $Location = "") {

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "A wrapper to ease integration into Wirecard (previously MyGate) webservices.",
44
"license": "MIT",
55
"minimum-stability": "stable",
6-
"version": "1.1.1",
6+
"version": "1.1.2",
77
"authors": [
88
{
99
"name": "Christopher Smit",

0 commit comments

Comments
 (0)