📄 frmiprules.frm
字号:
VERSION 5.00
Begin VB.Form frmIPRules
BorderStyle = 3 'Fixed Dialog
Caption = "Edit IP rules"
ClientHeight = 4140
ClientLeft = 45
ClientTop = 330
ClientWidth = 2805
Icon = "frmIPRules.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 276
ScaleMode = 3 'Pixel
ScaleWidth = 187
ShowInTaskbar = 0 'False
StartUpPosition = 1 'CenterOwner
Begin VB.CommandButton cmdOK
Caption = "OK"
Height = 315
Left = 1080
TabIndex = 8
Top = 3720
Width = 735
End
Begin VB.CommandButton cmdCancel
Caption = "Cancel"
Height = 315
Left = 1920
TabIndex = 7
Top = 3720
Width = 735
End
Begin VB.CommandButton cmdRemove
Caption = "Remove"
Enabled = 0 'False
Height = 315
Left = 1080
TabIndex = 6
Top = 3120
Width = 855
End
Begin VB.CommandButton cmdAdd
Caption = "Add"
Height = 315
Left = 120
TabIndex = 5
Top = 3120
Width = 855
End
Begin VB.ListBox lstPatterns
Height = 1425
Left = 120
TabIndex = 4
Top = 1560
Width = 2535
End
Begin VB.OptionButton optAllow
Caption = "Deny all"
Height = 375
Index = 1
Left = 240
TabIndex = 2
Top = 720
Width = 2055
End
Begin VB.OptionButton optAllow
Caption = "Allow all"
Height = 375
Index = 0
Left = 240
TabIndex = 1
Top = 360
Width = 2055
End
Begin VB.Label lblDenyAllow
Caption = "lblDenyAllow"
Height = 255
Left = 120
TabIndex = 3
Top = 1320
Width = 2415
End
Begin VB.Label Label1
Caption = "Main rule:"
Height = 255
Left = 120
TabIndex = 0
Top = 120
Width = 4095
End
End
Attribute VB_Name = "frmIPRules"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private strCurFile As String
Private Sub cmdAdd_Click()
' add pattern
Dim strPat As String
strPat = InputBox("Enter pattern:")
If strPat <> Empty Then
lstPatterns.AddItem strPat
End If
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
' re-save file
Dim FF As Integer, i As Long, strToken As String
FF = FreeFile
Open strCurFile For Output As #FF
' main rule
If optAllow(0).Value Then
Print #FF, "allow all"
strToken = "deny "
Else
Print #FF, "deny all"
strToken = "allow "
End If
' patterns
For i = 1 To lstPatterns.ListCount
Print #FF, strToken + lstPatterns.List(i - 1)
Next i
Close #FF
Unload Me
End Sub
Private Sub cmdRemove_Click()
' remove pattern
lstPatterns.RemoveItem lstPatterns.ListIndex
cmdRemove.Enabled = False
End Sub
Private Sub lstPatterns_Click()
cmdRemove.Enabled = True
End Sub
Private Sub optAllow_Click(Index As Integer)
If Index = 0 Then
lblDenyAllow.Caption = "Deny IP patterns:"
Else
lblDenyAllow.Caption = "Allow IP patterns:"
End If
End Sub
Public Sub LoadFile(strFile As String)
' load ip rules
Dim FF As Integer, strLine As String, bFirst As Boolean, pos As Long
strCurFile = strFile
FF = FreeFile
bFirst = True
' read file line by line
Open strFile For Binary As #FF
Do While Not EOF(FF)
On Error Resume Next
Line Input #FF, strLine
If Err Then Exit Do
On Error GoTo 0
If Trim(strLine <> Empty) Then
If bFirst = True Then
' main-rule...
If Left(strLine, 5) = "allow" Then
optAllow(0).Value = True
Else
optAllow(1).Value = True
End If
bFirst = False
Else
' add pattern
pos = InStr(1, strLine, " ")
lstPatterns.AddItem Mid(strLine, pos + 1)
End If
End If
Loop
Close #FF
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -