Form1.frm
上传用户:xhbjoy
上传日期:2015-10-26
资源大小:41k
文件大小:14k
- VERSION 5.00
- Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
- Begin VB.Form Form1
- BackColor = &H00000000&
- BorderStyle = 1 'Fixed Single
- Caption = "JOS 3 - 0 connection(s)"
- ClientHeight = 3420
- ClientLeft = 315
- ClientTop = 330
- ClientWidth = 6315
- Icon = "Form1.frx":0000
- LinkTopic = "Form1"
- MaxButton = 0 'False
- ScaleHeight = 3420
- ScaleWidth = 6315
- Begin VB.CheckBox Check1
- Caption = "Check1"
- Height = 255
- Left = 1680
- TabIndex = 5
- Top = 5520
- Visible = 0 'False
- Width = 1815
- End
- Begin VB.ListBox console
- Appearance = 0 'Flat
- BackColor = &H00000000&
- Enabled = 0 'False
- BeginProperty Font
- Name = "Courier New"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00FF8080&
- Height = 3180
- Left = 120
- TabIndex = 4
- Top = 120
- Width = 6135
- End
- Begin VB.DriveListBox drives
- Height = 315
- Index = 1
- Left = 1200
- TabIndex = 3
- Top = 1080
- Width = 2895
- End
- Begin VB.FileListBox files
- Height = 1065
- Index = 1
- Left = 1080
- TabIndex = 2
- Top = 840
- Width = 2055
- End
- Begin VB.DirListBox folders
- Height = 1215
- Index = 1
- Left = 1320
- TabIndex = 1
- Top = 600
- Width = 1935
- End
- Begin MSWinsockLib.Winsock acc
- Left = 3240
- Top = 480
- _ExtentX = 741
- _ExtentY = 741
- _Version = 393216
- End
- Begin MSWinsockLib.Winsock pol
- Index = 0
- Left = 1800
- Top = 840
- _ExtentX = 741
- _ExtentY = 741
- _Version = 393216
- End
- Begin VB.ListBox List1
- Height = 1425
- Left = 360
- TabIndex = 0
- Top = 600
- Width = 3495
- End
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- 'The code for accepting connections is not mine!
- 'The rest is though...
- Private WaitText As String
- Private Sub acc_ConnectionRequest(ByVal requestID As Long)
- On Error Resume Next
- ' ***** Code for accepting multiple connections *****
- 'this is the big cheese! When someone tries to login, it will open a diffrent
- 'winsock and accept the connection! That way winsock1 keeps watching port 21
- i = i + 1 'adds one to make sure we dont get errors
- Load pol(i) 'load a new winsock control
- Load Form1.folders(i)
- Form1.folders(i).Path = RootDir
- Form1.files(i).Path = RootDir
- Load Form1.files(i)
- pol(i).Close 'close it cuz of errors
- pol(i).Accept requestID 'accept the connection
- acc.Close
- acc.Listen
- For scan = 1 To 35
- If Ac_Name(scan) = Empty Then
- refid = scan
- Exit For
- End If
- Next scan
- ' Too many users - cut them off
- 'If refid = 0 Then Exit Sub
- Ac_Name(refid) = "no user"
- Ac_Host(refid) = pol(i).RemoteHostIP
- Ac_What(refid) = "login"
- Ac_Sock(refid) = i
- JustFile(Form1.folders(refid).Path) = ""
- ConsolePrint pol(i).RemoteHostIP & " has connected"
- ' Atm only accepts one connection at a time
- SendFile "filesconnect.txt", refid
- Send Crt, refid
- Send ServerName & " login> ", refid
- Update
- End Sub
- Private Sub Command1_Click()
- pol(List1.ListIndex + 1).Close
- Update
- End Sub
- Private Sub Command4_Click()
- On Error Resume Next
- Dim TM As Single
- TM = InputBox("Shutdown in how many seconds?", "JOServer")
- BroadcastKillMessage TM
- End Sub
- Sub Update()
- List1.Clear
- For scan = 1 To 35
- If Ac_Name(scan) <> Empty Then
- If Ac_SuperUser(scan) = False Then
- List1.AddItem Ac_Name(scan) & " - " & Ac_Host(scan)
- Else
- List1.AddItem "@" & Ac_Name(scan) & " - " & Ac_Host(scan)
- End If
- p = p + 1
- End If
- Next scan
- Me.Caption = "JOS 3 - " & Trim(p) & " connection(s)"
- End Sub
- Private Sub Form_Load()
- acc.LocalPort = 23
- acc.Bind
- acc.Listen
- Crt = Chr(10) & Chr(13)
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- Dim TM As Single
- TM = InputBox("Shutdown in how many seconds?", "JOServer")
- BroadcastKillMessage TM
- Cancel = 1
- End Sub
- Private Sub pol_Close(Index As Integer)
- ' locate who index is assigned to
- For scan = 1 To 35
- If Ac_Sock(scan) = Index Then
- refid = scan
- Exit For
- End If
- Next scan
- ConsolePrint pol(Index) & "(" & Ac_Name(refid) & ") has disconnected."
- Ac_Name(refid) = Empty
- Ac_Input(refid) = Empty
- Ac_Host(refid) = Empty
- Ac_What(refid) = Empty
- Ac_Sock(refid) = Empty
- Ac_WFT(refid) = Empty
- Ac_RelDir(refid) = Empty
- pol(Index).Close
- Update
- End Sub
- Sub SendFile(ByVal filename As String, ByVal person As Integer)
- If InStr(1, filename, ":") Then
- Else
- filename = App.Path & "" & filename
- End If
- On Error GoTo ErrSpot
- Open filename For Input As #1
- Do
- If EOF(1) Then Exit Do
- Line Input #1, temp
- Send temp & Chr(10) & Chr(13), person
- Loop
- Close #1
- ErrSpot:
- End Sub
- Sub Send(ByVal text As String, ByVal person As Integer)
- ' Simple send, sends text directly to whoever person
- ' person is an integer referring to the person
- On Error GoTo blah
- If Ac_Name(person) = "" Then Exit Sub
- pol(Ac_Sock(person)).SendData text
- blah:
- Exit Sub
- End Sub
- Private Sub pol_DataArrival(Index As Integer, ByVal bytesTotal As Long)
- pol(Index).GetData text, vbString
- ' find what index is assigned to
- For scan = 1 To 35
- If Ac_Sock(scan) = Index Then
- refid = scan
- Exit For
- End If
- Next scan
- stack = ""
- ' ?!
- If refid = 0 Then
- pol(Index).Close
- Exit Sub
- End If
- For H = 1 To Len(text)
- pg = Mid(text, H, 1)
- If pg = Chr(13) Then
-
- ' ---- Commands that can be used once logged in ----
- If Ac_What(refid) = "prompt" Then
- reason = "command not found"
- Ac_Input(refid) = Trim(Ac_Input(refid))
- Send Crt, 1
- If Ac_Input(refid) = Empty Then goodcom = True
-
- For scan = 1 To Len(Ac_Input(refid))
- If Mid(Ac_Input(refid), scan, 1) = " " Then
- i_command = Mid(Ac_Input(refid), 1, scan - 1)
- i_arg = Mid(Ac_Input(refid), scan + 1, 100)
- Exit For
- End If
- Next scan
- If i_command = "" Then i_command = Ac_Input(refid)
- If Ac_WFT(refid) = True Then
- WaitText = i_command & " " & i_arg
- Else
- goodcom = CommandParse(i_command, i_arg, True, refid)
- End If
- ' log 'em out
-
-
- ' shutdown
-
- ' who
-
- If goodcom = False Then
- stack = stack & vbCrLf & i_command & ": " & reason & Crt
- End If
-
- Ac_Input(refid) = Empty
- If Ac_WFT(refid) = False Then
- stack = stack & Ac_Name(refid) & "@" & ServerName & " " & JustFile2(Form1.folders(refid).Path) & "> "
- Send stack, refid
- End If
- Exit Sub
- End If
-
-
- If Ac_What(refid) = "login" Then
- If Ac_Input(refid) = Empty Then
- stack = stack & Crt
- stack = stack & Crt
- stack = stack & ServerName & " login> "
-
- Send stack, refid
- Exit Sub
- End If
- Ac_Name(refid) = Ac_Input(refid)
- Ac_Input(refid) = Empty
- stack = stack & Crt
- stack = stack & "Password: "
- Ac_What(refid) = "password"
- Send stack, refid
- Exit Sub
- End If
-
- If Ac_What(refid) = "password" Then
- Open App.Path & "filesusers.txt" For Input As #1
- Do
- If EOF(1) Then Exit Do
- Line Input #1, temp
- If Mid(temp, 1, 1) <> "#" Then
- G = 0
- rscan:
- For scan = 1 To Len(temp)
- If Mid(temp, scan, 1) = "," Then
- G = G + 1
- If G = 1 Then
- load_name = Mid(temp, 1, scan - 1)
- temp = Mid(temp, scan + 1, 100)
- GoTo rscan
- End If
- If G = 2 Then
- load_password = Mid(temp, 1, scan - 1)
- temp = Mid(temp, scan + 1, 100)
- GoTo rscan
- End If
- If G = 3 Then
- load_su = Mid(temp, 1, scan - 1)
- temp = Mid(temp, scan + 1, 100)
- End If
-
- If Check1.Value = False Then
-
- If load_name = Ac_Name(refid) Then
- If load_password = Ac_Input(refid) Then
- stack = stack & Crt
- stack = stack & "Login approved." & Crt & Crt
- ConsolePrint pol(Index).RemoteHostIP & " validated as " & Ac_Name(refid)
- stack = stack & Ac_Name(refid) & "@" & ServerName & " " & JustFile2(Form1.folders(refid).Path) & "> "
- Ac_What(refid) = "prompt"
- Ac_Input(refid) = Empty
- Ac_SuperUser(refid) = False
- If load_su = "1" Then
- Ac_SuperUser(refid) = True
- End If
-
- Close #1
- Send stack, refid
- Update
- Exit Sub
- End If
- Ac_Input(refid) = Empty
- End If
- Else
- Send "This server is currently not accepting connections", refid
- End If
- End If
- Next scan
- End If
- Loop
- Close #1
-
- Ac_Input(refid) = Empty
-
-
-
- stack = stack & Crt
- stack = stack & "Login incorrect" & Crt & Crt
- stack = stack & ServerName & " login>"
- Send stack, refid
-
- Ac_What(refid) = "login"
- Exit Sub
- End If
- End If
-
-
- If pg = Chr(8) Then
- If Ac_Input(refid) <> "" Then
- Ac_Input(refid) = Mid(Ac_Input(refid), 1, Len(Ac_Input(refid)) - 1)
- If Ac_What(refid) <> "password" Then
- Send Chr(8) & " " & Chr(8), refid
- End If
- End If
- Exit Sub
- End If
-
- If pg = Chr(21) Then
- If Ac_Input(refid) <> "" Then
- For G = 1 To Len(Ac_Input(refid))
- Send Chr(8) & " " & Chr(8), refid
- Next G
- End If
- Ac_Input(refid) = ""
- Exit Sub
- End If
-
-
- If Ac_What(refid) <> "password" Then
- Send pg, refid
- End If
- If Ac_What(refid) = "wft" Then
- WaitText = WaitText & text
- End If
-
- Ac_Input(refid) = Ac_Input(refid) & pg
- Next H
- End Sub
- Private Sub pol_Error(Index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
- On Error Resume Next
- ' locate who index is assigned to
- For scan = 1 To 35
- If Ac_Sock(scan) = Index Then
- refid = scan
- Exit For
- End If
- Next scan
- Ac_Name(refid) = Empty
- Ac_Input(refid) = Empty
- Ac_Host(refid) = Empty
- Ac_What(refid) = Empty
- Ac_Sock(refid) = Empty
- Ac_RelDir(refid) = Empty
- pol(Index).Close
- Update
- End Sub
- Public Function WaitForText(refid) As String
- Ac_Input(refid) = ""
- Ac_WFT(refid) = True
- Do
- DoEvents
- Loop Until WaitText <> ""
- WaitForText = WaitText
- WaitText = ""
- Ac_WFT(refid) = False
- End Function
- Sub RootManPage(cmd As String)
- On Error Resume Next
- Dim TempVar As String
- Open "filesman" & cmd & ".txt" For Input As #1
- While EOF(1) = False
- Line Input #1, TempVar
- ConsolePrint TempVar
- Wend
- Close #1
- End Sub