From 312d35dd955f36f94feaec593a3b4a5cd2c0f67f Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Tue, 14 May 2019 08:29:34 -0500 Subject: [PATCH] SMS Eagle reduce chances of user mis-configuration (#10223) * Merge pull request #54 from librenms-plugins/revert-52-PluginNamespaceCorrection Revert "Adding namespace LibreNMS\Plugins;" SMS Eagle prevent user mis-configuration Only allow URLs, but automatically append http:// to ones that are only hostname * restore whitespace --- LibreNMS/Alert/Transport/Smseagle.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/LibreNMS/Alert/Transport/Smseagle.php b/LibreNMS/Alert/Transport/Smseagle.php index 6c39ce605d..147287891f 100644 --- a/LibreNMS/Alert/Transport/Smseagle.php +++ b/LibreNMS/Alert/Transport/Smseagle.php @@ -44,7 +44,8 @@ class Smseagle extends Transport 'to' => implode(',', $opts['to']), 'message' => $obj['title'], ]; - $url = 'http://' . $opts['url'] . '/index.php/http_api/send_sms?' . http_build_query($params); + $url = starts_with($opts['url'], 'http') ? '' : 'http://'; + $url .= $opts['url'] . '/index.php/http_api/send_sms?' . http_build_query($params); $curl = curl_init($url); set_curl_proxy($curl); @@ -64,7 +65,7 @@ class Smseagle extends Transport return [ 'config' => [ [ - 'title' => 'SMSEagle Host', + 'title' => 'SMSEagle Base URL', 'name' => 'smseagle-url', 'descr' => 'SMSEagle Host', 'type' => 'text', @@ -89,7 +90,7 @@ class Smseagle extends Transport ], ], 'validation' => [ - 'smseagle-url' => 'required|string', + 'smseagle-url' => 'required|url', 'smseagle-user' => 'required|string', 'smseagle-pass' => 'required|string', 'smseagle-mobiles' => 'required',