home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 6_2008-2009.ISO / data / zips / An_Interne213918132009.psc / Client / Client.frm < prev    next >
Text File  |  2008-01-30  |  20KB  |  640 lines

  1. VERSION 5.00
  2. Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
  3. Begin VB.Form Client 
  4.    BackColor       =   &H80000007&
  5.    BorderStyle     =   0  'None
  6.    Caption         =   "Client"
  7.    ClientHeight    =   11520
  8.    ClientLeft      =   105
  9.    ClientTop       =   105
  10.    ClientWidth     =   15360
  11.    Icon            =   "Client.frx":0000
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   11520
  14.    ScaleWidth      =   15360
  15.    ShowInTaskbar   =   0   'False
  16.    StartUpPosition =   3  'Windows Default
  17.    WindowState     =   2  'Maximized
  18.    Begin VB.Frame Frame1 
  19.       BackColor       =   &H80000007&
  20.       Height          =   9255
  21.       Left            =   120
  22.       TabIndex        =   0
  23.       Top             =   360
  24.       Width           =   12015
  25.       Begin VB.TextBox txtCompName 
  26.          Height          =   375
  27.          Left            =   510
  28.          TabIndex        =   19
  29.          Top             =   480
  30.          Visible         =   0   'False
  31.          Width           =   2175
  32.       End
  33.       Begin VB.CommandButton Command2 
  34.          Caption         =   "Connect"
  35.          Height          =   375
  36.          Left            =   2640
  37.          TabIndex        =   18
  38.          Top             =   480
  39.          Visible         =   0   'False
  40.          Width           =   1095
  41.       End
  42.       Begin VB.TextBox txtIPADDRESS 
  43.          Height          =   375
  44.          Left            =   5760
  45.          TabIndex        =   8
  46.          Top             =   5700
  47.          Width           =   1095
  48.       End
  49.       Begin VB.CommandButton CmdOKAdmin 
  50.          Caption         =   "OK"
  51.          Height          =   495
  52.          Left            =   5850
  53.          TabIndex        =   7
  54.          Top             =   6930
  55.          Width           =   1785
  56.       End
  57.       Begin VB.CommandButton CmdExit 
  58.          Caption         =   "Exit"
  59.          Height          =   495
  60.          Left            =   3900
  61.          TabIndex        =   6
  62.          Top             =   6960
  63.          Width           =   1785
  64.       End
  65.       Begin VB.CommandButton CmdRestart 
  66.          Caption         =   "Restart"
  67.          Height          =   495
  68.          Left            =   3900
  69.          TabIndex        =   5
  70.          Top             =   6270
  71.          Width           =   1785
  72.       End
  73.       Begin VB.CommandButton CmdShutdown 
  74.          Caption         =   "Shutdown"
  75.          Height          =   495
  76.          Left            =   5850
  77.          TabIndex        =   4
  78.          Top             =   6270
  79.          Width           =   1785
  80.       End
  81.       Begin VB.Timer Timer1 
  82.          Interval        =   1000
  83.          Left            =   1590
  84.          Top             =   4650
  85.       End
  86.       Begin VB.CommandButton CmdOK 
  87.          Caption         =   "OK"
  88.          Height          =   435
  89.          Left            =   4950
  90.          TabIndex        =   3
  91.          Top             =   4350
  92.          Width           =   1905
  93.       End
  94.       Begin VB.TextBox txtPassword 
  95.          BeginProperty Font 
  96.             Name            =   "MS Sans Serif"
  97.             Size            =   12
  98.             Charset         =   0
  99.             Weight          =   400
  100.             Underline       =   0   'False
  101.             Italic          =   0   'False
  102.             Strikethrough   =   0   'False
  103.          EndProperty
  104.          Height          =   405
  105.          IMEMode         =   3  'DISABLE
  106.          Left            =   5460
  107.          PasswordChar    =   "*"
  108.          TabIndex        =   2
  109.          Top             =   3870
  110.          Width           =   1875
  111.       End
  112.       Begin VB.TextBox txtUser 
  113.          BeginProperty Font 
  114.             Name            =   "MS Sans Serif"
  115.             Size            =   12
  116.             Charset         =   0
  117.             Weight          =   400
  118.             Underline       =   0   'False
  119.             Italic          =   0   'False
  120.             Strikethrough   =   0   'False
  121.          EndProperty
  122.          Height          =   435
  123.          Left            =   5460
  124.          TabIndex        =   1
  125.          Top             =   3390
  126.          Width           =   1875
  127.       End
  128.       Begin VB.Label Label1 
  129.          Alignment       =   2  'Center
  130.          BackStyle       =   0  'Transparent
  131.          Caption         =   "jaYPee will never be the same. whew! kewl!"
  132.          ForeColor       =   &H8000000D&
  133.          Height          =   375
  134.          Left            =   4080
  135.          TabIndex        =   20
  136.          Top             =   3000
  137.          Width           =   3255
  138.       End
  139.       Begin VB.Label lblStatus 
  140.          Height          =   255
  141.          Left            =   4320
  142.          TabIndex        =   17
  143.          Top             =   8580
  144.          Width           =   3735
  145.       End
  146.       Begin VB.Label lblAdmin 
  147.          Alignment       =   2  'Center
  148.          BackStyle       =   0  'Transparent
  149.          Caption         =   "Administrator's Option"
  150.          BeginProperty Font 
  151.             Name            =   "MS Sans Serif"
  152.             Size            =   12
  153.             Charset         =   0
  154.             Weight          =   400
  155.             Underline       =   0   'False
  156.             Italic          =   0   'False
  157.             Strikethrough   =   0   'False
  158.          EndProperty
  159.          ForeColor       =   &H8000000E&
  160.          Height          =   315
  161.          Left            =   3990
  162.          TabIndex        =   16
  163.          Top             =   5220
  164.          Width           =   3435
  165.       End
  166.       Begin VB.Label lblIPADDRESS 
  167.          Caption         =   "IP Address:"
  168.          BeginProperty Font 
  169.             Name            =   "MS Sans Serif"
  170.             Size            =   9.75
  171.             Charset         =   0
  172.             Weight          =   400
  173.             Underline       =   0   'False
  174.             Italic          =   0   'False
  175.             Strikethrough   =   0   'False
  176.          EndProperty
  177.          Height          =   345
  178.          Left            =   4620
  179.          TabIndex        =   15
  180.          Top             =   5700
  181.          Width           =   1125
  182.       End
  183.       Begin VB.Label lblTime 
  184.          Alignment       =   2  'Center
  185.          BackColor       =   &H80000012&
  186.          BackStyle       =   0  'Transparent
  187.          Caption         =   "00:00:00 AM"
  188.          BeginProperty Font 
  189.             Name            =   "Times New Roman"
  190.             Size            =   12
  191.             Charset         =   0
  192.             Weight          =   700
  193.             Underline       =   0   'False
  194.             Italic          =   0   'False
  195.             Strikethrough   =   0   'False
  196.          EndProperty
  197.          ForeColor       =   &H8000000D&
  198.          Height          =   315
  199.          Left            =   4665
  200.          TabIndex        =   14
  201.          Top             =   2595
  202.          Width           =   2445
  203.       End
  204.       Begin VB.Label Label3 
  205.          Alignment       =   2  'Center
  206.          BackColor       =   &H80000012&
  207.          BackStyle       =   0  'Transparent
  208.          Caption         =   "The current time is"
  209.          BeginProperty Font 
  210.             Name            =   "Times New Roman"
  211.             Size            =   12
  212.             Charset         =   0
  213.             Weight          =   700
  214.             Underline       =   0   'False
  215.             Italic          =   0   'False
  216.             Strikethrough   =   0   'False
  217.          EndProperty
  218.          ForeColor       =   &H8000000D&
  219.          Height          =   375
  220.          Left            =   4950
  221.          TabIndex        =   13
  222.          Top             =   2220
  223.          Width           =   1935
  224.       End
  225.       Begin VB.Label lblAnimate 
  226.          BackStyle       =   0  'Transparent
  227.          ForeColor       =   &H80000001&
  228.          Height          =   315
  229.          Left            =   4320
  230.          TabIndex        =   12
  231.          Top             =   3030
  232.          Width           =   3195
  233.       End
  234.       Begin VB.Label lblComputerName 
  235.          Alignment       =   2  'Center
  236.          BackStyle       =   0  'Transparent
  237.          BeginProperty Font 
  238.             Name            =   "MS Sans Serif"
  239.             Size            =   12
  240.             Charset         =   0
  241.             Weight          =   400
  242.             Underline       =   0   'False
  243.             Italic          =   0   'False
  244.             Strikethrough   =   0   'False
  245.          EndProperty
  246.          Height          =   345
  247.          Left            =   5010
  248.          TabIndex        =   11
  249.          Top             =   7500
  250.          Width           =   1905
  251.       End
  252.       Begin VB.Label lblUser 
  253.          BackStyle       =   0  'Transparent
  254.          Caption         =   "User"
  255.          BeginProperty Font 
  256.             Name            =   "MS Sans Serif"
  257.             Size            =   12
  258.             Charset         =   0
  259.             Weight          =   700
  260.             Underline       =   0   'False
  261.             Italic          =   0   'False
  262.             Strikethrough   =   0   'False
  263.          EndProperty
  264.          ForeColor       =   &H80000002&
  265.          Height          =   375
  266.          Left            =   4080
  267.          TabIndex        =   10
  268.          Top             =   3420
  269.          Width           =   1275
  270.       End
  271.       Begin VB.Label lblPassword 
  272.          BackStyle       =   0  'Transparent
  273.          Caption         =   "Password"
  274.          BeginProperty Font 
  275.             Name            =   "MS Sans Serif"
  276.             Size            =   12
  277.             Charset         =   0
  278.             Weight          =   700
  279.             Underline       =   0   'False
  280.             Italic          =   0   'False
  281.             Strikethrough   =   0   'False
  282.          EndProperty
  283.          ForeColor       =   &H80000002&
  284.          Height          =   375
  285.          Left            =   4080
  286.          TabIndex        =   9
  287.          Top             =   3900
  288.          Width           =   1275
  289.       End
  290.       Begin VB.Shape Shape1 
  291.          BackColor       =   &H80000001&
  292.          BorderColor     =   &H80000002&
  293.          Height          =   1875
  294.          Left            =   3870
  295.          Shape           =   4  'Rounded Rectangle
  296.          Top             =   2970
  297.          Width           =   3675
  298.       End
  299.       Begin VB.Shape Shape2 
  300.          BorderColor     =   &H80000002&
  301.          BorderWidth     =   2
  302.          Height          =   2955
  303.          Left            =   3480
  304.          Shape           =   4  'Rounded Rectangle
  305.          Top             =   5040
  306.          Width           =   4515
  307.       End
  308.       Begin VB.Image Image1 
  309.          Height          =   8580
  310.          Left            =   240
  311.          Picture         =   "Client.frx":0442
  312.          Stretch         =   -1  'True
  313.          Top             =   360
  314.          Width           =   11430
  315.       End
  316.    End
  317.    Begin MSWinsockLib.Winsock WinSockClient 
  318.       Left            =   2760
  319.       Top             =   120
  320.       _ExtentX        =   741
  321.       _ExtentY        =   741
  322.       _Version        =   393216
  323.       RemotePort      =   2400
  324.    End
  325. End
  326. Attribute VB_Name = "Client"
  327. Attribute VB_GlobalNameSpace = False
  328. Attribute VB_Creatable = False
  329. Attribute VB_PredeclaredId = True
  330. Attribute VB_Exposed = False
  331. Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" _
  332.         (ByVal lpBuffer As String, nSize As Long) As Long
  333. Private Declare Function ExitWindowsEx Lib "user32" _
  334.         (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
  335.  
  336. Dim cBuffer As String * 255
  337. Dim strIPADDRESS As String
  338.  
  339. Function ComputerName() As String
  340.    Call GetComputerName(cBuffer, 255)
  341.    ComputerName = left$(cBuffer, InStr(cBuffer, Chr$(0)) - 1)
  342. End Function
  343.  
  344. Private Sub Connect()
  345.     On Error GoTo err_Connect:
  346.     
  347.     While WinSockClient.State <> sckClosed
  348.         WinSockClient.Close
  349.         DoEvents
  350.     Wend
  351.     
  352.     WinSockClient.RemoteHost = strIPADDRESS '"127.0.0.1"
  353.     WinSockClient.Connect
  354.     
  355.     Do Until WinSockClient.State = 7
  356.         ' 0 is closed, 9 is error
  357.         If WinSockClient.State = 0 Or WinSockClient.State = 9 Then
  358.             lblStatus = "Error in connecting!, Winsock Error"
  359.             ' there was an error, so let's leave
  360.             Exit Sub
  361.         End If
  362.         DoEvents  'don't freeze the system!
  363.     Loop
  364.     
  365.     If WinSockClient.State = 7 Then lblStatus = "connected..."
  366.     
  367.     ' "log-in":
  368.     Send_Data COMMAND_CONNECT & Chr(1) & txtCompName.Text
  369.     DoEvents
  370.     
  371. exit_err_Connect:
  372.     Exit Sub
  373.     
  374. err_Connect:
  375.     If Err = 10055 Then
  376.         Resume exit_err_Connect
  377.     Else
  378.         lblStatus = Err.Number & "-" & Err.Description & " Connect procedure call"
  379.     End If
  380. End Sub
  381.  
  382. Public Sub Send_Data(cString As String)
  383.    On Error Resume Next
  384.  
  385.    WinSockClient.SendData cString
  386. End Sub
  387.  
  388. Private Sub CmdOK_Click()
  389.     strpassword = txtPassword.Text
  390.     txtPassword = ""
  391.     If txtUser = "" Or strpassword = "" Then Exit Sub
  392.     If txtUser = "admin" And strpassword = "jaypee" Then
  393.         Show_Control True
  394.     Else
  395.         Send_Data LOG_IN & Chr(1) & txtCompName.Text & "--" & txtUser.Text & "--" & strpassword
  396.         DoEvents
  397.     End If
  398. End Sub
  399.  
  400. Private Sub CmdOKAdmin_Click()
  401.     On Error GoTo CmdOKAdmin_Click
  402.     
  403.     strIPADDRESS = txtIPADDRESS
  404.     
  405.     Open "serverip" For Output As #1
  406.         Write #1, strIPADDRESS
  407.     Close #1
  408.     
  409.     Open "serverip" For Input As #1
  410.         Input #1, strIPADDRESS
  411.         strIPADDRESS = strIPADDRESS
  412.     Close #1
  413.     
  414.     WinSockClient.Close
  415.     
  416.     Show_Control False
  417.     
  418.     Exit Sub
  419.     
  420. CmdOKAdmin_Click:
  421.     lblStatus = Err.Number & "-" & Err.Description & " CmdOKAdmin_Click procedure call"
  422. End Sub
  423.  
  424. Private Sub Command2_Click()
  425.     If WinSockClient.State <> sckConnected Then Connect
  426. End Sub
  427.  
  428. Private Sub Form_Load()
  429.     On Error GoTo err_Form_Load
  430.     
  431.     If App.PrevInstance Then
  432.        End
  433.     End If
  434.  
  435.     CenterControl Me.Frame1
  436.        
  437.     'this will lock the task manager and prevent ctrl+alt+del
  438. '    Open "C:\Windows\system32\taskmgr.exe" For Random Lock Read As #2
  439.  
  440. '    Disabletaskmanager
  441.     
  442.     'this will disable alt+tab, ctrl+esc
  443. '    hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf LowLevelKeyboardProc, App.hInstance, 0)
  444.  
  445. '    DisableCtrlAltDelete (True)
  446. '    MakeWindowAlwaysTop Me.hwnd
  447. '    TrapMouse Me
  448.        
  449.     Show_Control False
  450.     
  451.     Get_IPADDRESS
  452.     DoEvents
  453.     txtIPADDRESS.Text = strIPADDRESS
  454.     
  455.     txtCompName.Text = ComputerName()
  456.     DoEvents
  457.     Connect
  458.     
  459.     Exit Sub
  460.     
  461. err_Form_Load:
  462.     lblStatus = Err.Number & "-" & Err.Description & " Form_Load procedure call"
  463. End Sub
  464.  
  465. Private Sub Get_IPADDRESS()
  466.     On Error GoTo err_Get_IPADDRESS
  467.     
  468.     Open "serverip" For Input As #1
  469.         Input #1, strIPADDRESS
  470.         strIPADDRESS = strIPADDRESS
  471.     Close #1
  472.     
  473.     Exit Sub
  474.     
  475. err_Get_IPADDRESS:
  476.     lblStatus = Err.Number & "-" & Err.Description & " Get_IPADDRESS procedure call"
  477. End Sub
  478.  
  479. Private Sub Form_Resize()
  480.     CenterControl Me.Frame1
  481. End Sub
  482.  
  483. Private Sub Form_Unload(Cancel As Integer)
  484.     'Call DisableCtrlAltDelete(False)
  485.     LetMouseGo Me
  486. End Sub
  487.  
  488. Private Sub Timer1_Timer()
  489.     A = Hour(Now)
  490.     If A > 12 Then
  491.         tStr = "PM"
  492.     Else
  493.         tStr = "AM"
  494.     End If
  495.  
  496.     Me.lblTime.Caption = A & ":" & Format(Minute(Now), "00") & ":" & Format(Second(Now), "00") & " " & tStr
  497.       
  498.     If WinSockClient.State <> sckConnected Then
  499.         'If txtIPADDRESS.Text = "" Then
  500.         '    Get_IPADDRESS
  501.         '    txtIPADDRESS.Text = strIPADDRESS
  502.         'End If
  503.         
  504.         connectstat = WinSockClient.State
  505.         lblStatus = "Disconnected from server..."
  506.         Connect
  507.     End If
  508. End Sub
  509.  
  510. Private Sub txtPassword_KeyPress(KeyAscii As Integer)
  511.     If KeyAscii = 13 Then CmdOK_Click: KeyAscii = 0
  512. End Sub
  513.  
  514. Private Sub WinSockClient_Close1()
  515.     Me.WinSockClient.Close
  516.     Unload frmTime
  517.     Unload frmBanUser
  518.     Me.Show
  519. End Sub
  520.  
  521. Private Sub WinSockClient_DataArrival(ByVal bytesTotal As Long)
  522.    Dim cDataReceived As String
  523.    
  524.    On Error Resume Next
  525.  
  526.    WinSockClient.GetData cDataReceived
  527.    Received_Data cDataReceived
  528. End Sub
  529.  
  530. Private Sub WinSockClient_Error(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)
  531.     lblStatus = "Winsock Error: " & Number & " " & Description
  532. End Sub
  533.  
  534. Public Sub Received_Data(cDataReceived As String)
  535.     Dim cCommandCode As String
  536.     Dim strArray() As String
  537.     
  538.     On Error GoTo err_Received_Data
  539.     
  540.     cCommandCode = left(cDataReceived, 3) ' Let's get the first char
  541.     cDataReceived = Mid(cDataReceived, 5)      ' Then cut it off
  542.     
  543.     Select Case cCommandCode   ' Check what it is
  544.         Case INVALID_USER_PASSWORD
  545.             lblStatus.Caption = "Invalid User or Password."
  546.         
  547.         Case MESSAGES
  548.             'lblStatus.Caption = "You do not have enough money left in your account."
  549.             lblStatus.Caption = cDataReceived
  550.             
  551.         Case INTERNET_RECORD
  552.             strArray = Split(cDataReceived, "|")
  553.             lblStatus = "Login Successfully."
  554.             Me.Hide
  555.             txtUser.Text = strArray(0)
  556.             frmTime.Show
  557.             Load frmBanUser
  558.             frmTime.lblInternet_Record.Caption = strArray(1)
  559.             
  560.         Case EXIT_CLIENT
  561.             CmdExit_Click
  562.             
  563.         Case FILL_LISTVIEW_AGAIN
  564.             
  565.             strArray = Split(frmTime.lblInternet_Record, "--")
  566.             
  567.             TotalHour = strArray(0)
  568.             UsedHour = strArray(1)
  569.             LeftHour = strArray(2)
  570.             RunningTime = strArray(3)
  571.             
  572.             Client.Send_Data FILL_LISTVIEW_AGAIN & Chr(1) & txtCompName & "--" & _
  573.                     strLastUser & "--" & TotalHour & "--" & UsedHour & "--" & LeftHour & "--" & RunningTime
  574.             DoEvents
  575.         Case SPECIAL_COMMAND
  576.             Client.Send_Data LOG_OUT & Chr(1) & txtCompName.Text & "--" & strLastUser
  577.             DoEvents
  578.             
  579.             Select Case cDataReceived
  580.             Case "Force_Logout"
  581. '                Send_Data UPDATE_LISTVIEW & Chr(1) & txtCompName.Text & _
  582.                     "--" & "" & "--" & "" & "--" & "" & "--" & "" & "--" & "" & "--" & "" & "--" & "" & "--" & "" & "--" & "--" & ""
  583. '                DoEvents
  584.                 Unload frmTime
  585.                 Me.Show
  586.             Case "Restart"
  587.                 CmdRestart_Click
  588.             Case "Shutdown"
  589.                 CmdShutdown_Click
  590.             End Select
  591.     End Select
  592.         
  593.     Exit Sub
  594.     
  595. err_Received_Data:
  596.     lblStatus = Err.Number & "-" & Err.Description & " Received_Data procedure call"
  597. End Sub
  598.  
  599. Private Sub CmdExit_Click()
  600.     Send_Data EXIT_CLIENT & Chr(1) & txtCompName.Text
  601.     DoEvents
  602.    
  603.     Call ExitWindowsEx(EWX_SHUTDOWN, 0)
  604.     Unload Me
  605.   
  606.     Unload frmBanUser
  607.     End
  608. End Sub
  609.  
  610. Private Sub CmdRestart_Click()
  611.     Send_Data EXIT_CLIENT & Chr(1) & txtCompName.Text
  612.     DoEvents
  613.     Unload Me
  614.     ExitWindowsEx 4 + 2, 0
  615. End Sub
  616.  
  617. Private Sub CmdShutdown_Click()
  618.     Send_Data EXIT_CLIENT & Chr(1) & txtCompName.Text
  619.     DoEvents
  620.     Unload Me
  621.     ExitWindowsEx 4 + 1, 0
  622. End Sub
  623.  
  624. Private Sub CenterControl(Ctrl As Control)
  625.     Ctrl.left = (Me.ScaleWidth - Ctrl.Width) \ 2
  626.     Ctrl.top = (Me.ScaleHeight - Ctrl.Height) \ 2
  627. End Sub
  628.  
  629. Private Sub Show_Control(bVal As Boolean)
  630.     lblAdmin.Visible = bVal
  631.     lblIPADDRESS.Visible = bVal
  632.     txtIPADDRESS.Visible = bVal
  633.     CmdRestart.Visible = bVal
  634.     CmdShutdown.Visible = bVal
  635.     CmdExit.Visible = bVal
  636.     CmdOKAdmin.Visible = bVal
  637.     Shape2.Visible = bVal
  638. End Sub
  639.  
  640.