diff --git a/emhttp/plugins/dynamix/NotificationAgents.page b/emhttp/plugins/dynamix/NotificationAgents.page index 66c1c4cb4..dfb7e2bec 100644 --- a/emhttp/plugins/dynamix/NotificationAgents.page +++ b/emhttp/plugins/dynamix/NotificationAgents.page @@ -91,69 +91,78 @@ function initDropdown() { Agent as $agent) { - $name = str_replace(' ','_',$agent->Name); - $enabledAgent = agent_fullname("$name.sh", "enabled"); - $disabledAgent = agent_fullname("$name.sh", "disabled"); - if (is_file($disabledAgent)) { - $file = $disabledAgent; - if (is_file($enabledAgent)) unlink($enabledAgent); - } else { - $file = $enabledAgent; - } - $values = []; - $script = ""; - if (is_file($file)) { - preg_match("/[#]{6,100}([^#]*?)[#]{6,100}/si", file_get_contents($file), $match); - if (isset($match[1])) { - foreach (explode(PHP_EOL, $match[1]) as $line) { - if (strpos($line, "=")) { - [$k, $v] = my_explode("=",str_replace("\"", "", $line),2); - $values[$k] = $v; +foreach ($xml_files as $xml_file) { + $xml = @simplexml_load_file($xml_file); + if ( ! $xml ) continue; + + if ( isset($xml->Language) ) { + $guiLanguage = ($locale == "" ) ? "en_US" : $locale; + $acceptedLanguages = explode(" ",$xml->Language); + if ( ! in_array($guiLanguage,$acceptedLanguages) ) + continue; + } + $name = str_replace(' ','_',$xml->Name); + $enabledAgent = agent_fullname("$name.sh", "enabled"); + $disabledAgent = agent_fullname("$name.sh", "disabled"); + if (is_file($disabledAgent)) { + $file = $disabledAgent; + if (is_file($enabledAgent)) unlink($enabledAgent); + } else { + $file = $enabledAgent; + } + $values = []; + $script = ""; + if (is_file($file)) { + preg_match("/[#]{6,100}([^#]*?)[#]{6,100}/si", file_get_contents($file), $match); + if (isset($match[1])) { + foreach (explode(PHP_EOL, $match[1]) as $line) { + if (strpos($line, "=")) { + [$k, $v] = my_explode("=",str_replace("\"", "", $line),2); + $values[$k] = $v; + } } } } - } - foreach (explode(PHP_EOL,(String) $agent->Script) as $line) if (trim($line)) $script .= trim($line)."{1}"; - echo '
'.str_replace('_',' ',$name).''.(is_file($enabledAgent) ? ''._("Enabled").'' : ''._("Disabled").'').'
'; - echo '
'; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '
'._("Agent function").':
'; - echo ''; - foreach ($agent->Variables->children() as $v) { - $vName = preg_replace('#\[([^\]]*)\]#', '<$1>', (string) $v); - $vDesc = ucfirst(strtolower(preg_replace('#\[([^\]]*)\]#', '<$1>', $v->attributes()->Desc))); - $vDefault = preg_replace('#\[([^\]]*)\]#', '<$1>', $v->attributes()->Default); - $vHelp = preg_replace('#\[([^\]]*)\]#', '<$1>', $v->attributes()->Help); - echo "
$vDesc:
"; - if (preg_match('/title|message/', $vDesc)) { - echo ''; - } else { - echo ''; + foreach (explode(PHP_EOL,(String) $xml->Script) as $line) if (trim($line)) $script .= trim($line)."{1}"; + echo '
'.str_replace('_',' ',$name).''.(is_file($enabledAgent) ? ''._("Enabled").'' : ''._("Disabled").'').'
'; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo '
'._("Agent function").':
'; + echo ''; + foreach ($xml->Variables->children() as $v) { + $vName = preg_replace('#\[([^\]]*)\]#', '<$1>', (string) $v); + $vDesc = ucfirst(strtolower(preg_replace('#\[([^\]]*)\]#', '<$1>', $v->attributes()->Desc))); + $vDefault = preg_replace('#\[([^\]]*)\]#', '<$1>', $v->attributes()->Default); + $vHelp = preg_replace('#\[([^\]]*)\]#', '<$1>', $v->attributes()->Help); + echo "
$vDesc:
"; + if (preg_match('/title|message/', $vDesc)) { + echo ''; + } else { + echo ''; + } + echo '
'; + if ($vHelp) echo '
'.$vHelp.'
'; } - echo '
'; - if ($vHelp) echo '
'.$vHelp.'
'; - } - echo '
 
'; - echo ''; - if (is_file($file)) { - echo ''; - echo '' : ' disabled>'); - } - echo '
'; + echo '
 
'; + echo ''; + if (is_file($file)) { + echo ''; + echo '' : ' disabled>'); + } + echo '
'; + } ?> diff --git a/emhttp/plugins/dynamix/agents/Bark.xml b/emhttp/plugins/dynamix/agents/Bark.xml new file mode 100644 index 000000000..459174c0b --- /dev/null +++ b/emhttp/plugins/dynamix/agents/Bark.xml @@ -0,0 +1,29 @@ + + + Bark + + PUSHURL + GROUP + SOUND + TITLE + MESSAGE + + + + diff --git a/emhttp/plugins/dynamix/agents/Boxcar.xml b/emhttp/plugins/dynamix/agents/Boxcar.xml new file mode 100644 index 000000000..79344fc7e --- /dev/null +++ b/emhttp/plugins/dynamix/agents/Boxcar.xml @@ -0,0 +1,27 @@ + + + Boxcar + + ACCESS_TOKEN + TITLE + MESSAGE + + + diff --git a/emhttp/plugins/dynamix/agents/Discord.xml b/emhttp/plugins/dynamix/agents/Discord.xml new file mode 100644 index 000000000..652af1218 --- /dev/null +++ b/emhttp/plugins/dynamix/agents/Discord.xml @@ -0,0 +1,199 @@ + + + Discord + + WEBH_URL + SERVER_ICON + DISCORD_TAG_ID + + + diff --git a/emhttp/plugins/dynamix/agents/Gotify.xml b/emhttp/plugins/dynamix/agents/Gotify.xml new file mode 100644 index 000000000..049b942f0 --- /dev/null +++ b/emhttp/plugins/dynamix/agents/Gotify.xml @@ -0,0 +1,39 @@ + + + Gotify + + SERVER_URL + APP_TOKEN + TITLE + MESSAGE + + + diff --git a/emhttp/plugins/dynamix/agents/Prowl.xml b/emhttp/plugins/dynamix/agents/Prowl.xml new file mode 100644 index 000000000..aaef58a82 --- /dev/null +++ b/emhttp/plugins/dynamix/agents/Prowl.xml @@ -0,0 +1,40 @@ + + + Prowl + + API_KEY + APP_NAME + TITLE + MESSAGE + + + diff --git a/emhttp/plugins/dynamix/agents/PushBits.xml b/emhttp/plugins/dynamix/agents/PushBits.xml new file mode 100644 index 000000000..063054774 --- /dev/null +++ b/emhttp/plugins/dynamix/agents/PushBits.xml @@ -0,0 +1,62 @@ + + + PushBits + + SERVER_URL + APP_TOKEN + TITLE + MESSAGE + + + + + Pushbullet + + TOKEN + TITLE + MESSAGE + + + diff --git a/emhttp/plugins/dynamix/agents/Pushover.xml b/emhttp/plugins/dynamix/agents/Pushover.xml new file mode 100644 index 000000000..fde95484a --- /dev/null +++ b/emhttp/plugins/dynamix/agents/Pushover.xml @@ -0,0 +1,38 @@ + + + Pushover + + USER_KEY + APP_TOKEN + MESSAGE + + + diff --git a/emhttp/plugins/dynamix/agents/Pushplus.xml b/emhttp/plugins/dynamix/agents/Pushplus.xml new file mode 100644 index 000000000..5ff40697f --- /dev/null +++ b/emhttp/plugins/dynamix/agents/Pushplus.xml @@ -0,0 +1,40 @@ + + + Pushplus + + TOKEN + TOPIC + CHANNEL + WEBHOOK + CALLBACKURL + TITLE + MESSAGE + + + diff --git a/emhttp/plugins/dynamix/agents/ServerChan.xml b/emhttp/plugins/dynamix/agents/ServerChan.xml new file mode 100644 index 000000000..4d02aa59b --- /dev/null +++ b/emhttp/plugins/dynamix/agents/ServerChan.xml @@ -0,0 +1,31 @@ + + + ServerChan + + SENDKEY + CHANNEL + OPENID + TITLE + MESSAGE + + + diff --git a/emhttp/plugins/dynamix/agents/Slack.xml b/emhttp/plugins/dynamix/agents/Slack.xml new file mode 100644 index 000000000..0ccfb5baf --- /dev/null +++ b/emhttp/plugins/dynamix/agents/Slack.xml @@ -0,0 +1,22 @@ + + + Slack + + WEBH_URL + APP_NAME + TITLE + MESSAGE + + + diff --git a/emhttp/plugins/dynamix/agents/Telegram.xml b/emhttp/plugins/dynamix/agents/Telegram.xml new file mode 100644 index 000000000..946bab3ab --- /dev/null +++ b/emhttp/plugins/dynamix/agents/Telegram.xml @@ -0,0 +1,43 @@ + + + Telegram + + BOT_TOKEN + TITLE + MESSAGE + + + diff --git a/emhttp/plugins/dynamix/agents/ntfy.sh.xml b/emhttp/plugins/dynamix/agents/ntfy.sh.xml new file mode 100644 index 000000000..0085a504e --- /dev/null +++ b/emhttp/plugins/dynamix/agents/ntfy.sh.xml @@ -0,0 +1,42 @@ + + + ntfy.sh + + SERVER_URL + NTFY_TOKEN + TOPIC + TITLE + MESSAGE + + + diff --git a/emhttp/plugins/dynamix/include/NotificationAgents.xml b/emhttp/plugins/dynamix/include/NotificationAgents.xml deleted file mode 100644 index fecccdeb0..000000000 --- a/emhttp/plugins/dynamix/include/NotificationAgents.xml +++ /dev/null @@ -1,677 +0,0 @@ - - - - Boxcar - - ACCESS_TOKEN - TITLE - MESSAGE - - - - - Discord - - WEBH_URL - SERVER_ICON - DISCORD_TAG_ID - - - - - Gotify - - SERVER_URL - APP_TOKEN - TITLE - MESSAGE - - - - - Join - - API_KEY - TITLE - MESSAGE - - - - - ntfy.sh - - SERVER_URL - NTFY_TOKEN - TOPIC - TITLE - MESSAGE - - - - - Prowl - - API_KEY - APP_NAME - TITLE - MESSAGE - - - - - PushBits - - SERVER_URL - APP_TOKEN - TITLE - MESSAGE - - - - - Pushbullet - - TOKEN - TITLE - MESSAGE - - - - - Pushover - - USER_KEY - APP_TOKEN - MESSAGE - - - - - Pushplus - - TOKEN - TOPIC - CHANNEL - WEBHOOK - CALLBACKURL - TITLE - MESSAGE - - - - - ServerChan - - SENDKEY - CHANNEL - OPENID - TITLE - MESSAGE - - - - - Slack - - WEBH_URL - APP_NAME - TITLE - MESSAGE - - - - - Telegram - - BOT_TOKEN - TITLE - MESSAGE - - - - - Bark - - PUSHURL - GROUP - SOUND - TITLE - MESSAGE - - - - - Wxwork - - CropId - AgentId - Secret - ProxyUrl - TITLE - MESSAGE - - - -