From 48955c372c9c9abe986aae0609420bf8fd33a629 Mon Sep 17 00:00:00 2001
From: afanucchi <32469691+afanucchi@users.noreply.github.com>
Date: Wed, 9 Oct 2019 09:04:36 +1100
Subject: [PATCH] Registrations page: Parse for LAN IP in "Contact" field
(#4617)
* Registrations XML from Freeswitch contains invalid characters '>' and '<' in the contact field; stripped. Registrations does not parse the Freeswitch 'Contact' field for a Yealink LAN IP address; added condition.
* Fix the indentation.
---
app/registrations/resources/classes/registrations.php | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/app/registrations/resources/classes/registrations.php b/app/registrations/resources/classes/registrations.php
index 2660719d75..23df699d9d 100644
--- a/app/registrations/resources/classes/registrations.php
+++ b/app/registrations/resources/classes/registrations.php
@@ -54,6 +54,8 @@ if (!class_exists('registrations')) {
if ($xml_response == "Invalid Profile!") { $xml_response = "".$text['label-message'].""; }
$xml_response = str_replace("", "", $xml_response);
$xml_response = str_replace("", "", $xml_response);
+ $xml_response = str_replace("<", "", $xml_response);
+ $xml_response = str_replace(">", "", $xml_response);
if (strlen($xml_response) > 101) {
try {
$xml = new SimpleXMLElement($xml_response);
@@ -117,6 +119,10 @@ if (!class_exists('registrations')) {
}
$registrations[$id]['lan-ip'] = $lan_ip;
}
+ else if (preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $row['contact'], $ip_match)) {
+ $lan_ip = preg_replace('/_/', '.', $ip_match[0]);
+ $registrations[$id]['lan-ip'] = "$lan_ip";
+ }
else {
$registrations[$id]['lan-ip'] = '';
}
@@ -207,4 +213,4 @@ $registrations = $obj->get('all');
print($registrations);
*/
-?>
\ No newline at end of file
+?>