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
This commit is contained in:
Tony Murray
2019-05-14 08:29:34 -05:00
committed by GitHub
parent b58527cc84
commit 312d35dd95

View File

@@ -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',