mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
mod/notification-email: move $QuotedPrintable (from global-functions)
This is used for e-mail only...
This commit is contained in:
parent
329bef94df
commit
a953a8fa59
2 changed files with 37 additions and 37 deletions
|
@ -42,7 +42,6 @@
|
|||
:global NotificationFunctions;
|
||||
:global ParseKeyValueStore;
|
||||
:global PrettyPrint;
|
||||
:global QuotedPrintable;
|
||||
:global RandomDelay;
|
||||
:global Read;
|
||||
:global RequiredRouterOS;
|
||||
|
@ -612,42 +611,6 @@
|
|||
:put [ $CharacterReplace $Input ("\n") ("\n\r") ];
|
||||
}
|
||||
|
||||
# convert string to quoted-printable
|
||||
:global QuotedPrintable do={
|
||||
:local Input [ :tostr $1 ];
|
||||
|
||||
:if ([ :len $Input ] = 0) do={
|
||||
:return $Input;
|
||||
}
|
||||
|
||||
:local Return "";
|
||||
:local Chars ("\80\81\82\83\84\85\86\87\88\89\8A\8B\8C\8D\8E\8F\90\91\92\93\94\95\96\97" . \
|
||||
"\98\99\9A\9B\9C\9D\9E\9F\A0\A1\A2\A3\A4\A5\A6\A7\A8\A9\AA\AB\AC\AD\AE\AF\B0\B1\B2\B3" . \
|
||||
"\B4\B5\B6\B7\B8\B9\BA\BB\BC\BD\BE\BF\C0\C1\C2\C3\C4\C5\C6\C7\C8\C9\CA\CB\CC\CD\CE\CF" . \
|
||||
"\D0\D1\D2\D3\D4\D5\D6\D7\D8\D9\DA\DB\DC\DD\DE\DF\E0\E1\E2\E3\E4\E5\E6\E7\E8\E9\EA\EB" . \
|
||||
"\EC\ED\EE\EF\F0\F1\F2\F3\F4\F5\F6\F7\F8\F9\FA\FB\FC\FD\FE\FF");
|
||||
:local Hex { "0"; "1"; "2"; "3"; "4"; "5"; "6"; "7"; "8"; "9"; "A"; "B"; "C"; "D"; "E"; "F" };
|
||||
|
||||
:for I from=0 to=([ :len $Input ] - 1) do={
|
||||
:local Char [ :pick $Input $I ];
|
||||
:local Replace [ :find $Chars $Char ];
|
||||
|
||||
:if ($Char = "=") do={
|
||||
:set Char "=3D";
|
||||
}
|
||||
:if ([ :typeof $Replace ] = "num") do={
|
||||
:set Char ("=" . ($Hex->($Replace / 16 + 8)) . ($Hex->($Replace % 16)));
|
||||
}
|
||||
:set Return ($Return . $Char);
|
||||
}
|
||||
|
||||
:if ($Input = $Return) do={
|
||||
:return $Input;
|
||||
}
|
||||
|
||||
:return ("=\?utf-8\?Q\?" . $Return . "\?=");
|
||||
}
|
||||
|
||||
# delay a random amount of seconds
|
||||
:set RandomDelay do={
|
||||
:global EitherOr;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
:global FlushEmailQueue;
|
||||
:global LogForwardFilterLogForwarding;
|
||||
:global NotificationFunctions;
|
||||
:global QuotedPrintable;
|
||||
:global SendEMail;
|
||||
:global SendEMail2;
|
||||
|
||||
|
@ -144,6 +145,42 @@
|
|||
}
|
||||
}
|
||||
|
||||
# convert string to quoted-printable
|
||||
:global QuotedPrintable do={
|
||||
:local Input [ :tostr $1 ];
|
||||
|
||||
:if ([ :len $Input ] = 0) do={
|
||||
:return $Input;
|
||||
}
|
||||
|
||||
:local Return "";
|
||||
:local Chars ("\80\81\82\83\84\85\86\87\88\89\8A\8B\8C\8D\8E\8F\90\91\92\93\94\95\96\97" . \
|
||||
"\98\99\9A\9B\9C\9D\9E\9F\A0\A1\A2\A3\A4\A5\A6\A7\A8\A9\AA\AB\AC\AD\AE\AF\B0\B1\B2\B3" . \
|
||||
"\B4\B5\B6\B7\B8\B9\BA\BB\BC\BD\BE\BF\C0\C1\C2\C3\C4\C5\C6\C7\C8\C9\CA\CB\CC\CD\CE\CF" . \
|
||||
"\D0\D1\D2\D3\D4\D5\D6\D7\D8\D9\DA\DB\DC\DD\DE\DF\E0\E1\E2\E3\E4\E5\E6\E7\E8\E9\EA\EB" . \
|
||||
"\EC\ED\EE\EF\F0\F1\F2\F3\F4\F5\F6\F7\F8\F9\FA\FB\FC\FD\FE\FF");
|
||||
:local Hex { "0"; "1"; "2"; "3"; "4"; "5"; "6"; "7"; "8"; "9"; "A"; "B"; "C"; "D"; "E"; "F" };
|
||||
|
||||
:for I from=0 to=([ :len $Input ] - 1) do={
|
||||
:local Char [ :pick $Input $I ];
|
||||
:local Replace [ :find $Chars $Char ];
|
||||
|
||||
:if ($Char = "=") do={
|
||||
:set Char "=3D";
|
||||
}
|
||||
:if ([ :typeof $Replace ] = "num") do={
|
||||
:set Char ("=" . ($Hex->($Replace / 16 + 8)) . ($Hex->($Replace % 16)));
|
||||
}
|
||||
:set Return ($Return . $Char);
|
||||
}
|
||||
|
||||
:if ($Input = $Return) do={
|
||||
:return $Input;
|
||||
}
|
||||
|
||||
:return ("=\?utf-8\?Q\?" . $Return . "\?=");
|
||||
}
|
||||
|
||||
# send notification via e-mail - expects at least two string arguments
|
||||
:set SendEMail do={
|
||||
:global SendEMail2;
|
||||
|
|
Loading…
Reference in a new issue