mirror of
https://github.com/librenms/librenms.git
synced 2024-09-21 18:38:25 +00:00
ac1cd1296b
Windows puts line returns as \r\n, when parsing LibreNMS previously left the \r, which could cause issues Centralize the code so we just have one place to fix. Try to fix SMSEagle, it had the options wrong (copied from another transport)
41 lines
1.0 KiB
PHP
41 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace LibreNMS\Alert;
|
|
|
|
use LibreNMS\Interfaces\Alert\Transport as TransportInterface;
|
|
|
|
abstract class Transport implements TransportInterface
|
|
{
|
|
protected $config;
|
|
|
|
/**
|
|
* Transport constructor.
|
|
* @param null $transport_id
|
|
*/
|
|
public function __construct($transport_id = null)
|
|
{
|
|
if (!empty($transport_id)) {
|
|
$sql = "SELECT `transport_config` FROM `alert_transports` WHERE `transport_id`=?";
|
|
$this->config = json_decode(dbFetchCell($sql, [$transport_id]), true);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Helper function to parse free form text box defined in ini style to key value pairs
|
|
*
|
|
* @param string $input
|
|
* @return array
|
|
*/
|
|
protected function parseUserOptions($input)
|
|
{
|
|
$options = [];
|
|
foreach (explode(PHP_EOL, $input) as $option) {
|
|
if (str_contains($option, '=')) {
|
|
list($k,$v) = explode('=', $option, 2);
|
|
$options[$k] = trim($v);
|
|
}
|
|
}
|
|
return $options;
|
|
}
|
|
}
|