Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.18 KB | None | 0 0
  1. Attribute VB_Name = "modAccount"
  2. '**************************************************************************
  3. 'This program is free software; you can redistribute it and/or modify
  4. 'it under the terms of the GNU General Public License as published by
  5. 'the Free Software Foundation; either version 2 of the License, or
  6. '(at your option) any later version.
  7. '
  8. 'This program is distributed in the hope that it will be useful,
  9. 'but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. 'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. 'GNU General Public License for more details.
  12. '
  13. 'You should have received a copy of the GNU General Public License
  14. 'along with this program; if not, write to the Free Software
  15. 'Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. '**************************************************************************
  17. '@Module Author: Wolftein
  18. '@Module Update: 4/7/09
  19. '@Module Explination: Account Functions
  20. '@Module Todo:
  21.  
  22. Option Explicit
  23.  
  24. Public Function accountExist(ByVal Name As String) As Boolean
  25. '*****************************************************************
  26. 'Return if the Account Exist or NOT
  27. 'Author: Wolftein
  28. '*****************************************************************
  29. srvDatabase.Open "SELECT * FROM accounts WHERE name='" & UCase$(Name) & "'", , adOpenStatic, adLockOptimistic, adCmdText
  30.  
  31. accountExist = (srvDatabase.EOF = False)
  32.  
  33. srvDatabase.Close
  34. End Function
  35.  
  36. Public Function accountCreate(ByVal Name As String, ByVal Password As String, ByVal Email As String) As Boolean
  37. '*****************************************************************
  38. 'Create a new Account
  39. 'Author: Wolftein
  40. '*****************************************************************
  41. accountCreate = False
  42.  
  43. ' if the file create, then exit the function
  44. If (accountExist(Name) = True) Then Exit Function
  45. ' create the account to the database
  46. srvDatabaseConnection.Execute "INSERT INTO accounts VALUES('" & UCase$(Name) & "','" & Password & "','" & Email & "'," & 0 & ",' ')"
  47.  
  48. accountCreate = True
  49. End Function
  50.  
  51. Public Function accountCheckPassword(ByVal Name As String, ByVal Password As String) As Boolean
  52. '*****************************************************************
  53. 'Return if the password Match or not
  54. 'Author: Wolftein
  55. '*****************************************************************
  56. srvDatabase.Open "SELECT * from accounts WHERE name='" & UCase$(Name) & "'", , adOpenStatic, adLockOptimistic, adCmdText
  57.  
  58. accountCheckPassword = (Trim$(srvDatabase!Password) = Password)
  59.  
  60. srvDatabase.Close
  61. End Function
  62.  
  63. Public Function accountChangePassword(ByVal Name As String, ByVal Password As String, ByVal newPassword As String) As Boolean
  64. '*****************************************************************
  65. 'Change the password of an account
  66. 'Author: Wolftein
  67. '*****************************************************************
  68. accountChangePassword = False
  69.  
  70. ' if the account doesn't exist then exit
  71. If (accountExist(Name) = False) Then Exit Function
  72.  
  73. ' Check if the password match
  74. If (accountCheckPassword(Name, Password) = False) Then Exit Function
  75.  
  76. ' get the account row
  77. srvDatabase.Open "SELECT * from accounts WHERE name='" & UCase$(Name) & "'", , adOpenStatic, adLockOptimistic, adCmdText
  78. ' change the password
  79. srvDatabase!Password = newPassword
  80. ' update and close
  81. srvDatabase.Update
  82. srvDatabase.Close
  83.  
  84. accountChangePassword = True
  85. End Function
  86. Public Function accountDelete(ByVal Name As String, ByVal Password As String) As Boolean
  87. '*****************************************************************
  88. 'Delete an Account
  89. 'Author: Wolftein
  90. '*****************************************************************
  91. accountDelete = False
  92.  
  93. ' if the account doesn't exist then exit
  94. If (accountExist(Name) = False) Then Exit Function
  95.  
  96. ' Check if the password match
  97. If (accountCheckPassword(Name, Password) = False) Then Exit Function
  98.  
  99. ' delete each character on that account
  100. ' TODO:
  101.  
  102. ' destroy the account
  103. srvDatabase.Open "SELECT * from accounts WHERE name='" & UCase$(Name) & "'", , adOpenStatic, adLockOptimistic, adCmdText
  104. srvDatabase.Delete adAffectCurrent
  105.  
  106. accountDelete = True
  107. End Function
  108.  
  109. Public Function accountLogin(ByVal Name As String, ByVal Password As String, ByRef List As String) As Boolean
  110. '*****************************************************************
  111. 'Login an existing Account, save in @List the list of Characters
  112. 'Author: Wolftein
  113. '*****************************************************************
  114. accountLogin = False
  115.  
  116. ' if the file create, then exit the function
  117. If (accountExist(Name) = False) Then Exit Function
  118. ' Check if the password match
  119. If (accountCheckPassword(Name, Password) = False) Then Exit Function
  120. ' get the list of characters
  121. srvDatabase.Open "SELECT * from accounts WHERE name='" & UCase$(Name) & "'", , adOpenStatic, adLockOptimistic, adCmdText
  122. List = srvDatabase!Characters
  123. ' close the query
  124. srvDatabase.Close
  125.  
  126. accountLogin = True
  127. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement