Advertisement
Guest User

COMP230

a guest
Feb 13th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script language="VBScript">
  2. Class Logins
  3.  
  4.     Public SpitOut
  5.    
  6.     Public Function ReadLogIns
  7.        
  8.         Const READ = 1
  9.         Dim ObjFile
  10.      
  11.         set FSO = CreateObject("Scripting.FileSystemObject")
  12.        
  13.         cPath = InputBox("Please enter location of username/password .csv","File Location")
  14.      
  15.         If FSO.fileexists(cPath) then
  16.             Set objReadFile = FSO.OpenTextFile(cPath, READ)
  17.         Else
  18.             Msgbox "Unable to find file! Did you include the file extension?",,"Error!"
  19.             WScript.Quit
  20.         End If
  21.        
  22.         Dim counter : counter = 0
  23.         Dim myBigArray ()
  24.         ReDim myBigArray(counter)                    
  25.        
  26.         Do Until objReadFile.AtEndofStream
  27.             strLine = objReadFile.ReadLine()
  28.         Dim myLittleArray : myLittleArray = Split (strLine,",")
  29.             myBigArray (counter) = myLittleArray
  30.             counter = counter + 1
  31.         ReDim Preserve myBigArray(counter + 1)    
  32.         Loop
  33.    
  34.         objReadFile.Close
  35.        
  36.         ReDim Preserve myBigArray(counter - 1)
  37.            
  38.         Spitout = MyBigArray
  39.     End Function
  40.  
  41. End Class  
  42.  
  43.  
  44.  
  45. Class Login
  46.  
  47.     Public Data
  48.  
  49.     Private attempts  
  50.     Public Sub Class_Initialize()
  51.         attempts = 3
  52.     End Sub
  53.     Public Default Function Init(s)
  54.         attempts = s
  55.     Set Init = Me
  56.     End Function
  57.  
  58.     Public Function Go
  59.  
  60.         do while true
  61.             dim user : user = InputBox("Enter your username","Enter Value")
  62.            
  63.             dim password : password = InputBox("Enter your password","Enter Value")
  64.            
  65.  
  66.             For Each Data In MyLogins.SpitOut
  67.                 if Data(0) = user and Data(1) = password then
  68.                      Go = True
  69.                 Exit Function
  70.                 End If
  71.                
  72.             Next
  73.  
  74.             attempts = attempts - 1
  75.             if attempts = 0 then
  76.                 Go = False
  77.                 Exit Function
  78.             End If
  79.  
  80.             MsgBox "Invalid attempt. You have " & attempts & " attempts left", vbOKOnly, "Try again..."
  81.  
  82.         loop
  83.     End Function
  84. End Class
  85.  
  86.  
  87.  
  88. set myLogin = (new Login)(2)
  89. set myLogins = (new Logins)
  90.  
  91. MyLogins.ReadLogins
  92. myLogin.Data = myLogins.SpitOut
  93.  
  94. dim result : result = myLogin.Go
  95.  
  96. if result then MsgBox "I'm in" else MsgBox "I'm out"
  97.  
  98.  
  99.     </script>
  100. </job>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement