]> Git [git.vados.ru] :: Repos - Mikrotiks/ros.vados.ru.git/commitdiff
Autocommit in repo: ros.vados.ru, generated by owner: root, in 04:15:02 18.03.2026.
authorvados-dev <192440777+vados-dev@users.noreply.github.com>
Wed, 18 Mar 2026 01:15:03 +0000 (04:15 +0300)
committervados-dev <192440777+vados-dev@users.noreply.github.com>
Wed, 18 Mar 2026 01:15:03 +0000 (04:15 +0300)
html/AM-GlobalFunc.rsc
html/mod/AM-DateTime.rsc [new file with mode: 0644]
html/mod/AM-TG-Bot.rsc
html/mod/AM-TG-Notifications.rsc
html/mod/CustomBackups.rsc [new file with mode: 0644]

index 0197261f8272d573c022c650a09aab41ee3c64d7..f77f78a09f3ca0108bff1fcc99e1a897efa67f22 100644 (file)
@@ -16,9 +16,9 @@
 :global GlobalFuncReady false;
 
 # Git commit id & info, expected configuration version
-:global CommitId "main/192/93260240";
+:global CommitId "main/193/34ed506c";
 :global CommitTAG "unknown";
-:global CommitInfo "Autocommit in repo: ros.vados.ru, generated by owner: root, in 04:10:03 18.03.2026.";
+:global CommitInfo "Autocommit in repo: ros.vados.ru, generated by owner: root, in 04:15:02 18.03.2026.";
 
 # The variables are received right here.
 :global GlobalConfVersion 138;
diff --git a/html/mod/AM-DateTime.rsc b/html/mod/AM-DateTime.rsc
new file mode 100644 (file)
index 0000000..cee377a
--- /dev/null
@@ -0,0 +1,94 @@
+#!rsc by Vados
+# RouterOS function-collection
+# DateTime Functions
+
+:global CurrentDateTime;
+:global FullDateTimeStamp;
+:global MiniDateTimeStamp;
+
+:set CurrentDateTime do={
+  :local rawTime [/system clock get time];
+  :local rawDate [/system clock get date];
+  :local currDate "undefined";
+     :local currTime ([:pick $rawTime 0 2] . ":" . [:pick $rawTime 3 5] . ":" . [:pick $rawTime 6 8]);
+     :if ([:len [:tonum [:pick $rawDate 0 1]]] = 0) do={
+         :set currDate ([:pick $rawDate 7 11] . "-" . [:pick $rawDate 0 3] . "-" . [:pick $rawDate 4 6]);
+       } else={:set currDate $rawDate}
+:return ($currDate . " " . $currTime);
+}
+:set FullDateTimeStamp do={
+    /system clock
+    :local vdate [get date]
+    :local vtime [get time]
+    :local vgmt  [:tonum [get gmt-offset]]; :if ($vgmt > 0x7FFFFFFF) do={:set vgmt ($vgmt - 0x100000000)}
+    :local prMntDays [:toarray "0,0,31,59,90,120,151,181,212,243,273,304,334"]
+    :local daysOnMnt [:toarray "0,31,28,31,30,31,30,31,31,30,31,30,31"]
+    :local LcaseMnts [:toarray "0,jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec"]
+    :local PcaseMnts [:toarray "0,Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"]
+    :local UcaseMnts [:toarray "0,JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC"]
+    :local LcaseWeekDays [:toarray "thu,fri,sat,sun,mon,tue,wed"]
+    :local PcaseWeekDays [:toarray "Thu,Fri,Sat,Sun,Mon,Tue,Wed"]
+    :local UcaseWeekDays [:toarray "THU,FRI,SAT,SUN,MON,TUE,WED"]
+    :local NumbrWeekDays [:toarray "4,5,6,7,1,2,3"]
+    :local Fzerofill do={:return [:pick (100 + $1) 1 3]}
+    :local gmtSg "+"; :if ($vgmt < 0) do={:set gmtSg "-"; :set vgmt ($vgmt * -1)}
+    :local gmtHr [:pick [:totime $vgmt] 0 2]
+    :local gmtMn [:pick [:totime $vgmt] 3 5]
+    :local vdoff [:toarray "0,4,5,7,8,10"]
+    :local MM    [:pick $vdate ($vdoff->2) ($vdoff->3)]
+    :local M     [:tonum $MM]
+    :if ($vdate ~ ".../../....") do={
+        :set vdoff [:toarray "7,11,1,3,4,6"]
+        :set M     ([:find "xxanebarprayunulugepctovecANEBARPRAYUNULUGEPCTOVEC" [:pick $vdate ($vdoff->2) ($vdoff->3)] -1] / 2)
+        :if ($M>12) do={:set M ($M - 12)}
+        :set MM    [:pick (100 + $M) 1 3]
+    }
+    :local yyyy [:pick $vdate ($vdoff->0) ($vdoff->1)]
+    :local Leap "No-Leap"
+    :if ((($yyyy - 1968) % 4) = 0) do={:set Leap "Leap"; :set ($prMntDays->1) -1; :set ($prMntDays->2) 30; :set ($daysOnMnt->2) 29}
+    :local mmm  ($LcaseMnts->$M)
+    :local Mmm  ($PcaseMnts->$M)
+    :local MMM  ($UcaseMnts->$M)
+    :local MD   ($daysOnMnt->$M)
+    :local dd   [:pick $vdate ($vdoff->4) ($vdoff->5)]
+    :local d    [:tonum $dd] ; :local totd ((($yyyy - 1970) * 365) + (($yyyy - 1968) / 4) + ($prMntDays->$M) + ($d - 1))
+    :local YD   (($prMntDays->$M) + $d)
+    :local www  ($LcaseWeekDays->($totd % 7))
+    :local Www  ($PcaseWeekDays->($totd % 7))
+    :local WWW  ($UcaseWeekDays->($totd % 7))
+    :local WD   ($NumbrWeekDays->($totd % 7))
+    :local HH   [:pick $vtime 0  2]
+    :local H    [:tonum $HH]
+    :local hh   ([:tonum $HH] % 12); :if ($hh = 0) do={:set hh 12}; :set hh [$Fzerofill $hh]
+    :local h    [:tonum $hh]
+    :local a    "A"; :if ([:tonum $HH] > 11) do={:set a "P"}
+    :local aa   "$a\4D"
+    :local mm   [:pick $vtime 3  5]
+    :local m    [:tonum $mm]
+    :local ss   [:pick $vtime 6  8]
+    :local s    [:tonum $ss]
+    :local Z    "$gmtSg$gmtHr:$gmtMn"
+    :local Unix (((((($totd * 24) + $H) * 60) + $m) * 60) + $s - $vgmt)
+#    :return "$yyyy-$MM-$dd\54$HH:$mm:$ss$Z $Www (YD: $YD) (MD: $MD) (WD: $WD) $Leap $Unix"
+    :return "$yyyy$MM$dd$HH$mm$ss"
+}
+:set MiniDateTimeStamp do={
+    /system clock
+    :local vdate [get date]
+    :local vtime [get time]
+    :local vdoff [:toarray "0,4,5,7,8,10"]
+    :local MM    [:pick $vdate ($vdoff->2) ($vdoff->3)]
+    :local M     [:tonum $MM]
+    :if ($vdate ~ ".../../....") do={
+        :set vdoff [:toarray "7,11,1,3,4,6"]
+        :set M     ([:find "xxanebarprayunulugepctovecANEBARPRAYUNULUGEPCTOVEC" [:pick $vdate ($vdoff->2) ($vdoff->3)] -1] / 2)
+        :if ($M>12) do={:set M ($M - 12)}
+        :set MM    [:pick (100 + $M) 1 3]
+    }
+    :local yyyy [:pick $vdate ($vdoff->0) ($vdoff->1)]
+    :local dd   [:pick $vdate ($vdoff->4) ($vdoff->5)]
+    :local HH   [:pick $vtime 0  2]
+    :local mm   [:pick $vtime 3  5]
+    :local ss   [:pick $vtime 6  8]
+    :return "$yyyy$MM$dd$HH$mm$ss"
+}
index 3477c3c47386e2a05a6659a8aa7b545edb1ed20c..17ef3aff39262520e0bd6c1c259d3f85f43d5dbf 100644 (file)
   :global SymbolForNotification;
   :global ValidateSyntax;
   :global WaitForFile;
