Browse Source

Загрузил(а) файлы в ''

master
paravis 1 month ago
parent
commit
cd1f9a249b
  1. 70
      Mikrotik_ALC.au3

70
Mikrotik_ALC.au3

@ -0,0 +1,70 @@
#include <GUIConstants.au3>
#include <Array.au3>
#include <File.au3>
#NoTrayIcon
Global $hFile, $tFile, $oFile, $Data, $dList, $lList, $cList, $ccList
$Main = GUICreate('Mikrotik ALC', 320, 400, -1, -1)
$sList = GUICtrlCreateEdit('', 8, 30, 304, 325, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_NOHIDESEL + $ES_WANTRETURN)
GUICtrlSetFont(-1, 9, 400, 0, "Tahoma")
GUICtrlCreateLabel('Domian;List;Comment', 86, 8, 150, 17, $SS_CENTER)
GUICtrlSetFont(-1, 9, 700, 0, "Tahoma")
GUICtrlCreateLabel('DNS', 289, 8, 21, 17, $SS_CENTER)
$sDNS = GUICtrlCreateCheckbox('',273, 9, 12, 12)
GUICtrlSetState($sDNS, $GUI_CHECKED)
$sRun = GUICtrlCreateButton("Generate", 8, 360, 304, 33)
GUICtrlSetFont(-1, 9, 700, 0, "Tahoma")
GUISetState(@SW_SHOW)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $sRun
$sFile = @ScriptDir & "\_tmp.txt"
$tFile = FileOpen($sFile, 10)
FileWrite($tFile, GUICtrlRead($sList))
FileClose ($tFile)
$hFile = (@ScriptDir & "\rules.txt")
_array_filter_dns()
EndSwitch
WEnd
Func _array_filter_dns()
_FileReadToArray($sFile, $Data, 1, ";")
$oFile = FileOpen($hFile, 10)
If UBound($Data, 2) > 3 Then
MsgBox(48, 'Предупреждение!', 'Указано неверное количество аргументов. Завершаю работу.')
Exit
EndIf
If UBound($Data, 2) < 2 Then
MsgBox(48, 'Предупреждение!', 'Указано неверное количество аргументов. Завершаю работу.')
Exit
EndIf
For $i = 1 To $Data[0][0]
$dList = $Data[$i][0]
$lList = $Data[$i][1]
If UBound($Data, 2) = 3 Then
$cList = " comment=" & $Data[$i][2]
Else
$cList = ""
EndIf
FileWrite($oFile, "/ip firewall address-list add address=" & $dList &" list=" & $lList & $cList & @CRLF)
Next
If GUICtrlRead($sDNS) = $GUI_CHECKED Then
For $i = 1 To $Data[0][0]
$dList = $Data[$i][0]
$lList = $Data[$i][1]
If UBound($Data, 2) = 3 Then
$cList = " comment=" & $Data[$i][2]
Else
$cList = ""
EndIf
FileWrite($oFile, @CRLF & "/ip dns static add address-list=" & $lList &" match-subdomain=yes name=" & $dList & " type=FWD" & $cList)
Next
EndIf
FileClose($oFile)
FileDelete($sFile)
ShellExecute(@ScriptDir & "\Rules.txt")
EndFunc
Loading…
Cancel
Save