home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD36692272000.psc / Server / frmMain.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2000-02-28  |  32.1 KB  |  869 lines

  1. VERSION 5.00
  2. Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
  3. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  4. Begin VB.Form frmMain 
  5.    BackColor       =   &H00C0C0C0&
  6.    BorderStyle     =   1  'Fixed Single
  7.    Caption         =   "Personal Webserver"
  8.    ClientHeight    =   4410
  9.    ClientLeft      =   4875
  10.    ClientTop       =   4155
  11.    ClientWidth     =   4260
  12.    BeginProperty Font 
  13.       Name            =   "Verdana"
  14.       Size            =   8.25
  15.       Charset         =   0
  16.       Weight          =   400
  17.       Underline       =   0   'False
  18.       Italic          =   0   'False
  19.       Strikethrough   =   0   'False
  20.    EndProperty
  21.    Icon            =   "frmMain.frx":0000
  22.    LinkTopic       =   "Form1"
  23.    MaxButton       =   0   'False
  24.    MinButton       =   0   'False
  25.    ScaleHeight     =   4410
  26.    ScaleWidth      =   4260
  27.    Begin VB.PictureBox Picture4 
  28.       BackColor       =   &H00C0C0C0&
  29.       BorderStyle     =   0  'None
  30.       BeginProperty Font 
  31.          Name            =   "MS Sans Serif"
  32.          Size            =   8.25
  33.          Charset         =   0
  34.          Weight          =   400
  35.          Underline       =   0   'False
  36.          Italic          =   0   'False
  37.          Strikethrough   =   0   'False
  38.       EndProperty
  39.       Height          =   3135
  40.       Left            =   240
  41.       ScaleHeight     =   3135
  42.       ScaleWidth      =   3735
  43.       TabIndex        =   21
  44.       Top             =   480
  45.       Visible         =   0   'False
  46.       Width           =   3735
  47.       Begin VB.Frame Frame8 
  48.          BackColor       =   &H00C0C0C0&
  49.          Caption         =   "Open/Closed"
  50.          Height          =   790
  51.          Left            =   240
  52.          TabIndex        =   22
  53.          Top             =   240
  54.          Width           =   3255
  55.          Begin VB.CheckBox Check1 
  56.             BackColor       =   &H00C0C0C0&
  57.             Caption         =   "Temporarily Closed"
  58.             Height          =   255
  59.             Left            =   120
  60.             TabIndex        =   23
  61.             Top             =   330
  62.             Width           =   2175
  63.          End
  64.       End
  65.       Begin VB.Line Line13 
  66.          BorderColor     =   &H00000000&
  67.          X1              =   3720
  68.          X2              =   3720
  69.          Y1              =   3120
  70.          Y2              =   -120
  71.       End
  72.       Begin VB.Line Line16 
  73.          BorderColor     =   &H00000000&
  74.          X1              =   0
  75.          X2              =   3720
  76.          Y1              =   3120
  77.          Y2              =   3120
  78.       End
  79.       Begin VB.Line Line15 
  80.          BorderColor     =   &H00FFFFFF&
  81.          X1              =   3720
  82.          X2              =   0
  83.          Y1              =   0
  84.          Y2              =   0
  85.       End
  86.       Begin VB.Line Line14 
  87.          BorderColor     =   &H00FFFFFF&
  88.          X1              =   0
  89.          X2              =   0
  90.          Y1              =   0
  91.          Y2              =   3120
  92.       End
  93.    End
  94.    Begin VB.CommandButton cmdOK 
  95.       BackColor       =   &H00C0C0C0&
  96.       Caption         =   "OK"
  97.       Height          =   375
  98.       Left            =   3000
  99.       Style           =   1  'Graphical
  100.       TabIndex        =   1
  101.       Top             =   3960
  102.       Width           =   1215
  103.    End
  104.    Begin VB.PictureBox Picture3 
  105.       BackColor       =   &H00C0C0C0&
  106.       BorderStyle     =   0  'None
  107.       BeginProperty Font 
  108.          Name            =   "MS Sans Serif"
  109.          Size            =   8.25
  110.          Charset         =   0
  111.          Weight          =   400
  112.          Underline       =   0   'False
  113.          Italic          =   0   'False
  114.          Strikethrough   =   0   'False
  115.       EndProperty
  116.       Height          =   3135
  117.       Left            =   240
  118.       ScaleHeight     =   3135
  119.       ScaleWidth      =   3735
  120.       TabIndex        =   13
  121.       Top             =   480
  122.       Visible         =   0   'False
  123.       Width           =   3735
  124.       Begin VB.Frame Frame1 
  125.          BackColor       =   &H00C0C0C0&
  126.          Caption         =   "Connections/Requests:"
  127.          Height          =   1695
  128.          Left            =   240
  129.          TabIndex        =   19
  130.          Top             =   1200
  131.          Width           =   3255
  132.          Begin VB.ListBox List1 
  133.             Height          =   1035
  134.             ItemData        =   "frmMain.frx":0E42
  135.             Left            =   120
  136.             List            =   "frmMain.frx":0E44
  137.             TabIndex        =   20
  138.             Top             =   480
  139.             Width           =   3015
  140.          End
  141.       End
  142.       Begin VB.Frame Frame5 
  143.          BackColor       =   &H00C0C0C0&
  144.          Caption         =   "Logging:"
  145.          Height          =   735
  146.          Left            =   240
  147.          TabIndex        =   14
  148.          Top             =   240
  149.          Width           =   3255
  150.          Begin VB.CheckBox cheLogging 
  151.             BackColor       =   &H00C0C0C0&
  152.             Caption         =   "Logging"
  153.             Height          =   255
  154.             Left            =   120
  155.             TabIndex        =   15
  156.             Top             =   330
  157.             Width           =   975
  158.          End
  159.       End
  160.       Begin VB.Line Line9 
  161.          BorderColor     =   &H00000000&
  162.          X1              =   3720
  163.          X2              =   3720
  164.          Y1              =   3120
  165.          Y2              =   -120
  166.       End
  167.       Begin VB.Line Line10 
  168.          BorderColor     =   &H00FFFFFF&
  169.          X1              =   0
  170.          X2              =   0
  171.          Y1              =   0
  172.          Y2              =   3120
  173.       End
  174.       Begin VB.Line Line11 
  175.          BorderColor     =   &H00FFFFFF&
  176.          X1              =   3720
  177.          X2              =   0
  178.          Y1              =   0
  179.          Y2              =   0
  180.       End
  181.       Begin VB.Line Line12 
  182.          BorderColor     =   &H00000000&
  183.          X1              =   0
  184.          X2              =   3720
  185.          Y1              =   3120
  186.          Y2              =   3120
  187.       End
  188.    End
  189.    Begin VB.PictureBox Picture2 
  190.       BackColor       =   &H00C0C0C0&
  191.       BorderStyle     =   0  'None
  192.       BeginProperty Font 
  193.          Name            =   "MS Sans Serif"
  194.          Size            =   8.25
  195.          Charset         =   0
  196.          Weight          =   400
  197.          Underline       =   0   'False
  198.          Italic          =   0   'False
  199.          Strikethrough   =   0   'False
  200.       EndProperty
  201.       Height          =   3135
  202.       Left            =   240
  203.       ScaleHeight     =   3135
  204.       ScaleWidth      =   3735
  205.       TabIndex        =   9
  206.       Top             =   480
  207.       Visible         =   0   'False
  208.       Width           =   3735
  209.       Begin VB.Frame Frame4 
  210.          BackColor       =   &H00C0C0C0&
  211.          Caption         =   "Active Objects:"
  212.          Height          =   1095
  213.          Left            =   240
  214.          TabIndex        =   10
  215.          Top             =   240
  216.          Width           =   3255
  217.          Begin VB.CheckBox cheCounter 
  218.             BackColor       =   &H00C0C0C0&
  219.             Caption         =   "Enable counter"
  220.             Height          =   255
  221.             Left            =   120
  222.             TabIndex        =   12
  223.             Top             =   650
  224.             Width           =   1695
  225.          End
  226.          Begin VB.CheckBox cheGuest 
  227.             BackColor       =   &H00C0C0C0&
  228.             Caption         =   "Enable guestbook"
  229.             Height          =   255
  230.             Left            =   120
  231.             TabIndex        =   11
  232.             Top             =   330
  233.             Width           =   1935
  234.          End
  235.       End
  236.       Begin VB.Line Line6 
  237.          BorderColor     =   &H00000000&
  238.          X1              =   3720
  239.          X2              =   3720
  240.          Y1              =   3120
  241.          Y2              =   -120
  242.       End
  243.       Begin VB.Line Line8 
  244.          BorderColor     =   &H00FFFFFF&
  245.          X1              =   0
  246.          X2              =   0
  247.          Y1              =   0
  248.          Y2              =   3120
  249.       End
  250.       Begin VB.Line Line7 
  251.          BorderColor     =   &H00FFFFFF&
  252.          X1              =   3720
  253.          X2              =   0
  254.          Y1              =   0
  255.          Y2              =   0
  256.       End
  257.       Begin VB.Line Line5 
  258.          BorderColor     =   &H00000000&
  259.          X1              =   0
  260.          X2              =   3720
  261.          Y1              =   3120
  262.          Y2              =   3120
  263.       End
  264.    End
  265.    Begin VB.PictureBox Picture1 
  266.       BackColor       =   &H00C0C0C0&
  267.       BorderStyle     =   0  'None
  268.       BeginProperty Font 
  269.          Name            =   "MS Sans Serif"
  270.          Size            =   8.25
  271.          Charset         =   0
  272.          Weight          =   400
  273.          Underline       =   0   'False
  274.          Italic          =   0   'False
  275.          Strikethrough   =   0   'False
  276.       EndProperty
  277.       Height          =   3135
  278.       Left            =   240
  279.       ScaleHeight     =   3135
  280.       ScaleWidth      =   3735
  281.       TabIndex        =   2
  282.       Top             =   480
  283.       Width           =   3735
  284.       Begin VB.CommandButton Command1 
  285.          BackColor       =   &H00C0C0C0&
  286.          Caption         =   "Start"
  287.          Height          =   375
  288.          Left            =   2280
  289.          Style           =   1  'Graphical
  290.          TabIndex        =   16
  291.          Top             =   2640
  292.          Width           =   1215
  293.       End
  294.       Begin VB.Frame Frame3 
  295.          BackColor       =   &H00C0C0C0&
  296.          Caption         =   "Server Options:"
  297.          Height          =   1095
  298.          Left            =   240
  299.          TabIndex        =   6
  300.          Top             =   1320
  301.          Width           =   3255
  302.          Begin VB.CheckBox cheMinimized 
  303.             BackColor       =   &H00C0C0C0&
  304.             Caption         =   "Start minimized"
  305.             Height          =   255
  306.             Left            =   120
  307.             TabIndex        =   8
  308.             Top             =   330
  309.             Width           =   1815
  310.          End
  311.          Begin VB.CheckBox cheActivate 
  312.             BackColor       =   &H00C0C0C0&
  313.             Caption         =   "Activate server on start"
  314.             Height          =   255
  315.             Left            =   120
  316.             TabIndex        =   7
  317.             Top             =   650
  318.             Width           =   2535
  319.          End
  320.       End
  321.       Begin VB.Frame Frame2 
  322.          BackColor       =   &H00C0C0C0&
  323.          Caption         =   "Server Directory:"
  324.          Height          =   855
  325.          Left            =   240
  326.          TabIndex        =   3
  327.          Top             =   240
  328.          Width           =   3255
  329.          Begin VB.TextBox txtRoot 
  330.             Height          =   285
  331.             Left            =   120
  332.             TabIndex        =   5
  333.             Top             =   360
  334.             Width           =   2295
  335.          End
  336.          Begin VB.CommandButton cmdDirChoose 
  337.             Caption         =   "..."
  338.             Height          =   285
  339.             Left            =   2520
  340.             Style           =   1  'Graphical
  341.             TabIndex        =   4
  342.             Top             =   360
  343.             Width           =   495
  344.          End
  345.       End
  346.       Begin VB.CommandButton Command2 
  347.          BackColor       =   &H00C0C0C0&
  348.          Caption         =   "Stop"
  349.          Height          =   375
  350.          Left            =   2280
  351.          Style           =   1  'Graphical
  352.          TabIndex        =   17
  353.          Top             =   2640
  354.          Visible         =   0   'False
  355.          Width           =   1215
  356.       End
  357.       Begin VB.Label Server 
  358.          AutoSize        =   -1  'True
  359.          BackColor       =   &H8000000A&
  360.          BackStyle       =   0  'Transparent
  361.          BeginProperty Font 
  362.             Name            =   "Arial"
  363.             Size            =   9.75
  364.             Charset         =   0
  365.             Weight          =   700
  366.             Underline       =   0   'False
  367.             Italic          =   0   'False
  368.             Strikethrough   =   0   'False
  369.          EndProperty
  370.          ForeColor       =   &H8000000D&
  371.          Height          =   240
  372.          Left            =   240
  373.          MouseIcon       =   "frmMain.frx":0E46
  374.          TabIndex        =   18
  375.          Top             =   2640
  376.          Width           =   60
  377.       End
  378.       Begin VB.Line Line4 
  379.          BorderColor     =   &H00000000&
  380.          X1              =   0
  381.          X2              =   3720
  382.          Y1              =   3120
  383.          Y2              =   3120
  384.       End
  385.       Begin VB.Line Line3 
  386.          BorderColor     =   &H00000000&
  387.          X1              =   3720
  388.          X2              =   3720
  389.          Y1              =   3120
  390.          Y2              =   -120
  391.       End
  392.       Begin VB.Line Line2 
  393.          BorderColor     =   &H00FFFFFF&
  394.          X1              =   3720
  395.          X2              =   0
  396.          Y1              =   0
  397.          Y2              =   0
  398.       End
  399.       Begin VB.Line Line1 
  400.          BorderColor     =   &H00FFFFFF&
  401.          X1              =   0
  402.          X2              =   0
  403.          Y1              =   0
  404.          Y2              =   3120
  405.       End
  406.    End
  407.    Begin MSComctlLib.TabStrip TabStrip1 
  408.       Height          =   3840
  409.       Left            =   20
  410.       TabIndex        =   0
  411.       Top             =   20
  412.       Width           =   4200
  413.       _ExtentX        =   7408
  414.       _ExtentY        =   6773
  415.       MultiRow        =   -1  'True
  416.       _Version        =   393216
  417.       BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} 
  418.          NumTabs         =   4
  419.          BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
  420.             Caption         =   "Server"
  421.             ImageVarType    =   2
  422.          EndProperty
  423.          BeginProperty Tab2 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
  424.             Caption         =   "Active Objects"
  425.             ImageVarType    =   2
  426.          EndProperty
  427.          BeginProperty Tab3 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
  428.             Caption         =   "Security"
  429.             ImageVarType    =   2
  430.          EndProperty
  431.          BeginProperty Tab4 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
  432.             Caption         =   "Access"
  433.             ImageVarType    =   2
  434.          EndProperty
  435.       EndProperty
  436.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  437.          Name            =   "Verdana"
  438.          Size            =   8.25
  439.          Charset         =   0
  440.          Weight          =   400
  441.          Underline       =   0   'False
  442.          Italic          =   0   'False
  443.          Strikethrough   =   0   'False
  444.       EndProperty
  445.    End
  446.    Begin MSWinsockLib.Winsock sckWS 
  447.       Index           =   0
  448.       Left            =   120
  449.       Top             =   3960
  450.       _ExtentX        =   741
  451.       _ExtentY        =   741
  452.       _Version        =   393216
  453.    End
  454.    Begin VB.Image ServerOff 
  455.       Height          =   240
  456.       Left            =   2280
  457.       Picture         =   "frmMain.frx":1150
  458.       Top             =   3480
  459.       Visible         =   0   'False
  460.       Width           =   240
  461.    End
  462.    Begin VB.Image ServerOn 
  463.       Height          =   240
  464.       Left            =   2520
  465.       Picture         =   "frmMain.frx":129A
  466.       Top             =   3480
  467.       Visible         =   0   'False
  468.       Width           =   240
  469.    End
  470.    Begin VB.Menu mnuTray 
  471.       Caption         =   "&Tray"
  472.       Visible         =   0   'False
  473.       Begin VB.Menu mnuAbout 
  474.          Caption         =   "&About"
  475.       End
  476.       Begin VB.Menu Sep3 
  477.          Caption         =   "-"
  478.       End
  479.       Begin VB.Menu mnuOptions 
  480.          Caption         =   "Show S&erver"
  481.       End
  482.       Begin VB.Menu Sep2 
  483.          Caption         =   "-"
  484.       End
  485.       Begin VB.Menu mnuStart 
  486.          Caption         =   "&Start"
  487.       End
  488.       Begin VB.Menu Sep1 
  489.          Caption         =   "-"
  490.       End
  491.       Begin VB.Menu mnuExit 
  492.          Caption         =   "&Exit"
  493.       End
  494.    End
  495.    Begin VB.Menu mnuFile 
  496.       Caption         =   "&File"
  497.       Begin VB.Menu mnuFileExit 
  498.          Caption         =   "&Exit"
  499.       End
  500.    End
  501.    Begin VB.Menu mnuHelp 
  502.       Caption         =   "&Help"
  503.       Begin VB.Menu mnuHelpAbout 
  504.          Caption         =   "&About"
  505.       End
  506.    End
  507. Attribute VB_Name = "frmMain"
  508. Attribute VB_GlobalNameSpace = False
  509. Attribute VB_Creatable = False
  510. Attribute VB_PredeclaredId = True
  511. Attribute VB_Exposed = False
  512. Private requestedPage As String
  513. Private strdata As String
  514. Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
  515. Private Sub cmdDirChoose_Click()
  516. frmDirChoose.Show ownerform:=Me
  517. frmMain.Enabled = False
  518. End Sub
  519. Private Sub cmdOK_Click()
  520. If FileExists(AddASlash(txtRoot.Text)) = False Then
  521. MsgBox "Please enter a valid path for Server Directory.", vbMsgBoxSetForeground + vbInformation
  522. Exit Sub
  523. End If
  524. htmlPageDir = txtRoot.Text
  525. Me.Hide
  526. End Sub
  527. Private Sub Command1_Click()
  528. load_defaults
  529. Command2.Visible = True
  530. Command1.Visible = False
  531. End Sub
  532. Private Sub Command2_Click()
  533. stop_server
  534. Command1.Visible = True
  535. Command2.Visible = False
  536. End Sub
  537. Private Sub Form_Load()
  538. SendMessage Command1.hWnd, &HF4&, &H0&, 0&
  539. SendMessage Command2.hWnd, &HF4&, &H0&, 0&
  540. SendMessage cmdOK.hWnd, &HF4&, &H0&, 0&
  541. SendMessage cmdDirChoose.hWnd, &HF4&, &H0&, 0&
  542. Dim OS As OSVERSIONINFO
  543. OS.dwOSVersionInfoSize = Len(OS)
  544. GetVersionEx OS
  545. If OS.dwMajorVersion < 4 Then
  546. MsgBox "Sorry. You must have Windows 95, Windows 98, NT4 or later!", vbInformation, "Program closed!"
  547. End If
  548. If App.PrevInstance Then 'This checks if webserver is allready started
  549. MsgBox "Sorry, but you have Webserver allready started.", vbMsgBoxSetForeground + vbInformation
  550. End If
  551. Left = Screen.Width \ 2 - Width \ 2
  552. Top = Screen.Height \ 2 - Height \ 2
  553. TakeOutMenu Me, SC_CLOSE ', SC_MOVE
  554. gHW = Me.hWnd
  555. myNID.cbSize = Len(myNID)
  556. myNID.hWnd = gHW
  557. myNID.uID = uID
  558. myNID.uFlags = NIF_MESSAGE Or NIF_TIP Or NIF_ICON
  559. myNID.uCallbackMessage = cbNotify
  560. myNID.hIcon = ServerOff
  561. myNID.szTip = "Server Inactive" & Chr(0)
  562. ShellNotifyIcon NIM_ADD, myNID
  563. SetWindowPos Me.hWnd, -1, 0, 0, 0, 0, 3
  564. ttlConnections = 0 'Set the ttlConnections varible to zero. :)
  565. Server.Caption = "Inactive"
  566. If FileExists(AddASlash(App.Path) & "Webserver.ini") = True Then
  567. Dim Cache As String
  568. Files = FreeFile
  569. Open AddASlash(App.Path) & "Webserver.ini" For Input As #Files
  570. Do While Not EOF(Files)
  571. Line Input #Files, Cache
  572. If Mid(Chache, 1, 1) <> "[" Then
  573. If Mid(Cache, 1, 10) = "ServerRoot" Then
  574. If FileExists(AddASlash(Mid(Cache, 12, Len(Cache)))) = True Then
  575. txtRoot.Text = Mid(Cache, 12, Len(Cache))
  576. txtRoot.Text = App.Path
  577. End If
  578. ElseIf Mid(Cache, 1, 7) = "Logging" Then
  579. If Mid(Cache, 9, 1) = "1" Then
  580. cheLogging.Value = 1
  581. End If
  582. ElseIf Mid(Cache, 1, 9) = "Guestbook" Then
  583. If Mid(Cache, 11, 1) = "1" Then
  584. cheGuest.Value = 1
  585. End If
  586. ElseIf Mid(Cache, 1, 7) = "Counter" Then
  587. If Mid(Cache, 9, 1) = "1" Then
  588. cheCounter.Value = 1
  589. End If
  590. ElseIf Mid(Cache, 1, 9) = "Minimized" Then
  591. If Mid(Cache, 11, 1) = "1" Then
  592. cheMinimized = 1
  593. Me.Hide
  594. End If
  595. ElseIf Mid(Cache, 1, 11) = "TempOffline" Then
  596. If Mid(Cache, 13, 1) = "1" Then
  597. Check1.Value = 1
  598. End If
  599. ElseIf Mid(Cache, 1, 15) = "ActivateOnStart" Then
  600. If Mid(Cache, 17, 1) = "1" Then
  601. cheActivate.Value = 1
  602. load_defaults
  603. Command2.Visible = True
  604. Command1.Visible = False
  605. End If
  606. End If
  607. End If
  608. Close #Files
  609. txtRoot.Text = App.Path
  610. cheGuest.Value = 1
  611. cheCounter.Value = 1
  612. cheLogging.Value = 1
  613. cheMinimized.Value = 0
  614. cheActivate.Value = 0
  615. End If
  616. htmlPageDir = txtRoot.Text
  617. End Sub
  618. Private Sub Form_Unload(Cancel As Integer)
  619. Call stop_server
  620. Files = FreeFile
  621. Open AddASlash(App.Path) & "Webserver.ini" For Output As Files
  622. Buffer = ""
  623. Buffer = "[Webserver Options]" & vbCrLf
  624. Buffer = Buffer & "ServerRoot=" & txtRoot.Text & vbCrLf
  625. Buffer = Buffer & "Logging=" & cheLogging.Value & vbCrLf
  626. Buffer = Buffer & "Guestbook=" & cheGuest.Value & vbCrLf
  627. Buffer = Buffer & "Counter=" & cheCounter.Value & vbCrLf
  628. Buffer = Buffer & "Minimized=" & cheMinimized & vbCrLf
  629. Buffer = Buffer & "TempOffline=" & Check1.Value & vbCrLf
  630. Buffer = Buffer & "ActivateOnStart=" & cheActivate.Value & vbCrLf
  631. Print #Files, Buffer
  632. Close #Files
  633. SetWindowPos Me.hWnd, -2, 0, 0, 0, 0, 3
  634. Unhook
  635. ShellNotifyIcon NIM_DELETE, myNID
  636. End Sub
  637. Private Sub mnuAbout_Click()
  638. frmAbout.Show ownerform:=Me
  639. frmMain.Enabled = False
  640. End Sub
  641. Private Sub mnuExit_Click()
  642. Unload Me
  643. End Sub
  644. Private Sub mnuFileExit_Click()
  645. Unload Me
  646. End Sub
  647. Private Sub mnuHelpAbout_Click()
  648. frmAbout.Show ownerform:=Me
  649. frmMain.Enabled = False
  650. End Sub
  651. Private Sub mnuOptions_Click()
  652. frmMain.Visible = True
  653. AppActivate frmMain.Caption
  654. End Sub
  655. Private Sub mnuStart_Click()
  656. If mnuStart.Caption = "&Start" Then
  657. load_defaults
  658. Command1.Visible = False
  659. Command2.Visible = True
  660. stop_server
  661. End If
  662. End Sub
  663. Private Sub sckWS_ConnectionRequest(Index As Integer, ByVal requestID As Long)
  664. On Error Resume Next
  665. If Index = 0 Then
  666. If Check1.Value = 1 Then Exit Sub
  667. If sckWS(ttlConnections).RemoteHostIP = "192.168.0.5" Then Exit Sub
  668. ttlConnections = ttlConnections + 1  'add 1 to the total # of connections
  669. numConnections = numConnections + 1 'number of connected clients + 1
  670. If numConnections = maxConnections Then GoTo done 'if we've reached the max # of connections, exit sub.
  671. Load sckWS(ttlConnections) 'load a new instance of sckWS.
  672. sckWS(ttlConnections).LocalPort = 0 'set its local port to 0
  673. sckWS(ttlConnections).Accept requestID 'Accept the connection request.
  674. List1.AddItem sckWS(ttlConnections).RemoteHostIP & " Connected"
  675. StartOver:
  676. DoEvents 'DoEvents so it doesn't freeze while we wait.
  677. If requestedPage$ = "" Then GoTo StartOver 'if we havent gotten the page request yet, go back to startOver.
  678. List1.AddItem "Requested: " & requestedPage$
  679. If cheLogging.Value = 1 Then
  680. Logging = FreeFile      'This is for the logging function
  681. Open AddASlash(App.Path) & "Log.log" For Append As #Logging
  682. Print #Logging, Format(Date, "Long Date") & " " & Format(Time, "Long Time") & " ; " & sckWS(ttlConnections).RemoteHostIP & "; " & Mid(strdata$, InStr(1, UCase(strdata$), "USER-AGENT:") + 12, InStr(InStr(1, UCase(strdata$), "USER-AGENT:") + 12, UCase(strdata$), vbCrLf) - InStr(1, UCase(strdata$), "USER-AGENT:") - 12) & "; requested Language: " & Mid(strdata$, InStr(1, UCase(strdata$), "ACCEPT-LANGUAGE:") + 17, InStr(InStr(1, UCase(strdata$), "ACCEPT-LANGUAGE:") + 17, UCase(strdata$), vbCrLf) - InStr(1, UCase(strdata$), "ACCEPT-LANGUAGE:") - 17) & "; requested page: " & requestedPage$
  683. Close #Logging
  684. End If
  685. If requestedPage$ = "/" Then
  686. requestedPage$ = htmlIndexPage$ ' if the page '/' was requested, set requested page to the index html page.
  687. requestedPage$ = Mid(requestedPage$, 2, Len(requestedPage$) - 1)
  688. End If
  689. If cheGuest.Value = 1 Then
  690. If UCase(requestedPage$) = "GUESTBOOK.CGI" Then 'This is check if the Guestbook.cgi is requested
  691. NameStart = InStr(UCase(strdata$), "NAME=")
  692. NameEnd = InStr(NameStart + 5, strdata$, "&")
  693. NameValue = Mid$(strdata$, NameStart + 5, NameEnd - (NameStart + 5))
  694. MailStart = InStr(UCase(strdata$), "E-MAIL=")
  695. MailEnd = InStr(MailStart + 7, strdata$, "&")
  696. MailValue = Mid$(strdata$, MailStart + 7, MailEnd - (MailStart + 7))
  697. CommentStart = InStr(UCase(strdata$), "COMMENT=")
  698. CommentEnd = InStr(CommentStart + 8, strdata$, "&")
  699. CommentValue = Mid$(strdata$, CommentStart + 8, CommentEnd - (CommentStart + 8))
  700. CommentValue = ReplaceStr(CommentValue, "+", " ")
  701. CommentValue = ReplaceStr(CommentValue, "%0D%0A", "<br>")
  702. CommentValue = ReplaceStr(CommentValue, "%21", "!")
  703. CommentValue = ReplaceStr(CommentValue, "%22", """)
  704. CommentValue = ReplaceStr(CommentValue, "%A7", "
  705. CommentValue = ReplaceStr(CommentValue, "%24", "$")
  706. CommentValue = ReplaceStr(CommentValue, "%25", "%")
  707. CommentValue = ReplaceStr(CommentValue, "%26", "&")
  708. CommentValue = ReplaceStr(CommentValue, "%2F", "/")
  709. CommentValue = ReplaceStr(CommentValue, "%28", "(")
  710. CommentValue = ReplaceStr(CommentValue, "%29", ")")
  711. CommentValue = ReplaceStr(CommentValue, "%3D", "=")
  712. CommentValue = ReplaceStr(CommentValue, "%3F", "?")
  713. CommentValue = ReplaceStr(CommentValue, "%B2", "
  714. CommentValue = ReplaceStr(CommentValue, "%B3", "
  715. CommentValue = ReplaceStr(CommentValue, "%7B", "{")
  716. CommentValue = ReplaceStr(CommentValue, "%5B", "[")
  717. CommentValue = ReplaceStr(CommentValue, "%5D", "]")
  718. CommentValue = ReplaceStr(CommentValue, "%7D", "}")
  719. CommentValue = ReplaceStr(CommentValue, "%5C", "\")
  720. CommentValue = ReplaceStr(CommentValue, "%DF", "
  721. CommentValue = ReplaceStr(CommentValue, "%23", "#")
  722. CommentValue = ReplaceStr(CommentValue, "%27", "'")
  723. CommentValue = ReplaceStr(CommentValue, "%3A", ":")
  724. CommentValue = ReplaceStr(CommentValue, "%2C", ",")
  725. CommentValue = ReplaceStr(CommentValue, "%3B", ";")
  726. CommentValue = ReplaceStr(CommentValue, "%60", "`")
  727. CommentValue = ReplaceStr(CommentValue, "%7E", "~")
  728. CommentValue = ReplaceStr(CommentValue, "%2B", "+")
  729. CommentValue = ReplaceStr(CommentValue, "%B4", "
  730. MailValue = ReplaceStr(MailValue, "%21", "!")
  731. MailValue = ReplaceStr(MailValue, "%22", """)
  732. MailValue = ReplaceStr(MailValue, "%A7", "
  733. MailValue = ReplaceStr(MailValue, "%24", "$")
  734. MailValue = ReplaceStr(MailValue, "%25", "%")
  735. MailValue = ReplaceStr(MailValue, "%26", "&")
  736. MailValue = ReplaceStr(MailValue, "%2F", "/")
  737. MailValue = ReplaceStr(MailValue, "%28", "(")
  738. MailValue = ReplaceStr(MailValue, "%29", ")")
  739. MailValue = ReplaceStr(MailValue, "%3D", "=")
  740. MailValue = ReplaceStr(MailValue, "%3F", "?")
  741. MailValue = ReplaceStr(MailValue, "%B2", "
  742. MailValue = ReplaceStr(MailValue, "%B3", "
  743. MailValue = ReplaceStr(MailValue, "%7B", "{")
  744. MailValue = ReplaceStr(MailValue, "%5B", "[")
  745. MailValue = ReplaceStr(MailValue, "%5D", "]")
  746. MailValue = ReplaceStr(MailValue, "%7D", "}")
  747. MailValue = ReplaceStr(MailValue, "%5C", "\")
  748. MailValue = ReplaceStr(MailValue, "%DF", "
  749. MailValue = ReplaceStr(MailValue, "%23", "#")
  750. MailValue = ReplaceStr(MailValue, "%27", "'")
  751. MailValue = ReplaceStr(MailValue, "%3A", ":")
  752. MailValue = ReplaceStr(MailValue, "%2C", ",")
  753. MailValue = ReplaceStr(MailValue, "%3B", ";")
  754. MailValue = ReplaceStr(MailValue, "%60", "`")
  755. MailValue = ReplaceStr(MailValue, "%7E", "~")
  756. MailValue = ReplaceStr(MailValue, "%2B", "+")
  757. MailValue = ReplaceStr(MailValue, "%B4", "
  758. NameValue = ReplaceStr(NameValue, "%21", "!")
  759. NameValue = ReplaceStr(NameValue, "%22", """)
  760. NameValue = ReplaceStr(NameValue, "%A7", "
  761. NameValue = ReplaceStr(NameValue, "%24", "$")
  762. NameValue = ReplaceStr(NameValue, "%25", "%")
  763. NameValue = ReplaceStr(NameValue, "%26", "&")
  764. NameValue = ReplaceStr(NameValue, "%2F", "/")
  765. NameValue = ReplaceStr(NameValue, "%28", "(")
  766. NameValue = ReplaceStr(NameValue, "%29", ")")
  767. NameValue = ReplaceStr(NameValue, "%3D", "=")
  768. NameValue = ReplaceStr(NameValue, "%3F", "?")
  769. NameValue = ReplaceStr(NameValue, "%B2", "
  770. NameValue = ReplaceStr(NameValue, "%B3", "
  771. NameValue = ReplaceStr(NameValue, "%7B", "{")
  772. NameValue = ReplaceStr(NameValue, "%5B", "[")
  773. NameValue = ReplaceStr(NameValue, "%5D", "]")
  774. NameValue = ReplaceStr(NameValue, "%7D", "}")
  775. NameValue = ReplaceStr(NameValue, "%5C", "\")
  776. NameValue = ReplaceStr(NameValue, "%DF", "
  777. NameValue = ReplaceStr(NameValue, "%23", "#")
  778. NameValue = ReplaceStr(NameValue, "%27", "'")
  779. NameValue = ReplaceStr(NameValue, "%3A", ":")
  780. NameValue = ReplaceStr(NameValue, "%2C", ",")
  781. NameValue = ReplaceStr(NameValue, "%3B", ";")
  782. NameValue = ReplaceStr(NameValue, "%60", "`")
  783. NameValue = ReplaceStr(NameValue, "%7E", "~")
  784. NameValue = ReplaceStr(NameValue, "%2B", "+")
  785. NameValue = ReplaceStr(NameValue, "%B4", "
  786. NameValue = ReplaceStr(NameValue, "+", " ")
  787. Guestbook = FreeFile
  788. Open AddASlash(App.Path) & "guestbook.ini" For Append As #Guestbook
  789. datastr = "<b><u>Name:</u></b>  " & NameValue
  790. datastr = datastr & "   <b><u>E-Mail:</u></b>  <a href=mailto:" & MailValue
  791. datastr = datastr & ">" & MailValue
  792. datastr = datastr & "</a><br><br><b><u>Comment:</u></b><br>" & CommentValue
  793. datastr = datastr & "<br><br><br><br>"
  794. Print #Guestbook, datastr
  795. Close #Guestbook
  796. strdata$ = ""
  797. requestedPage$ = "guestbook.html"
  798. End If
  799. If UCase(requestedPage$) = "GUESTBOOK.HTML" Then
  800. htmldata$ = html_guestbookstart & vbCrLf & text_read(AddASlash(App.Path) & "guestbook.ini") & vbCrLf & html_guestbookend & vbCrLf
  801. sckWS(ttlConnections).SendData ReplaceStr(htmldata$, "$ip", sckWS(0).LocalIP)
  802. GoTo done
  803. End If
  804. End If
  805. If FileExists(AddASlash(htmlPageDir) & requestedPage$) Then 'if the requested page exists, then..
  806. htmldata$ = text_read(AddASlash(htmlPageDir) & requestedPage$) 'This reads the file and stores it's contents in htmldata$
  807. If cheCounter.Value = 1 Then
  808. If InStr(1, htmldata$, "$counter") <> 0 Then 'Checks if $counter is in the html page
  809. If FileExists(AddASlash(App.Path) & "counter.ini") Then  ' if true the counter will count one up
  810. CountValue = text_read(AddASlash(App.Path) & "counter.ini")
  811. CountValue = "0"
  812. End If
  813. CountValue = CountValue + 1
  814. Counter = FreeFile
  815. Open AddASlash(App.Path) & "counter.ini" For Output As #Counter
  816. Print #Counter, CountValue
  817. Close #Counter
  818. htmldata$ = ReplaceStr(htmldata$, "$counter", Str(CountValue))
  819. End If
  820. End If
  821. htmldata$ = ReplaceStr(htmldata$, "$ip", sckWS(0).LocalIP) 'Oops, i didn't use the replace function right.  Now it's fixed at replaces $ip with your IP.
  822. sckWS(ttlConnections).SendData htmldata$ & vbCrLf  'open and read the requested HTML page.
  823. Else 'if it doesn't exist, then...
  824. If requestedPage$ = htmlIndexPage$ Then 'If the requested page is the index page and it doesn't exist, print this.
  825. sckWS(ttlConnections).SendData "<html><font face=""Verdana, Arial, Helvetica, sans-serif"" size=""1""><b>Please create an index html page.  It was not found.</font></html>" & vbCrLf ' If the requested page is the index and it doesn't exist, it tells you.
  826. requestedPage$ = ""
  827. End If
  828. requestedPage$ = "/a"
  829. sckWS(ttlConnections).SendData html_404$ & vbCrLf 'Send the 404 Error HTML
  830. End If
  831. End If
  832. done:
  833. numConnections = numConnections - 1 'number of connections at the moment - 1
  834. End Sub
  835. Private Sub sckWS_DataArrival(Index As Integer, ByVal bytesTotal As Long)
  836. On Error Resume Next
  837. sckWS(Index).GetData strdata$ 'Get any data sent to us
  838. 'MsgBox strdata$ ' I used this for debugging
  839. If Mid$(strdata$, 1, 3) = "GET" Then 'If it is trying to get a site, find out
  840. findget = InStr(strdata$, "GET ")      ' the site they want then set requestedPage$
  841. spc2 = InStr(findget + 5, strdata$, " ") ' to it.
  842. pagetoget$ = Mid$(strdata$, findget + 4, spc2 - (findget + 4))
  843. requestedPage$ = pagetoget$
  844. ElseIf Mid$(strdata$, 1, 4) = "POST" Then 'This is the code when it is trying to post something!
  845. findpost = InStr(strdata$, "POST ")        'the data where filtered in the ConnectionRequest
  846. spc2 = InStr(findpost + 5, strdata$, " ")   'Function of the winsock control
  847. pagetopost$ = Mid$(strdata$, findpost + 5, spc2 - (findpost + 5))
  848. requestedPage$ = pagetopost$
  849. End If
  850. End Sub
  851. Private Sub sckWS_SendComplete(Index As Integer)
  852. 'This was a bug that was fixed from v.2a.
  853. If requestedPage$ <> "" Then 'f the requested page doesn't = nothing then...
  854. requestedPage$ = "" 'clear the requestedPage varible.
  855. sckWS(ttlConnections).Close 'Close the connection.
  856. End If
  857. End Sub
  858. Private Sub Server_Click()
  859. If Mid(Server.Caption, 1, 7) = "http://" Then
  860. Call ShellExecute(Me.hWnd, "Open", Server.Caption, "", "", 1)
  861. End If
  862. End Sub
  863. Private Sub TabStrip1_Click()
  864. If TabStrip1.SelectedItem = "Server" Then Picture1.Visible = True: Picture2.Visible = False: Picture3.Visible = False: Picture4.Visible = False
  865. If TabStrip1.SelectedItem = "Active Objects" Then Picture2.Visible = True: Picture1.Visible = False: Picture3.Visible = False: Picture4.Visible = False
  866. If TabStrip1.SelectedItem = "Security" Then Picture3.Visible = True: Picture1.Visible = False: Picture2.Visible = False: Picture4.Visible = False
  867. If TabStrip1.SelectedItem = "Access" Then Picture4.Visible = True: Picture1.Visible = False: Picture2.Visible = False: Picture3.Visible = False
  868. End Sub
  869.