-  
+
   :if ([ $ScriptLock $ScriptName ] = false) do={
     :set ExitOK true;
     :error false;
   }
-  
+
   :if ([ :len [ /system/scheduler/find where name=$ScriptName ] ] = 0) do={
     /system/scheduler/add start-time=startup interval=30s name=$ScriptName on-event="/system/script/run $ScriptName;" comment="Telegram Chat Bot";
   }
index dfd30db5e927597b334dccf333e5b34ddcf3697f..fdcc947a1c0a7da3983da846e729bd249cb3e636 100644 (file)
       "&reply_to_message_id=" . ($Notification->"replyto") . "&message_thread_id=" . $ThreadId . \
       "&disable_web_page_preview=true&parse_mode=MarkdownV2");
   :onerror Err {
-#    :if ([ $CertificateAvailable "Go Daddy Root Certificate Authority - G2" "fetch" ] = false) do={
-#      $LogPrint warning $0 ("Downloading required certificate failed.");
-#      :error false;
-#    }
-#check-certificate=yes-without-crl     
-    :local Data ([ /tool/fetch output=user http-method=post \
+    :if ([ $CertificateAvailable "Go Daddy Root Certificate Authority - G2" "fetch" ] = false) do={
+      $LogPrint warning $0 ("Downloading required certificate failed.");
+      :error false;
+    }
+    :local Data ([ /tool/fetch check-certificate=yes-without-crl output=user http-method=post \
       ("https://api.telegram.org/bot" . $TokenId . "/sendMessage") \
       http-data=($HTTPData . "&text=" . [ $UrlEncode $Text ]) as-value ]->"data");
     :set ($TelegramMessageIDs->[ :tostr ([ :deserialize from=json value=$Data ]->"result"->"message_id") ]) 1;
diff --git a/html/mod/CustomBackups.rsc b/html/mod/CustomBackups.rsc
new file mode 100644 (file)
index 0000000..c63c352
--- /dev/null
@@ -0,0 +1,22 @@
+#
+# RouterOS function-collection
+# CustomBackups Functions
+
+:global DoLocalBackup;
+
+:set DoLocalBackup do={
+#:foreach BakScript in=([ /system/script/find where name~"*" ]) do={ import file=Scripts/$BakScript}; 
+tool e-mail export show-sensitive file=export/email.rsc;
+system scheduler export file=export/scheduler.rsc;
+system script export show-sensitive file=export/script.rsc;
+certificate export file=export/certificate_settings.rsc;
+ip firewall nat export file=export/nat.rsc;
+ip firewall filter export file=export/filter.rsc;
+ip firewall address-list export file=export/address-list.rsc;
+ip route export file=export/route.rsc;
+ip dhcp-server network export file=export/network.rsc;
+interface ethernet export file=export/ethernet.rsc;
+ip pool export file=export/pool.rsc;
+ip dns export file=export/dns.rsc;
+}
+